1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <unotools/saveopt.hxx>
21 #include "rtl/instance.hxx"
22 #include <unotools/configmgr.hxx>
23 #include <unotools/configitem.hxx>
24 #include <tools/debug.hxx>
25 #include <com/sun/star/uno/Any.hxx>
26 #include <com/sun/star/uno/Sequence.hxx>
28 #include <osl/mutex.hxx>
29 #include <comphelper/configurationhelper.hxx>
30 #include <comphelper/processfactory.hxx>
31 #include <rtl/logfile.hxx>
32 #include "itemholder1.hxx"
35 using namespace com::sun::star::uno
;
38 class SvtSaveOptions_Impl
;
39 class SvtLoadOptions_Impl
;
41 #define CFG_READONLY_DEFAULT sal_False
43 struct SvtLoadSaveOptions_Impl
45 SvtSaveOptions_Impl
* pSaveOpt
;
46 SvtLoadOptions_Impl
* pLoadOpt
;
49 static SvtLoadSaveOptions_Impl
* pOptions
= NULL
;
50 static sal_Int32 nRefCount
= 0;
52 class SvtSaveOptions_Impl
: public utl::ConfigItem
54 sal_Int32 nAutoSaveTime
;
55 sal_Bool bUseUserData
,
72 SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion
;
74 sal_Bool bROAutoSaveTime
,
91 bROUseBlowfishInODF12
;
94 SvtSaveOptions_Impl();
95 ~SvtSaveOptions_Impl();
97 virtual void Notify( const com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
);
98 virtual void Commit();
100 sal_Int32
GetAutoSaveTime() const { return nAutoSaveTime
; }
101 sal_Bool
IsUseUserData() const { return bUseUserData
; }
102 sal_Bool
IsBackup() const { return bBackup
; }
103 sal_Bool
IsAutoSave() const { return bAutoSave
; }
104 sal_Bool
IsAutoSavePrompt() const { return bAutoSavePrompt
; }
105 sal_Bool
IsUserAutoSave() const { return bUserAutoSave
; }
106 sal_Bool
IsDocInfoSave() const { return bDocInfSave
; }
107 sal_Bool
IsSaveWorkingSet() const { return bSaveWorkingSet
; }
108 sal_Bool
IsSaveDocView() const { return bSaveDocView
; }
109 sal_Bool
IsSaveRelINet() const { return bSaveRelINet
; }
110 sal_Bool
IsSaveRelFSys() const { return bSaveRelFSys
; }
111 sal_Bool
IsSaveUnpacked() const { return bSaveUnpacked
; }
112 sal_Bool
IsPrettyPrintingEnabled( ) const { return bDoPrettyPrinting
; }
113 sal_Bool
IsWarnAlienFormat() const { return bWarnAlienFormat
; }
114 sal_Bool
IsLoadDocPrinter() const { return bLoadDocPrinter
; }
115 sal_Bool
IsUseSHA1InODF12() const { return bUseSHA1InODF12
; }
116 sal_Bool
IsUseBlowfishInODF12() const { return bUseBlowfishInODF12
; }
118 SvtSaveOptions::ODFDefaultVersion
119 GetODFDefaultVersion() const { return eODFDefaultVersion
; }
121 void SetAutoSaveTime( sal_Int32 n
);
122 void SetUseUserData( sal_Bool b
);
123 void SetBackup( sal_Bool b
);
124 void SetAutoSave( sal_Bool b
);
125 void SetAutoSavePrompt( sal_Bool b
);
126 void SetUserAutoSave( sal_Bool b
);
127 void SetDocInfoSave( sal_Bool b
);
128 void SetSaveWorkingSet( sal_Bool b
);
129 void SetSaveDocView( sal_Bool b
);
130 void SetSaveRelINet( sal_Bool b
);
131 void SetSaveRelFSys( sal_Bool b
);
132 void EnablePrettyPrinting( sal_Bool _bDoPP
);
133 void SetWarnAlienFormat( sal_Bool _bDoPP
);
134 void SetLoadDocPrinter( sal_Bool bNew
);
135 void SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew
);
137 sal_Bool
IsReadOnly( SvtSaveOptions::EOption eOption
) const;
140 void SvtSaveOptions_Impl::SetAutoSaveTime( sal_Int32 n
)
142 if (!bROAutoSaveTime
&& nAutoSaveTime
!=n
)
150 void SvtSaveOptions_Impl::SetUseUserData( sal_Bool b
)
152 if (!bROUseUserData
&& bUseUserData
!=b
)
159 void SvtSaveOptions_Impl::SetBackup( sal_Bool b
)
161 if (!bROBackup
&& bBackup
!=b
)
168 void SvtSaveOptions_Impl::SetAutoSave( sal_Bool b
)
170 if (!bROAutoSave
&& bAutoSave
!=b
)
178 void SvtSaveOptions_Impl::SetAutoSavePrompt( sal_Bool b
)
180 if (!bROAutoSavePrompt
&& bAutoSavePrompt
!=b
)
187 void SvtSaveOptions_Impl::SetUserAutoSave( sal_Bool b
)
189 if (!bROUserAutoSave
&& bUserAutoSave
!=b
)
197 void SvtSaveOptions_Impl::SetDocInfoSave(sal_Bool b
)
199 if (!bRODocInfSave
&& bDocInfSave
!=b
)
206 void SvtSaveOptions_Impl::SetSaveWorkingSet( sal_Bool b
)
208 if (!bROSaveWorkingSet
&& bSaveWorkingSet
!=b
)
215 void SvtSaveOptions_Impl::SetSaveDocView( sal_Bool b
)
217 if (!bROSaveDocView
&& bSaveDocView
!=b
)
224 void SvtSaveOptions_Impl::SetSaveRelINet( sal_Bool b
)
226 if (!bROSaveRelINet
&& bSaveRelINet
!=b
)
233 void SvtSaveOptions_Impl::SetSaveRelFSys( sal_Bool b
)
235 if (!bROSaveRelFSys
&& bSaveRelFSys
!=b
)
242 void SvtSaveOptions_Impl::EnablePrettyPrinting( sal_Bool _bDoPP
)
244 if (!bRODoPrettyPrinting
&& bDoPrettyPrinting
!=_bDoPP
)
246 bDoPrettyPrinting
= _bDoPP
;
251 void SvtSaveOptions_Impl::SetWarnAlienFormat( sal_Bool _bDoPP
)
253 if (!bROWarnAlienFormat
&& bWarnAlienFormat
!=_bDoPP
)
255 bWarnAlienFormat
= _bDoPP
;
260 void SvtSaveOptions_Impl::SetLoadDocPrinter( sal_Bool bNew
)
262 if ( !bROLoadDocPrinter
&& bLoadDocPrinter
!= bNew
)
264 bLoadDocPrinter
= bNew
;
269 void SvtSaveOptions_Impl::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew
)
271 if ( !bROODFDefaultVersion
&& eODFDefaultVersion
!= eNew
)
273 eODFDefaultVersion
= eNew
;
278 sal_Bool
SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption
) const
280 sal_Bool bReadOnly
= CFG_READONLY_DEFAULT
;
283 case SvtSaveOptions::E_AUTOSAVETIME
:
284 bReadOnly
= bROAutoSaveTime
;
286 case SvtSaveOptions::E_USEUSERDATA
:
287 bReadOnly
= bROUseUserData
;
289 case SvtSaveOptions::E_BACKUP
:
290 bReadOnly
= bROBackup
;
292 case SvtSaveOptions::E_AUTOSAVE
:
293 bReadOnly
= bROAutoSave
;
295 case SvtSaveOptions::E_AUTOSAVEPROMPT
:
296 bReadOnly
= bROAutoSavePrompt
;
298 case SvtSaveOptions::E_USERAUTOSAVE
:
299 bReadOnly
= bROUserAutoSave
;
301 case SvtSaveOptions::E_DOCINFSAVE
:
302 bReadOnly
= bRODocInfSave
;
304 case SvtSaveOptions::E_SAVEWORKINGSET
:
305 bReadOnly
= bROSaveWorkingSet
;
307 case SvtSaveOptions::E_SAVEDOCVIEW
:
308 bReadOnly
= bROSaveDocView
;
310 case SvtSaveOptions::E_SAVERELINET
:
311 bReadOnly
= bROSaveRelINet
;
313 case SvtSaveOptions::E_SAVERELFSYS
:
314 bReadOnly
= bROSaveRelFSys
;
316 case SvtSaveOptions::E_SAVEUNPACKED
:
317 bReadOnly
= bROSaveUnpacked
;
319 case SvtSaveOptions::E_DOPRETTYPRINTING
:
320 bReadOnly
= bRODoPrettyPrinting
;
322 case SvtSaveOptions::E_WARNALIENFORMAT
:
323 bReadOnly
= bROWarnAlienFormat
;
325 case SvtSaveOptions::E_LOADDOCPRINTER
:
326 bReadOnly
= bROLoadDocPrinter
;
328 case SvtSaveOptions::E_ODFDEFAULTVERSION
:
329 bReadOnly
= bROLoadDocPrinter
;
331 case SvtSaveOptions::E_USESHA1INODF12
:
332 bReadOnly
= bROUseSHA1InODF12
;
334 case SvtSaveOptions::E_USEBLOWFISHINODF12
:
335 bReadOnly
= bROUseBlowfishInODF12
;
342 #define TIMEINTERVALL 1
343 #define USEUSERDATA 2
344 #define CREATEBACKUP 3
347 #define EDITPROPERTY 6
348 #define SAVEVIEWINFO 7
350 #define PRETTYPRINTING 9
351 #define WARNALIENFORMAT 10
352 #define LOADDOCPRINTER 11
353 #define FILESYSTEM 12
355 #define SAVEWORKINGSET 14
356 #define ODFDEFAULTVERSION 15
357 #define USESHA1INODF12 16
358 #define USEBLOWFISHINODF12 17
360 Sequence
< OUString
> GetPropertyNames()
362 static const char* aPropNames
[] =
365 "Document/AutoSaveTimeIntervall",
366 "Document/UseUserData",
367 "Document/CreateBackup",
369 "Document/AutoSavePrompt",
370 "Document/EditProperty",
373 "Document/PrettyPrinting",
374 "Document/WarnAlienFormat",
375 "Document/LoadPrinter",
379 "ODF/DefaultVersion",
380 "ODF/UseSHA1InODF12",
381 "ODF/UseBlowfishInODF12"
384 const int nCount
= sizeof( aPropNames
) / sizeof( const char* );
385 Sequence
< OUString
> aNames( nCount
);
386 OUString
* pNames
= aNames
.getArray();
387 for ( int i
= 0; i
< nCount
; i
++ )
388 pNames
[i
] = OUString::createFromAscii( aPropNames
[i
] );
393 // -----------------------------------------------------------------------
395 SvtSaveOptions_Impl::SvtSaveOptions_Impl()
396 : ConfigItem( OUString("Office.Common/Save") )
398 , bUseUserData( sal_False
)
399 , bBackup( sal_False
)
400 , bAutoSave( sal_False
)
401 , bAutoSavePrompt( sal_False
)
402 , bUserAutoSave( sal_False
)
403 , bDocInfSave( sal_False
)
404 , bSaveWorkingSet( sal_False
)
405 , bSaveDocView( sal_False
)
406 , bSaveRelINet( sal_False
)
407 , bSaveRelFSys( sal_False
)
408 , bSaveUnpacked( sal_False
)
409 , bDoPrettyPrinting( sal_False
)
410 , bWarnAlienFormat( sal_True
)
411 , bLoadDocPrinter( sal_True
)
412 , bUseSHA1InODF12( sal_False
)
413 , bUseBlowfishInODF12( sal_False
)
414 , eODFDefaultVersion( SvtSaveOptions::ODFVER_LATEST
)
415 , bROAutoSaveTime( CFG_READONLY_DEFAULT
)
416 , bROUseUserData( CFG_READONLY_DEFAULT
)
417 , bROBackup( CFG_READONLY_DEFAULT
)
418 , bROAutoSave( CFG_READONLY_DEFAULT
)
419 , bROAutoSavePrompt( CFG_READONLY_DEFAULT
)
420 , bROUserAutoSave( CFG_READONLY_DEFAULT
)
421 , bRODocInfSave( CFG_READONLY_DEFAULT
)
422 , bROSaveWorkingSet( CFG_READONLY_DEFAULT
)
423 , bROSaveDocView( CFG_READONLY_DEFAULT
)
424 , bROSaveRelINet( CFG_READONLY_DEFAULT
)
425 , bROSaveRelFSys( CFG_READONLY_DEFAULT
)
426 , bROSaveUnpacked( CFG_READONLY_DEFAULT
)
427 , bROWarnAlienFormat( CFG_READONLY_DEFAULT
)
428 , bRODoPrettyPrinting( CFG_READONLY_DEFAULT
)
429 , bROLoadDocPrinter( CFG_READONLY_DEFAULT
)
430 , bROODFDefaultVersion( CFG_READONLY_DEFAULT
)
431 , bROUseSHA1InODF12( CFG_READONLY_DEFAULT
)
432 , bROUseBlowfishInODF12( CFG_READONLY_DEFAULT
)
434 Sequence
< OUString
> aNames
= GetPropertyNames();
435 Sequence
< Any
> aValues
= GetProperties( aNames
);
436 Sequence
< sal_Bool
> aROStates
= GetReadOnlyStates( aNames
);
437 EnableNotification( aNames
);
438 const Any
* pValues
= aValues
.getConstArray();
439 const sal_Bool
* pROStates
= aROStates
.getConstArray();
440 DBG_ASSERT( aValues
.getLength() == aNames
.getLength(), "GetProperties failed" );
441 DBG_ASSERT( aROStates
.getLength() == aNames
.getLength(), "GetReadOnlyStates failed" );
442 if ( aValues
.getLength() == aNames
.getLength() && aROStates
.getLength() == aNames
.getLength() )
444 for ( int nProp
= 0; nProp
< aNames
.getLength(); nProp
++ )
446 if ( pValues
[nProp
].hasValue() )
452 // not supported anymore
456 if ( pValues
[nProp
] >>= nTemp
)
457 nAutoSaveTime
= nTemp
;
459 OSL_FAIL( "Wrong Type!" );
461 bROAutoSaveTime
= pROStates
[nProp
];
464 case ODFDEFAULTVERSION
:
467 if ( pValues
[nProp
] >>= nTmp
)
470 eODFDefaultVersion
= SvtSaveOptions::ODFVER_LATEST
;
472 eODFDefaultVersion
= SvtSaveOptions::ODFDefaultVersion( nTmp
);
475 SAL_WARN( "unotools.config", "SvtSaveOptions_Impl::SvtSaveOptions_Impl(): Wrong Type!" );
477 bROODFDefaultVersion
= pROStates
[nProp
];
483 sal_Bool bTemp
= sal_Bool();
484 if ( pValues
[nProp
] >>= bTemp
)
489 bUseUserData
= bTemp
;
490 bROUseUserData
= pROStates
[nProp
];
494 bROBackup
= pROStates
[nProp
];
498 bROAutoSave
= pROStates
[nProp
];
501 bAutoSavePrompt
= bTemp
;
502 bROAutoSavePrompt
= pROStates
[nProp
];
506 bRODocInfSave
= pROStates
[nProp
];
508 case SAVEWORKINGSET
:
509 bSaveWorkingSet
= bTemp
;
510 bROSaveWorkingSet
= pROStates
[nProp
];
513 bSaveDocView
= bTemp
;
514 bROSaveDocView
= pROStates
[nProp
];
517 bSaveRelFSys
= bTemp
;
518 bROSaveRelFSys
= pROStates
[nProp
];
521 bSaveRelINet
= bTemp
;
522 bROSaveRelINet
= pROStates
[nProp
];
525 bSaveUnpacked
= bTemp
;
526 bROSaveUnpacked
= pROStates
[nProp
];
530 bDoPrettyPrinting
= bTemp
;
531 bRODoPrettyPrinting
= pROStates
[nProp
];
534 case WARNALIENFORMAT
:
535 bWarnAlienFormat
= bTemp
;
536 bROWarnAlienFormat
= pROStates
[nProp
];
540 bLoadDocPrinter
= bTemp
;
541 bROLoadDocPrinter
= pROStates
[nProp
];
545 bUseSHA1InODF12
= bTemp
;
546 bROUseSHA1InODF12
= pROStates
[nProp
];
549 case USEBLOWFISHINODF12
:
550 bUseBlowfishInODF12
= bTemp
;
551 bROUseBlowfishInODF12
= pROStates
[nProp
];
555 SAL_WARN( "unotools.config", "invalid index to load a path" );
560 OSL_FAIL( "Wrong Type!" );
570 css::uno::Reference
< css::uno::XInterface
> xCFG
= ::comphelper::ConfigurationHelper::openConfig(
571 ::comphelper::getProcessComponentContext(),
572 OUString("org.openoffice.Office.Recovery"),
573 ::comphelper::ConfigurationHelper::E_READONLY
);
575 ::comphelper::ConfigurationHelper::readRelativeKey(
577 OUString("AutoSave"),
578 OUString("Enabled")) >>= bAutoSave
;
580 ::comphelper::ConfigurationHelper::readRelativeKey(
582 OUString("AutoSave"),
583 OUString("TimeIntervall")) >>= nAutoSaveTime
;
585 ::comphelper::ConfigurationHelper::readRelativeKey(
587 OUString("AutoSave"),
588 OUString("UserAutoSaveEnabled")) >>= bUserAutoSave
;
590 catch(const css::uno::Exception
&)
591 { OSL_FAIL("Could not find needed information for AutoSave feature."); }
594 SvtSaveOptions_Impl::~SvtSaveOptions_Impl()
597 void SvtSaveOptions_Impl::Commit()
599 Sequence
< OUString
> aOrgNames
= GetPropertyNames();
600 OUString
* pOrgNames
= aOrgNames
.getArray();
601 sal_Int32 nOrgCount
= aOrgNames
.getLength();
603 Sequence
< OUString
> aNames( nOrgCount
);
604 Sequence
< Any
> aValues( nOrgCount
);
605 OUString
* pNames
= aNames
.getArray();
606 Any
* pValues
= aValues
.getArray();
607 sal_Int32 nRealCount
= 0;
609 for (sal_Int32 i
=0; i
<nOrgCount
; ++i
)
614 // not supported anymore
617 if (!bROAutoSaveTime
)
619 pValues
[nRealCount
] <<= nAutoSaveTime
;
620 pNames
[nRealCount
] = pOrgNames
[i
];
627 pValues
[nRealCount
] <<= bUseUserData
;
628 pNames
[nRealCount
] = pOrgNames
[i
];
635 pValues
[nRealCount
] <<= bBackup
;
636 pNames
[nRealCount
] = pOrgNames
[i
];
643 pValues
[nRealCount
] <<= bAutoSave
;
644 pNames
[nRealCount
] = pOrgNames
[i
];
649 if (!bROAutoSavePrompt
)
651 pValues
[nRealCount
] <<= bAutoSavePrompt
;
652 pNames
[nRealCount
] = pOrgNames
[i
];
659 pValues
[nRealCount
] <<= bDocInfSave
;
660 pNames
[nRealCount
] = pOrgNames
[i
];
664 case SAVEWORKINGSET
:
665 if (!bROSaveWorkingSet
)
667 pValues
[nRealCount
] <<= bSaveWorkingSet
;
668 pNames
[nRealCount
] = pOrgNames
[i
];
675 pValues
[nRealCount
] <<= bSaveDocView
;
676 pNames
[nRealCount
] = pOrgNames
[i
];
683 pValues
[nRealCount
] <<= bSaveRelFSys
;
684 pNames
[nRealCount
] = pOrgNames
[i
];
691 pValues
[nRealCount
] <<= bSaveRelINet
;
692 pNames
[nRealCount
] = pOrgNames
[i
];
697 if (!bROSaveUnpacked
)
699 pValues
[nRealCount
] <<= bSaveUnpacked
;
700 pNames
[nRealCount
] = pOrgNames
[i
];
705 if (!bRODoPrettyPrinting
)
707 pValues
[nRealCount
] <<= bDoPrettyPrinting
;
708 pNames
[nRealCount
] = pOrgNames
[i
];
712 case WARNALIENFORMAT
:
713 if (!bROWarnAlienFormat
)
715 pValues
[nRealCount
] <<= bWarnAlienFormat
;
716 pNames
[nRealCount
] = pOrgNames
[i
];
721 if (!bROLoadDocPrinter
)
723 pValues
[nRealCount
] <<= bLoadDocPrinter
;
724 pNames
[nRealCount
] = pOrgNames
[i
];
728 case ODFDEFAULTVERSION
:
729 if (!bROODFDefaultVersion
)
731 pValues
[nRealCount
] <<= (eODFDefaultVersion
== SvtSaveOptions::ODFVER_LATEST
) ? sal_Int16( 3 ) : sal_Int16( eODFDefaultVersion
);
732 pNames
[nRealCount
] = pOrgNames
[i
];
737 if (!bROUseSHA1InODF12
)
739 pValues
[nRealCount
] <<= bUseSHA1InODF12
;
740 pNames
[nRealCount
] = pOrgNames
[i
];
744 case USEBLOWFISHINODF12
:
745 if (!bROUseBlowfishInODF12
)
747 pValues
[nRealCount
] <<= bUseBlowfishInODF12
;
748 pNames
[nRealCount
] = pOrgNames
[i
];
754 SAL_WARN( "unotools.config", "invalid index to save a path" );
758 aNames
.realloc(nRealCount
);
759 aValues
.realloc(nRealCount
);
760 PutProperties( aNames
, aValues
);
762 css::uno::Reference
< css::uno::XInterface
> xCFG
= ::comphelper::ConfigurationHelper::openConfig(
763 ::comphelper::getProcessComponentContext(),
764 OUString("org.openoffice.Office.Recovery"),
765 ::comphelper::ConfigurationHelper::E_STANDARD
);
767 ::comphelper::ConfigurationHelper::writeRelativeKey(
769 OUString("AutoSave"),
770 OUString("TimeIntervall"),
771 css::uno::makeAny(nAutoSaveTime
));
773 ::comphelper::ConfigurationHelper::writeRelativeKey(
775 OUString("AutoSave"),
777 css::uno::makeAny(bAutoSave
));
779 ::comphelper::ConfigurationHelper::writeRelativeKey(
781 OUString("AutoSave"),
782 OUString("UserAutoSaveEnabled"),
783 css::uno::makeAny(bUserAutoSave
));
785 ::comphelper::ConfigurationHelper::flush(xCFG
);
788 // -----------------------------------------------------------------------
790 void SvtSaveOptions_Impl::Notify( const Sequence
<OUString
>& )
795 class SvtLoadOptions_Impl
: public utl::ConfigItem
798 sal_Bool bLoadUserDefinedSettings
;
801 SvtLoadOptions_Impl();
802 ~SvtLoadOptions_Impl();
804 virtual void Notify( const com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
);
805 virtual void Commit();
807 void SetLoadUserSettings(sal_Bool b
){bLoadUserDefinedSettings
= b
; SetModified();}
808 sal_Bool
IsLoadUserSettings() const {return bLoadUserDefinedSettings
;}
810 // -----------------------------------------------------------------------
811 const sal_Char cUserDefinedSettings
[] = "UserDefinedSettings";
813 SvtLoadOptions_Impl::SvtLoadOptions_Impl()
814 : ConfigItem( OUString("Office.Common/Load") )
815 , bLoadUserDefinedSettings( sal_False
)
817 Sequence
< OUString
> aNames(1);
818 aNames
[0] = OUString::createFromAscii(cUserDefinedSettings
);
819 Sequence
< Any
> aValues
= GetProperties( aNames
);
820 EnableNotification( aNames
);
821 const Any
* pValues
= aValues
.getConstArray();
822 DBG_ASSERT( aValues
.getLength() == aNames
.getLength(), "GetProperties failed" );
823 if (pValues
[0].getValueTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN
)
824 bLoadUserDefinedSettings
= *(sal_Bool
*)pValues
[0].getValue();
826 // -----------------------------------------------------------------------
827 SvtLoadOptions_Impl::~SvtLoadOptions_Impl()
830 // -----------------------------------------------------------------------
831 void SvtLoadOptions_Impl::Commit()
833 Sequence
< OUString
> aNames(1);
834 aNames
[0] = OUString::createFromAscii(cUserDefinedSettings
);
835 Sequence
< Any
> aValues( 1 );
836 aValues
[0].setValue(&bLoadUserDefinedSettings
, ::getBooleanCppuType());
837 PutProperties( aNames
, aValues
);
839 // -----------------------------------------------------------------------
840 void SvtLoadOptions_Impl::Notify( const Sequence
<OUString
>& )
842 SAL_WARN( "unotools.config", "properties have been changed" );
844 // -----------------------------------------------------------------------
848 class LocalSingleton
: public rtl::Static
< osl::Mutex
, LocalSingleton
>
853 // -----------------------------------------------------------------------
854 SvtSaveOptions::SvtSaveOptions()
856 // Global access, must be guarded (multithreading)
857 ::osl::MutexGuard
aGuard( LocalSingleton::get() );
860 RTL_LOGFILE_CONTEXT(aLog
, "unotools ( ??? ) ::SvtSaveOptions_Impl::ctor()");
861 pOptions
= new SvtLoadSaveOptions_Impl
;
862 pOptions
->pSaveOpt
= new SvtSaveOptions_Impl
;
863 pOptions
->pLoadOpt
= new SvtLoadOptions_Impl
;
865 ItemHolder1::holdConfigItem(E_SAVEOPTIONS
);
871 // -----------------------------------------------------------------------
873 SvtSaveOptions::~SvtSaveOptions()
875 // Global access, must be guarded (multithreading)
876 ::osl::MutexGuard
aGuard( LocalSingleton::get() );
879 if ( pOptions
->pSaveOpt
->IsModified() )
880 pOptions
->pSaveOpt
->Commit();
881 if ( pOptions
->pLoadOpt
->IsModified() )
882 pOptions
->pLoadOpt
->Commit();
884 DELETEZ( pOptions
->pLoadOpt
);
885 DELETEZ( pOptions
->pSaveOpt
);
890 void SvtSaveOptions::SetAutoSaveTime( sal_Int32 n
)
892 pImp
->pSaveOpt
->SetAutoSaveTime( n
);
895 sal_Int32
SvtSaveOptions::GetAutoSaveTime() const
897 return pImp
->pSaveOpt
->GetAutoSaveTime();
900 void SvtSaveOptions::SetUseUserData( sal_Bool b
)
902 pImp
->pSaveOpt
->SetUseUserData( b
);
905 sal_Bool
SvtSaveOptions::IsUseUserData() const
907 return pImp
->pSaveOpt
->IsUseUserData();
910 void SvtSaveOptions::SetBackup( sal_Bool b
)
912 pImp
->pSaveOpt
->SetBackup( b
);
915 sal_Bool
SvtSaveOptions::IsBackup() const
917 return pImp
->pSaveOpt
->IsBackup();
920 void SvtSaveOptions::SetAutoSave( sal_Bool b
)
922 pImp
->pSaveOpt
->SetAutoSave( b
);
925 sal_Bool
SvtSaveOptions::IsAutoSave() const
927 return pImp
->pSaveOpt
->IsAutoSave();
930 void SvtSaveOptions::SetAutoSavePrompt( sal_Bool b
)
932 pImp
->pSaveOpt
->SetAutoSavePrompt( b
);
935 sal_Bool
SvtSaveOptions::IsAutoSavePrompt() const
937 return pImp
->pSaveOpt
->IsAutoSavePrompt();
940 void SvtSaveOptions::SetUserAutoSave( sal_Bool b
)
942 pImp
->pSaveOpt
->SetUserAutoSave( b
);
945 sal_Bool
SvtSaveOptions::IsUserAutoSave() const
947 return pImp
->pSaveOpt
->IsUserAutoSave();
950 void SvtSaveOptions::SetDocInfoSave(sal_Bool b
)
952 pImp
->pSaveOpt
->SetDocInfoSave( b
);
955 sal_Bool
SvtSaveOptions::IsDocInfoSave() const
957 return pImp
->pSaveOpt
->IsDocInfoSave();
960 void SvtSaveOptions::SetSaveWorkingSet( sal_Bool b
)
962 pImp
->pSaveOpt
->SetSaveWorkingSet( b
);
965 sal_Bool
SvtSaveOptions::IsSaveWorkingSet() const
967 return pImp
->pSaveOpt
->IsSaveWorkingSet();
970 void SvtSaveOptions::SetSaveDocView( sal_Bool b
)
972 pImp
->pSaveOpt
->SetSaveDocView( b
);
975 sal_Bool
SvtSaveOptions::IsSaveDocView() const
977 return pImp
->pSaveOpt
->IsSaveDocView();
980 void SvtSaveOptions::SetSaveRelINet( sal_Bool b
)
982 pImp
->pSaveOpt
->SetSaveRelINet( b
);
985 sal_Bool
SvtSaveOptions::IsSaveRelINet() const
987 return pImp
->pSaveOpt
->IsSaveRelINet();
990 void SvtSaveOptions::SetSaveRelFSys( sal_Bool b
)
992 pImp
->pSaveOpt
->SetSaveRelFSys( b
);
995 sal_Bool
SvtSaveOptions::IsSaveRelFSys() const
997 return pImp
->pSaveOpt
->IsSaveRelFSys();
1000 sal_Bool
SvtSaveOptions::IsSaveUnpacked() const
1002 return pImp
->pSaveOpt
->IsSaveUnpacked();
1005 void SvtSaveOptions::SetLoadUserSettings(sal_Bool b
)
1007 pImp
->pLoadOpt
->SetLoadUserSettings(b
);
1010 sal_Bool
SvtSaveOptions::IsLoadUserSettings() const
1012 return pImp
->pLoadOpt
->IsLoadUserSettings();
1015 void SvtSaveOptions::SetPrettyPrinting( sal_Bool _bEnable
)
1017 pImp
->pSaveOpt
->EnablePrettyPrinting( _bEnable
);
1020 sal_Bool
SvtSaveOptions::IsPrettyPrinting() const
1022 return pImp
->pSaveOpt
->IsPrettyPrintingEnabled();
1025 void SvtSaveOptions::SetWarnAlienFormat( sal_Bool _bEnable
)
1027 pImp
->pSaveOpt
->SetWarnAlienFormat( _bEnable
);
1030 sal_Bool
SvtSaveOptions::IsWarnAlienFormat() const
1032 return pImp
->pSaveOpt
->IsWarnAlienFormat();
1035 void SvtSaveOptions::SetLoadDocumentPrinter( sal_Bool _bEnable
)
1037 pImp
->pSaveOpt
->SetLoadDocPrinter( _bEnable
);
1040 sal_Bool
SvtSaveOptions::IsLoadDocumentPrinter() const
1042 return pImp
->pSaveOpt
->IsLoadDocPrinter();
1045 void SvtSaveOptions::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eVersion
)
1047 pImp
->pSaveOpt
->SetODFDefaultVersion( eVersion
);
1050 SvtSaveOptions::ODFDefaultVersion
SvtSaveOptions::GetODFDefaultVersion() const
1052 return pImp
->pSaveOpt
->GetODFDefaultVersion();
1055 sal_Bool
SvtSaveOptions::IsUseSHA1InODF12() const
1057 return pImp
->pSaveOpt
->IsUseSHA1InODF12();
1060 sal_Bool
SvtSaveOptions::IsUseBlowfishInODF12() const
1062 return pImp
->pSaveOpt
->IsUseBlowfishInODF12();
1065 sal_Bool
SvtSaveOptions::IsReadOnly( SvtSaveOptions::EOption eOption
) const
1067 return pImp
->pSaveOpt
->IsReadOnly(eOption
);
1070 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */