1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_unotools.hxx" 30 31 #ifndef GCC 32 #endif 33 34 #include <unotools/saveopt.hxx> 35 #include "rtl/instance.hxx" 36 #include <unotools/configmgr.hxx> 37 #include <unotools/configitem.hxx> 38 #include <tools/debug.hxx> 39 #include <com/sun/star/uno/Any.hxx> 40 #include <com/sun/star/uno/Sequence.hxx> 41 42 #include <osl/mutex.hxx> 43 #include <comphelper/configurationhelper.hxx> 44 #include <unotools/processfactory.hxx> 45 #include <rtl/logfile.hxx> 46 #include "itemholder1.hxx" 47 48 using namespace utl; 49 using namespace rtl; 50 using namespace com::sun::star::uno; 51 namespace css = ::com::sun::star; 52 53 class SvtSaveOptions_Impl; 54 class SvtLoadOptions_Impl; 55 56 #define CFG_READONLY_DEFAULT sal_False 57 58 struct SvtLoadSaveOptions_Impl 59 { 60 SvtSaveOptions_Impl* pSaveOpt; 61 SvtLoadOptions_Impl* pLoadOpt; 62 }; 63 64 static SvtLoadSaveOptions_Impl* pOptions = NULL; 65 static sal_Int32 nRefCount = 0; 66 67 class SvtSaveOptions_Impl : public utl::ConfigItem 68 { 69 sal_Int32 nAutoSaveTime; 70 sal_Bool bUseUserData, 71 bBackup, 72 bAutoSave, 73 bAutoSavePrompt, 74 bDocInfSave, 75 bSaveWorkingSet, 76 bSaveDocView, 77 bSaveRelINet, 78 bSaveRelFSys, 79 bSaveUnpacked, 80 bDoPrettyPrinting, 81 bWarnAlienFormat, 82 bLoadDocPrinter, 83 bUseSHA1InODF12, 84 bUseBlowfishInODF12; 85 86 SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion; 87 88 sal_Bool bROAutoSaveTime, 89 bROUseUserData, 90 bROBackup, 91 bROAutoSave, 92 bROAutoSavePrompt, 93 bRODocInfSave, 94 bROSaveWorkingSet, 95 bROSaveDocView, 96 bROSaveRelINet, 97 bROSaveRelFSys, 98 bROSaveUnpacked, 99 bROWarnAlienFormat, 100 bRODoPrettyPrinting, 101 bROLoadDocPrinter, 102 bROODFDefaultVersion, 103 bROUseSHA1InODF12, 104 bROUseBlowfishInODF12; 105 106 public: 107 SvtSaveOptions_Impl(); 108 ~SvtSaveOptions_Impl(); 109 110 virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); 111 virtual void Commit(); 112 113 sal_Int32 GetAutoSaveTime() const { return nAutoSaveTime; } 114 sal_Bool IsUseUserData() const { return bUseUserData; } 115 sal_Bool IsBackup() const { return bBackup; } 116 sal_Bool IsAutoSave() const { return bAutoSave; } 117 sal_Bool IsAutoSavePrompt() const { return bAutoSavePrompt; } 118 sal_Bool IsDocInfoSave() const { return bDocInfSave; } 119 sal_Bool IsSaveWorkingSet() const { return bSaveWorkingSet; } 120 sal_Bool IsSaveDocView() const { return bSaveDocView; } 121 sal_Bool IsSaveRelINet() const { return bSaveRelINet; } 122 sal_Bool IsSaveRelFSys() const { return bSaveRelFSys; } 123 sal_Bool IsSaveUnpacked() const { return bSaveUnpacked; } 124 sal_Bool IsPrettyPrintingEnabled( ) const { return bDoPrettyPrinting; } 125 sal_Bool IsWarnAlienFormat() const { return bWarnAlienFormat; } 126 sal_Bool IsLoadDocPrinter() const { return bLoadDocPrinter; } 127 sal_Bool IsUseSHA1InODF12() const { return bUseSHA1InODF12; } 128 sal_Bool IsUseBlowfishInODF12() const { return bUseBlowfishInODF12; } 129 130 SvtSaveOptions::ODFDefaultVersion 131 GetODFDefaultVersion() const { return eODFDefaultVersion; } 132 133 void SetAutoSaveTime( sal_Int32 n ); 134 void SetUseUserData( sal_Bool b ); 135 void SetBackup( sal_Bool b ); 136 void SetAutoSave( sal_Bool b ); 137 void SetAutoSavePrompt( sal_Bool b ); 138 void SetDocInfoSave( sal_Bool b ); 139 void SetSaveWorkingSet( sal_Bool b ); 140 void SetSaveDocView( sal_Bool b ); 141 void SetSaveRelINet( sal_Bool b ); 142 void SetSaveRelFSys( sal_Bool b ); 143 void SetSaveUnpacked( sal_Bool b ); 144 void EnablePrettyPrinting( sal_Bool _bDoPP ); 145 void SetWarnAlienFormat( sal_Bool _bDoPP ); 146 void SetLoadDocPrinter( sal_Bool bNew ); 147 void SetUseSHA1InODF12( sal_Bool bUse ); 148 void SetUseBlowfishInODF12( sal_Bool bUse ); 149 void SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew ); 150 151 sal_Bool IsReadOnly( SvtSaveOptions::EOption eOption ) const; 152 }; 153 154 void SvtSaveOptions_Impl::SetAutoSaveTime( sal_Int32 n ) 155 { 156 if (!bROAutoSaveTime && nAutoSaveTime!=n) 157 { 158 nAutoSaveTime = n; 159 SetModified(); 160 Commit(); 161 } 162 } 163 164 void SvtSaveOptions_Impl::SetUseUserData( sal_Bool b ) 165 { 166 if (!bROUseUserData && bUseUserData!=b) 167 { 168 bUseUserData = b; 169 SetModified(); 170 } 171 } 172 173 void SvtSaveOptions_Impl::SetBackup( sal_Bool b ) 174 { 175 if (!bROBackup && bBackup!=b) 176 { 177 bBackup = b; 178 SetModified(); 179 } 180 } 181 182 void SvtSaveOptions_Impl::SetAutoSave( sal_Bool b ) 183 { 184 if (!bROAutoSave && bAutoSave!=b) 185 { 186 bAutoSave = b; 187 SetModified(); 188 Commit(); 189 } 190 } 191 192 void SvtSaveOptions_Impl::SetAutoSavePrompt( sal_Bool b ) 193 { 194 if (!bROAutoSavePrompt && bAutoSavePrompt!=b) 195 { 196 bAutoSavePrompt = b; 197 SetModified(); 198 } 199 } 200 201 void SvtSaveOptions_Impl::SetDocInfoSave(sal_Bool b) 202 { 203 if (!bRODocInfSave && bDocInfSave!=b) 204 { 205 bDocInfSave = b; 206 SetModified(); 207 } 208 } 209 210 void SvtSaveOptions_Impl::SetSaveWorkingSet( sal_Bool b ) 211 { 212 if (!bROSaveWorkingSet && bSaveWorkingSet!=b) 213 { 214 bSaveWorkingSet = b; 215 SetModified(); 216 } 217 } 218 219 void SvtSaveOptions_Impl::SetSaveDocView( sal_Bool b ) 220 { 221 if (!bROSaveDocView && bSaveDocView!=b) 222 { 223 bSaveDocView = b; 224 SetModified(); 225 } 226 } 227 228 void SvtSaveOptions_Impl::SetSaveRelINet( sal_Bool b ) 229 { 230 if (!bROSaveRelINet && bSaveRelINet!=b) 231 { 232 bSaveRelINet = b; 233 SetModified(); 234 } 235 } 236 237 void SvtSaveOptions_Impl::SetSaveRelFSys( sal_Bool b ) 238 { 239 if (!bROSaveRelFSys && bSaveRelFSys!=b) 240 { 241 bSaveRelFSys = b; 242 SetModified(); 243 } 244 } 245 246 void SvtSaveOptions_Impl::SetSaveUnpacked( sal_Bool b ) 247 { 248 if (!bROSaveUnpacked && bSaveUnpacked!=b) 249 { 250 bSaveUnpacked = b; 251 SetModified(); 252 } 253 } 254 255 void SvtSaveOptions_Impl::EnablePrettyPrinting( sal_Bool _bDoPP ) 256 { 257 if (!bRODoPrettyPrinting && bDoPrettyPrinting!=_bDoPP) 258 { 259 bDoPrettyPrinting = _bDoPP; 260 SetModified(); 261 } 262 } 263 264 void SvtSaveOptions_Impl::SetWarnAlienFormat( sal_Bool _bDoPP ) 265 { 266 if (!bROWarnAlienFormat && bWarnAlienFormat!=_bDoPP) 267 { 268 bWarnAlienFormat = _bDoPP; 269 SetModified(); 270 } 271 } 272 273 void SvtSaveOptions_Impl::SetLoadDocPrinter( sal_Bool bNew ) 274 { 275 if ( !bROLoadDocPrinter && bLoadDocPrinter != bNew ) 276 { 277 bLoadDocPrinter = bNew; 278 SetModified(); 279 } 280 } 281 282 void SvtSaveOptions_Impl::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew ) 283 { 284 if ( !bROODFDefaultVersion && eODFDefaultVersion != eNew ) 285 { 286 eODFDefaultVersion = eNew; 287 SetModified(); 288 } 289 } 290 291 void SvtSaveOptions_Impl::SetUseSHA1InODF12( sal_Bool bUse ) 292 { 293 if ( !bROUseSHA1InODF12 && bUseSHA1InODF12 != bUse ) 294 { 295 bUseSHA1InODF12 = bUse; 296 SetModified(); 297 } 298 } 299 300 void SvtSaveOptions_Impl::SetUseBlowfishInODF12( sal_Bool bUse ) 301 { 302 if ( !bROUseBlowfishInODF12 && bUseBlowfishInODF12 != bUse ) 303 { 304 bUseBlowfishInODF12 = bUse; 305 SetModified(); 306 } 307 } 308 309 sal_Bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const 310 { 311 sal_Bool bReadOnly = CFG_READONLY_DEFAULT; 312 switch(eOption) 313 { 314 case SvtSaveOptions::E_AUTOSAVETIME : 315 bReadOnly = bROAutoSaveTime; 316 break; 317 case SvtSaveOptions::E_USEUSERDATA : 318 bReadOnly = bROUseUserData; 319 break; 320 case SvtSaveOptions::E_BACKUP : 321 bReadOnly = bROBackup; 322 break; 323 case SvtSaveOptions::E_AUTOSAVE : 324 bReadOnly = bROAutoSave; 325 break; 326 case SvtSaveOptions::E_AUTOSAVEPROMPT : 327 bReadOnly = bROAutoSavePrompt; 328 break; 329 case SvtSaveOptions::E_DOCINFSAVE : 330 bReadOnly = bRODocInfSave; 331 break; 332 case SvtSaveOptions::E_SAVEWORKINGSET : 333 bReadOnly = bROSaveWorkingSet; 334 break; 335 case SvtSaveOptions::E_SAVEDOCVIEW : 336 bReadOnly = bROSaveDocView; 337 break; 338 case SvtSaveOptions::E_SAVERELINET : 339 bReadOnly = bROSaveRelINet; 340 break; 341 case SvtSaveOptions::E_SAVERELFSYS : 342 bReadOnly = bROSaveRelFSys; 343 break; 344 case SvtSaveOptions::E_SAVEUNPACKED : 345 bReadOnly = bROSaveUnpacked; 346 break; 347 case SvtSaveOptions::E_DOPRETTYPRINTING : 348 bReadOnly = bRODoPrettyPrinting; 349 break; 350 case SvtSaveOptions::E_WARNALIENFORMAT : 351 bReadOnly = bROWarnAlienFormat; 352 break; 353 case SvtSaveOptions::E_LOADDOCPRINTER : 354 bReadOnly = bROLoadDocPrinter; 355 break; 356 case SvtSaveOptions::E_ODFDEFAULTVERSION : 357 bReadOnly = bROLoadDocPrinter; 358 break; 359 case SvtSaveOptions::E_USESHA1INODF12: 360 bReadOnly = bROUseSHA1InODF12; 361 break; 362 case SvtSaveOptions::E_USEBLOWFISHINODF12: 363 bReadOnly = bROUseBlowfishInODF12; 364 break; 365 } 366 return bReadOnly; 367 } 368 369 #define FORMAT 0 370 #define TIMEINTERVALL 1 371 #define USEUSERDATA 2 372 #define CREATEBACKUP 3 373 #define AUTOSAVE 4 374 #define PROMPT 5 375 #define EDITPROPERTY 6 376 #define SAVEVIEWINFO 7 377 #define UNPACKED 8 378 #define PRETTYPRINTING 9 379 #define WARNALIENFORMAT 10 380 #define LOADDOCPRINTER 11 381 #define FILESYSTEM 12 382 #define INTERNET 13 383 #define SAVEWORKINGSET 14 384 #define ODFDEFAULTVERSION 15 385 #define USESHA1INODF12 16 386 #define USEBLOWFISHINODF12 17 387 388 Sequence< OUString > GetPropertyNames() 389 { 390 static const char* aPropNames[] = 391 { 392 "Graphic/Format", 393 "Document/AutoSaveTimeIntervall", 394 "Document/UseUserData", 395 "Document/CreateBackup", 396 "Document/AutoSave", 397 "Document/AutoSavePrompt", 398 "Document/EditProperty", 399 "Document/ViewInfo", 400 "Document/Unpacked", 401 "Document/PrettyPrinting", 402 "Document/WarnAlienFormat", 403 "Document/LoadPrinter", 404 "URL/FileSystem", 405 "URL/Internet", 406 "WorkingSet", 407 "ODF/DefaultVersion", 408 "ODF/UseSHA1InODF12", 409 "ODF/UseBlowfishInODF12" 410 }; 411 412 const int nCount = sizeof( aPropNames ) / sizeof( const char* ); 413 Sequence< OUString > aNames( nCount ); 414 OUString* pNames = aNames.getArray(); 415 for ( int i = 0; i < nCount; i++ ) 416 pNames[i] = OUString::createFromAscii( aPropNames[i] ); 417 418 return aNames; 419 } 420 421 // ----------------------------------------------------------------------- 422 423 SvtSaveOptions_Impl::SvtSaveOptions_Impl() 424 : ConfigItem( OUString::createFromAscii("Office.Common/Save") ) 425 , nAutoSaveTime( 0 ) 426 , bUseUserData( sal_False ) 427 , bBackup( sal_False ) 428 , bAutoSave( sal_False ) 429 , bAutoSavePrompt( sal_False ) 430 , bDocInfSave( sal_False ) 431 , bSaveWorkingSet( sal_False ) 432 , bSaveDocView( sal_False ) 433 , bSaveRelINet( sal_False ) 434 , bSaveRelFSys( sal_False ) 435 , bSaveUnpacked( sal_False ) 436 , bDoPrettyPrinting( sal_False ) 437 , bWarnAlienFormat( sal_True ) 438 , bLoadDocPrinter( sal_True ) 439 , bUseSHA1InODF12( sal_False ) 440 , bUseBlowfishInODF12( sal_False ) 441 , eODFDefaultVersion( SvtSaveOptions::ODFVER_LATEST ) 442 , bROAutoSaveTime( CFG_READONLY_DEFAULT ) 443 , bROUseUserData( CFG_READONLY_DEFAULT ) 444 , bROBackup( CFG_READONLY_DEFAULT ) 445 , bROAutoSave( CFG_READONLY_DEFAULT ) 446 , bROAutoSavePrompt( CFG_READONLY_DEFAULT ) 447 , bRODocInfSave( CFG_READONLY_DEFAULT ) 448 , bROSaveWorkingSet( CFG_READONLY_DEFAULT ) 449 , bROSaveDocView( CFG_READONLY_DEFAULT ) 450 , bROSaveRelINet( CFG_READONLY_DEFAULT ) 451 , bROSaveRelFSys( CFG_READONLY_DEFAULT ) 452 , bROSaveUnpacked( CFG_READONLY_DEFAULT ) 453 , bROWarnAlienFormat( CFG_READONLY_DEFAULT ) 454 , bRODoPrettyPrinting( CFG_READONLY_DEFAULT ) 455 , bROLoadDocPrinter( CFG_READONLY_DEFAULT ) 456 , bROODFDefaultVersion( CFG_READONLY_DEFAULT ) 457 , bROUseSHA1InODF12( CFG_READONLY_DEFAULT ) 458 , bROUseBlowfishInODF12( CFG_READONLY_DEFAULT ) 459 { 460 Sequence< OUString > aNames = GetPropertyNames(); 461 Sequence< Any > aValues = GetProperties( aNames ); 462 Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames ); 463 EnableNotification( aNames ); 464 const Any* pValues = aValues.getConstArray(); 465 const sal_Bool* pROStates = aROStates.getConstArray(); 466 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); 467 DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" ); 468 if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() ) 469 { 470 for ( int nProp = 0; nProp < aNames.getLength(); nProp++ ) 471 { 472 DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" ); 473 if ( pValues[nProp].hasValue() ) 474 { 475 sal_Int32 nTemp = 0; 476 switch ( nProp ) 477 { 478 case FORMAT: 479 // not supported anymore 480 break; 481 482 case TIMEINTERVALL : 483 if ( pValues[nProp] >>= nTemp ) 484 nAutoSaveTime = nTemp; 485 else { 486 DBG_ERROR( "Wrong Type!" ); 487 }; 488 bROAutoSaveTime = pROStates[nProp]; 489 break; 490 491 case ODFDEFAULTVERSION : 492 { 493 sal_Int16 nTmp = 0; 494 if ( pValues[nProp] >>= nTmp ) 495 { 496 if( nTmp == 3 ) 497 eODFDefaultVersion = SvtSaveOptions::ODFVER_LATEST; 498 else 499 eODFDefaultVersion = SvtSaveOptions::ODFDefaultVersion( nTmp ); 500 } 501 else { 502 DBG_ERRORFILE( "SvtSaveOptions_Impl::SvtSaveOptions_Impl(): Wrong Type!" ); 503 }; 504 bROODFDefaultVersion = pROStates[nProp]; 505 break; 506 } 507 508 default: 509 { 510 sal_Bool bTemp = sal_Bool(); 511 if ( pValues[nProp] >>= bTemp ) 512 { 513 switch ( nProp ) 514 { 515 case USEUSERDATA : 516 bUseUserData = bTemp; 517 bROUseUserData = pROStates[nProp]; 518 break; 519 case CREATEBACKUP : 520 bBackup = bTemp; 521 bROBackup = pROStates[nProp]; 522 break; 523 case AUTOSAVE : 524 bAutoSave = bTemp; 525 bROAutoSave = pROStates[nProp]; 526 break; 527 case PROMPT : 528 bAutoSavePrompt = bTemp; 529 bROAutoSavePrompt = pROStates[nProp]; 530 break; 531 case EDITPROPERTY : 532 bDocInfSave = bTemp; 533 bRODocInfSave = pROStates[nProp]; 534 break; 535 case SAVEWORKINGSET : 536 bSaveWorkingSet = bTemp; 537 bROSaveWorkingSet = pROStates[nProp]; 538 break; 539 case SAVEVIEWINFO : 540 bSaveDocView = bTemp; 541 bROSaveDocView = pROStates[nProp]; 542 break; 543 case FILESYSTEM : 544 bSaveRelFSys = bTemp; 545 bROSaveRelFSys = pROStates[nProp]; 546 break; 547 case INTERNET : 548 bSaveRelINet = bTemp; 549 bROSaveRelINet = pROStates[nProp]; 550 break; 551 case UNPACKED : 552 bSaveUnpacked = bTemp; 553 bROSaveUnpacked = pROStates[nProp]; 554 break; 555 556 case PRETTYPRINTING: 557 bDoPrettyPrinting = bTemp; 558 bRODoPrettyPrinting = pROStates[nProp]; 559 break; 560 561 case WARNALIENFORMAT: 562 bWarnAlienFormat = bTemp; 563 bROWarnAlienFormat = pROStates[nProp]; 564 break; 565 566 case LOADDOCPRINTER: 567 bLoadDocPrinter = bTemp; 568 bROLoadDocPrinter = pROStates[nProp]; 569 break; 570 571 case USESHA1INODF12: 572 bUseSHA1InODF12 = bTemp; 573 bROUseSHA1InODF12 = pROStates[nProp]; 574 break; 575 576 case USEBLOWFISHINODF12: 577 bUseBlowfishInODF12 = bTemp; 578 bROUseBlowfishInODF12 = pROStates[nProp]; 579 break; 580 581 default : 582 DBG_ERRORFILE( "invalid index to load a path" ); 583 } 584 } 585 else 586 { 587 DBG_ERROR( "Wrong Type!" ); 588 } 589 } 590 } 591 } 592 } 593 } 594 595 try 596 { 597 css::uno::Reference< css::uno::XInterface > xCFG = ::comphelper::ConfigurationHelper::openConfig( 598 ::utl::getProcessServiceFactory(), 599 ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery"), 600 ::comphelper::ConfigurationHelper::E_READONLY); 601 602 ::comphelper::ConfigurationHelper::readRelativeKey( 603 xCFG, 604 ::rtl::OUString::createFromAscii("AutoSave"), 605 ::rtl::OUString::createFromAscii("Enabled")) >>= bAutoSave; 606 607 ::comphelper::ConfigurationHelper::readRelativeKey( 608 xCFG, 609 ::rtl::OUString::createFromAscii("AutoSave"), 610 ::rtl::OUString::createFromAscii("TimeIntervall")) >>= nAutoSaveTime; 611 } 612 catch(const css::uno::Exception&) 613 { DBG_ERROR("Could not find needed informations for AutoSave feature."); } 614 } 615 616 SvtSaveOptions_Impl::~SvtSaveOptions_Impl() 617 {} 618 619 void SvtSaveOptions_Impl::Commit() 620 { 621 Sequence< OUString > aOrgNames = GetPropertyNames(); 622 OUString* pOrgNames = aOrgNames.getArray(); 623 sal_Int32 nOrgCount = aOrgNames.getLength(); 624 625 Sequence< OUString > aNames( nOrgCount ); 626 Sequence< Any > aValues( nOrgCount ); 627 OUString* pNames = aNames.getArray(); 628 Any* pValues = aValues.getArray(); 629 sal_Int32 nRealCount = 0; 630 631 for (sal_Int32 i=0; i<nOrgCount; ++i) 632 { 633 switch (i) 634 { 635 case FORMAT: 636 // not supported anymore 637 break; 638 case TIMEINTERVALL : 639 if (!bROAutoSaveTime) 640 { 641 pValues[nRealCount] <<= nAutoSaveTime; 642 pNames[nRealCount] = pOrgNames[i]; 643 ++nRealCount; 644 } 645 break; 646 case USEUSERDATA : 647 if (!bROUseUserData) 648 { 649 pValues[nRealCount] <<= bUseUserData; 650 pNames[nRealCount] = pOrgNames[i]; 651 ++nRealCount; 652 } 653 break; 654 case CREATEBACKUP : 655 if (!bROBackup) 656 { 657 pValues[nRealCount] <<= bBackup; 658 pNames[nRealCount] = pOrgNames[i]; 659 ++nRealCount; 660 } 661 break; 662 case AUTOSAVE : 663 if (!bROAutoSave) 664 { 665 pValues[nRealCount] <<= bAutoSave; 666 pNames[nRealCount] = pOrgNames[i]; 667 ++nRealCount; 668 } 669 break; 670 case PROMPT : 671 if (!bROAutoSavePrompt) 672 { 673 pValues[nRealCount] <<= bAutoSavePrompt; 674 pNames[nRealCount] = pOrgNames[i]; 675 ++nRealCount; 676 } 677 break; 678 case EDITPROPERTY : 679 if (!bRODocInfSave) 680 { 681 pValues[nRealCount] <<= bDocInfSave; 682 pNames[nRealCount] = pOrgNames[i]; 683 ++nRealCount; 684 } 685 break; 686 case SAVEWORKINGSET : 687 if (!bROSaveWorkingSet) 688 { 689 pValues[nRealCount] <<= bSaveWorkingSet; 690 pNames[nRealCount] = pOrgNames[i]; 691 ++nRealCount; 692 } 693 break; 694 case SAVEVIEWINFO : 695 if (!bROSaveDocView) 696 { 697 pValues[nRealCount] <<= bSaveDocView; 698 pNames[nRealCount] = pOrgNames[i]; 699 ++nRealCount; 700 } 701 break; 702 case FILESYSTEM : 703 if (!bROSaveRelFSys) 704 { 705 pValues[nRealCount] <<= bSaveRelFSys; 706 pNames[nRealCount] = pOrgNames[i]; 707 ++nRealCount; 708 } 709 break; 710 case INTERNET : 711 if (!bROSaveRelINet) 712 { 713 pValues[nRealCount] <<= bSaveRelINet; 714 pNames[nRealCount] = pOrgNames[i]; 715 ++nRealCount; 716 } 717 break; 718 case UNPACKED : 719 if (!bROSaveUnpacked) 720 { 721 pValues[nRealCount] <<= bSaveUnpacked; 722 pNames[nRealCount] = pOrgNames[i]; 723 ++nRealCount; 724 } 725 break; 726 case PRETTYPRINTING: 727 if (!bRODoPrettyPrinting) 728 { 729 pValues[nRealCount] <<= bDoPrettyPrinting; 730 pNames[nRealCount] = pOrgNames[i]; 731 ++nRealCount; 732 } 733 break; 734 case WARNALIENFORMAT: 735 if (!bROWarnAlienFormat) 736 { 737 pValues[nRealCount] <<= bWarnAlienFormat; 738 pNames[nRealCount] = pOrgNames[i]; 739 ++nRealCount; 740 } 741 break; 742 case LOADDOCPRINTER: 743 if (!bROLoadDocPrinter) 744 { 745 pValues[nRealCount] <<= bLoadDocPrinter; 746 pNames[nRealCount] = pOrgNames[i]; 747 ++nRealCount; 748 } 749 break; 750 case ODFDEFAULTVERSION: 751 if (!bROODFDefaultVersion) 752 { 753 pValues[nRealCount] <<= (eODFDefaultVersion == SvtSaveOptions::ODFVER_LATEST) ? sal_Int16( 3 ) : sal_Int16( eODFDefaultVersion ); 754 pNames[nRealCount] = pOrgNames[i]; 755 ++nRealCount; 756 } 757 break; 758 case USESHA1INODF12: 759 if (!bROUseSHA1InODF12) 760 { 761 pValues[nRealCount] <<= bUseSHA1InODF12; 762 pNames[nRealCount] = pOrgNames[i]; 763 ++nRealCount; 764 } 765 break; 766 case USEBLOWFISHINODF12: 767 if (!bROUseBlowfishInODF12) 768 { 769 pValues[nRealCount] <<= bUseBlowfishInODF12; 770 pNames[nRealCount] = pOrgNames[i]; 771 ++nRealCount; 772 } 773 break; 774 775 default: 776 DBG_ERRORFILE( "invalid index to save a path" ); 777 } 778 } 779 780 aNames.realloc(nRealCount); 781 aValues.realloc(nRealCount); 782 PutProperties( aNames, aValues ); 783 784 css::uno::Reference< css::uno::XInterface > xCFG = ::comphelper::ConfigurationHelper::openConfig( 785 ::utl::getProcessServiceFactory(), 786 ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery"), 787 ::comphelper::ConfigurationHelper::E_STANDARD); 788 789 ::comphelper::ConfigurationHelper::writeRelativeKey( 790 xCFG, 791 ::rtl::OUString::createFromAscii("AutoSave"), 792 ::rtl::OUString::createFromAscii("TimeIntervall"), 793 css::uno::makeAny(nAutoSaveTime)); 794 795 ::comphelper::ConfigurationHelper::writeRelativeKey( 796 xCFG, 797 ::rtl::OUString::createFromAscii("AutoSave"), 798 ::rtl::OUString::createFromAscii("Enabled"), 799 css::uno::makeAny(bAutoSave)); 800 801 ::comphelper::ConfigurationHelper::flush(xCFG); 802 } 803 804 // ----------------------------------------------------------------------- 805 806 void SvtSaveOptions_Impl::Notify( const Sequence<rtl::OUString>& ) 807 { 808 } 809 810 811 class SvtLoadOptions_Impl : public utl::ConfigItem 812 { 813 814 sal_Bool bLoadUserDefinedSettings; 815 816 public: 817 SvtLoadOptions_Impl(); 818 ~SvtLoadOptions_Impl(); 819 820 virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); 821 virtual void Commit(); 822 823 void SetLoadUserSettings(sal_Bool b){bLoadUserDefinedSettings = b; SetModified();} 824 sal_Bool IsLoadUserSettings() const {return bLoadUserDefinedSettings;} 825 }; 826 // ----------------------------------------------------------------------- 827 const sal_Char cUserDefinedSettings[] = "UserDefinedSettings"; 828 829 SvtLoadOptions_Impl::SvtLoadOptions_Impl() 830 : ConfigItem( OUString::createFromAscii("Office.Common/Load") ) 831 , bLoadUserDefinedSettings( sal_False ) 832 { 833 Sequence< OUString > aNames(1); 834 aNames[0] = OUString::createFromAscii(cUserDefinedSettings); 835 Sequence< Any > aValues = GetProperties( aNames ); 836 EnableNotification( aNames ); 837 const Any* pValues = aValues.getConstArray(); 838 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); 839 if (pValues[0].getValueTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN) 840 bLoadUserDefinedSettings = *(sal_Bool *)pValues[0].getValue(); 841 } 842 // ----------------------------------------------------------------------- 843 SvtLoadOptions_Impl::~SvtLoadOptions_Impl() 844 { 845 } 846 // ----------------------------------------------------------------------- 847 void SvtLoadOptions_Impl::Commit() 848 { 849 Sequence< OUString > aNames(1); 850 aNames[0] = OUString::createFromAscii(cUserDefinedSettings); 851 Sequence< Any > aValues( 1 ); 852 aValues[0].setValue(&bLoadUserDefinedSettings, ::getBooleanCppuType()); 853 PutProperties( aNames, aValues ); 854 } 855 // ----------------------------------------------------------------------- 856 void SvtLoadOptions_Impl::Notify( const Sequence<rtl::OUString>& ) 857 { 858 DBG_ERRORFILE( "properties have been changed" ); 859 } 860 // ----------------------------------------------------------------------- 861 862 namespace 863 { 864 class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton > 865 { 866 }; 867 } 868 869 // ----------------------------------------------------------------------- 870 SvtSaveOptions::SvtSaveOptions() 871 { 872 // Global access, must be guarded (multithreading) 873 ::osl::MutexGuard aGuard( LocalSingleton::get() ); 874 if ( !pOptions ) 875 { 876 RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtSaveOptions_Impl::ctor()"); 877 pOptions = new SvtLoadSaveOptions_Impl; 878 pOptions->pSaveOpt = new SvtSaveOptions_Impl; 879 pOptions->pLoadOpt = new SvtLoadOptions_Impl; 880 881 ItemHolder1::holdConfigItem(E_SAVEOPTIONS); 882 } 883 ++nRefCount; 884 pImp = pOptions; 885 } 886 887 // ----------------------------------------------------------------------- 888 889 SvtSaveOptions::~SvtSaveOptions() 890 { 891 // Global access, must be guarded (multithreading) 892 ::osl::MutexGuard aGuard( LocalSingleton::get() ); 893 if ( !--nRefCount ) 894 { 895 if ( pOptions->pSaveOpt->IsModified() ) 896 pOptions->pSaveOpt->Commit(); 897 if ( pOptions->pLoadOpt->IsModified() ) 898 pOptions->pLoadOpt->Commit(); 899 900 DELETEZ( pOptions->pLoadOpt ); 901 DELETEZ( pOptions->pSaveOpt ); 902 DELETEZ( pOptions ); 903 } 904 } 905 906 void SvtSaveOptions::SetAutoSaveTime( sal_Int32 n ) 907 { 908 pImp->pSaveOpt->SetAutoSaveTime( n ); 909 } 910 911 sal_Int32 SvtSaveOptions::GetAutoSaveTime() const 912 { 913 return pImp->pSaveOpt->GetAutoSaveTime(); 914 } 915 916 void SvtSaveOptions::SetUseUserData( sal_Bool b ) 917 { 918 pImp->pSaveOpt->SetUseUserData( b ); 919 } 920 921 sal_Bool SvtSaveOptions::IsUseUserData() const 922 { 923 return pImp->pSaveOpt->IsUseUserData(); 924 } 925 926 void SvtSaveOptions::SetBackup( sal_Bool b ) 927 { 928 pImp->pSaveOpt->SetBackup( b ); 929 } 930 931 sal_Bool SvtSaveOptions::IsBackup() const 932 { 933 return pImp->pSaveOpt->IsBackup(); 934 } 935 936 void SvtSaveOptions::SetAutoSave( sal_Bool b ) 937 { 938 pImp->pSaveOpt->SetAutoSave( b ); 939 } 940 941 sal_Bool SvtSaveOptions::IsAutoSave() const 942 { 943 return pImp->pSaveOpt->IsAutoSave(); 944 } 945 946 void SvtSaveOptions::SetAutoSavePrompt( sal_Bool b ) 947 { 948 pImp->pSaveOpt->SetAutoSavePrompt( b ); 949 } 950 951 sal_Bool SvtSaveOptions::IsAutoSavePrompt() const 952 { 953 return pImp->pSaveOpt->IsAutoSavePrompt(); 954 } 955 956 void SvtSaveOptions::SetDocInfoSave(sal_Bool b) 957 { 958 pImp->pSaveOpt->SetDocInfoSave( b ); 959 } 960 961 sal_Bool SvtSaveOptions::IsDocInfoSave() const 962 { 963 return pImp->pSaveOpt->IsDocInfoSave(); 964 } 965 966 void SvtSaveOptions::SetSaveWorkingSet( sal_Bool b ) 967 { 968 pImp->pSaveOpt->SetSaveWorkingSet( b ); 969 } 970 971 sal_Bool SvtSaveOptions::IsSaveWorkingSet() const 972 { 973 return pImp->pSaveOpt->IsSaveWorkingSet(); 974 } 975 976 void SvtSaveOptions::SetSaveDocView( sal_Bool b ) 977 { 978 pImp->pSaveOpt->SetSaveDocView( b ); 979 } 980 981 sal_Bool SvtSaveOptions::IsSaveDocView() const 982 { 983 return pImp->pSaveOpt->IsSaveDocView(); 984 } 985 986 void SvtSaveOptions::SetSaveRelINet( sal_Bool b ) 987 { 988 pImp->pSaveOpt->SetSaveRelINet( b ); 989 } 990 991 sal_Bool SvtSaveOptions::IsSaveRelINet() const 992 { 993 return pImp->pSaveOpt->IsSaveRelINet(); 994 } 995 996 void SvtSaveOptions::SetSaveRelFSys( sal_Bool b ) 997 { 998 pImp->pSaveOpt->SetSaveRelFSys( b ); 999 } 1000 1001 sal_Bool SvtSaveOptions::IsSaveRelFSys() const 1002 { 1003 return pImp->pSaveOpt->IsSaveRelFSys(); 1004 } 1005 1006 void SvtSaveOptions::SetSaveUnpacked( sal_Bool b ) 1007 { 1008 pImp->pSaveOpt->SetSaveUnpacked( b ); 1009 } 1010 1011 sal_Bool SvtSaveOptions::IsSaveUnpacked() const 1012 { 1013 return pImp->pSaveOpt->IsSaveUnpacked(); 1014 } 1015 1016 void SvtSaveOptions::SetLoadUserSettings(sal_Bool b) 1017 { 1018 pImp->pLoadOpt->SetLoadUserSettings(b); 1019 } 1020 1021 sal_Bool SvtSaveOptions::IsLoadUserSettings() const 1022 { 1023 return pImp->pLoadOpt->IsLoadUserSettings(); 1024 } 1025 1026 void SvtSaveOptions::SetPrettyPrinting( sal_Bool _bEnable ) 1027 { 1028 pImp->pSaveOpt->EnablePrettyPrinting( _bEnable ); 1029 } 1030 1031 sal_Bool SvtSaveOptions::IsPrettyPrinting() const 1032 { 1033 return pImp->pSaveOpt->IsPrettyPrintingEnabled(); 1034 } 1035 1036 void SvtSaveOptions::SetWarnAlienFormat( sal_Bool _bEnable ) 1037 { 1038 pImp->pSaveOpt->SetWarnAlienFormat( _bEnable ); 1039 } 1040 1041 sal_Bool SvtSaveOptions::IsWarnAlienFormat() const 1042 { 1043 return pImp->pSaveOpt->IsWarnAlienFormat(); 1044 } 1045 1046 void SvtSaveOptions::SetLoadDocumentPrinter( sal_Bool _bEnable ) 1047 { 1048 pImp->pSaveOpt->SetLoadDocPrinter( _bEnable ); 1049 } 1050 1051 sal_Bool SvtSaveOptions::IsLoadDocumentPrinter() const 1052 { 1053 return pImp->pSaveOpt->IsLoadDocPrinter(); 1054 } 1055 1056 void SvtSaveOptions::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eVersion ) 1057 { 1058 pImp->pSaveOpt->SetODFDefaultVersion( eVersion ); 1059 } 1060 1061 SvtSaveOptions::ODFDefaultVersion SvtSaveOptions::GetODFDefaultVersion() const 1062 { 1063 return pImp->pSaveOpt->GetODFDefaultVersion(); 1064 } 1065 1066 void SvtSaveOptions::SetUseSHA1InODF12( sal_Bool bUse ) 1067 { 1068 pImp->pSaveOpt->SetUseSHA1InODF12( bUse ); 1069 } 1070 1071 sal_Bool SvtSaveOptions::IsUseSHA1InODF12() const 1072 { 1073 return pImp->pSaveOpt->IsUseSHA1InODF12(); 1074 } 1075 1076 void SvtSaveOptions::SetUseBlowfishInODF12( sal_Bool bUse ) 1077 { 1078 pImp->pSaveOpt->SetUseBlowfishInODF12( bUse ); 1079 } 1080 1081 sal_Bool SvtSaveOptions::IsUseBlowfishInODF12() const 1082 { 1083 return pImp->pSaveOpt->IsUseBlowfishInODF12(); 1084 } 1085 1086 sal_Bool SvtSaveOptions::IsReadOnly( SvtSaveOptions::EOption eOption ) const 1087 { 1088 return pImp->pSaveOpt->IsReadOnly(eOption); 1089 } 1090 1091