update emoji autocorrect entries from po-files
[LibreOffice.git] / unotools / source / config / saveopt.cxx
blobccea2c533af85dd632cd40f859e2bb10282326bf
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 <tools/solar.h>
29 #include <com/sun/star/uno/Any.hxx>
30 #include <com/sun/star/uno/Sequence.hxx>
32 #include <osl/diagnose.h>
33 #include <osl/mutex.hxx>
34 #include <comphelper/processfactory.hxx>
35 #include "itemholder1.hxx"
36 #include <officecfg/Office/Recovery.hxx>
38 using namespace utl;
39 using namespace com::sun::star::uno;
41 class SvtSaveOptions_Impl;
42 class SvtLoadOptions_Impl;
44 #define CFG_READONLY_DEFAULT false
46 struct SvtLoadSaveOptions_Impl
48 SvtSaveOptions_Impl* pSaveOpt;
49 SvtLoadOptions_Impl* pLoadOpt;
52 static SvtLoadSaveOptions_Impl* pOptions = NULL;
53 static sal_Int32 nRefCount = 0;
55 class SvtSaveOptions_Impl : public utl::ConfigItem
57 sal_Int32 nAutoSaveTime;
58 bool bUseUserData,
59 bBackup,
60 bAutoSave,
61 bAutoSavePrompt,
62 bUserAutoSave,
63 bDocInfSave,
64 bSaveWorkingSet,
65 bSaveDocView,
66 bSaveRelINet,
67 bSaveRelFSys,
68 bSaveUnpacked,
69 bDoPrettyPrinting,
70 bWarnAlienFormat,
71 bLoadDocPrinter,
72 bUseSHA1InODF12,
73 bUseBlowfishInODF12;
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 bROSaveUnpacked,
89 bROWarnAlienFormat,
90 bRODoPrettyPrinting,
91 bROLoadDocPrinter,
92 bROODFDefaultVersion,
93 bROUseSHA1InODF12,
94 bROUseBlowfishInODF12;
96 virtual void ImplCommit() SAL_OVERRIDE;
98 public:
99 SvtSaveOptions_Impl();
100 virtual ~SvtSaveOptions_Impl();
102 virtual void Notify( const com::sun::star::uno::Sequence< OUString >& aPropertyNames ) SAL_OVERRIDE;
104 sal_Int32 GetAutoSaveTime() const { return nAutoSaveTime; }
105 bool IsUseUserData() const { return bUseUserData; }
106 bool IsBackup() const { return bBackup; }
107 bool IsAutoSave() const { return bAutoSave; }
108 bool IsAutoSavePrompt() const { return bAutoSavePrompt; }
109 bool IsUserAutoSave() const { return bUserAutoSave; }
110 bool IsDocInfoSave() const { return bDocInfSave; }
111 bool IsSaveWorkingSet() const { return bSaveWorkingSet; }
112 bool IsSaveDocView() const { return bSaveDocView; }
113 bool IsSaveRelINet() const { return bSaveRelINet; }
114 bool IsSaveRelFSys() const { return bSaveRelFSys; }
115 bool IsSaveUnpacked() const { return bSaveUnpacked; }
116 bool IsPrettyPrintingEnabled( ) const { return bDoPrettyPrinting; }
117 bool IsWarnAlienFormat() const { return bWarnAlienFormat; }
118 bool IsLoadDocPrinter() const { return bLoadDocPrinter; }
119 bool IsUseSHA1InODF12() const { return bUseSHA1InODF12; }
120 bool IsUseBlowfishInODF12() const { return bUseBlowfishInODF12; }
122 SvtSaveOptions::ODFDefaultVersion
123 GetODFDefaultVersion() const { return eODFDefaultVersion; }
125 void SetAutoSaveTime( sal_Int32 n );
126 void SetUseUserData( bool b );
127 void SetBackup( bool b );
128 void SetAutoSave( bool b );
129 void SetAutoSavePrompt( bool b );
130 void SetUserAutoSave( bool b );
131 void SetDocInfoSave( bool b );
132 void SetSaveWorkingSet( bool b );
133 void SetSaveDocView( bool b );
134 void SetSaveRelINet( bool b );
135 void SetSaveRelFSys( bool b );
136 void EnablePrettyPrinting( bool _bDoPP );
137 void SetWarnAlienFormat( bool _bDoPP );
138 void SetLoadDocPrinter( bool bNew );
139 void SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew );
141 bool IsReadOnly( SvtSaveOptions::EOption eOption ) const;
144 void SvtSaveOptions_Impl::SetAutoSaveTime( sal_Int32 n )
146 if (!bROAutoSaveTime && nAutoSaveTime!=n)
148 nAutoSaveTime = n;
149 SetModified();
150 Commit();
154 void SvtSaveOptions_Impl::SetUseUserData( bool b )
156 if (!bROUseUserData && bUseUserData!=b)
158 bUseUserData = b;
159 SetModified();
163 void SvtSaveOptions_Impl::SetBackup( bool b )
165 if (!bROBackup && bBackup!=b)
167 bBackup = b;
168 SetModified();
172 void SvtSaveOptions_Impl::SetAutoSave( bool b )
174 if (!bROAutoSave && bAutoSave!=b)
176 bAutoSave = b;
177 SetModified();
178 Commit();
182 void SvtSaveOptions_Impl::SetAutoSavePrompt( bool b )
184 if (!bROAutoSavePrompt && bAutoSavePrompt!=b)
186 bAutoSavePrompt = b;
187 SetModified();
191 void SvtSaveOptions_Impl::SetUserAutoSave( bool b )
193 if (!bROUserAutoSave && bUserAutoSave!=b)
195 bUserAutoSave = b;
196 SetModified();
197 Commit();
201 void SvtSaveOptions_Impl::SetDocInfoSave(bool b)
203 if (!bRODocInfSave && bDocInfSave!=b)
205 bDocInfSave = b;
206 SetModified();
210 void SvtSaveOptions_Impl::SetSaveWorkingSet( bool b )
212 if (!bROSaveWorkingSet && bSaveWorkingSet!=b)
214 bSaveWorkingSet = b;
215 SetModified();
219 void SvtSaveOptions_Impl::SetSaveDocView( bool b )
221 if (!bROSaveDocView && bSaveDocView!=b)
223 bSaveDocView = b;
224 SetModified();
228 void SvtSaveOptions_Impl::SetSaveRelINet( bool b )
230 if (!bROSaveRelINet && bSaveRelINet!=b)
232 bSaveRelINet = b;
233 SetModified();
237 void SvtSaveOptions_Impl::SetSaveRelFSys( bool b )
239 if (!bROSaveRelFSys && bSaveRelFSys!=b)
241 bSaveRelFSys = b;
242 SetModified();
246 void SvtSaveOptions_Impl::EnablePrettyPrinting( bool _bDoPP )
248 if (!bRODoPrettyPrinting && bDoPrettyPrinting!=_bDoPP)
250 bDoPrettyPrinting = _bDoPP;
251 SetModified();
255 void SvtSaveOptions_Impl::SetWarnAlienFormat( bool _bDoPP )
257 if (!bROWarnAlienFormat && bWarnAlienFormat!=_bDoPP)
259 bWarnAlienFormat = _bDoPP;
260 SetModified();
264 void SvtSaveOptions_Impl::SetLoadDocPrinter( bool bNew )
266 if ( !bROLoadDocPrinter && bLoadDocPrinter != bNew )
268 bLoadDocPrinter = bNew;
269 SetModified();
273 void SvtSaveOptions_Impl::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew )
275 if ( !bROODFDefaultVersion && eODFDefaultVersion != eNew )
277 eODFDefaultVersion = eNew;
278 SetModified();
282 bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const
284 bool bReadOnly = CFG_READONLY_DEFAULT;
285 switch(eOption)
287 case SvtSaveOptions::E_AUTOSAVETIME :
288 bReadOnly = bROAutoSaveTime;
289 break;
290 case SvtSaveOptions::E_USEUSERDATA :
291 bReadOnly = bROUseUserData;
292 break;
293 case SvtSaveOptions::E_BACKUP :
294 bReadOnly = bROBackup;
295 break;
296 case SvtSaveOptions::E_AUTOSAVE :
297 bReadOnly = bROAutoSave;
298 break;
299 case SvtSaveOptions::E_AUTOSAVEPROMPT :
300 bReadOnly = bROAutoSavePrompt;
301 break;
302 case SvtSaveOptions::E_USERAUTOSAVE :
303 bReadOnly = bROUserAutoSave;
304 break;
305 case SvtSaveOptions::E_DOCINFSAVE :
306 bReadOnly = bRODocInfSave;
307 break;
308 case SvtSaveOptions::E_SAVEWORKINGSET :
309 bReadOnly = bROSaveWorkingSet;
310 break;
311 case SvtSaveOptions::E_SAVEDOCVIEW :
312 bReadOnly = bROSaveDocView;
313 break;
314 case SvtSaveOptions::E_SAVERELINET :
315 bReadOnly = bROSaveRelINet;
316 break;
317 case SvtSaveOptions::E_SAVERELFSYS :
318 bReadOnly = bROSaveRelFSys;
319 break;
320 case SvtSaveOptions::E_SAVEUNPACKED :
321 bReadOnly = bROSaveUnpacked;
322 break;
323 case SvtSaveOptions::E_DOPRETTYPRINTING :
324 bReadOnly = bRODoPrettyPrinting;
325 break;
326 case SvtSaveOptions::E_WARNALIENFORMAT :
327 bReadOnly = bROWarnAlienFormat;
328 break;
329 case SvtSaveOptions::E_LOADDOCPRINTER :
330 bReadOnly = bROLoadDocPrinter;
331 break;
332 case SvtSaveOptions::E_ODFDEFAULTVERSION :
333 bReadOnly = bROLoadDocPrinter;
334 break;
335 case SvtSaveOptions::E_USESHA1INODF12:
336 bReadOnly = bROUseSHA1InODF12;
337 break;
338 case SvtSaveOptions::E_USEBLOWFISHINODF12:
339 bReadOnly = bROUseBlowfishInODF12;
340 break;
342 return bReadOnly;
345 #define FORMAT 0
346 #define TIMEINTERVALL 1
347 #define USEUSERDATA 2
348 #define CREATEBACKUP 3
349 #define AUTOSAVE 4
350 #define PROMPT 5
351 #define EDITPROPERTY 6
352 #define SAVEVIEWINFO 7
353 #define UNPACKED 8
354 #define PRETTYPRINTING 9
355 #define WARNALIENFORMAT 10
356 #define LOADDOCPRINTER 11
357 #define FILESYSTEM 12
358 #define INTERNET 13
359 #define SAVEWORKINGSET 14
360 #define ODFDEFAULTVERSION 15
361 #define USESHA1INODF12 16
362 #define USEBLOWFISHINODF12 17
364 Sequence< OUString > GetPropertyNames()
366 static const char* aPropNames[] =
368 "Graphic/Format",
369 "Document/AutoSaveTimeIntervall",
370 "Document/UseUserData",
371 "Document/CreateBackup",
372 "Document/AutoSave",
373 "Document/AutoSavePrompt",
374 "Document/EditProperty",
375 "Document/ViewInfo",
376 "Document/Unpacked",
377 "Document/PrettyPrinting",
378 "Document/WarnAlienFormat",
379 "Document/LoadPrinter",
380 "URL/FileSystem",
381 "URL/Internet",
382 "WorkingSet",
383 "ODF/DefaultVersion",
384 "ODF/UseSHA1InODF12",
385 "ODF/UseBlowfishInODF12"
388 const int nCount = sizeof( aPropNames ) / sizeof( const char* );
389 Sequence< OUString > aNames( nCount );
390 OUString* pNames = aNames.getArray();
391 for ( int i = 0; i < nCount; i++ )
392 pNames[i] = OUString::createFromAscii( aPropNames[i] );
394 return aNames;
397 SvtSaveOptions_Impl::SvtSaveOptions_Impl()
398 : ConfigItem( OUString("Office.Common/Save") )
399 , nAutoSaveTime( 0 )
400 , bUseUserData( false )
401 , bBackup( false )
402 , bAutoSave( false )
403 , bAutoSavePrompt( false )
404 , bUserAutoSave( false )
405 , bDocInfSave( false )
406 , bSaveWorkingSet( false )
407 , bSaveDocView( false )
408 , bSaveRelINet( false )
409 , bSaveRelFSys( false )
410 , bSaveUnpacked( false )
411 , bDoPrettyPrinting( false )
412 , bWarnAlienFormat( true )
413 , bLoadDocPrinter( true )
414 , bUseSHA1InODF12( false )
415 , bUseBlowfishInODF12( false )
416 , eODFDefaultVersion( SvtSaveOptions::ODFVER_LATEST )
417 , bROAutoSaveTime( CFG_READONLY_DEFAULT )
418 , bROUseUserData( CFG_READONLY_DEFAULT )
419 , bROBackup( CFG_READONLY_DEFAULT )
420 , bROAutoSave( CFG_READONLY_DEFAULT )
421 , bROAutoSavePrompt( CFG_READONLY_DEFAULT )
422 , bROUserAutoSave( CFG_READONLY_DEFAULT )
423 , bRODocInfSave( CFG_READONLY_DEFAULT )
424 , bROSaveWorkingSet( CFG_READONLY_DEFAULT )
425 , bROSaveDocView( CFG_READONLY_DEFAULT )
426 , bROSaveRelINet( CFG_READONLY_DEFAULT )
427 , bROSaveRelFSys( CFG_READONLY_DEFAULT )
428 , bROSaveUnpacked( CFG_READONLY_DEFAULT )
429 , bROWarnAlienFormat( CFG_READONLY_DEFAULT )
430 , bRODoPrettyPrinting( CFG_READONLY_DEFAULT )
431 , bROLoadDocPrinter( CFG_READONLY_DEFAULT )
432 , bROODFDefaultVersion( CFG_READONLY_DEFAULT )
433 , bROUseSHA1InODF12( CFG_READONLY_DEFAULT )
434 , bROUseBlowfishInODF12( CFG_READONLY_DEFAULT )
436 Sequence< OUString > aNames = GetPropertyNames();
437 Sequence< Any > aValues = GetProperties( aNames );
438 Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames );
439 EnableNotification( aNames );
440 const Any* pValues = aValues.getConstArray();
441 const sal_Bool* pROStates = aROStates.getConstArray();
442 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
443 DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" );
444 if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
446 for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
448 if ( pValues[nProp].hasValue() )
450 sal_Int32 nTemp = 0;
451 switch ( nProp )
453 case FORMAT:
454 // not supported anymore
455 break;
457 case TIMEINTERVALL :
458 if ( pValues[nProp] >>= nTemp )
459 nAutoSaveTime = nTemp;
460 else {
461 OSL_FAIL( "Wrong Type!" );
463 bROAutoSaveTime = pROStates[nProp];
464 break;
466 case ODFDEFAULTVERSION :
468 sal_Int16 nTmp = 0;
469 if ( pValues[nProp] >>= nTmp )
471 if( nTmp == 3 )
472 eODFDefaultVersion = SvtSaveOptions::ODFVER_LATEST;
473 else
474 eODFDefaultVersion = SvtSaveOptions::ODFDefaultVersion( nTmp );
476 else {
477 SAL_WARN( "unotools.config", "SvtSaveOptions_Impl::SvtSaveOptions_Impl(): Wrong Type!" );
479 bROODFDefaultVersion = pROStates[nProp];
480 break;
483 default:
485 bool bTemp = bool();
486 if ( pValues[nProp] >>= bTemp )
488 switch ( nProp )
490 case USEUSERDATA :
491 bUseUserData = bTemp;
492 bROUseUserData = pROStates[nProp];
493 break;
494 case CREATEBACKUP :
495 bBackup = bTemp;
496 bROBackup = pROStates[nProp];
497 break;
498 case AUTOSAVE :
499 bAutoSave = bTemp;
500 bROAutoSave = pROStates[nProp];
501 break;
502 case PROMPT :
503 bAutoSavePrompt = bTemp;
504 bROAutoSavePrompt = pROStates[nProp];
505 break;
506 case EDITPROPERTY :
507 bDocInfSave = bTemp;
508 bRODocInfSave = pROStates[nProp];
509 break;
510 case SAVEWORKINGSET :
511 bSaveWorkingSet = bTemp;
512 bROSaveWorkingSet = pROStates[nProp];
513 break;
514 case SAVEVIEWINFO :
515 bSaveDocView = bTemp;
516 bROSaveDocView = pROStates[nProp];
517 break;
518 case FILESYSTEM :
519 bSaveRelFSys = bTemp;
520 bROSaveRelFSys = pROStates[nProp];
521 break;
522 case INTERNET :
523 bSaveRelINet = bTemp;
524 bROSaveRelINet = pROStates[nProp];
525 break;
526 case UNPACKED :
527 bSaveUnpacked = bTemp;
528 bROSaveUnpacked = pROStates[nProp];
529 break;
531 case PRETTYPRINTING:
532 bDoPrettyPrinting = bTemp;
533 bRODoPrettyPrinting = pROStates[nProp];
534 break;
536 case WARNALIENFORMAT:
537 bWarnAlienFormat = bTemp;
538 bROWarnAlienFormat = pROStates[nProp];
539 break;
541 case LOADDOCPRINTER:
542 bLoadDocPrinter = bTemp;
543 bROLoadDocPrinter = pROStates[nProp];
544 break;
546 case USESHA1INODF12:
547 bUseSHA1InODF12 = bTemp;
548 bROUseSHA1InODF12 = pROStates[nProp];
549 break;
551 case USEBLOWFISHINODF12:
552 bUseBlowfishInODF12 = bTemp;
553 bROUseBlowfishInODF12 = pROStates[nProp];
554 break;
556 default :
557 SAL_WARN( "unotools.config", "invalid index to load a path" );
560 else
562 OSL_FAIL( "Wrong Type!" );
570 bAutoSave = officecfg::Office::Recovery::AutoSave::Enabled::get();
571 nAutoSaveTime = officecfg::Office::Recovery::AutoSave::TimeIntervall::get();
572 bUserAutoSave = officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get();
575 SvtSaveOptions_Impl::~SvtSaveOptions_Impl()
578 void SvtSaveOptions_Impl::ImplCommit()
580 Sequence< OUString > aOrgNames = GetPropertyNames();
581 OUString* pOrgNames = aOrgNames.getArray();
582 sal_Int32 nOrgCount = aOrgNames.getLength();
584 Sequence< OUString > aNames( nOrgCount );
585 Sequence< Any > aValues( nOrgCount );
586 OUString* pNames = aNames.getArray();
587 Any* pValues = aValues.getArray();
588 sal_Int32 nRealCount = 0;
590 for (sal_Int32 i=0; i<nOrgCount; ++i)
592 switch (i)
594 case FORMAT:
595 // not supported anymore
596 break;
597 case TIMEINTERVALL :
598 if (!bROAutoSaveTime)
600 pValues[nRealCount] <<= nAutoSaveTime;
601 pNames[nRealCount] = pOrgNames[i];
602 ++nRealCount;
604 break;
605 case USEUSERDATA :
606 if (!bROUseUserData)
608 pValues[nRealCount] <<= bUseUserData;
609 pNames[nRealCount] = pOrgNames[i];
610 ++nRealCount;
612 break;
613 case CREATEBACKUP :
614 if (!bROBackup)
616 pValues[nRealCount] <<= bBackup;
617 pNames[nRealCount] = pOrgNames[i];
618 ++nRealCount;
620 break;
621 case AUTOSAVE :
622 if (!bROAutoSave)
624 pValues[nRealCount] <<= bAutoSave;
625 pNames[nRealCount] = pOrgNames[i];
626 ++nRealCount;
628 break;
629 case PROMPT :
630 if (!bROAutoSavePrompt)
632 pValues[nRealCount] <<= bAutoSavePrompt;
633 pNames[nRealCount] = pOrgNames[i];
634 ++nRealCount;
636 break;
637 case EDITPROPERTY :
638 if (!bRODocInfSave)
640 pValues[nRealCount] <<= bDocInfSave;
641 pNames[nRealCount] = pOrgNames[i];
642 ++nRealCount;
644 break;
645 case SAVEWORKINGSET :
646 if (!bROSaveWorkingSet)
648 pValues[nRealCount] <<= bSaveWorkingSet;
649 pNames[nRealCount] = pOrgNames[i];
650 ++nRealCount;
652 break;
653 case SAVEVIEWINFO :
654 if (!bROSaveDocView)
656 pValues[nRealCount] <<= bSaveDocView;
657 pNames[nRealCount] = pOrgNames[i];
658 ++nRealCount;
660 break;
661 case FILESYSTEM :
662 if (!bROSaveRelFSys)
664 pValues[nRealCount] <<= bSaveRelFSys;
665 pNames[nRealCount] = pOrgNames[i];
666 ++nRealCount;
668 break;
669 case INTERNET :
670 if (!bROSaveRelINet)
672 pValues[nRealCount] <<= bSaveRelINet;
673 pNames[nRealCount] = pOrgNames[i];
674 ++nRealCount;
676 break;
677 case UNPACKED :
678 if (!bROSaveUnpacked)
680 pValues[nRealCount] <<= bSaveUnpacked;
681 pNames[nRealCount] = pOrgNames[i];
682 ++nRealCount;
684 break;
685 case PRETTYPRINTING:
686 if (!bRODoPrettyPrinting)
688 pValues[nRealCount] <<= bDoPrettyPrinting;
689 pNames[nRealCount] = pOrgNames[i];
690 ++nRealCount;
692 break;
693 case WARNALIENFORMAT:
694 if (!bROWarnAlienFormat)
696 pValues[nRealCount] <<= bWarnAlienFormat;
697 pNames[nRealCount] = pOrgNames[i];
698 ++nRealCount;
700 break;
701 case LOADDOCPRINTER:
702 if (!bROLoadDocPrinter)
704 pValues[nRealCount] <<= bLoadDocPrinter;
705 pNames[nRealCount] = pOrgNames[i];
706 ++nRealCount;
708 break;
709 case ODFDEFAULTVERSION:
710 if (!bROODFDefaultVersion)
712 pValues[nRealCount] <<= (eODFDefaultVersion == SvtSaveOptions::ODFVER_LATEST) ? sal_Int16( 3 ) : sal_Int16( eODFDefaultVersion );
713 pNames[nRealCount] = pOrgNames[i];
714 ++nRealCount;
716 break;
717 case USESHA1INODF12:
718 if (!bROUseSHA1InODF12)
720 pValues[nRealCount] <<= bUseSHA1InODF12;
721 pNames[nRealCount] = pOrgNames[i];
722 ++nRealCount;
724 break;
725 case USEBLOWFISHINODF12:
726 if (!bROUseBlowfishInODF12)
728 pValues[nRealCount] <<= bUseBlowfishInODF12;
729 pNames[nRealCount] = pOrgNames[i];
730 ++nRealCount;
732 break;
734 default:
735 SAL_WARN( "unotools.config", "invalid index to save a path" );
739 aNames.realloc(nRealCount);
740 aValues.realloc(nRealCount);
741 PutProperties( aNames, aValues );
743 std::shared_ptr< comphelper::ConfigurationChanges > batch(
744 comphelper::ConfigurationChanges::create());
745 officecfg::Office::Recovery::AutoSave::TimeIntervall::set(nAutoSaveTime, batch);
746 officecfg::Office::Recovery::AutoSave::Enabled::set(bAutoSave, batch);
747 officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::set(bUserAutoSave, batch);
748 batch->commit();
751 void SvtSaveOptions_Impl::Notify( const Sequence<OUString>& )
755 class SvtLoadOptions_Impl : public utl::ConfigItem
757 private:
758 bool bLoadUserDefinedSettings;
760 virtual void ImplCommit() SAL_OVERRIDE;
762 public:
763 SvtLoadOptions_Impl();
764 virtual ~SvtLoadOptions_Impl();
766 virtual void Notify( const com::sun::star::uno::Sequence< OUString >& aPropertyNames ) SAL_OVERRIDE;
768 void SetLoadUserSettings(bool b){bLoadUserDefinedSettings = b; SetModified();}
769 bool IsLoadUserSettings() const {return bLoadUserDefinedSettings;}
772 const sal_Char cUserDefinedSettings[] = "UserDefinedSettings";
774 SvtLoadOptions_Impl::SvtLoadOptions_Impl()
775 : ConfigItem( OUString("Office.Common/Load") )
776 , bLoadUserDefinedSettings( false )
778 Sequence< OUString > aNames(1);
779 aNames[0] = cUserDefinedSettings;
780 Sequence< Any > aValues = GetProperties( aNames );
781 EnableNotification( aNames );
782 const Any* pValues = aValues.getConstArray();
783 DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
784 if (pValues[0].getValueTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN)
785 bLoadUserDefinedSettings = *static_cast<sal_Bool const *>(pValues[0].getValue());
788 SvtLoadOptions_Impl::~SvtLoadOptions_Impl()
792 void SvtLoadOptions_Impl::ImplCommit()
794 Sequence< OUString > aNames(1);
795 aNames[0] = cUserDefinedSettings;
796 Sequence< Any > aValues( 1 );
797 aValues[0].setValue(&bLoadUserDefinedSettings, cppu::UnoType<bool>::get());
798 PutProperties( aNames, aValues );
801 void SvtLoadOptions_Impl::Notify( const Sequence<OUString>& )
803 SAL_WARN( "unotools.config", "properties have been changed" );
806 namespace
808 class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton >
813 SvtSaveOptions::SvtSaveOptions()
815 // Global access, must be guarded (multithreading)
816 ::osl::MutexGuard aGuard( LocalSingleton::get() );
817 if ( !pOptions )
819 pOptions = new SvtLoadSaveOptions_Impl;
820 pOptions->pSaveOpt = new SvtSaveOptions_Impl;
821 pOptions->pLoadOpt = new SvtLoadOptions_Impl;
823 ItemHolder1::holdConfigItem(E_SAVEOPTIONS);
825 ++nRefCount;
826 pImp = pOptions;
829 SvtSaveOptions::~SvtSaveOptions()
831 // Global access, must be guarded (multithreading)
832 ::osl::MutexGuard aGuard( LocalSingleton::get() );
833 if ( !--nRefCount )
835 if ( pOptions->pSaveOpt->IsModified() )
836 pOptions->pSaveOpt->Commit();
837 if ( pOptions->pLoadOpt->IsModified() )
838 pOptions->pLoadOpt->Commit();
840 DELETEZ( pOptions->pLoadOpt );
841 DELETEZ( pOptions->pSaveOpt );
842 DELETEZ( pOptions );
846 void SvtSaveOptions::SetAutoSaveTime( sal_Int32 n )
848 pImp->pSaveOpt->SetAutoSaveTime( n );
851 sal_Int32 SvtSaveOptions::GetAutoSaveTime() const
853 return pImp->pSaveOpt->GetAutoSaveTime();
856 void SvtSaveOptions::SetUseUserData( bool b )
858 pImp->pSaveOpt->SetUseUserData( b );
861 bool SvtSaveOptions::IsUseUserData() const
863 return pImp->pSaveOpt->IsUseUserData();
866 void SvtSaveOptions::SetBackup( bool b )
868 pImp->pSaveOpt->SetBackup( b );
871 bool SvtSaveOptions::IsBackup() const
873 return pImp->pSaveOpt->IsBackup();
876 void SvtSaveOptions::SetAutoSave( bool b )
878 pImp->pSaveOpt->SetAutoSave( b );
881 bool SvtSaveOptions::IsAutoSave() const
883 return pImp->pSaveOpt->IsAutoSave();
886 void SvtSaveOptions::SetAutoSavePrompt( bool b )
888 pImp->pSaveOpt->SetAutoSavePrompt( b );
891 bool SvtSaveOptions::IsAutoSavePrompt() const
893 return pImp->pSaveOpt->IsAutoSavePrompt();
896 void SvtSaveOptions::SetUserAutoSave( bool b )
898 pImp->pSaveOpt->SetUserAutoSave( b );
901 bool SvtSaveOptions::IsUserAutoSave() const
903 return pImp->pSaveOpt->IsUserAutoSave();
906 void SvtSaveOptions::SetDocInfoSave(bool b)
908 pImp->pSaveOpt->SetDocInfoSave( b );
911 bool SvtSaveOptions::IsDocInfoSave() const
913 return pImp->pSaveOpt->IsDocInfoSave();
916 void SvtSaveOptions::SetSaveWorkingSet( bool b )
918 pImp->pSaveOpt->SetSaveWorkingSet( b );
921 bool SvtSaveOptions::IsSaveWorkingSet() const
923 return pImp->pSaveOpt->IsSaveWorkingSet();
926 void SvtSaveOptions::SetSaveDocView( bool b )
928 pImp->pSaveOpt->SetSaveDocView( b );
931 bool SvtSaveOptions::IsSaveDocView() const
933 return pImp->pSaveOpt->IsSaveDocView();
936 void SvtSaveOptions::SetSaveRelINet( bool b )
938 pImp->pSaveOpt->SetSaveRelINet( b );
941 bool SvtSaveOptions::IsSaveRelINet() const
943 return pImp->pSaveOpt->IsSaveRelINet();
946 void SvtSaveOptions::SetSaveRelFSys( bool b )
948 pImp->pSaveOpt->SetSaveRelFSys( b );
951 bool SvtSaveOptions::IsSaveRelFSys() const
953 return pImp->pSaveOpt->IsSaveRelFSys();
956 bool SvtSaveOptions::IsSaveUnpacked() const
958 return pImp->pSaveOpt->IsSaveUnpacked();
961 void SvtSaveOptions::SetLoadUserSettings(bool b)
963 pImp->pLoadOpt->SetLoadUserSettings(b);
966 bool SvtSaveOptions::IsLoadUserSettings() const
968 return pImp->pLoadOpt->IsLoadUserSettings();
971 void SvtSaveOptions::SetPrettyPrinting( bool _bEnable )
973 pImp->pSaveOpt->EnablePrettyPrinting( _bEnable );
976 bool SvtSaveOptions::IsPrettyPrinting() const
978 return pImp->pSaveOpt->IsPrettyPrintingEnabled();
981 void SvtSaveOptions::SetWarnAlienFormat( bool _bEnable )
983 pImp->pSaveOpt->SetWarnAlienFormat( _bEnable );
986 bool SvtSaveOptions::IsWarnAlienFormat() const
988 return pImp->pSaveOpt->IsWarnAlienFormat();
991 void SvtSaveOptions::SetLoadDocumentPrinter( bool _bEnable )
993 pImp->pSaveOpt->SetLoadDocPrinter( _bEnable );
996 bool SvtSaveOptions::IsLoadDocumentPrinter() const
998 return pImp->pSaveOpt->IsLoadDocPrinter();
1001 void SvtSaveOptions::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eVersion )
1003 pImp->pSaveOpt->SetODFDefaultVersion( eVersion );
1006 SvtSaveOptions::ODFDefaultVersion SvtSaveOptions::GetODFDefaultVersion() const
1008 return pImp->pSaveOpt->GetODFDefaultVersion();
1011 SvtSaveOptions::ODFSaneDefaultVersion SvtSaveOptions::GetODFSaneDefaultVersion() const
1013 const ODFSaneDefaultVersion NOW_CURRENT_LATEST = ODFSVER_012_EXTENDED;
1015 switch (pImp->pSaveOpt->GetODFDefaultVersion())
1017 default:
1018 assert(!"map new ODFDefaultVersion to ODFSaneDefaultVersion");
1019 break;
1020 case ODFVER_UNKNOWN:
1021 case ODFVER_LATEST:
1022 return NOW_CURRENT_LATEST;
1023 case ODFVER_010:
1024 return ODFSVER_010;
1025 case ODFVER_011:
1026 return ODFSVER_011;
1027 case ODFVER_012:
1028 return ODFSVER_012;
1029 case ODFVER_012_EXT_COMPAT:
1030 return ODFSVER_012_EXT_COMPAT;
1032 return NOW_CURRENT_LATEST;
1035 bool SvtSaveOptions::IsUseSHA1InODF12() const
1037 return pImp->pSaveOpt->IsUseSHA1InODF12();
1040 bool SvtSaveOptions::IsUseBlowfishInODF12() const
1042 return pImp->pSaveOpt->IsUseBlowfishInODF12();
1045 bool SvtSaveOptions::IsReadOnly( SvtSaveOptions::EOption eOption ) const
1047 return pImp->pSaveOpt->IsReadOnly(eOption);
1050 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */