1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #include <sal/config.h> 21 22 #include <utility> 23 24 #include <config_features.h> 25 26 #include <confuno.hxx> 27 #include <unonames.hxx> 28 #include <docsh.hxx> 29 #include <miscuno.hxx> 30 #include <forbiuno.hxx> 31 #include <appoptio.hxx> 32 #include <viewopti.hxx> 33 #include <docpool.hxx> 34 #include <sc.hrc> 35 #include <scmod.hxx> 36 37 #include <com/sun/star/beans/PropertyAttribute.hpp> 38 #include <com/sun/star/document/LinkUpdateModes.hpp> 39 #include <cppuhelper/supportsservice.hxx> 40 #include <formula/grammar.hxx> 41 #include <sfx2/printer.hxx> 42 #include <svl/itemset.hxx> 43 #include <vcl/svapp.hxx> 44 #include <tools/stream.hxx> 45 46 using namespace com::sun::star; 47 48 constexpr OUStringLiteral SCSAVEVERSION = u"SaveVersionOnClose"; 49 50 static const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap() 51 { 52 static const SfxItemPropertyMapEntry aConfigPropertyMap_Impl[] = 53 { 54 { SC_UNO_SHOWZERO, 0, cppu::UnoType<bool>::get(), 0, 0}, 55 { SC_UNO_SHOWNOTES, 0, cppu::UnoType<bool>::get(), 0, 0}, 56 { SC_UNO_SHOWGRID, 0, cppu::UnoType<bool>::get(), 0, 0}, 57 { SC_UNO_GRIDCOLOR, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, 58 { SC_UNO_SHOWPAGEBR, 0, cppu::UnoType<bool>::get(), 0, 0}, 59 { SC_UNONAME_LINKUPD, 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, 60 { SC_UNO_COLROWHDR, 0, cppu::UnoType<bool>::get(), 0, 0}, 61 { SC_UNO_SHEETTABS, 0, cppu::UnoType<bool>::get(), 0, 0}, 62 { SC_UNO_OUTLSYMB, 0, cppu::UnoType<bool>::get(), 0, 0}, 63 { SC_UNO_SNAPTORASTER, 0, cppu::UnoType<bool>::get(), 0, 0}, 64 { SC_UNO_RASTERVIS, 0, cppu::UnoType<bool>::get(), 0, 0}, 65 { SC_UNO_RASTERRESX, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, 66 { SC_UNO_RASTERRESY, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, 67 { SC_UNO_RASTERSUBX, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, 68 { SC_UNO_RASTERSUBY, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, 69 { SC_UNO_RASTERSYNC, 0, cppu::UnoType<bool>::get(), 0, 0}, 70 { SC_UNO_AUTOCALC, 0, cppu::UnoType<bool>::get(), 0, 0}, 71 { SC_UNO_PRINTERNAME, 0, cppu::UnoType<OUString>::get(), 0, 0}, 72 { SC_UNO_PRINTERSETUP, 0, cppu::UnoType<uno::Sequence<sal_Int8>>::get(), 0, 0}, 73 { SC_UNO_PRINTERPAPER, 0, cppu::UnoType<bool>::get(), 0, 0}, 74 { SC_UNO_APPLYDOCINF, 0, cppu::UnoType<bool>::get(), 0, 0 }, 75 { SC_UNO_SAVE_THUMBNAIL, 0, cppu::UnoType<bool>::get(), 0, 0 }, 76 { SC_UNO_FORBIDDEN, 0, cppu::UnoType<i18n::XForbiddenCharacters>::get(), beans::PropertyAttribute::READONLY, 0}, 77 { SC_UNO_CHARCOMP, 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, 78 { SC_UNO_ASIANKERN, 0, cppu::UnoType<bool>::get(), 0, 0}, 79 { SCSAVEVERSION, 0, cppu::UnoType<bool>::get(), 0, 0}, 80 { SC_UNO_UPDTEMPL, 0, cppu::UnoType<bool>::get(), 0, 0}, 81 /*Stampit enable/disable print cancel */ 82 { SC_UNO_ALLOWPRINTJOBCANCEL, 0, cppu::UnoType<bool>::get(), 0, 0}, 83 { SC_UNO_LOADREADONLY, 0, cppu::UnoType<bool>::get(), 0, 0}, 84 { SC_UNO_SHAREDOC, 0, cppu::UnoType<bool>::get(), 0, 0}, 85 { SC_UNO_MODIFYPASSWORDINFO, 0, cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(), 0, 0}, 86 { SC_UNO_MODIFYPASSWORDHASH, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, 87 { SC_UNO_EMBED_FONTS, 0, cppu::UnoType<bool>::get(), 0, 0}, 88 { SC_UNO_EMBED_ONLY_USED_FONTS, 0, cppu::UnoType<bool>::get(), 0, 0}, 89 { SC_UNO_EMBED_FONT_SCRIPT_LATIN, 0, cppu::UnoType<bool>::get(), 0, 0}, 90 { SC_UNO_EMBED_FONT_SCRIPT_ASIAN, 0, cppu::UnoType<bool>::get(), 0, 0}, 91 { SC_UNO_EMBED_FONT_SCRIPT_COMPLEX, 0, cppu::UnoType<bool>::get(), 0, 0}, 92 { SC_UNO_IMAGE_PREFERRED_DPI, 0, cppu::UnoType<sal_Int32>::get(), 0, 0}, 93 { SC_UNO_SYNTAXSTRINGREF, 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, 94 { u"", 0, css::uno::Type(), 0, 0 } 95 }; 96 return aConfigPropertyMap_Impl; 97 } 98 99 ScDocumentConfiguration::ScDocumentConfiguration(ScDocShell* pDocSh) 100 : pDocShell(pDocSh) , 101 aPropSet ( lcl_GetConfigPropertyMap() ) 102 { 103 pDocShell->GetDocument().AddUnoObject(*this); 104 } 105 106 ScDocumentConfiguration::~ScDocumentConfiguration() 107 { 108 SolarMutexGuard g; 109 110 if (pDocShell) 111 pDocShell->GetDocument().RemoveUnoObject(*this); 112 } 113 114 void ScDocumentConfiguration::Notify( SfxBroadcaster&, const SfxHint& rHint ) 115 { 116 // reference update does not matter here 117 118 if ( rHint.GetId() == SfxHintId::Dying ) 119 { 120 pDocShell = nullptr; 121 } 122 } 123 124 // XPropertySet 125 126 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDocumentConfiguration::getPropertySetInfo() 127 { 128 SolarMutexGuard aGuard; 129 static uno::Reference<beans::XPropertySetInfo> aRef( 130 new SfxItemPropertySetInfo( aPropSet.getPropertyMap() )); 131 return aRef; 132 } 133 134 void SAL_CALL ScDocumentConfiguration::setPropertyValue( 135 const OUString& aPropertyName, const uno::Any& aValue ) 136 { 137 SolarMutexGuard aGuard; 138 139 if(!pDocShell) 140 throw uno::RuntimeException(); 141 142 ScDocument& rDoc = pDocShell->GetDocument(); 143 bool bUpdateHeights = false; 144 145 ScViewOptions aViewOpt(rDoc.GetViewOptions()); 146 147 /*Stampit enable/disable print cancel */ 148 if ( aPropertyName == SC_UNO_ALLOWPRINTJOBCANCEL ) 149 pDocShell->Stamp_SetPrintCancelState( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 150 /*Stampit enable/disable print cancel */ 151 152 else if ( aPropertyName == SC_UNO_SHOWZERO ) 153 aViewOpt.SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 154 else if ( aPropertyName == SC_UNO_SHOWNOTES ) 155 aViewOpt.SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 156 else if ( aPropertyName == SC_UNO_SHOWGRID ) 157 aViewOpt.SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 158 else if ( aPropertyName == SC_UNO_GRIDCOLOR ) 159 { 160 Color aColor; 161 if (aValue >>= aColor) 162 aViewOpt.SetGridColor(aColor, OUString()); 163 } 164 else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) 165 aViewOpt.SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 166 else if ( aPropertyName == SC_UNONAME_LINKUPD ) 167 { 168 // XXX NOTE: this is the css::document::Settings property 169 // LinkUpdateMode, not the css::sheet::XGlobalSheetSettings 170 // attribute LinkUpdateMode. 171 sal_Int16 n; 172 if (!(aValue >>= n) || n < css::document::LinkUpdateModes::NEVER || 173 n > css::document::LinkUpdateModes::GLOBAL_SETTING) 174 { 175 throw css::lang::IllegalArgumentException( 176 ("LinkUpdateMode property value must be a SHORT with a value in" 177 " the range of the css::document::LinkUpdateModes constants"), 178 css::uno::Reference<css::uno::XInterface>(), -1); 179 } 180 ScLkUpdMode eMode; 181 switch (n) 182 { 183 case css::document::LinkUpdateModes::NEVER: 184 eMode = LM_NEVER; 185 break; 186 case css::document::LinkUpdateModes::MANUAL: 187 eMode = LM_ON_DEMAND; 188 break; 189 case css::document::LinkUpdateModes::AUTO: 190 eMode = LM_ALWAYS; 191 break; 192 case css::document::LinkUpdateModes::GLOBAL_SETTING: 193 default: 194 eMode = SC_MOD()->GetAppOptions().GetLinkMode(); 195 break; 196 } 197 rDoc.SetLinkMode( eMode ); 198 } 199 else if ( aPropertyName == SC_UNO_COLROWHDR ) 200 aViewOpt.SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 201 else if ( aPropertyName == SC_UNO_SHEETTABS ) 202 aViewOpt.SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 203 else if ( aPropertyName == SC_UNO_OUTLSYMB ) 204 aViewOpt.SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 205 else if ( aPropertyName == SC_UNO_AUTOCALC ) 206 rDoc.SetAutoCalc( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 207 else if ( aPropertyName == SC_UNO_PRINTERNAME ) 208 { 209 OUString sPrinterName; 210 if ( !(aValue >>= sPrinterName) ) 211 throw lang::IllegalArgumentException(); 212 213 // #i75610# if the name is empty, do nothing (don't create any printer) 214 if ( !sPrinterName.isEmpty() && pDocShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) 215 { 216 SfxPrinter* pPrinter = pDocShell->GetPrinter(); 217 if (!pPrinter) 218 throw uno::RuntimeException(); 219 220 if (pPrinter->GetName() != sPrinterName) 221 { 222 VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName ); 223 if (pNewPrinter->IsKnown()) 224 pDocShell->SetPrinter( pNewPrinter, SfxPrinterChangeFlags::PRINTER ); 225 else 226 pNewPrinter.disposeAndClear(); 227 } 228 229 } 230 231 } 232 else if ( aPropertyName == SC_UNO_PRINTERSETUP ) 233 { 234 uno::Sequence<sal_Int8> aSequence; 235 if ( aValue >>= aSequence ) 236 { 237 sal_uInt32 nSize = aSequence.getLength(); 238 // #i75610# if the sequence is empty, do nothing (don't create any printer) 239 if ( nSize != 0 ) 240 { 241 SvMemoryStream aStream (aSequence.getArray(), nSize, StreamMode::READ ); 242 aStream.Seek ( STREAM_SEEK_TO_BEGIN ); 243 auto pSet = std::make_unique<SfxItemSetFixed 244 <SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, 245 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, 246 SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET, 247 SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS>>( *rDoc.GetPool()); 248 249 SfxPrinter* pPrinter = pDocShell->GetPrinter(); 250 bool bPreferPrinterPapersize = false; 251 if ( pPrinter ) 252 bPreferPrinterPapersize = pPrinter->GetPrinterSettingsPreferred(); 253 254 VclPtr<SfxPrinter> pTempPrinter = SfxPrinter::Create( aStream, std::move(pSet) ); 255 pTempPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize ); 256 pDocShell->SetPrinter( pTempPrinter ); 257 } 258 } 259 } 260 else if ( aPropertyName == SC_UNO_PRINTERPAPER ) 261 { 262 bool bPreferPrinterPapersize; 263 if( aValue >>= bPreferPrinterPapersize ) 264 { 265 if( pDocShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) 266 { 267 SfxPrinter *pTempPrinter = pDocShell->GetPrinter( true ); 268 if (pTempPrinter) 269 pTempPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize ); 270 } 271 } 272 } 273 else if ( aPropertyName == SC_UNO_APPLYDOCINF ) 274 { 275 bool bTmp=true; 276 if ( aValue >>= bTmp ) 277 pDocShell->SetUseUserData( bTmp ); 278 } 279 else if ( aPropertyName == SC_UNO_SAVE_THUMBNAIL) 280 { 281 bool bTmp = true; 282 if (aValue >>= bTmp) 283 pDocShell->SetUseThumbnailSave( bTmp ); 284 } 285 else if ( aPropertyName == SC_UNO_FORBIDDEN ) 286 { 287 // read-only - should not be set 288 } 289 else if ( aPropertyName == SC_UNO_CHARCOMP ) 290 { 291 // Int16 contains CharacterCompressionType values 292 sal_Int16 nUno = ScUnoHelpFunctions::GetInt16FromAny( aValue ); 293 rDoc.SetAsianCompression( static_cast<CharCompressType>(nUno) ); 294 bUpdateHeights = true; 295 } 296 else if ( aPropertyName == SC_UNO_ASIANKERN ) 297 { 298 rDoc.SetAsianKerning( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 299 bUpdateHeights = true; 300 } 301 else if ( aPropertyName == SCSAVEVERSION ) 302 { 303 bool bTmp=false; 304 if ( aValue >>= bTmp ) 305 pDocShell->SetSaveVersionOnClose( bTmp ); 306 } 307 else if ( aPropertyName == SC_UNO_UPDTEMPL ) 308 { 309 bool bTmp=true; 310 if ( aValue >>= bTmp ) 311 pDocShell->SetQueryLoadTemplate( bTmp ); 312 } 313 else if ( aPropertyName == SC_UNO_LOADREADONLY ) 314 { 315 bool bTmp=false; 316 if ( aValue >>= bTmp ) 317 pDocShell->SetLoadReadonly( bTmp ); 318 } 319 else if ( aPropertyName == SC_UNO_SHAREDOC ) 320 { 321 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT 322 bool bDocShared = false; 323 if ( aValue >>= bDocShared ) 324 { 325 pDocShell->SetSharedXMLFlag( bDocShared ); 326 } 327 #endif 328 } 329 else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO ) 330 { 331 uno::Sequence< beans::PropertyValue > aInfo; 332 if ( !( aValue >>= aInfo ) ) 333 throw lang::IllegalArgumentException( 334 "Value of type Sequence<PropertyValue> expected!", 335 uno::Reference< uno::XInterface >(), 336 2 ); 337 338 if ( !pDocShell->SetModifyPasswordInfo( aInfo ) ) 339 throw beans::PropertyVetoException( 340 "The hash is not allowed to be changed now!" ); 341 } 342 else if (aPropertyName == SC_UNO_MODIFYPASSWORDHASH) 343 { 344 sal_Int32 nHash; 345 if (!(aValue >>= nHash)) 346 throw lang::IllegalArgumentException("Value of type sal_Int32 expected!", 347 uno::Reference<uno::XInterface>(), 2); 348 349 if (!pDocShell->SetModifyPasswordHash(nHash)) 350 throw beans::PropertyVetoException("The hash is not allowed to be changed now!"); 351 } 352 else if (aPropertyName == SC_UNO_EMBED_FONTS) 353 { 354 bool bVal = aValue.has<bool>() && aValue.get<bool>(); 355 rDoc.SetEmbedFonts(bVal); 356 } 357 else if (aPropertyName == SC_UNO_EMBED_ONLY_USED_FONTS) 358 { 359 bool bVal = aValue.has<bool>() && aValue.get<bool>(); 360 rDoc.SetEmbedUsedFontsOnly(bVal); 361 } 362 else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_LATIN) 363 { 364 bool bVal = aValue.has<bool>() && aValue.get<bool>(); 365 rDoc.SetEmbedFontScriptLatin(bVal); 366 } 367 else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_ASIAN) 368 { 369 bool bVal = aValue.has<bool>() && aValue.get<bool>(); 370 rDoc.SetEmbedFontScriptAsian(bVal); 371 } 372 else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_COMPLEX) 373 { 374 bool bVal = aValue.has<bool>() && aValue.get<bool>(); 375 rDoc.SetEmbedFontScriptComplex(bVal); 376 } 377 else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF ) 378 { 379 ScCalcConfig aCalcConfig = rDoc.GetCalcConfig(); 380 sal_Int16 nUno = 0; 381 382 if( aValue >>= nUno ) 383 { 384 switch (nUno) 385 { 386 case 0: // CONV_OOO 387 case 2: // CONV_XL_A1 388 case 3: // CONV_XL_R1C1 389 case 7: // CONV_A1_XL_A1 390 aCalcConfig.SetStringRefSyntax( static_cast<formula::FormulaGrammar::AddressConvention>( nUno ) ); 391 break; 392 default: 393 aCalcConfig.SetStringRefSyntax( formula::FormulaGrammar::CONV_UNSPECIFIED ); 394 break; 395 396 } 397 rDoc.SetCalcConfig( aCalcConfig ); 398 } 399 } 400 else if (aPropertyName == SC_UNO_IMAGE_PREFERRED_DPI) 401 { 402 if (aValue.has<sal_Int32>()) 403 { 404 rDoc.SetImagePreferredDPI(aValue.get<sal_Int32>()); 405 } 406 } 407 else 408 { 409 ScGridOptions aGridOpt(aViewOpt.GetGridOptions()); 410 if ( aPropertyName == SC_UNO_SNAPTORASTER ) 411 aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 412 else if ( aPropertyName == SC_UNO_RASTERVIS ) 413 aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 414 else if ( aPropertyName == SC_UNO_RASTERRESX ) 415 aGridOpt.SetFieldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); 416 else if ( aPropertyName == SC_UNO_RASTERRESY ) 417 aGridOpt.SetFieldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); 418 else if ( aPropertyName == SC_UNO_RASTERSUBX ) 419 aGridOpt.SetFieldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); 420 else if ( aPropertyName == SC_UNO_RASTERSUBY ) 421 aGridOpt.SetFieldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); 422 else if ( aPropertyName == SC_UNO_RASTERSYNC ) 423 aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); 424 else 425 throw beans::UnknownPropertyException(aPropertyName); 426 aViewOpt.SetGridOptions(aGridOpt); 427 } 428 rDoc.SetViewOptions(aViewOpt); 429 430 if ( bUpdateHeights && !rDoc.IsImportingXML() ) 431 { 432 // update automatic row heights and repaint 433 SCTAB nTabCount = rDoc.GetTableCount(); 434 for (SCTAB nTab=0; nTab<nTabCount; nTab++) 435 if ( !pDocShell->AdjustRowHeight( 0, rDoc.MaxRow(), nTab ) ) 436 pDocShell->PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab), PaintPartFlags::Grid); 437 pDocShell->SetDocumentModified(); 438 } 439 440 } 441 442 uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const OUString& aPropertyName ) 443 { 444 SolarMutexGuard aGuard; 445 uno::Any aRet; 446 447 if(!pDocShell) 448 throw uno::RuntimeException(); 449 450 ScDocument& rDoc = pDocShell->GetDocument(); 451 const ScViewOptions& aViewOpt = rDoc.GetViewOptions(); 452 453 /*Stampit enable/disable print cancel */ 454 if ( aPropertyName == SC_UNO_ALLOWPRINTJOBCANCEL ) 455 aRet <<= pDocShell->Stamp_GetPrintCancelState(); 456 /*Stampit enable/disable print cancel */ 457 458 else if ( aPropertyName == SC_UNO_SHOWZERO ) 459 aRet <<= aViewOpt.GetOption( VOPT_NULLVALS ); 460 else if ( aPropertyName == SC_UNO_SHOWNOTES ) 461 aRet <<= aViewOpt.GetOption( VOPT_NOTES ); 462 else if ( aPropertyName == SC_UNO_SHOWGRID ) 463 aRet <<= aViewOpt.GetOption( VOPT_GRID ); 464 else if ( aPropertyName == SC_UNO_GRIDCOLOR ) 465 { 466 OUString aColorName; 467 Color aColor = aViewOpt.GetGridColor(&aColorName); 468 aRet <<= aColor; 469 } 470 else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) 471 aRet <<= aViewOpt.GetOption( VOPT_PAGEBREAKS ); 472 else if ( aPropertyName == SC_UNONAME_LINKUPD ) 473 { 474 sal_Int16 nLUM; 475 switch (rDoc.GetLinkMode()) 476 { 477 case LM_ALWAYS: 478 nLUM = css::document::LinkUpdateModes::AUTO; 479 break; 480 case LM_NEVER: 481 nLUM = css::document::LinkUpdateModes::NEVER; 482 break; 483 case LM_ON_DEMAND: 484 nLUM = css::document::LinkUpdateModes::MANUAL; 485 break; 486 case LM_UNKNOWN: 487 default: 488 nLUM = css::document::LinkUpdateModes::GLOBAL_SETTING; 489 break; 490 } 491 aRet <<= nLUM; 492 } 493 else if ( aPropertyName == SC_UNO_COLROWHDR ) 494 aRet <<= aViewOpt.GetOption( VOPT_HEADER ); 495 else if ( aPropertyName == SC_UNO_SHEETTABS ) 496 aRet <<= aViewOpt.GetOption( VOPT_TABCONTROLS ); 497 else if ( aPropertyName == SC_UNO_OUTLSYMB ) 498 aRet <<= aViewOpt.GetOption( VOPT_OUTLINER ); 499 else if ( aPropertyName == SC_UNO_AUTOCALC ) 500 aRet <<= rDoc.GetAutoCalc(); 501 else if ( aPropertyName == SC_UNO_PRINTERNAME ) 502 { 503 // #i75610# don't create the printer, return empty string if no printer created yet 504 // (as in SwXDocumentSettings) 505 SfxPrinter* pPrinter = rDoc.GetPrinter( false ); 506 if (pPrinter) 507 aRet <<= pPrinter->GetName(); 508 else 509 aRet <<= OUString(); 510 } 511 else if ( aPropertyName == SC_UNO_PRINTERSETUP ) 512 { 513 // #i75610# don't create the printer, return empty sequence if no printer created yet 514 // (as in SwXDocumentSettings) 515 SfxPrinter* pPrinter = rDoc.GetPrinter( false ); 516 if (pPrinter) 517 { 518 SvMemoryStream aStream; 519 pPrinter->Store( aStream ); 520 aRet <<= uno::Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aStream.GetData() ), 521 aStream.TellEnd() ); 522 } 523 else 524 aRet <<= uno::Sequence<sal_Int8>(); 525 } 526 else if ( aPropertyName == SC_UNO_PRINTERPAPER) 527 { 528 SfxPrinter *pTempPrinter = pDocShell->GetPrinter( false ); 529 aRet <<= pTempPrinter && pTempPrinter->GetPrinterSettingsPreferred(); 530 531 } 532 else if ( aPropertyName == SC_UNO_APPLYDOCINF ) 533 aRet <<= pDocShell->IsUseUserData(); 534 else if ( aPropertyName == SC_UNO_SAVE_THUMBNAIL ) 535 aRet <<= pDocShell->IsUseThumbnailSave(); 536 else if ( aPropertyName == SC_UNO_FORBIDDEN ) 537 { 538 aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell )); 539 } 540 else if ( aPropertyName == SC_UNO_CHARCOMP ) 541 aRet <<= static_cast<sal_Int16> ( rDoc.GetAsianCompression() ); 542 else if ( aPropertyName == SC_UNO_ASIANKERN ) 543 aRet <<= rDoc.GetAsianKerning(); 544 else if ( aPropertyName == SCSAVEVERSION ) 545 aRet <<= pDocShell->IsSaveVersionOnClose(); 546 else if ( aPropertyName == SC_UNO_UPDTEMPL ) 547 aRet <<= pDocShell->IsQueryLoadTemplate(); 548 else if ( aPropertyName == SC_UNO_LOADREADONLY ) 549 aRet <<= pDocShell->IsLoadReadonly(); 550 else if ( aPropertyName == SC_UNO_SHAREDOC ) 551 { 552 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT 553 aRet <<= pDocShell->HasSharedXMLFlagSet(); 554 #endif 555 } 556 else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO ) 557 aRet <<= pDocShell->GetModifyPasswordInfo(); 558 else if (aPropertyName == SC_UNO_MODIFYPASSWORDHASH) 559 aRet <<= pDocShell->GetModifyPasswordHash(); 560 else if (aPropertyName == SC_UNO_EMBED_FONTS) 561 aRet <<= rDoc.IsEmbedFonts(); 562 else if (aPropertyName == SC_UNO_EMBED_ONLY_USED_FONTS) 563 aRet <<= rDoc.IsEmbedUsedFontsOnly(); 564 else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_LATIN) 565 aRet <<= rDoc.IsEmbedFontScriptLatin(); 566 else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_ASIAN) 567 aRet <<= rDoc.IsEmbedFontScriptAsian(); 568 else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_COMPLEX) 569 aRet <<= rDoc.IsEmbedFontScriptComplex(); 570 else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF ) 571 { 572 ScCalcConfig aCalcConfig = rDoc.GetCalcConfig(); 573 formula::FormulaGrammar::AddressConvention eConv = aCalcConfig.meStringRefAddressSyntax; 574 575 // don't save "unspecified" string ref syntax ... query formula grammar 576 // and save that instead 577 if( eConv == formula::FormulaGrammar::CONV_UNSPECIFIED) 578 { 579 eConv = rDoc.GetAddressConvention(); 580 } 581 582 // write if it has been read|imported or explicitly changed 583 // or if ref syntax isn't what would be native for our file format 584 // i.e. CalcA1 in this case 585 if ( aCalcConfig.mbHasStringRefSyntax || 586 (eConv != formula::FormulaGrammar::CONV_OOO) ) 587 { 588 switch (eConv) 589 { 590 case formula::FormulaGrammar::CONV_OOO: 591 case formula::FormulaGrammar::CONV_XL_A1: 592 case formula::FormulaGrammar::CONV_XL_R1C1: 593 case formula::FormulaGrammar::CONV_A1_XL_A1: 594 aRet <<= static_cast<sal_Int16>( eConv ); 595 break; 596 597 case formula::FormulaGrammar::CONV_UNSPECIFIED: 598 case formula::FormulaGrammar::CONV_ODF: 599 case formula::FormulaGrammar::CONV_XL_OOX: 600 case formula::FormulaGrammar::CONV_LOTUS_A1: 601 case formula::FormulaGrammar::CONV_LAST: 602 { 603 aRet <<= sal_Int16(9999); 604 break; 605 } 606 } 607 } 608 } 609 else if (aPropertyName == SC_UNO_IMAGE_PREFERRED_DPI) 610 { 611 aRet <<= rDoc.GetImagePreferredDPI(); 612 } 613 else 614 { 615 const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions(); 616 if ( aPropertyName == SC_UNO_SNAPTORASTER ) 617 aRet <<= aGridOpt.GetUseGridSnap(); 618 else if ( aPropertyName == SC_UNO_RASTERVIS ) 619 aRet <<= aGridOpt.GetGridVisible(); 620 else if ( aPropertyName == SC_UNO_RASTERRESX ) 621 aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDrawX() ); 622 else if ( aPropertyName == SC_UNO_RASTERRESY ) 623 aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDrawY() ); 624 else if ( aPropertyName == SC_UNO_RASTERSUBX ) 625 aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDivisionX() ); 626 else if ( aPropertyName == SC_UNO_RASTERSUBY ) 627 aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDivisionY() ); 628 else if ( aPropertyName == SC_UNO_RASTERSYNC ) 629 aRet <<= aGridOpt.GetSynchronize(); 630 else 631 throw beans::UnknownPropertyException(aPropertyName); 632 } 633 634 635 return aRet; 636 } 637 638 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDocumentConfiguration ) 639 640 // XServiceInfo 641 OUString SAL_CALL ScDocumentConfiguration::getImplementationName() 642 { 643 return "ScDocumentConfiguration"; 644 } 645 646 sal_Bool SAL_CALL ScDocumentConfiguration::supportsService( const OUString& rServiceName ) 647 { 648 return cppu::supportsService(this, rServiceName); 649 } 650 651 uno::Sequence<OUString> SAL_CALL ScDocumentConfiguration::getSupportedServiceNames() 652 { 653 return {"com.sun.star.comp.SpreadsheetSettings", 654 "com.sun.star.document.Settings"}; 655 } 656 657 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 658
