bump product version to 4.1.6.2
[LibreOffice.git] / unotools / source / config / saveopt.cxx
blob9a25220f9a4114c0d365268fea847c481a41c38f
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 <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"
34 using namespace utl;
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,
56 bBackup,
57 bAutoSave,
58 bAutoSavePrompt,
59 bUserAutoSave,
60 bDocInfSave,
61 bSaveWorkingSet,
62 bSaveDocView,
63 bSaveRelINet,
64 bSaveRelFSys,
65 bSaveUnpacked,
66 bDoPrettyPrinting,
67 bWarnAlienFormat,
68 bLoadDocPrinter,
69 bUseSHA1InODF12,
70 bUseBlowfishInODF12;
72 SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion;
74 sal_Bool bROAutoSaveTime,
75 bROUseUserData,
76 bROBackup,
77 bROAutoSave,
78 bROAutoSavePrompt,
79 bROUserAutoSave,
80 bRODocInfSave,
81 bROSaveWorkingSet,
82 bROSaveDocView,
83 bROSaveRelINet,
84 bROSaveRelFSys,
85 bROSaveUnpacked,
86 bROWarnAlienFormat,
87 bRODoPrettyPrinting,
88 bROLoadDocPrinter,
89 bROODFDefaultVersion,
90 bROUseSHA1InODF12,
91 bROUseBlowfishInODF12;
93 public:
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)
144 nAutoSaveTime = n;
145 SetModified();
146 Commit();
150 void SvtSaveOptions_Impl::SetUseUserData( sal_Bool b )
152 if (!bROUseUserData && bUseUserData!=b)
154 bUseUserData = b;
155 SetModified();
159 void SvtSaveOptions_Impl::SetBackup( sal_Bool b )
161 if (!bROBackup && bBackup!=b)
163 bBackup = b;
164 SetModified();
168 void SvtSaveOptions_Impl::SetAutoSave( sal_Bool b )
170 if (!bROAutoSave && bAutoSave!=b)
172 bAutoSave = b;
173 SetModified();
174 Commit();
178 void SvtSaveOptions_Impl::SetAutoSavePrompt( sal_Bool b )
180 if (!bROAutoSavePrompt && bAutoSavePrompt!=b)
182 bAutoSavePrompt = b;
183 SetModified();
187 void SvtSaveOptions_Impl::SetUserAutoSave( sal_Bool b )
189 if (!bROUserAutoSave && bUserAutoSave!=b)
191 bUserAutoSave = b;
192 SetModified();
193 Commit();
197 void SvtSaveOptions_Impl::SetDocInfoSave(sal_Bool b)
199 if (!bRODocInfSave && bDocInfSave!=b)
201 bDocInfSave = b;
202 SetModified();
206 void SvtSaveOptions_Impl::SetSaveWorkingSet( sal_Bool b )
208 if (!bROSaveWorkingSet && bSaveWorkingSet!=b)
210 bSaveWorkingSet = b;
211 SetModified();
215 void SvtSaveOptions_Impl::SetSaveDocView( sal_Bool b )
217 if (!bROSaveDocView && bSaveDocView!=b)
219 bSaveDocView = b;
220 SetModified();
224 void SvtSaveOptions_Impl::SetSaveRelINet( sal_Bool b )
226 if (!bROSaveRelINet && bSaveRelINet!=b)
228 bSaveRelINet = b;
229 SetModified();
233 void SvtSaveOptions_Impl::SetSaveRelFSys( sal_Bool b )
235 if (!bROSaveRelFSys && bSaveRelFSys!=b)
237 bSaveRelFSys = b;
238 SetModified();
242 void SvtSaveOptions_Impl::EnablePrettyPrinting( sal_Bool _bDoPP )
244 if (!bRODoPrettyPrinting && bDoPrettyPrinting!=_bDoPP)
246 bDoPrettyPrinting = _bDoPP;
247 SetModified();
251 void SvtSaveOptions_Impl::SetWarnAlienFormat( sal_Bool _bDoPP )
253 if (!bROWarnAlienFormat && bWarnAlienFormat!=_bDoPP)
255 bWarnAlienFormat = _bDoPP;
256 SetModified();
260 void SvtSaveOptions_Impl::SetLoadDocPrinter( sal_Bool bNew )
262 if ( !bROLoadDocPrinter && bLoadDocPrinter != bNew )
264 bLoadDocPrinter = bNew;
265 SetModified();
269 void SvtSaveOptions_Impl::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew )
271 if ( !bROODFDefaultVersion && eODFDefaultVersion != eNew )
273 eODFDefaultVersion = eNew;
274 SetModified();
278 sal_Bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const
280 sal_Bool bReadOnly = CFG_READONLY_DEFAULT;
281 switch(eOption)
283 case SvtSaveOptions::E_AUTOSAVETIME :
284 bReadOnly = bROAutoSaveTime;
285 break;
286 case SvtSaveOptions::E_USEUSERDATA :
287 bReadOnly = bROUseUserData;
288 break;
289 case SvtSaveOptions::E_BACKUP :
290 bReadOnly = bROBackup;
291 break;
292 case SvtSaveOptions::E_AUTOSAVE :
293 bReadOnly = bROAutoSave;
294 break;
295 case SvtSaveOptions::E_AUTOSAVEPROMPT :
296 bReadOnly = bROAutoSavePrompt;
297 break;
298 case SvtSaveOptions::E_USERAUTOSAVE :
299 bReadOnly = bROUserAutoSave;
300 break;
301 case SvtSaveOptions::E_DOCINFSAVE :
302 bReadOnly = bRODocInfSave;
303 break;
304 case SvtSaveOptions::E_SAVEWORKINGSET :
305 bReadOnly = bROSaveWorkingSet;
306 break;
307 case SvtSaveOptions::E_SAVEDOCVIEW :
308 bReadOnly = bROSaveDocView;
309 break;
310 case SvtSaveOptions::E_SAVERELINET :
311 bReadOnly = bROSaveRelINet;
312 break;
313 case SvtSaveOptions::E_SAVERELFSYS :
314 bReadOnly = bROSaveRelFSys;
315 break;
316 case SvtSaveOptions::E_SAVEUNPACKED :
317 bReadOnly = bROSaveUnpacked;
318 break;
319 case SvtSaveOptions::E_DOPRETTYPRINTING :
320 bReadOnly = bRODoPrettyPrinting;
321 break;
322 case SvtSaveOptions::E_WARNALIENFORMAT :
323 bReadOnly = bROWarnAlienFormat;
324 break;
325 case SvtSaveOptions::E_LOADDOCPRINTER :
326 bReadOnly = bROLoadDocPrinter;
327 break;
328 case SvtSaveOptions::E_ODFDEFAULTVERSION :
329 bReadOnly = bROLoadDocPrinter;
330 break;
331 case SvtSaveOptions::E_USESHA1INODF12:
332 bReadOnly = bROUseSHA1InODF12;
333 break;
334 case SvtSaveOptions::E_USEBLOWFISHINODF12:
335 bReadOnly = bROUseBlowfishInODF12;
336 break;
338 return bReadOnly;
341 #define FORMAT 0
342 #define TIMEINTERVALL 1
343 #define USEUSERDATA 2
344 #define CREATEBACKUP 3
345 #define AUTOSAVE 4
346 #define PROMPT 5
347 #define EDITPROPERTY 6
348 #define SAVEVIEWINFO 7
349 #define UNPACKED 8
350 #define PRETTYPRINTING 9
351 #define WARNALIENFORMAT 10
352 #define LOADDOCPRINTER 11
353 #define FILESYSTEM 12
354 #define INTERNET 13
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[] =
364 "Graphic/Format",
365 "Document/AutoSaveTimeIntervall",
366 "Document/UseUserData",
367 "Document/CreateBackup",
368 "Document/AutoSave",
369 "Document/AutoSavePrompt",
370 "Document/EditProperty",
371 "Document/ViewInfo",
372 "Document/Unpacked",
373 "Document/PrettyPrinting",
374 "Document/WarnAlienFormat",
375 "Document/LoadPrinter",
376 "URL/FileSystem",
377 "URL/Internet",
378 "WorkingSet",
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] );
390 return aNames;
393 // -----------------------------------------------------------------------
395 SvtSaveOptions_Impl::SvtSaveOptions_Impl()
396 : ConfigItem( OUString("Office.Common/Save") )
397 , nAutoSaveTime( 0 )
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() )
448 sal_Int32 nTemp = 0;
449 switch ( nProp )
451 case FORMAT:
452 // not supported anymore
453 break;
455 case TIMEINTERVALL :
456 if ( pValues[nProp] >>= nTemp )
457 nAutoSaveTime = nTemp;
458 else {
459 OSL_FAIL( "Wrong Type!" );
461 bROAutoSaveTime = pROStates[nProp];
462 break;
464 case ODFDEFAULTVERSION :
466 sal_Int16 nTmp = 0;
467 if ( pValues[nProp] >>= nTmp )
469 if( nTmp == 3 )
470 eODFDefaultVersion = SvtSaveOptions::ODFVER_LATEST;
471 else
472 eODFDefaultVersion = SvtSaveOptions::ODFDefaultVersion( nTmp );
474 else {
475 SAL_WARN( "unotools.config", "SvtSaveOptions_Impl::SvtSaveOptions_Impl(): Wrong Type!" );
477 bROODFDefaultVersion = pROStates[nProp];
478 break;
481 default:
483 sal_Bool bTemp = sal_Bool();
484 if ( pValues[nProp] >>= bTemp )
486 switch ( nProp )
488 case USEUSERDATA :
489 bUseUserData = bTemp;
490 bROUseUserData = pROStates[nProp];
491 break;
492 case CREATEBACKUP :
493 bBackup = bTemp;
494 bROBackup = pROStates[nProp];
495 break;
496 case AUTOSAVE :
497 bAutoSave = bTemp;
498 bROAutoSave = pROStates[nProp];
499 break;
500 case PROMPT :
501 bAutoSavePrompt = bTemp;
502 bROAutoSavePrompt = pROStates[nProp];
503 break;
504 case EDITPROPERTY :
505 bDocInfSave = bTemp;
506 bRODocInfSave = pROStates[nProp];
507 break;
508 case SAVEWORKINGSET :
509 bSaveWorkingSet = bTemp;
510 bROSaveWorkingSet = pROStates[nProp];
511 break;
512 case SAVEVIEWINFO :
513 bSaveDocView = bTemp;
514 bROSaveDocView = pROStates[nProp];
515 break;
516 case FILESYSTEM :
517 bSaveRelFSys = bTemp;
518 bROSaveRelFSys = pROStates[nProp];
519 break;
520 case INTERNET :
521 bSaveRelINet = bTemp;
522 bROSaveRelINet = pROStates[nProp];
523 break;
524 case UNPACKED :
525 bSaveUnpacked = bTemp;
526 bROSaveUnpacked = pROStates[nProp];
527 break;
529 case PRETTYPRINTING:
530 bDoPrettyPrinting = bTemp;
531 bRODoPrettyPrinting = pROStates[nProp];
532 break;
534 case WARNALIENFORMAT:
535 bWarnAlienFormat = bTemp;
536 bROWarnAlienFormat = pROStates[nProp];
537 break;
539 case LOADDOCPRINTER:
540 bLoadDocPrinter = bTemp;
541 bROLoadDocPrinter = pROStates[nProp];
542 break;
544 case USESHA1INODF12:
545 bUseSHA1InODF12 = bTemp;
546 bROUseSHA1InODF12 = pROStates[nProp];
547 break;
549 case USEBLOWFISHINODF12:
550 bUseBlowfishInODF12 = bTemp;
551 bROUseBlowfishInODF12 = pROStates[nProp];
552 break;
554 default :
555 SAL_WARN( "unotools.config", "invalid index to load a path" );
558 else
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(
576 xCFG,
577 OUString("AutoSave"),
578 OUString("Enabled")) >>= bAutoSave;
580 ::comphelper::ConfigurationHelper::readRelativeKey(
581 xCFG,
582 OUString("AutoSave"),
583 OUString("TimeIntervall")) >>= nAutoSaveTime;
585 ::comphelper::ConfigurationHelper::readRelativeKey(
586 xCFG,
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)
611 switch (i)
613 case FORMAT:
614 // not supported anymore
615 break;
616 case TIMEINTERVALL :
617 if (!bROAutoSaveTime)
619 pValues[nRealCount] <<= nAutoSaveTime;
620 pNames[nRealCount] = pOrgNames[i];
621 ++nRealCount;
623 break;
624 case USEUSERDATA :
625 if (!bROUseUserData)
627 pValues[nRealCount] <<= bUseUserData;
628 pNames[nRealCount] = pOrgNames[i];
629 ++nRealCount;
631 break;
632 case CREATEBACKUP :
633 if (!bROBackup)
635 pValues[nRealCount] <<= bBackup;
636 pNames[nRealCount] = pOrgNames[i];
637 ++nRealCount;
639 break;
640 case AUTOSAVE :
641 if (!bROAutoSave)
643 pValues[nRealCount] <<= bAutoSave;
644 pNames[nRealCount] = pOrgNames[i];
645 ++nRealCount;
647 break;
648 case PROMPT :
649 if (!bROAutoSavePrompt)
651 pValues[nRealCount] <<= bAutoSavePrompt;
652 pNames[nRealCount] = pOrgNames[i];
653 ++nRealCount;
655 break;
656 case EDITPROPERTY :
657 if (!bRODocInfSave)
659 pValues[nRealCount] <<= bDocInfSave;
660 pNames[nRealCount] = pOrgNames[i];
661 ++nRealCount;
663 break;
664 case SAVEWORKINGSET :
665 if (!bROSaveWorkingSet)
667 pValues[nRealCount] <<= bSaveWorkingSet;
668 pNames[nRealCount] = pOrgNames[i];
669 ++nRealCount;
671 break;
672 case SAVEVIEWINFO :
673 if (!bROSaveDocView)
675 pValues[nRealCount] <<= bSaveDocView;
676 pNames[nRealCount] = pOrgNames[i];
677 ++nRealCount;
679 break;
680 case FILESYSTEM :
681 if (!bROSaveRelFSys)
683 pValues[nRealCount] <<= bSaveRelFSys;
684 pNames[nRealCount] = pOrgNames[i];
685 ++nRealCount;
687 break;
688 case INTERNET :
689 if (!bROSaveRelINet)
691 pValues[nRealCount] <<= bSaveRelINet;
692 pNames[nRealCount] = pOrgNames[i];
693 ++nRealCount;
695 break;
696 case UNPACKED :
697 if (!bROSaveUnpacked)
699 pValues[nRealCount] <<= bSaveUnpacked;
700 pNames[nRealCount] = pOrgNames[i];
701 ++nRealCount;
703 break;
704 case PRETTYPRINTING:
705 if (!bRODoPrettyPrinting)
707 pValues[nRealCount] <<= bDoPrettyPrinting;
708 pNames[nRealCount] = pOrgNames[i];
709 ++nRealCount;
711 break;
712 case WARNALIENFORMAT:
713 if (!bROWarnAlienFormat)
715 pValues[nRealCount] <<= bWarnAlienFormat;
716 pNames[nRealCount] = pOrgNames[i];
717 ++nRealCount;
719 break;
720 case LOADDOCPRINTER:
721 if (!bROLoadDocPrinter)
723 pValues[nRealCount] <<= bLoadDocPrinter;
724 pNames[nRealCount] = pOrgNames[i];
725 ++nRealCount;
727 break;
728 case ODFDEFAULTVERSION:
729 if (!bROODFDefaultVersion)
731 pValues[nRealCount] <<= (eODFDefaultVersion == SvtSaveOptions::ODFVER_LATEST) ? sal_Int16( 3 ) : sal_Int16( eODFDefaultVersion );
732 pNames[nRealCount] = pOrgNames[i];
733 ++nRealCount;
735 break;
736 case USESHA1INODF12:
737 if (!bROUseSHA1InODF12)
739 pValues[nRealCount] <<= bUseSHA1InODF12;
740 pNames[nRealCount] = pOrgNames[i];
741 ++nRealCount;
743 break;
744 case USEBLOWFISHINODF12:
745 if (!bROUseBlowfishInODF12)
747 pValues[nRealCount] <<= bUseBlowfishInODF12;
748 pNames[nRealCount] = pOrgNames[i];
749 ++nRealCount;
751 break;
753 default:
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(
768 xCFG,
769 OUString("AutoSave"),
770 OUString("TimeIntervall"),
771 css::uno::makeAny(nAutoSaveTime));
773 ::comphelper::ConfigurationHelper::writeRelativeKey(
774 xCFG,
775 OUString("AutoSave"),
776 OUString("Enabled"),
777 css::uno::makeAny(bAutoSave));
779 ::comphelper::ConfigurationHelper::writeRelativeKey(
780 xCFG,
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;
800 public:
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 // -----------------------------------------------------------------------
846 namespace
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() );
858 if ( !pOptions )
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);
867 ++nRefCount;
868 pImp = pOptions;
871 // -----------------------------------------------------------------------
873 SvtSaveOptions::~SvtSaveOptions()
875 // Global access, must be guarded (multithreading)
876 ::osl::MutexGuard aGuard( LocalSingleton::get() );
877 if ( !--nRefCount )
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 );
886 DELETEZ( pOptions );
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: */