nss: upgrade to release 3.73
[LibreOffice.git] / unotools / source / config / saveopt.cxx
blobd8f4d37dd79081b28d8ac0ba1cb4f92c610e053a
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 namespace {
40 class SvtSaveOptions_Impl;
41 class SvtLoadOptions_Impl;
45 #define CFG_READONLY_DEFAULT false
47 struct SvtLoadSaveOptions_Impl
49 std::unique_ptr<SvtSaveOptions_Impl> pSaveOpt;
50 std::unique_ptr<SvtLoadOptions_Impl> pLoadOpt;
53 static std::unique_ptr<SvtLoadSaveOptions_Impl> pOptions;
54 static sal_Int32 nRefCount = 0;
56 namespace {
58 class SvtSaveOptions_Impl : public utl::ConfigItem
60 sal_Int32 nAutoSaveTime;
61 bool bUseUserData,
62 bBackup,
63 bAutoSave,
64 bAutoSavePrompt,
65 bUserAutoSave,
66 bDocInfSave,
67 bSaveWorkingSet,
68 bSaveDocView,
69 bSaveRelINet,
70 bSaveRelFSys,
71 bDoPrettyPrinting,
72 bWarnAlienFormat,
73 bLoadDocPrinter;
75 SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion;
77 bool bROAutoSaveTime,
78 bROUseUserData,
79 bROBackup,
80 bROAutoSave,
81 bROAutoSavePrompt,
82 bROUserAutoSave,
83 bRODocInfSave,
84 bROSaveWorkingSet,
85 bROSaveDocView,
86 bROSaveRelINet,
87 bROSaveRelFSys,
88 bROWarnAlienFormat,
89 bRODoPrettyPrinting,
90 bROLoadDocPrinter,
91 bROODFDefaultVersion;
93 virtual void ImplCommit() override;
95 public:
96 SvtSaveOptions_Impl();
98 virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override;
100 sal_Int32 GetAutoSaveTime() const { return nAutoSaveTime; }
101 bool IsUseUserData() const { return bUseUserData; }
102 bool IsBackup() const { return bBackup; }
103 bool IsAutoSave() const { return bAutoSave; }
104 bool IsAutoSavePrompt() const { return bAutoSavePrompt; }
105 bool IsUserAutoSave() const { return bUserAutoSave; }
106 bool IsDocInfoSave() const { return bDocInfSave; }
107 bool IsSaveWorkingSet() const { return bSaveWorkingSet; }
108 bool IsSaveDocView() const { return bSaveDocView; }
109 bool IsSaveRelINet() const { return bSaveRelINet; }
110 bool IsSaveRelFSys() const { return bSaveRelFSys; }
111 bool IsPrettyPrintingEnabled( ) const { return bDoPrettyPrinting; }
112 bool IsWarnAlienFormat() const { return bWarnAlienFormat; }
113 bool IsLoadDocPrinter() const { return bLoadDocPrinter; }
115 SvtSaveOptions::ODFDefaultVersion
116 GetODFDefaultVersion() const { return eODFDefaultVersion; }
118 void SetAutoSaveTime( sal_Int32 n );
119 void SetUseUserData( bool b );
120 void SetBackup( bool b );
121 void SetAutoSave( bool b );
122 void SetAutoSavePrompt( bool b );
123 void SetUserAutoSave( bool b );
124 void SetDocInfoSave( bool b );
125 void SetSaveWorkingSet( bool b );
126 void SetSaveDocView( bool b );
127 void SetSaveRelINet( bool b );
128 void SetSaveRelFSys( bool b );
129 void EnablePrettyPrinting( bool _bDoPP );
130 void SetWarnAlienFormat( bool _bDoPP );
131 void SetLoadDocPrinter( bool bNew );
132 void SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew );
134 bool IsReadOnly( SvtSaveOptions::EOption eOption ) const;
139 void SvtSaveOptions_Impl::SetAutoSaveTime( sal_Int32 n )
141 if (!bROAutoSaveTime && nAutoSaveTime!=n)
143 nAutoSaveTime = n;
144 SetModified();
145 Commit();
149 void SvtSaveOptions_Impl::SetUseUserData( bool b )
151 if (!bROUseUserData && bUseUserData!=b)
153 bUseUserData = b;
154 SetModified();
158 void SvtSaveOptions_Impl::SetBackup( bool b )
160 if (!bROBackup && bBackup!=b)
162 bBackup = b;
163 SetModified();
167 void SvtSaveOptions_Impl::SetAutoSave( bool b )
169 if (!bROAutoSave && bAutoSave!=b)
171 bAutoSave = b;
172 SetModified();
173 Commit();
177 void SvtSaveOptions_Impl::SetAutoSavePrompt( bool b )
179 if (!bROAutoSavePrompt && bAutoSavePrompt!=b)
181 bAutoSavePrompt = b;
182 SetModified();
186 void SvtSaveOptions_Impl::SetUserAutoSave( bool b )
188 if (!bROUserAutoSave && bUserAutoSave!=b)
190 bUserAutoSave = b;
191 SetModified();
192 Commit();
196 void SvtSaveOptions_Impl::SetDocInfoSave(bool b)
198 if (!bRODocInfSave && bDocInfSave!=b)
200 bDocInfSave = b;
201 SetModified();
205 void SvtSaveOptions_Impl::SetSaveWorkingSet( bool b )
207 if (!bROSaveWorkingSet && bSaveWorkingSet!=b)
209 bSaveWorkingSet = b;
210 SetModified();
214 void SvtSaveOptions_Impl::SetSaveDocView( bool b )
216 if (!bROSaveDocView && bSaveDocView!=b)
218 bSaveDocView = b;
219 SetModified();
223 void SvtSaveOptions_Impl::SetSaveRelINet( bool b )
225 if (!bROSaveRelINet && bSaveRelINet!=b)
227 bSaveRelINet = b;
228 SetModified();
232 void SvtSaveOptions_Impl::SetSaveRelFSys( bool b )
234 if (!bROSaveRelFSys && bSaveRelFSys!=b)
236 bSaveRelFSys = b;
237 SetModified();
241 void SvtSaveOptions_Impl::EnablePrettyPrinting( bool _bDoPP )
243 if (!bRODoPrettyPrinting && bDoPrettyPrinting!=_bDoPP)
245 bDoPrettyPrinting = _bDoPP;
246 SetModified();
250 void SvtSaveOptions_Impl::SetWarnAlienFormat( bool _bDoPP )
252 if (!bROWarnAlienFormat && bWarnAlienFormat!=_bDoPP)
254 bWarnAlienFormat = _bDoPP;
255 SetModified();
259 void SvtSaveOptions_Impl::SetLoadDocPrinter( bool bNew )
261 if ( !bROLoadDocPrinter && bLoadDocPrinter != bNew )
263 bLoadDocPrinter = bNew;
264 SetModified();
268 void SvtSaveOptions_Impl::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew )
270 if ( !bROODFDefaultVersion && eODFDefaultVersion != eNew )
272 eODFDefaultVersion = eNew;
273 SetModified();
277 bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const
279 bool bReadOnly = CFG_READONLY_DEFAULT;
280 switch(eOption)
282 case SvtSaveOptions::EOption::AutoSaveTime :
283 bReadOnly = bROAutoSaveTime;
284 break;
285 case SvtSaveOptions::EOption::UseUserData :
286 bReadOnly = bROUseUserData;
287 break;
288 case SvtSaveOptions::EOption::Backup :
289 bReadOnly = bROBackup;
290 break;
291 case SvtSaveOptions::EOption::AutoSave :
292 bReadOnly = bROAutoSave;
293 break;
294 case SvtSaveOptions::EOption::AutoSavePrompt :
295 bReadOnly = bROAutoSavePrompt;
296 break;
297 case SvtSaveOptions::EOption::UserAutoSave :
298 bReadOnly = bROUserAutoSave;
299 break;
300 case SvtSaveOptions::EOption::DocInfSave :
301 bReadOnly = bRODocInfSave;
302 break;
303 case SvtSaveOptions::EOption::SaveWorkingSet :
304 bReadOnly = bROSaveWorkingSet;
305 break;
306 case SvtSaveOptions::EOption::SaveDocView :
307 bReadOnly = bROSaveDocView;
308 break;
309 case SvtSaveOptions::EOption::SaveRelInet :
310 bReadOnly = bROSaveRelINet;
311 break;
312 case SvtSaveOptions::EOption::SaveRelFsys :
313 bReadOnly = bROSaveRelFSys;
314 break;
315 case SvtSaveOptions::EOption::DoPrettyPrinting :
316 bReadOnly = bRODoPrettyPrinting;
317 break;
318 case SvtSaveOptions::EOption::WarnAlienFormat :
319 bReadOnly = bROWarnAlienFormat;
320 break;
321 case SvtSaveOptions::EOption::LoadDocPrinter :
322 bReadOnly = bROLoadDocPrinter;
323 break;
324 case SvtSaveOptions::EOption::OdfDefaultVersion :
325 bReadOnly = bROODFDefaultVersion;
326 break;
328 return bReadOnly;
331 #define FORMAT 0
332 #define TIMEINTERVALL 1
333 #define USEUSERDATA 2
334 #define CREATEBACKUP 3
335 #define AUTOSAVE 4
336 #define PROMPT 5
337 #define EDITPROPERTY 6
338 #define SAVEVIEWINFO 7
339 #define PRETTYPRINTING 8
340 #define WARNALIENFORMAT 9
341 #define LOADDOCPRINTER 10
342 #define FILESYSTEM 11
343 #define INTERNET 12
344 #define SAVEWORKINGSET 13
345 #define ODFDEFAULTVERSION 14
347 static Sequence< OUString > GetPropertyNames()
349 static const char* aPropNames[] =
351 "Graphic/Format",
352 "Document/AutoSaveTimeIntervall",
353 "Document/UseUserData",
354 "Document/CreateBackup",
355 "Document/AutoSave",
356 "Document/AutoSavePrompt",
357 "Document/EditProperty",
358 "Document/ViewInfo",
359 "Document/PrettyPrinting",
360 "Document/WarnAlienFormat",
361 "Document/LoadPrinter",
362 "URL/FileSystem",
363 "URL/Internet",
364 "WorkingSet",
365 "ODF/DefaultVersion"
368 const int nCount = SAL_N_ELEMENTS( aPropNames );
369 Sequence< OUString > aNames( nCount );
370 OUString* pNames = aNames.getArray();
371 for ( int i = 0; i < nCount; i++ )
372 pNames[i] = OUString::createFromAscii( aPropNames[i] );
374 return aNames;
377 SvtSaveOptions_Impl::SvtSaveOptions_Impl()
378 : ConfigItem( "Office.Common/Save" )
379 , nAutoSaveTime( 0 )
380 , bUseUserData( false )
381 , bBackup( false )
382 , bAutoSave( false )
383 , bAutoSavePrompt( false )
384 , bUserAutoSave( false )
385 , bDocInfSave( false )
386 , bSaveWorkingSet( false )
387 , bSaveDocView( false )
388 , bSaveRelINet( false )
389 , bSaveRelFSys( false )
390 , bDoPrettyPrinting( false )
391 , bWarnAlienFormat( true )
392 , bLoadDocPrinter( true )
393 , eODFDefaultVersion( SvtSaveOptions::ODFVER_LATEST )
394 , bROAutoSaveTime( CFG_READONLY_DEFAULT )
395 , bROUseUserData( CFG_READONLY_DEFAULT )
396 , bROBackup( CFG_READONLY_DEFAULT )
397 , bROAutoSave( CFG_READONLY_DEFAULT )
398 , bROAutoSavePrompt( CFG_READONLY_DEFAULT )
399 , bROUserAutoSave( CFG_READONLY_DEFAULT )
400 , bRODocInfSave( CFG_READONLY_DEFAULT )
401 , bROSaveWorkingSet( CFG_READONLY_DEFAULT )
402 , bROSaveDocView( CFG_READONLY_DEFAULT )
403 , bROSaveRelINet( CFG_READONLY_DEFAULT )
404 , bROSaveRelFSys( CFG_READONLY_DEFAULT )
405 , bROWarnAlienFormat( CFG_READONLY_DEFAULT )
406 , bRODoPrettyPrinting( CFG_READONLY_DEFAULT )
407 , bROLoadDocPrinter( CFG_READONLY_DEFAULT )
408 , bROODFDefaultVersion( CFG_READONLY_DEFAULT )
410 Sequence< OUString > aNames = GetPropertyNames();
411 Sequence< Any > aValues = GetProperties( aNames );
412 Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames );
413 EnableNotification( aNames );
414 const Any* pValues = aValues.getConstArray();
415 const sal_Bool* pROStates = aROStates.getConstArray();
416 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
417 DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" );
418 if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
420 for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
422 if ( pValues[nProp].hasValue() )
424 sal_Int32 nTemp = 0;
425 switch ( nProp )
427 case FORMAT:
428 // not supported anymore
429 break;
431 case TIMEINTERVALL :
432 if ( pValues[nProp] >>= nTemp )
433 nAutoSaveTime = nTemp;
434 else {
435 OSL_FAIL( "Wrong Type!" );
437 bROAutoSaveTime = pROStates[nProp];
438 break;
440 case ODFDEFAULTVERSION :
442 sal_Int16 nTmp = 0;
443 if ( pValues[nProp] >>= nTmp )
445 if( nTmp == 3 )
446 eODFDefaultVersion = SvtSaveOptions::ODFVER_LATEST;
447 else
448 eODFDefaultVersion = SvtSaveOptions::ODFDefaultVersion( nTmp );
450 else {
451 SAL_WARN( "unotools.config", "SvtSaveOptions_Impl::SvtSaveOptions_Impl(): Wrong Type!" );
453 bROODFDefaultVersion = pROStates[nProp];
454 break;
457 default:
459 bool bTemp = bool();
460 if ( pValues[nProp] >>= bTemp )
462 switch ( nProp )
464 case USEUSERDATA :
465 bUseUserData = bTemp;
466 bROUseUserData = pROStates[nProp];
467 break;
468 case CREATEBACKUP :
469 bBackup = bTemp;
470 bROBackup = pROStates[nProp];
471 break;
472 case AUTOSAVE :
473 bAutoSave = bTemp;
474 bROAutoSave = pROStates[nProp];
475 break;
476 case PROMPT :
477 bAutoSavePrompt = bTemp;
478 bROAutoSavePrompt = pROStates[nProp];
479 break;
480 case EDITPROPERTY :
481 bDocInfSave = bTemp;
482 bRODocInfSave = pROStates[nProp];
483 break;
484 case SAVEWORKINGSET :
485 bSaveWorkingSet = bTemp;
486 bROSaveWorkingSet = pROStates[nProp];
487 break;
488 case SAVEVIEWINFO :
489 bSaveDocView = bTemp;
490 bROSaveDocView = pROStates[nProp];
491 break;
492 case FILESYSTEM :
493 bSaveRelFSys = bTemp;
494 bROSaveRelFSys = pROStates[nProp];
495 break;
496 case INTERNET :
497 bSaveRelINet = bTemp;
498 bROSaveRelINet = pROStates[nProp];
499 break;
501 case PRETTYPRINTING:
502 bDoPrettyPrinting = bTemp;
503 bRODoPrettyPrinting = pROStates[nProp];
504 break;
506 case WARNALIENFORMAT:
507 bWarnAlienFormat = bTemp;
508 bROWarnAlienFormat = pROStates[nProp];
509 break;
511 case LOADDOCPRINTER:
512 bLoadDocPrinter = bTemp;
513 bROLoadDocPrinter = pROStates[nProp];
514 break;
516 default :
517 SAL_WARN( "unotools.config", "invalid index to load a path" );
520 else
522 OSL_FAIL( "Wrong Type!" );
530 if (!utl::ConfigManager::IsFuzzing())
532 bAutoSave = officecfg::Office::Recovery::AutoSave::Enabled::get();
533 nAutoSaveTime = officecfg::Office::Recovery::AutoSave::TimeIntervall::get();
534 bUserAutoSave = officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get();
536 else
538 bAutoSave = false;
539 nAutoSaveTime = 0;
540 bUserAutoSave = false;
544 void SvtSaveOptions_Impl::ImplCommit()
546 Sequence< OUString > aOrgNames = GetPropertyNames();
547 OUString* pOrgNames = aOrgNames.getArray();
548 sal_Int32 nOrgCount = aOrgNames.getLength();
550 Sequence< OUString > aNames( nOrgCount );
551 Sequence< Any > aValues( nOrgCount );
552 OUString* pNames = aNames.getArray();
553 Any* pValues = aValues.getArray();
554 sal_Int32 nRealCount = 0;
556 for (sal_Int32 i=0; i<nOrgCount; ++i)
558 switch (i)
560 case FORMAT:
561 // not supported anymore
562 break;
563 case TIMEINTERVALL :
564 if (!bROAutoSaveTime)
566 pValues[nRealCount] <<= nAutoSaveTime;
567 pNames[nRealCount] = pOrgNames[i];
568 ++nRealCount;
570 break;
571 case USEUSERDATA :
572 if (!bROUseUserData)
574 pValues[nRealCount] <<= bUseUserData;
575 pNames[nRealCount] = pOrgNames[i];
576 ++nRealCount;
578 break;
579 case CREATEBACKUP :
580 if (!bROBackup)
582 pValues[nRealCount] <<= bBackup;
583 pNames[nRealCount] = pOrgNames[i];
584 ++nRealCount;
586 break;
587 case AUTOSAVE :
588 if (!bROAutoSave)
590 pValues[nRealCount] <<= bAutoSave;
591 pNames[nRealCount] = pOrgNames[i];
592 ++nRealCount;
594 break;
595 case PROMPT :
596 if (!bROAutoSavePrompt)
598 pValues[nRealCount] <<= bAutoSavePrompt;
599 pNames[nRealCount] = pOrgNames[i];
600 ++nRealCount;
602 break;
603 case EDITPROPERTY :
604 if (!bRODocInfSave)
606 pValues[nRealCount] <<= bDocInfSave;
607 pNames[nRealCount] = pOrgNames[i];
608 ++nRealCount;
610 break;
611 case SAVEWORKINGSET :
612 if (!bROSaveWorkingSet)
614 pValues[nRealCount] <<= bSaveWorkingSet;
615 pNames[nRealCount] = pOrgNames[i];
616 ++nRealCount;
618 break;
619 case SAVEVIEWINFO :
620 if (!bROSaveDocView)
622 pValues[nRealCount] <<= bSaveDocView;
623 pNames[nRealCount] = pOrgNames[i];
624 ++nRealCount;
626 break;
627 case FILESYSTEM :
628 if (!bROSaveRelFSys)
630 pValues[nRealCount] <<= bSaveRelFSys;
631 pNames[nRealCount] = pOrgNames[i];
632 ++nRealCount;
634 break;
635 case INTERNET :
636 if (!bROSaveRelINet)
638 pValues[nRealCount] <<= bSaveRelINet;
639 pNames[nRealCount] = pOrgNames[i];
640 ++nRealCount;
642 break;
643 case PRETTYPRINTING:
644 if (!bRODoPrettyPrinting)
646 pValues[nRealCount] <<= bDoPrettyPrinting;
647 pNames[nRealCount] = pOrgNames[i];
648 ++nRealCount;
650 break;
651 case WARNALIENFORMAT:
652 if (!bROWarnAlienFormat)
654 pValues[nRealCount] <<= bWarnAlienFormat;
655 pNames[nRealCount] = pOrgNames[i];
656 ++nRealCount;
658 break;
659 case LOADDOCPRINTER:
660 if (!bROLoadDocPrinter)
662 pValues[nRealCount] <<= bLoadDocPrinter;
663 pNames[nRealCount] = pOrgNames[i];
664 ++nRealCount;
666 break;
667 case ODFDEFAULTVERSION:
668 if (!bROODFDefaultVersion)
670 pValues[nRealCount] <<= (eODFDefaultVersion == SvtSaveOptions::ODFVER_LATEST) ? sal_Int16( 3 ) : sal_Int16( eODFDefaultVersion );
671 pNames[nRealCount] = pOrgNames[i];
672 ++nRealCount;
674 break;
676 default:
677 SAL_WARN( "unotools.config", "invalid index to save a path" );
681 aNames.realloc(nRealCount);
682 aValues.realloc(nRealCount);
683 PutProperties( aNames, aValues );
685 std::shared_ptr< comphelper::ConfigurationChanges > batch(
686 comphelper::ConfigurationChanges::create());
687 officecfg::Office::Recovery::AutoSave::TimeIntervall::set(nAutoSaveTime, batch);
688 officecfg::Office::Recovery::AutoSave::Enabled::set(bAutoSave, batch);
689 officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::set(bUserAutoSave, batch);
690 batch->commit();
693 void SvtSaveOptions_Impl::Notify( const Sequence<OUString>& )
697 namespace {
699 class SvtLoadOptions_Impl : public utl::ConfigItem
701 private:
702 bool bLoadUserDefinedSettings;
704 virtual void ImplCommit() override;
706 public:
707 SvtLoadOptions_Impl();
709 virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override;
711 void SetLoadUserSettings(bool b){bLoadUserDefinedSettings = b; SetModified();}
712 bool IsLoadUserSettings() const {return bLoadUserDefinedSettings;}
717 const char cUserDefinedSettings[] = "UserDefinedSettings";
719 SvtLoadOptions_Impl::SvtLoadOptions_Impl()
720 : ConfigItem( "Office.Common/Load" )
721 , bLoadUserDefinedSettings( false )
723 Sequence< OUString > aNames { cUserDefinedSettings };
724 Sequence< Any > aValues = GetProperties( aNames );
725 EnableNotification( aNames );
726 const Any* pValues = aValues.getConstArray();
727 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
728 pValues[0] >>= bLoadUserDefinedSettings;
731 void SvtLoadOptions_Impl::ImplCommit()
733 PutProperties(
734 {cUserDefinedSettings}, {css::uno::Any(bLoadUserDefinedSettings)});
737 void SvtLoadOptions_Impl::Notify( const Sequence<OUString>& )
739 SAL_WARN( "unotools.config", "properties have been changed" );
742 namespace
744 class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton >
749 SvtSaveOptions::SvtSaveOptions()
751 // Global access, must be guarded (multithreading)
752 ::osl::MutexGuard aGuard( LocalSingleton::get() );
753 if ( !pOptions )
755 pOptions.reset(new SvtLoadSaveOptions_Impl);
756 pOptions->pSaveOpt.reset(new SvtSaveOptions_Impl);
757 pOptions->pLoadOpt.reset( new SvtLoadOptions_Impl);
759 ++nRefCount;
760 pImp = pOptions.get();
763 SvtSaveOptions::~SvtSaveOptions()
765 // Global access, must be guarded (multithreading)
766 ::osl::MutexGuard aGuard( LocalSingleton::get() );
767 if ( !--nRefCount )
769 if ( pOptions->pSaveOpt->IsModified() )
770 pOptions->pSaveOpt->Commit();
771 if ( pOptions->pLoadOpt->IsModified() )
772 pOptions->pLoadOpt->Commit();
774 pOptions.reset();
778 void SvtSaveOptions::SetAutoSaveTime( sal_Int32 n )
780 pImp->pSaveOpt->SetAutoSaveTime( n );
783 sal_Int32 SvtSaveOptions::GetAutoSaveTime() const
785 return pImp->pSaveOpt->GetAutoSaveTime();
788 void SvtSaveOptions::SetUseUserData( bool b )
790 pImp->pSaveOpt->SetUseUserData( b );
793 bool SvtSaveOptions::IsUseUserData() const
795 return pImp->pSaveOpt->IsUseUserData();
798 void SvtSaveOptions::SetBackup( bool b )
800 pImp->pSaveOpt->SetBackup( b );
803 bool SvtSaveOptions::IsBackup() const
805 return pImp->pSaveOpt->IsBackup();
808 void SvtSaveOptions::SetAutoSave( bool b )
810 pImp->pSaveOpt->SetAutoSave( b );
813 bool SvtSaveOptions::IsAutoSave() const
815 return pImp->pSaveOpt->IsAutoSave();
818 void SvtSaveOptions::SetAutoSavePrompt( bool b )
820 pImp->pSaveOpt->SetAutoSavePrompt( b );
823 bool SvtSaveOptions::IsAutoSavePrompt() const
825 return pImp->pSaveOpt->IsAutoSavePrompt();
828 void SvtSaveOptions::SetUserAutoSave( bool b )
830 pImp->pSaveOpt->SetUserAutoSave( b );
833 bool SvtSaveOptions::IsUserAutoSave() const
835 return pImp->pSaveOpt->IsUserAutoSave();
838 void SvtSaveOptions::SetDocInfoSave(bool b)
840 pImp->pSaveOpt->SetDocInfoSave( b );
843 bool SvtSaveOptions::IsDocInfoSave() const
845 return pImp->pSaveOpt->IsDocInfoSave();
848 void SvtSaveOptions::SetSaveWorkingSet( bool b )
850 pImp->pSaveOpt->SetSaveWorkingSet( b );
853 bool SvtSaveOptions::IsSaveWorkingSet() const
855 return pImp->pSaveOpt->IsSaveWorkingSet();
858 void SvtSaveOptions::SetSaveDocView( bool b )
860 pImp->pSaveOpt->SetSaveDocView( b );
863 bool SvtSaveOptions::IsSaveDocView() const
865 return pImp->pSaveOpt->IsSaveDocView();
868 void SvtSaveOptions::SetSaveRelINet( bool b )
870 pImp->pSaveOpt->SetSaveRelINet( b );
873 bool SvtSaveOptions::IsSaveRelINet() const
875 return pImp->pSaveOpt->IsSaveRelINet();
878 void SvtSaveOptions::SetSaveRelFSys( bool b )
880 pImp->pSaveOpt->SetSaveRelFSys( b );
883 bool SvtSaveOptions::IsSaveRelFSys() const
885 return pImp->pSaveOpt->IsSaveRelFSys();
888 void SvtSaveOptions::SetLoadUserSettings(bool b)
890 pImp->pLoadOpt->SetLoadUserSettings(b);
893 bool SvtSaveOptions::IsLoadUserSettings() const
895 return pImp->pLoadOpt->IsLoadUserSettings();
898 void SvtSaveOptions::SetPrettyPrinting( bool _bEnable )
900 pImp->pSaveOpt->EnablePrettyPrinting( _bEnable );
903 bool SvtSaveOptions::IsPrettyPrinting() const
905 return pImp->pSaveOpt->IsPrettyPrintingEnabled();
908 void SvtSaveOptions::SetWarnAlienFormat( bool _bEnable )
910 pImp->pSaveOpt->SetWarnAlienFormat( _bEnable );
913 bool SvtSaveOptions::IsWarnAlienFormat() const
915 return pImp->pSaveOpt->IsWarnAlienFormat();
918 void SvtSaveOptions::SetLoadDocumentPrinter( bool _bEnable )
920 pImp->pSaveOpt->SetLoadDocPrinter( _bEnable );
923 bool SvtSaveOptions::IsLoadDocumentPrinter() const
925 return pImp->pSaveOpt->IsLoadDocPrinter();
928 void SvtSaveOptions::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eVersion )
930 pImp->pSaveOpt->SetODFDefaultVersion( eVersion );
933 SvtSaveOptions::ODFDefaultVersion SvtSaveOptions::GetODFDefaultVersion() const
935 auto const nRet = pImp->pSaveOpt->GetODFDefaultVersion();
936 SAL_WARN_IF(nRet == ODFVER_UNKNOWN, "unotools.config", "DefaultVersion is ODFVER_UNKNOWN?");
937 return (nRet == ODFVER_UNKNOWN) ? ODFVER_LATEST : nRet;
940 SvtSaveOptions::ODFSaneDefaultVersion SvtSaveOptions::GetODFSaneDefaultVersion() const
942 switch (pImp->pSaveOpt->GetODFDefaultVersion())
944 default:
945 assert(!"map new ODFDefaultVersion to ODFSaneDefaultVersion");
946 break;
947 case ODFVER_UNKNOWN:
948 case ODFVER_LATEST:
949 return ODFSVER_LATEST_EXTENDED;
950 case ODFVER_010:
951 return ODFSVER_010;
952 case ODFVER_011:
953 return ODFSVER_011;
954 case ODFVER_012:
955 return ODFSVER_012;
956 case ODFVER_012_EXT_COMPAT:
957 return ODFSVER_012_EXT_COMPAT;
958 case ODFVER_012_EXTENDED:
959 return ODFSVER_012_EXTENDED;
960 case ODFVER_013:
961 return ODFSVER_013;
963 return ODFSVER_LATEST_EXTENDED;
966 bool SvtSaveOptions::IsReadOnly( SvtSaveOptions::EOption eOption ) const
968 return pImp->pSaveOpt->IsReadOnly(eOption);
971 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */