Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / unotools / source / config / saveopt.cxx
blob6c8922edf706ed4594ce0489a0bbd38f00b89f66
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <sal/log.hxx>
23 #include <unotools/saveopt.hxx>
24 #include <rtl/instance.hxx>
25 #include <unotools/configmgr.hxx>
26 #include <unotools/configitem.hxx>
27 #include <tools/debug.hxx>
28 #include <com/sun/star/uno/Any.hxx>
29 #include <com/sun/star/uno/Sequence.hxx>
31 #include <osl/diagnose.h>
32 #include <osl/mutex.hxx>
33 #include <officecfg/Office/Recovery.hxx>
35 using namespace utl;
36 using namespace com::sun::star::uno;
38 class SvtSaveOptions_Impl;
39 class SvtLoadOptions_Impl;
41 #define CFG_READONLY_DEFAULT false
43 struct SvtLoadSaveOptions_Impl
45 std::unique_ptr<SvtSaveOptions_Impl> pSaveOpt;
46 std::unique_ptr<SvtLoadOptions_Impl> pLoadOpt;
49 static std::unique_ptr<SvtLoadSaveOptions_Impl> pOptions;
50 static sal_Int32 nRefCount = 0;
52 class SvtSaveOptions_Impl : public utl::ConfigItem
54 sal_Int32 nAutoSaveTime;
55 bool bUseUserData,
56 bBackup,
57 bAutoSave,
58 bAutoSavePrompt,
59 bUserAutoSave,
60 bDocInfSave,
61 bSaveWorkingSet,
62 bSaveDocView,
63 bSaveRelINet,
64 bSaveRelFSys,
65 bDoPrettyPrinting,
66 bWarnAlienFormat,
67 bLoadDocPrinter;
69 SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion;
71 bool bROAutoSaveTime,
72 bROUseUserData,
73 bROBackup,
74 bROAutoSave,
75 bROAutoSavePrompt,
76 bROUserAutoSave,
77 bRODocInfSave,
78 bROSaveWorkingSet,
79 bROSaveDocView,
80 bROSaveRelINet,
81 bROSaveRelFSys,
82 bROWarnAlienFormat,
83 bRODoPrettyPrinting,
84 bROLoadDocPrinter,
85 bROODFDefaultVersion;
87 virtual void ImplCommit() override;
89 public:
90 SvtSaveOptions_Impl();
92 virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override;
94 sal_Int32 GetAutoSaveTime() const { return nAutoSaveTime; }
95 bool IsUseUserData() const { return bUseUserData; }
96 bool IsBackup() const { return bBackup; }
97 bool IsAutoSave() const { return bAutoSave; }
98 bool IsAutoSavePrompt() const { return bAutoSavePrompt; }
99 bool IsUserAutoSave() const { return bUserAutoSave; }
100 bool IsDocInfoSave() const { return bDocInfSave; }
101 bool IsSaveWorkingSet() const { return bSaveWorkingSet; }
102 bool IsSaveDocView() const { return bSaveDocView; }
103 bool IsSaveRelINet() const { return bSaveRelINet; }
104 bool IsSaveRelFSys() const { return bSaveRelFSys; }
105 bool IsPrettyPrintingEnabled( ) const { return bDoPrettyPrinting; }
106 bool IsWarnAlienFormat() const { return bWarnAlienFormat; }
107 bool IsLoadDocPrinter() const { return bLoadDocPrinter; }
109 SvtSaveOptions::ODFDefaultVersion
110 GetODFDefaultVersion() const { return eODFDefaultVersion; }
112 void SetAutoSaveTime( sal_Int32 n );
113 void SetUseUserData( bool b );
114 void SetBackup( bool b );
115 void SetAutoSave( bool b );
116 void SetAutoSavePrompt( bool b );
117 void SetUserAutoSave( bool b );
118 void SetDocInfoSave( bool b );
119 void SetSaveWorkingSet( bool b );
120 void SetSaveDocView( bool b );
121 void SetSaveRelINet( bool b );
122 void SetSaveRelFSys( bool b );
123 void EnablePrettyPrinting( bool _bDoPP );
124 void SetWarnAlienFormat( bool _bDoPP );
125 void SetLoadDocPrinter( bool bNew );
126 void SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew );
128 bool IsReadOnly( SvtSaveOptions::EOption eOption ) const;
131 void SvtSaveOptions_Impl::SetAutoSaveTime( sal_Int32 n )
133 if (!bROAutoSaveTime && nAutoSaveTime!=n)
135 nAutoSaveTime = n;
136 SetModified();
137 Commit();
141 void SvtSaveOptions_Impl::SetUseUserData( bool b )
143 if (!bROUseUserData && bUseUserData!=b)
145 bUseUserData = b;
146 SetModified();
150 void SvtSaveOptions_Impl::SetBackup( bool b )
152 if (!bROBackup && bBackup!=b)
154 bBackup = b;
155 SetModified();
159 void SvtSaveOptions_Impl::SetAutoSave( bool b )
161 if (!bROAutoSave && bAutoSave!=b)
163 bAutoSave = b;
164 SetModified();
165 Commit();
169 void SvtSaveOptions_Impl::SetAutoSavePrompt( bool b )
171 if (!bROAutoSavePrompt && bAutoSavePrompt!=b)
173 bAutoSavePrompt = b;
174 SetModified();
178 void SvtSaveOptions_Impl::SetUserAutoSave( bool b )
180 if (!bROUserAutoSave && bUserAutoSave!=b)
182 bUserAutoSave = b;
183 SetModified();
184 Commit();
188 void SvtSaveOptions_Impl::SetDocInfoSave(bool b)
190 if (!bRODocInfSave && bDocInfSave!=b)
192 bDocInfSave = b;
193 SetModified();
197 void SvtSaveOptions_Impl::SetSaveWorkingSet( bool b )
199 if (!bROSaveWorkingSet && bSaveWorkingSet!=b)
201 bSaveWorkingSet = b;
202 SetModified();
206 void SvtSaveOptions_Impl::SetSaveDocView( bool b )
208 if (!bROSaveDocView && bSaveDocView!=b)
210 bSaveDocView = b;
211 SetModified();
215 void SvtSaveOptions_Impl::SetSaveRelINet( bool b )
217 if (!bROSaveRelINet && bSaveRelINet!=b)
219 bSaveRelINet = b;
220 SetModified();
224 void SvtSaveOptions_Impl::SetSaveRelFSys( bool b )
226 if (!bROSaveRelFSys && bSaveRelFSys!=b)
228 bSaveRelFSys = b;
229 SetModified();
233 void SvtSaveOptions_Impl::EnablePrettyPrinting( bool _bDoPP )
235 if (!bRODoPrettyPrinting && bDoPrettyPrinting!=_bDoPP)
237 bDoPrettyPrinting = _bDoPP;
238 SetModified();
242 void SvtSaveOptions_Impl::SetWarnAlienFormat( bool _bDoPP )
244 if (!bROWarnAlienFormat && bWarnAlienFormat!=_bDoPP)
246 bWarnAlienFormat = _bDoPP;
247 SetModified();
251 void SvtSaveOptions_Impl::SetLoadDocPrinter( bool bNew )
253 if ( !bROLoadDocPrinter && bLoadDocPrinter != bNew )
255 bLoadDocPrinter = bNew;
256 SetModified();
260 void SvtSaveOptions_Impl::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew )
262 if ( !bROODFDefaultVersion && eODFDefaultVersion != eNew )
264 eODFDefaultVersion = eNew;
265 SetModified();
269 bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const
271 bool bReadOnly = CFG_READONLY_DEFAULT;
272 switch(eOption)
274 case SvtSaveOptions::EOption::AutoSaveTime :
275 bReadOnly = bROAutoSaveTime;
276 break;
277 case SvtSaveOptions::EOption::UseUserData :
278 bReadOnly = bROUseUserData;
279 break;
280 case SvtSaveOptions::EOption::Backup :
281 bReadOnly = bROBackup;
282 break;
283 case SvtSaveOptions::EOption::AutoSave :
284 bReadOnly = bROAutoSave;
285 break;
286 case SvtSaveOptions::EOption::AutoSavePrompt :
287 bReadOnly = bROAutoSavePrompt;
288 break;
289 case SvtSaveOptions::EOption::UserAutoSave :
290 bReadOnly = bROUserAutoSave;
291 break;
292 case SvtSaveOptions::EOption::DocInfSave :
293 bReadOnly = bRODocInfSave;
294 break;
295 case SvtSaveOptions::EOption::SaveWorkingSet :
296 bReadOnly = bROSaveWorkingSet;
297 break;
298 case SvtSaveOptions::EOption::SaveDocView :
299 bReadOnly = bROSaveDocView;
300 break;
301 case SvtSaveOptions::EOption::SaveRelInet :
302 bReadOnly = bROSaveRelINet;
303 break;
304 case SvtSaveOptions::EOption::SaveRelFsys :
305 bReadOnly = bROSaveRelFSys;
306 break;
307 case SvtSaveOptions::EOption::DoPrettyPrinting :
308 bReadOnly = bRODoPrettyPrinting;
309 break;
310 case SvtSaveOptions::EOption::WarnAlienFormat :
311 bReadOnly = bROWarnAlienFormat;
312 break;
313 case SvtSaveOptions::EOption::LoadDocPrinter :
314 bReadOnly = bROLoadDocPrinter;
315 break;
316 case SvtSaveOptions::EOption::OdfDefaultVersion :
317 bReadOnly = bROLoadDocPrinter;
318 break;
320 return bReadOnly;
323 #define FORMAT 0
324 #define TIMEINTERVALL 1
325 #define USEUSERDATA 2
326 #define CREATEBACKUP 3
327 #define AUTOSAVE 4
328 #define PROMPT 5
329 #define EDITPROPERTY 6
330 #define SAVEVIEWINFO 7
331 #define PRETTYPRINTING 8
332 #define WARNALIENFORMAT 9
333 #define LOADDOCPRINTER 10
334 #define FILESYSTEM 11
335 #define INTERNET 12
336 #define SAVEWORKINGSET 13
337 #define ODFDEFAULTVERSION 14
339 static Sequence< OUString > GetPropertyNames()
341 static const char* aPropNames[] =
343 "Graphic/Format",
344 "Document/AutoSaveTimeIntervall",
345 "Document/UseUserData",
346 "Document/CreateBackup",
347 "Document/AutoSave",
348 "Document/AutoSavePrompt",
349 "Document/EditProperty",
350 "Document/ViewInfo",
351 "Document/PrettyPrinting",
352 "Document/WarnAlienFormat",
353 "Document/LoadPrinter",
354 "URL/FileSystem",
355 "URL/Internet",
356 "WorkingSet",
357 "ODF/DefaultVersion"
360 const int nCount = SAL_N_ELEMENTS( aPropNames );
361 Sequence< OUString > aNames( nCount );
362 OUString* pNames = aNames.getArray();
363 for ( int i = 0; i < nCount; i++ )
364 pNames[i] = OUString::createFromAscii( aPropNames[i] );
366 return aNames;
369 SvtSaveOptions_Impl::SvtSaveOptions_Impl()
370 : ConfigItem( "Office.Common/Save" )
371 , nAutoSaveTime( 0 )
372 , bUseUserData( false )
373 , bBackup( false )
374 , bAutoSave( false )
375 , bAutoSavePrompt( false )
376 , bUserAutoSave( false )
377 , bDocInfSave( false )
378 , bSaveWorkingSet( false )
379 , bSaveDocView( false )
380 , bSaveRelINet( false )
381 , bSaveRelFSys( false )
382 , bDoPrettyPrinting( false )
383 , bWarnAlienFormat( true )
384 , bLoadDocPrinter( true )
385 , eODFDefaultVersion( SvtSaveOptions::ODFVER_LATEST )
386 , bROAutoSaveTime( CFG_READONLY_DEFAULT )
387 , bROUseUserData( CFG_READONLY_DEFAULT )
388 , bROBackup( CFG_READONLY_DEFAULT )
389 , bROAutoSave( CFG_READONLY_DEFAULT )
390 , bROAutoSavePrompt( CFG_READONLY_DEFAULT )
391 , bROUserAutoSave( CFG_READONLY_DEFAULT )
392 , bRODocInfSave( CFG_READONLY_DEFAULT )
393 , bROSaveWorkingSet( CFG_READONLY_DEFAULT )
394 , bROSaveDocView( CFG_READONLY_DEFAULT )
395 , bROSaveRelINet( CFG_READONLY_DEFAULT )
396 , bROSaveRelFSys( CFG_READONLY_DEFAULT )
397 , bROWarnAlienFormat( CFG_READONLY_DEFAULT )
398 , bRODoPrettyPrinting( CFG_READONLY_DEFAULT )
399 , bROLoadDocPrinter( CFG_READONLY_DEFAULT )
400 , bROODFDefaultVersion( CFG_READONLY_DEFAULT )
402 Sequence< OUString > aNames = GetPropertyNames();
403 Sequence< Any > aValues = GetProperties( aNames );
404 Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames );
405 EnableNotification( aNames );
406 const Any* pValues = aValues.getConstArray();
407 const sal_Bool* pROStates = aROStates.getConstArray();
408 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
409 DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" );
410 if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
412 for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
414 if ( pValues[nProp].hasValue() )
416 sal_Int32 nTemp = 0;
417 switch ( nProp )
419 case FORMAT:
420 // not supported anymore
421 break;
423 case TIMEINTERVALL :
424 if ( pValues[nProp] >>= nTemp )
425 nAutoSaveTime = nTemp;
426 else {
427 OSL_FAIL( "Wrong Type!" );
429 bROAutoSaveTime = pROStates[nProp];
430 break;
432 case ODFDEFAULTVERSION :
434 sal_Int16 nTmp = 0;
435 if ( pValues[nProp] >>= nTmp )
437 if( nTmp == 3 )
438 eODFDefaultVersion = SvtSaveOptions::ODFVER_LATEST;
439 else
440 eODFDefaultVersion = SvtSaveOptions::ODFDefaultVersion( nTmp );
442 else {
443 SAL_WARN( "unotools.config", "SvtSaveOptions_Impl::SvtSaveOptions_Impl(): Wrong Type!" );
445 bROODFDefaultVersion = pROStates[nProp];
446 break;
449 default:
451 bool bTemp = bool();
452 if ( pValues[nProp] >>= bTemp )
454 switch ( nProp )
456 case USEUSERDATA :
457 bUseUserData = bTemp;
458 bROUseUserData = pROStates[nProp];
459 break;
460 case CREATEBACKUP :
461 bBackup = bTemp;
462 bROBackup = pROStates[nProp];
463 break;
464 case AUTOSAVE :
465 bAutoSave = bTemp;
466 bROAutoSave = pROStates[nProp];
467 break;
468 case PROMPT :
469 bAutoSavePrompt = bTemp;
470 bROAutoSavePrompt = pROStates[nProp];
471 break;
472 case EDITPROPERTY :
473 bDocInfSave = bTemp;
474 bRODocInfSave = pROStates[nProp];
475 break;
476 case SAVEWORKINGSET :
477 bSaveWorkingSet = bTemp;
478 bROSaveWorkingSet = pROStates[nProp];
479 break;
480 case SAVEVIEWINFO :
481 bSaveDocView = bTemp;
482 bROSaveDocView = pROStates[nProp];
483 break;
484 case FILESYSTEM :
485 bSaveRelFSys = bTemp;
486 bROSaveRelFSys = pROStates[nProp];
487 break;
488 case INTERNET :
489 bSaveRelINet = bTemp;
490 bROSaveRelINet = pROStates[nProp];
491 break;
493 case PRETTYPRINTING:
494 bDoPrettyPrinting = bTemp;
495 bRODoPrettyPrinting = pROStates[nProp];
496 break;
498 case WARNALIENFORMAT:
499 bWarnAlienFormat = bTemp;
500 bROWarnAlienFormat = pROStates[nProp];
501 break;
503 case LOADDOCPRINTER:
504 bLoadDocPrinter = bTemp;
505 bROLoadDocPrinter = pROStates[nProp];
506 break;
508 default :
509 SAL_WARN( "unotools.config", "invalid index to load a path" );
512 else
514 OSL_FAIL( "Wrong Type!" );
522 if (!utl::ConfigManager::IsFuzzing())
524 bAutoSave = officecfg::Office::Recovery::AutoSave::Enabled::get();
525 nAutoSaveTime = officecfg::Office::Recovery::AutoSave::TimeIntervall::get();
526 bUserAutoSave = officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get();
528 else
530 bAutoSave = false;
531 nAutoSaveTime = 0;
532 bUserAutoSave = false;
536 void SvtSaveOptions_Impl::ImplCommit()
538 Sequence< OUString > aOrgNames = GetPropertyNames();
539 OUString* pOrgNames = aOrgNames.getArray();
540 sal_Int32 nOrgCount = aOrgNames.getLength();
542 Sequence< OUString > aNames( nOrgCount );
543 Sequence< Any > aValues( nOrgCount );
544 OUString* pNames = aNames.getArray();
545 Any* pValues = aValues.getArray();
546 sal_Int32 nRealCount = 0;
548 for (sal_Int32 i=0; i<nOrgCount; ++i)
550 switch (i)
552 case FORMAT:
553 // not supported anymore
554 break;
555 case TIMEINTERVALL :
556 if (!bROAutoSaveTime)
558 pValues[nRealCount] <<= nAutoSaveTime;
559 pNames[nRealCount] = pOrgNames[i];
560 ++nRealCount;
562 break;
563 case USEUSERDATA :
564 if (!bROUseUserData)
566 pValues[nRealCount] <<= bUseUserData;
567 pNames[nRealCount] = pOrgNames[i];
568 ++nRealCount;
570 break;
571 case CREATEBACKUP :
572 if (!bROBackup)
574 pValues[nRealCount] <<= bBackup;
575 pNames[nRealCount] = pOrgNames[i];
576 ++nRealCount;
578 break;
579 case AUTOSAVE :
580 if (!bROAutoSave)
582 pValues[nRealCount] <<= bAutoSave;
583 pNames[nRealCount] = pOrgNames[i];
584 ++nRealCount;
586 break;
587 case PROMPT :
588 if (!bROAutoSavePrompt)
590 pValues[nRealCount] <<= bAutoSavePrompt;
591 pNames[nRealCount] = pOrgNames[i];
592 ++nRealCount;
594 break;
595 case EDITPROPERTY :
596 if (!bRODocInfSave)
598 pValues[nRealCount] <<= bDocInfSave;
599 pNames[nRealCount] = pOrgNames[i];
600 ++nRealCount;
602 break;
603 case SAVEWORKINGSET :
604 if (!bROSaveWorkingSet)
606 pValues[nRealCount] <<= bSaveWorkingSet;
607 pNames[nRealCount] = pOrgNames[i];
608 ++nRealCount;
610 break;
611 case SAVEVIEWINFO :
612 if (!bROSaveDocView)
614 pValues[nRealCount] <<= bSaveDocView;
615 pNames[nRealCount] = pOrgNames[i];
616 ++nRealCount;
618 break;
619 case FILESYSTEM :
620 if (!bROSaveRelFSys)
622 pValues[nRealCount] <<= bSaveRelFSys;
623 pNames[nRealCount] = pOrgNames[i];
624 ++nRealCount;
626 break;
627 case INTERNET :
628 if (!bROSaveRelINet)
630 pValues[nRealCount] <<= bSaveRelINet;
631 pNames[nRealCount] = pOrgNames[i];
632 ++nRealCount;
634 break;
635 case PRETTYPRINTING:
636 if (!bRODoPrettyPrinting)
638 pValues[nRealCount] <<= bDoPrettyPrinting;
639 pNames[nRealCount] = pOrgNames[i];
640 ++nRealCount;
642 break;
643 case WARNALIENFORMAT:
644 if (!bROWarnAlienFormat)
646 pValues[nRealCount] <<= bWarnAlienFormat;
647 pNames[nRealCount] = pOrgNames[i];
648 ++nRealCount;
650 break;
651 case LOADDOCPRINTER:
652 if (!bROLoadDocPrinter)
654 pValues[nRealCount] <<= bLoadDocPrinter;
655 pNames[nRealCount] = pOrgNames[i];
656 ++nRealCount;
658 break;
659 case ODFDEFAULTVERSION:
660 if (!bROODFDefaultVersion)
662 pValues[nRealCount] <<= (eODFDefaultVersion == SvtSaveOptions::ODFVER_LATEST) ? sal_Int16( 3 ) : sal_Int16( eODFDefaultVersion );
663 pNames[nRealCount] = pOrgNames[i];
664 ++nRealCount;
666 break;
668 default:
669 SAL_WARN( "unotools.config", "invalid index to save a path" );
673 aNames.realloc(nRealCount);
674 aValues.realloc(nRealCount);
675 PutProperties( aNames, aValues );
677 std::shared_ptr< comphelper::ConfigurationChanges > batch(
678 comphelper::ConfigurationChanges::create());
679 officecfg::Office::Recovery::AutoSave::TimeIntervall::set(nAutoSaveTime, batch);
680 officecfg::Office::Recovery::AutoSave::Enabled::set(bAutoSave, batch);
681 officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::set(bUserAutoSave, batch);
682 batch->commit();
685 void SvtSaveOptions_Impl::Notify( const Sequence<OUString>& )
689 class SvtLoadOptions_Impl : public utl::ConfigItem
691 private:
692 bool bLoadUserDefinedSettings;
694 virtual void ImplCommit() override;
696 public:
697 SvtLoadOptions_Impl();
699 virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override;
701 void SetLoadUserSettings(bool b){bLoadUserDefinedSettings = b; SetModified();}
702 bool IsLoadUserSettings() const {return bLoadUserDefinedSettings;}
705 const sal_Char cUserDefinedSettings[] = "UserDefinedSettings";
707 SvtLoadOptions_Impl::SvtLoadOptions_Impl()
708 : ConfigItem( "Office.Common/Load" )
709 , bLoadUserDefinedSettings( false )
711 Sequence< OUString > aNames { cUserDefinedSettings };
712 Sequence< Any > aValues = GetProperties( aNames );
713 EnableNotification( aNames );
714 const Any* pValues = aValues.getConstArray();
715 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
716 pValues[0] >>= bLoadUserDefinedSettings;
719 void SvtLoadOptions_Impl::ImplCommit()
721 PutProperties(
722 {cUserDefinedSettings}, {css::uno::Any(bLoadUserDefinedSettings)});
725 void SvtLoadOptions_Impl::Notify( const Sequence<OUString>& )
727 SAL_WARN( "unotools.config", "properties have been changed" );
730 namespace
732 class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton >
737 SvtSaveOptions::SvtSaveOptions()
739 // Global access, must be guarded (multithreading)
740 ::osl::MutexGuard aGuard( LocalSingleton::get() );
741 if ( !pOptions )
743 pOptions.reset(new SvtLoadSaveOptions_Impl);
744 pOptions->pSaveOpt.reset(new SvtSaveOptions_Impl);
745 pOptions->pLoadOpt.reset( new SvtLoadOptions_Impl);
747 ++nRefCount;
748 pImp = pOptions.get();
751 SvtSaveOptions::~SvtSaveOptions()
753 // Global access, must be guarded (multithreading)
754 ::osl::MutexGuard aGuard( LocalSingleton::get() );
755 if ( !--nRefCount )
757 if ( pOptions->pSaveOpt->IsModified() )
758 pOptions->pSaveOpt->Commit();
759 if ( pOptions->pLoadOpt->IsModified() )
760 pOptions->pLoadOpt->Commit();
762 pOptions.reset();
766 void SvtSaveOptions::SetAutoSaveTime( sal_Int32 n )
768 pImp->pSaveOpt->SetAutoSaveTime( n );
771 sal_Int32 SvtSaveOptions::GetAutoSaveTime() const
773 return pImp->pSaveOpt->GetAutoSaveTime();
776 void SvtSaveOptions::SetUseUserData( bool b )
778 pImp->pSaveOpt->SetUseUserData( b );
781 bool SvtSaveOptions::IsUseUserData() const
783 return pImp->pSaveOpt->IsUseUserData();
786 void SvtSaveOptions::SetBackup( bool b )
788 pImp->pSaveOpt->SetBackup( b );
791 bool SvtSaveOptions::IsBackup() const
793 return pImp->pSaveOpt->IsBackup();
796 void SvtSaveOptions::SetAutoSave( bool b )
798 pImp->pSaveOpt->SetAutoSave( b );
801 bool SvtSaveOptions::IsAutoSave() const
803 return pImp->pSaveOpt->IsAutoSave();
806 void SvtSaveOptions::SetAutoSavePrompt( bool b )
808 pImp->pSaveOpt->SetAutoSavePrompt( b );
811 bool SvtSaveOptions::IsAutoSavePrompt() const
813 return pImp->pSaveOpt->IsAutoSavePrompt();
816 void SvtSaveOptions::SetUserAutoSave( bool b )
818 pImp->pSaveOpt->SetUserAutoSave( b );
821 bool SvtSaveOptions::IsUserAutoSave() const
823 return pImp->pSaveOpt->IsUserAutoSave();
826 void SvtSaveOptions::SetDocInfoSave(bool b)
828 pImp->pSaveOpt->SetDocInfoSave( b );
831 bool SvtSaveOptions::IsDocInfoSave() const
833 return pImp->pSaveOpt->IsDocInfoSave();
836 void SvtSaveOptions::SetSaveWorkingSet( bool b )
838 pImp->pSaveOpt->SetSaveWorkingSet( b );
841 bool SvtSaveOptions::IsSaveWorkingSet() const
843 return pImp->pSaveOpt->IsSaveWorkingSet();
846 void SvtSaveOptions::SetSaveDocView( bool b )
848 pImp->pSaveOpt->SetSaveDocView( b );
851 bool SvtSaveOptions::IsSaveDocView() const
853 return pImp->pSaveOpt->IsSaveDocView();
856 void SvtSaveOptions::SetSaveRelINet( bool b )
858 pImp->pSaveOpt->SetSaveRelINet( b );
861 bool SvtSaveOptions::IsSaveRelINet() const
863 return pImp->pSaveOpt->IsSaveRelINet();
866 void SvtSaveOptions::SetSaveRelFSys( bool b )
868 pImp->pSaveOpt->SetSaveRelFSys( b );
871 bool SvtSaveOptions::IsSaveRelFSys() const
873 return pImp->pSaveOpt->IsSaveRelFSys();
876 void SvtSaveOptions::SetLoadUserSettings(bool b)
878 pImp->pLoadOpt->SetLoadUserSettings(b);
881 bool SvtSaveOptions::IsLoadUserSettings() const
883 return pImp->pLoadOpt->IsLoadUserSettings();
886 void SvtSaveOptions::SetPrettyPrinting( bool _bEnable )
888 pImp->pSaveOpt->EnablePrettyPrinting( _bEnable );
891 bool SvtSaveOptions::IsPrettyPrinting() const
893 return pImp->pSaveOpt->IsPrettyPrintingEnabled();
896 void SvtSaveOptions::SetWarnAlienFormat( bool _bEnable )
898 pImp->pSaveOpt->SetWarnAlienFormat( _bEnable );
901 bool SvtSaveOptions::IsWarnAlienFormat() const
903 return pImp->pSaveOpt->IsWarnAlienFormat();
906 void SvtSaveOptions::SetLoadDocumentPrinter( bool _bEnable )
908 pImp->pSaveOpt->SetLoadDocPrinter( _bEnable );
911 bool SvtSaveOptions::IsLoadDocumentPrinter() const
913 return pImp->pSaveOpt->IsLoadDocPrinter();
916 void SvtSaveOptions::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eVersion )
918 pImp->pSaveOpt->SetODFDefaultVersion( eVersion );
921 SvtSaveOptions::ODFDefaultVersion SvtSaveOptions::GetODFDefaultVersion() const
923 return pImp->pSaveOpt->GetODFDefaultVersion();
926 SvtSaveOptions::ODFSaneDefaultVersion SvtSaveOptions::GetODFSaneDefaultVersion() const
928 switch (pImp->pSaveOpt->GetODFDefaultVersion())
930 default:
931 assert(!"map new ODFDefaultVersion to ODFSaneDefaultVersion");
932 break;
933 case ODFVER_UNKNOWN:
934 case ODFVER_LATEST:
935 return ODFSVER_LATEST_EXTENDED;
936 case ODFVER_010:
937 return ODFSVER_010;
938 case ODFVER_011:
939 return ODFSVER_011;
940 case ODFVER_012:
941 return ODFSVER_012;
942 case ODFVER_012_EXT_COMPAT:
943 return ODFSVER_012_EXT_COMPAT;
945 return ODFSVER_LATEST_EXTENDED;
948 bool SvtSaveOptions::IsReadOnly( SvtSaveOptions::EOption eOption ) const
950 return pImp->pSaveOpt->IsReadOnly(eOption);
953 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */