1*b5088357SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b5088357SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b5088357SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b5088357SAndrew Rist * distributed with this work for additional information
6*b5088357SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b5088357SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b5088357SAndrew Rist * "License"); you may not use this file except in compliance
9*b5088357SAndrew Rist * with the License. You may obtain a copy of the License at
10*b5088357SAndrew Rist *
11*b5088357SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*b5088357SAndrew Rist *
13*b5088357SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b5088357SAndrew Rist * software distributed under the License is distributed on an
15*b5088357SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b5088357SAndrew Rist * KIND, either express or implied. See the License for the
17*b5088357SAndrew Rist * specific language governing permissions and limitations
18*b5088357SAndrew Rist * under the License.
19*b5088357SAndrew Rist *
20*b5088357SAndrew Rist *************************************************************/
21*b5088357SAndrew Rist
22*b5088357SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_unotools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifndef GCC
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <unotools/saveopt.hxx>
31cdf0e10cSrcweir #include "rtl/instance.hxx"
32cdf0e10cSrcweir #include <unotools/configmgr.hxx>
33cdf0e10cSrcweir #include <unotools/configitem.hxx>
34cdf0e10cSrcweir #include <tools/debug.hxx>
35cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
36cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <osl/mutex.hxx>
39cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx>
40cdf0e10cSrcweir #include <unotools/processfactory.hxx>
41cdf0e10cSrcweir #include <rtl/logfile.hxx>
42cdf0e10cSrcweir #include "itemholder1.hxx"
43cdf0e10cSrcweir
44cdf0e10cSrcweir using namespace utl;
45cdf0e10cSrcweir using namespace rtl;
46cdf0e10cSrcweir using namespace com::sun::star::uno;
47cdf0e10cSrcweir namespace css = ::com::sun::star;
48cdf0e10cSrcweir
49cdf0e10cSrcweir class SvtSaveOptions_Impl;
50cdf0e10cSrcweir class SvtLoadOptions_Impl;
51cdf0e10cSrcweir
52cdf0e10cSrcweir #define CFG_READONLY_DEFAULT sal_False
53cdf0e10cSrcweir
54cdf0e10cSrcweir struct SvtLoadSaveOptions_Impl
55cdf0e10cSrcweir {
56cdf0e10cSrcweir SvtSaveOptions_Impl* pSaveOpt;
57cdf0e10cSrcweir SvtLoadOptions_Impl* pLoadOpt;
58cdf0e10cSrcweir };
59cdf0e10cSrcweir
60cdf0e10cSrcweir static SvtLoadSaveOptions_Impl* pOptions = NULL;
61cdf0e10cSrcweir static sal_Int32 nRefCount = 0;
62cdf0e10cSrcweir
63cdf0e10cSrcweir class SvtSaveOptions_Impl : public utl::ConfigItem
64cdf0e10cSrcweir {
65cdf0e10cSrcweir sal_Int32 nAutoSaveTime;
66cdf0e10cSrcweir sal_Bool bUseUserData,
67cdf0e10cSrcweir bBackup,
68cdf0e10cSrcweir bAutoSave,
69cdf0e10cSrcweir bAutoSavePrompt,
70cdf0e10cSrcweir bDocInfSave,
71cdf0e10cSrcweir bSaveWorkingSet,
72cdf0e10cSrcweir bSaveDocView,
73cdf0e10cSrcweir bSaveRelINet,
74cdf0e10cSrcweir bSaveRelFSys,
75cdf0e10cSrcweir bSaveUnpacked,
76cdf0e10cSrcweir bDoPrettyPrinting,
77cdf0e10cSrcweir bWarnAlienFormat,
78cdf0e10cSrcweir bLoadDocPrinter,
79cdf0e10cSrcweir bUseSHA1InODF12,
80cdf0e10cSrcweir bUseBlowfishInODF12;
81cdf0e10cSrcweir
82cdf0e10cSrcweir SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion;
83cdf0e10cSrcweir
84cdf0e10cSrcweir sal_Bool bROAutoSaveTime,
85cdf0e10cSrcweir bROUseUserData,
86cdf0e10cSrcweir bROBackup,
87cdf0e10cSrcweir bROAutoSave,
88cdf0e10cSrcweir bROAutoSavePrompt,
89cdf0e10cSrcweir bRODocInfSave,
90cdf0e10cSrcweir bROSaveWorkingSet,
91cdf0e10cSrcweir bROSaveDocView,
92cdf0e10cSrcweir bROSaveRelINet,
93cdf0e10cSrcweir bROSaveRelFSys,
94cdf0e10cSrcweir bROSaveUnpacked,
95cdf0e10cSrcweir bROWarnAlienFormat,
96cdf0e10cSrcweir bRODoPrettyPrinting,
97cdf0e10cSrcweir bROLoadDocPrinter,
98cdf0e10cSrcweir bROODFDefaultVersion,
99cdf0e10cSrcweir bROUseSHA1InODF12,
100cdf0e10cSrcweir bROUseBlowfishInODF12;
101cdf0e10cSrcweir
102cdf0e10cSrcweir public:
103cdf0e10cSrcweir SvtSaveOptions_Impl();
104cdf0e10cSrcweir ~SvtSaveOptions_Impl();
105cdf0e10cSrcweir
106cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
107cdf0e10cSrcweir virtual void Commit();
108cdf0e10cSrcweir
GetAutoSaveTime() const109cdf0e10cSrcweir sal_Int32 GetAutoSaveTime() const { return nAutoSaveTime; }
IsUseUserData() const110cdf0e10cSrcweir sal_Bool IsUseUserData() const { return bUseUserData; }
IsBackup() const111cdf0e10cSrcweir sal_Bool IsBackup() const { return bBackup; }
IsAutoSave() const112cdf0e10cSrcweir sal_Bool IsAutoSave() const { return bAutoSave; }
IsAutoSavePrompt() const113cdf0e10cSrcweir sal_Bool IsAutoSavePrompt() const { return bAutoSavePrompt; }
IsDocInfoSave() const114cdf0e10cSrcweir sal_Bool IsDocInfoSave() const { return bDocInfSave; }
IsSaveWorkingSet() const115cdf0e10cSrcweir sal_Bool IsSaveWorkingSet() const { return bSaveWorkingSet; }
IsSaveDocView() const116cdf0e10cSrcweir sal_Bool IsSaveDocView() const { return bSaveDocView; }
IsSaveRelINet() const117cdf0e10cSrcweir sal_Bool IsSaveRelINet() const { return bSaveRelINet; }
IsSaveRelFSys() const118cdf0e10cSrcweir sal_Bool IsSaveRelFSys() const { return bSaveRelFSys; }
IsSaveUnpacked() const119cdf0e10cSrcweir sal_Bool IsSaveUnpacked() const { return bSaveUnpacked; }
IsPrettyPrintingEnabled() const120cdf0e10cSrcweir sal_Bool IsPrettyPrintingEnabled( ) const { return bDoPrettyPrinting; }
IsWarnAlienFormat() const121cdf0e10cSrcweir sal_Bool IsWarnAlienFormat() const { return bWarnAlienFormat; }
IsLoadDocPrinter() const122cdf0e10cSrcweir sal_Bool IsLoadDocPrinter() const { return bLoadDocPrinter; }
IsUseSHA1InODF12() const123cdf0e10cSrcweir sal_Bool IsUseSHA1InODF12() const { return bUseSHA1InODF12; }
IsUseBlowfishInODF12() const124cdf0e10cSrcweir sal_Bool IsUseBlowfishInODF12() const { return bUseBlowfishInODF12; }
125cdf0e10cSrcweir
126cdf0e10cSrcweir SvtSaveOptions::ODFDefaultVersion
GetODFDefaultVersion() const127cdf0e10cSrcweir GetODFDefaultVersion() const { return eODFDefaultVersion; }
128cdf0e10cSrcweir
129cdf0e10cSrcweir void SetAutoSaveTime( sal_Int32 n );
130cdf0e10cSrcweir void SetUseUserData( sal_Bool b );
131cdf0e10cSrcweir void SetBackup( sal_Bool b );
132cdf0e10cSrcweir void SetAutoSave( sal_Bool b );
133cdf0e10cSrcweir void SetAutoSavePrompt( sal_Bool b );
134cdf0e10cSrcweir void SetDocInfoSave( sal_Bool b );
135cdf0e10cSrcweir void SetSaveWorkingSet( sal_Bool b );
136cdf0e10cSrcweir void SetSaveDocView( sal_Bool b );
137cdf0e10cSrcweir void SetSaveRelINet( sal_Bool b );
138cdf0e10cSrcweir void SetSaveRelFSys( sal_Bool b );
139cdf0e10cSrcweir void SetSaveUnpacked( sal_Bool b );
140cdf0e10cSrcweir void EnablePrettyPrinting( sal_Bool _bDoPP );
141cdf0e10cSrcweir void SetWarnAlienFormat( sal_Bool _bDoPP );
142cdf0e10cSrcweir void SetLoadDocPrinter( sal_Bool bNew );
143cdf0e10cSrcweir void SetUseSHA1InODF12( sal_Bool bUse );
144cdf0e10cSrcweir void SetUseBlowfishInODF12( sal_Bool bUse );
145cdf0e10cSrcweir void SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew );
146cdf0e10cSrcweir
147cdf0e10cSrcweir sal_Bool IsReadOnly( SvtSaveOptions::EOption eOption ) const;
148cdf0e10cSrcweir };
149cdf0e10cSrcweir
SetAutoSaveTime(sal_Int32 n)150cdf0e10cSrcweir void SvtSaveOptions_Impl::SetAutoSaveTime( sal_Int32 n )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir if (!bROAutoSaveTime && nAutoSaveTime!=n)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir nAutoSaveTime = n;
155cdf0e10cSrcweir SetModified();
156cdf0e10cSrcweir Commit();
157cdf0e10cSrcweir }
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
SetUseUserData(sal_Bool b)160cdf0e10cSrcweir void SvtSaveOptions_Impl::SetUseUserData( sal_Bool b )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir if (!bROUseUserData && bUseUserData!=b)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir bUseUserData = b;
165cdf0e10cSrcweir SetModified();
166cdf0e10cSrcweir }
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
SetBackup(sal_Bool b)169cdf0e10cSrcweir void SvtSaveOptions_Impl::SetBackup( sal_Bool b )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir if (!bROBackup && bBackup!=b)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir bBackup = b;
174cdf0e10cSrcweir SetModified();
175cdf0e10cSrcweir }
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
SetAutoSave(sal_Bool b)178cdf0e10cSrcweir void SvtSaveOptions_Impl::SetAutoSave( sal_Bool b )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir if (!bROAutoSave && bAutoSave!=b)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir bAutoSave = b;
183cdf0e10cSrcweir SetModified();
184cdf0e10cSrcweir Commit();
185cdf0e10cSrcweir }
186cdf0e10cSrcweir }
187cdf0e10cSrcweir
SetAutoSavePrompt(sal_Bool b)188cdf0e10cSrcweir void SvtSaveOptions_Impl::SetAutoSavePrompt( sal_Bool b )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir if (!bROAutoSavePrompt && bAutoSavePrompt!=b)
191cdf0e10cSrcweir {
192cdf0e10cSrcweir bAutoSavePrompt = b;
193cdf0e10cSrcweir SetModified();
194cdf0e10cSrcweir }
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
SetDocInfoSave(sal_Bool b)197cdf0e10cSrcweir void SvtSaveOptions_Impl::SetDocInfoSave(sal_Bool b)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir if (!bRODocInfSave && bDocInfSave!=b)
200cdf0e10cSrcweir {
201cdf0e10cSrcweir bDocInfSave = b;
202cdf0e10cSrcweir SetModified();
203cdf0e10cSrcweir }
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
SetSaveWorkingSet(sal_Bool b)206cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveWorkingSet( sal_Bool b )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir if (!bROSaveWorkingSet && bSaveWorkingSet!=b)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir bSaveWorkingSet = b;
211cdf0e10cSrcweir SetModified();
212cdf0e10cSrcweir }
213cdf0e10cSrcweir }
214cdf0e10cSrcweir
SetSaveDocView(sal_Bool b)215cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveDocView( sal_Bool b )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir if (!bROSaveDocView && bSaveDocView!=b)
218cdf0e10cSrcweir {
219cdf0e10cSrcweir bSaveDocView = b;
220cdf0e10cSrcweir SetModified();
221cdf0e10cSrcweir }
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
SetSaveRelINet(sal_Bool b)224cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveRelINet( sal_Bool b )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir if (!bROSaveRelINet && bSaveRelINet!=b)
227cdf0e10cSrcweir {
228cdf0e10cSrcweir bSaveRelINet = b;
229cdf0e10cSrcweir SetModified();
230cdf0e10cSrcweir }
231cdf0e10cSrcweir }
232cdf0e10cSrcweir
SetSaveRelFSys(sal_Bool b)233cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveRelFSys( sal_Bool b )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir if (!bROSaveRelFSys && bSaveRelFSys!=b)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir bSaveRelFSys = b;
238cdf0e10cSrcweir SetModified();
239cdf0e10cSrcweir }
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
SetSaveUnpacked(sal_Bool b)242cdf0e10cSrcweir void SvtSaveOptions_Impl::SetSaveUnpacked( sal_Bool b )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir if (!bROSaveUnpacked && bSaveUnpacked!=b)
245cdf0e10cSrcweir {
246cdf0e10cSrcweir bSaveUnpacked = b;
247cdf0e10cSrcweir SetModified();
248cdf0e10cSrcweir }
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
EnablePrettyPrinting(sal_Bool _bDoPP)251cdf0e10cSrcweir void SvtSaveOptions_Impl::EnablePrettyPrinting( sal_Bool _bDoPP )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir if (!bRODoPrettyPrinting && bDoPrettyPrinting!=_bDoPP)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir bDoPrettyPrinting = _bDoPP;
256cdf0e10cSrcweir SetModified();
257cdf0e10cSrcweir }
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
SetWarnAlienFormat(sal_Bool _bDoPP)260cdf0e10cSrcweir void SvtSaveOptions_Impl::SetWarnAlienFormat( sal_Bool _bDoPP )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir if (!bROWarnAlienFormat && bWarnAlienFormat!=_bDoPP)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir bWarnAlienFormat = _bDoPP;
265cdf0e10cSrcweir SetModified();
266cdf0e10cSrcweir }
267cdf0e10cSrcweir }
268cdf0e10cSrcweir
SetLoadDocPrinter(sal_Bool bNew)269cdf0e10cSrcweir void SvtSaveOptions_Impl::SetLoadDocPrinter( sal_Bool bNew )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir if ( !bROLoadDocPrinter && bLoadDocPrinter != bNew )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir bLoadDocPrinter = bNew;
274cdf0e10cSrcweir SetModified();
275cdf0e10cSrcweir }
276cdf0e10cSrcweir }
277cdf0e10cSrcweir
SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion eNew)278cdf0e10cSrcweir void SvtSaveOptions_Impl::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir if ( !bROODFDefaultVersion && eODFDefaultVersion != eNew )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir eODFDefaultVersion = eNew;
283cdf0e10cSrcweir SetModified();
284cdf0e10cSrcweir }
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
SetUseSHA1InODF12(sal_Bool bUse)287cdf0e10cSrcweir void SvtSaveOptions_Impl::SetUseSHA1InODF12( sal_Bool bUse )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir if ( !bROUseSHA1InODF12 && bUseSHA1InODF12 != bUse )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir bUseSHA1InODF12 = bUse;
292cdf0e10cSrcweir SetModified();
293cdf0e10cSrcweir }
294cdf0e10cSrcweir }
295cdf0e10cSrcweir
SetUseBlowfishInODF12(sal_Bool bUse)296cdf0e10cSrcweir void SvtSaveOptions_Impl::SetUseBlowfishInODF12( sal_Bool bUse )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir if ( !bROUseBlowfishInODF12 && bUseBlowfishInODF12 != bUse )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir bUseBlowfishInODF12 = bUse;
301cdf0e10cSrcweir SetModified();
302cdf0e10cSrcweir }
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
IsReadOnly(SvtSaveOptions::EOption eOption) const305cdf0e10cSrcweir sal_Bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const
306cdf0e10cSrcweir {
307cdf0e10cSrcweir sal_Bool bReadOnly = CFG_READONLY_DEFAULT;
308cdf0e10cSrcweir switch(eOption)
309cdf0e10cSrcweir {
310cdf0e10cSrcweir case SvtSaveOptions::E_AUTOSAVETIME :
311cdf0e10cSrcweir bReadOnly = bROAutoSaveTime;
312cdf0e10cSrcweir break;
313cdf0e10cSrcweir case SvtSaveOptions::E_USEUSERDATA :
314cdf0e10cSrcweir bReadOnly = bROUseUserData;
315cdf0e10cSrcweir break;
316cdf0e10cSrcweir case SvtSaveOptions::E_BACKUP :
317cdf0e10cSrcweir bReadOnly = bROBackup;
318cdf0e10cSrcweir break;
319cdf0e10cSrcweir case SvtSaveOptions::E_AUTOSAVE :
320cdf0e10cSrcweir bReadOnly = bROAutoSave;
321cdf0e10cSrcweir break;
322cdf0e10cSrcweir case SvtSaveOptions::E_AUTOSAVEPROMPT :
323cdf0e10cSrcweir bReadOnly = bROAutoSavePrompt;
324cdf0e10cSrcweir break;
325cdf0e10cSrcweir case SvtSaveOptions::E_DOCINFSAVE :
326cdf0e10cSrcweir bReadOnly = bRODocInfSave;
327cdf0e10cSrcweir break;
328cdf0e10cSrcweir case SvtSaveOptions::E_SAVEWORKINGSET :
329cdf0e10cSrcweir bReadOnly = bROSaveWorkingSet;
330cdf0e10cSrcweir break;
331cdf0e10cSrcweir case SvtSaveOptions::E_SAVEDOCVIEW :
332cdf0e10cSrcweir bReadOnly = bROSaveDocView;
333cdf0e10cSrcweir break;
334cdf0e10cSrcweir case SvtSaveOptions::E_SAVERELINET :
335cdf0e10cSrcweir bReadOnly = bROSaveRelINet;
336cdf0e10cSrcweir break;
337cdf0e10cSrcweir case SvtSaveOptions::E_SAVERELFSYS :
338cdf0e10cSrcweir bReadOnly = bROSaveRelFSys;
339cdf0e10cSrcweir break;
340cdf0e10cSrcweir case SvtSaveOptions::E_SAVEUNPACKED :
341cdf0e10cSrcweir bReadOnly = bROSaveUnpacked;
342cdf0e10cSrcweir break;
343cdf0e10cSrcweir case SvtSaveOptions::E_DOPRETTYPRINTING :
344cdf0e10cSrcweir bReadOnly = bRODoPrettyPrinting;
345cdf0e10cSrcweir break;
346cdf0e10cSrcweir case SvtSaveOptions::E_WARNALIENFORMAT :
347cdf0e10cSrcweir bReadOnly = bROWarnAlienFormat;
348cdf0e10cSrcweir break;
349cdf0e10cSrcweir case SvtSaveOptions::E_LOADDOCPRINTER :
350cdf0e10cSrcweir bReadOnly = bROLoadDocPrinter;
351cdf0e10cSrcweir break;
352cdf0e10cSrcweir case SvtSaveOptions::E_ODFDEFAULTVERSION :
353cdf0e10cSrcweir bReadOnly = bROLoadDocPrinter;
354cdf0e10cSrcweir break;
355cdf0e10cSrcweir case SvtSaveOptions::E_USESHA1INODF12:
356cdf0e10cSrcweir bReadOnly = bROUseSHA1InODF12;
357cdf0e10cSrcweir break;
358cdf0e10cSrcweir case SvtSaveOptions::E_USEBLOWFISHINODF12:
359cdf0e10cSrcweir bReadOnly = bROUseBlowfishInODF12;
360cdf0e10cSrcweir break;
361cdf0e10cSrcweir }
362cdf0e10cSrcweir return bReadOnly;
363cdf0e10cSrcweir }
364cdf0e10cSrcweir
365cdf0e10cSrcweir #define FORMAT 0
366cdf0e10cSrcweir #define TIMEINTERVALL 1
367cdf0e10cSrcweir #define USEUSERDATA 2
368cdf0e10cSrcweir #define CREATEBACKUP 3
369cdf0e10cSrcweir #define AUTOSAVE 4
370cdf0e10cSrcweir #define PROMPT 5
371cdf0e10cSrcweir #define EDITPROPERTY 6
372cdf0e10cSrcweir #define SAVEVIEWINFO 7
373cdf0e10cSrcweir #define UNPACKED 8
374cdf0e10cSrcweir #define PRETTYPRINTING 9
375cdf0e10cSrcweir #define WARNALIENFORMAT 10
376cdf0e10cSrcweir #define LOADDOCPRINTER 11
377cdf0e10cSrcweir #define FILESYSTEM 12
378cdf0e10cSrcweir #define INTERNET 13
379cdf0e10cSrcweir #define SAVEWORKINGSET 14
380cdf0e10cSrcweir #define ODFDEFAULTVERSION 15
381cdf0e10cSrcweir #define USESHA1INODF12 16
382cdf0e10cSrcweir #define USEBLOWFISHINODF12 17
383cdf0e10cSrcweir
GetPropertyNames()384cdf0e10cSrcweir Sequence< OUString > GetPropertyNames()
385cdf0e10cSrcweir {
386cdf0e10cSrcweir static const char* aPropNames[] =
387cdf0e10cSrcweir {
388cdf0e10cSrcweir "Graphic/Format",
389cdf0e10cSrcweir "Document/AutoSaveTimeIntervall",
390cdf0e10cSrcweir "Document/UseUserData",
391cdf0e10cSrcweir "Document/CreateBackup",
392cdf0e10cSrcweir "Document/AutoSave",
393cdf0e10cSrcweir "Document/AutoSavePrompt",
394cdf0e10cSrcweir "Document/EditProperty",
395cdf0e10cSrcweir "Document/ViewInfo",
396cdf0e10cSrcweir "Document/Unpacked",
397cdf0e10cSrcweir "Document/PrettyPrinting",
398cdf0e10cSrcweir "Document/WarnAlienFormat",
399cdf0e10cSrcweir "Document/LoadPrinter",
400cdf0e10cSrcweir "URL/FileSystem",
401cdf0e10cSrcweir "URL/Internet",
402cdf0e10cSrcweir "WorkingSet",
403cdf0e10cSrcweir "ODF/DefaultVersion",
404cdf0e10cSrcweir "ODF/UseSHA1InODF12",
405cdf0e10cSrcweir "ODF/UseBlowfishInODF12"
406cdf0e10cSrcweir };
407cdf0e10cSrcweir
408cdf0e10cSrcweir const int nCount = sizeof( aPropNames ) / sizeof( const char* );
409cdf0e10cSrcweir Sequence< OUString > aNames( nCount );
410cdf0e10cSrcweir OUString* pNames = aNames.getArray();
411cdf0e10cSrcweir for ( int i = 0; i < nCount; i++ )
412cdf0e10cSrcweir pNames[i] = OUString::createFromAscii( aPropNames[i] );
413cdf0e10cSrcweir
414cdf0e10cSrcweir return aNames;
415cdf0e10cSrcweir }
416cdf0e10cSrcweir
417cdf0e10cSrcweir // -----------------------------------------------------------------------
418cdf0e10cSrcweir
SvtSaveOptions_Impl()419cdf0e10cSrcweir SvtSaveOptions_Impl::SvtSaveOptions_Impl()
420cdf0e10cSrcweir : ConfigItem( OUString::createFromAscii("Office.Common/Save") )
421cdf0e10cSrcweir , nAutoSaveTime( 0 )
422cdf0e10cSrcweir , bUseUserData( sal_False )
423cdf0e10cSrcweir , bBackup( sal_False )
424cdf0e10cSrcweir , bAutoSave( sal_False )
425cdf0e10cSrcweir , bAutoSavePrompt( sal_False )
426cdf0e10cSrcweir , bDocInfSave( sal_False )
427cdf0e10cSrcweir , bSaveWorkingSet( sal_False )
428cdf0e10cSrcweir , bSaveDocView( sal_False )
429cdf0e10cSrcweir , bSaveRelINet( sal_False )
430cdf0e10cSrcweir , bSaveRelFSys( sal_False )
431cdf0e10cSrcweir , bSaveUnpacked( sal_False )
432cdf0e10cSrcweir , bDoPrettyPrinting( sal_False )
433cdf0e10cSrcweir , bWarnAlienFormat( sal_True )
434cdf0e10cSrcweir , bLoadDocPrinter( sal_True )
435cdf0e10cSrcweir , bUseSHA1InODF12( sal_False )
436cdf0e10cSrcweir , bUseBlowfishInODF12( sal_False )
437cdf0e10cSrcweir , eODFDefaultVersion( SvtSaveOptions::ODFVER_LATEST )
438cdf0e10cSrcweir , bROAutoSaveTime( CFG_READONLY_DEFAULT )
439cdf0e10cSrcweir , bROUseUserData( CFG_READONLY_DEFAULT )
440cdf0e10cSrcweir , bROBackup( CFG_READONLY_DEFAULT )
441cdf0e10cSrcweir , bROAutoSave( CFG_READONLY_DEFAULT )
442cdf0e10cSrcweir , bROAutoSavePrompt( CFG_READONLY_DEFAULT )
443cdf0e10cSrcweir , bRODocInfSave( CFG_READONLY_DEFAULT )
444cdf0e10cSrcweir , bROSaveWorkingSet( CFG_READONLY_DEFAULT )
445cdf0e10cSrcweir , bROSaveDocView( CFG_READONLY_DEFAULT )
446cdf0e10cSrcweir , bROSaveRelINet( CFG_READONLY_DEFAULT )
447cdf0e10cSrcweir , bROSaveRelFSys( CFG_READONLY_DEFAULT )
448cdf0e10cSrcweir , bROSaveUnpacked( CFG_READONLY_DEFAULT )
449cdf0e10cSrcweir , bROWarnAlienFormat( CFG_READONLY_DEFAULT )
450cdf0e10cSrcweir , bRODoPrettyPrinting( CFG_READONLY_DEFAULT )
451cdf0e10cSrcweir , bROLoadDocPrinter( CFG_READONLY_DEFAULT )
452cdf0e10cSrcweir , bROODFDefaultVersion( CFG_READONLY_DEFAULT )
453cdf0e10cSrcweir , bROUseSHA1InODF12( CFG_READONLY_DEFAULT )
454cdf0e10cSrcweir , bROUseBlowfishInODF12( CFG_READONLY_DEFAULT )
455cdf0e10cSrcweir {
456cdf0e10cSrcweir Sequence< OUString > aNames = GetPropertyNames();
457cdf0e10cSrcweir Sequence< Any > aValues = GetProperties( aNames );
458cdf0e10cSrcweir Sequence< sal_Bool > aROStates = GetReadOnlyStates( aNames );
459cdf0e10cSrcweir EnableNotification( aNames );
460cdf0e10cSrcweir const Any* pValues = aValues.getConstArray();
461cdf0e10cSrcweir const sal_Bool* pROStates = aROStates.getConstArray();
462cdf0e10cSrcweir DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
463cdf0e10cSrcweir DBG_ASSERT( aROStates.getLength() == aNames.getLength(), "GetReadOnlyStates failed" );
464cdf0e10cSrcweir if ( aValues.getLength() == aNames.getLength() && aROStates.getLength() == aNames.getLength() )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
469cdf0e10cSrcweir if ( pValues[nProp].hasValue() )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir sal_Int32 nTemp = 0;
472cdf0e10cSrcweir switch ( nProp )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir case FORMAT:
475cdf0e10cSrcweir // not supported anymore
476cdf0e10cSrcweir break;
477cdf0e10cSrcweir
478cdf0e10cSrcweir case TIMEINTERVALL :
479cdf0e10cSrcweir if ( pValues[nProp] >>= nTemp )
480cdf0e10cSrcweir nAutoSaveTime = nTemp;
481cdf0e10cSrcweir else {
482cdf0e10cSrcweir DBG_ERROR( "Wrong Type!" );
483cdf0e10cSrcweir };
484cdf0e10cSrcweir bROAutoSaveTime = pROStates[nProp];
485cdf0e10cSrcweir break;
486cdf0e10cSrcweir
487cdf0e10cSrcweir case ODFDEFAULTVERSION :
488cdf0e10cSrcweir {
489cdf0e10cSrcweir sal_Int16 nTmp = 0;
490cdf0e10cSrcweir if ( pValues[nProp] >>= nTmp )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir if( nTmp == 3 )
493cdf0e10cSrcweir eODFDefaultVersion = SvtSaveOptions::ODFVER_LATEST;
494cdf0e10cSrcweir else
495cdf0e10cSrcweir eODFDefaultVersion = SvtSaveOptions::ODFDefaultVersion( nTmp );
496cdf0e10cSrcweir }
497cdf0e10cSrcweir else {
498cdf0e10cSrcweir DBG_ERRORFILE( "SvtSaveOptions_Impl::SvtSaveOptions_Impl(): Wrong Type!" );
499cdf0e10cSrcweir };
500cdf0e10cSrcweir bROODFDefaultVersion = pROStates[nProp];
501cdf0e10cSrcweir break;
502cdf0e10cSrcweir }
503cdf0e10cSrcweir
504cdf0e10cSrcweir default:
505cdf0e10cSrcweir {
506cdf0e10cSrcweir sal_Bool bTemp = sal_Bool();
507cdf0e10cSrcweir if ( pValues[nProp] >>= bTemp )
508cdf0e10cSrcweir {
509cdf0e10cSrcweir switch ( nProp )
510cdf0e10cSrcweir {
511cdf0e10cSrcweir case USEUSERDATA :
512cdf0e10cSrcweir bUseUserData = bTemp;
513cdf0e10cSrcweir bROUseUserData = pROStates[nProp];
514cdf0e10cSrcweir break;
515cdf0e10cSrcweir case CREATEBACKUP :
516cdf0e10cSrcweir bBackup = bTemp;
517cdf0e10cSrcweir bROBackup = pROStates[nProp];
518cdf0e10cSrcweir break;
519cdf0e10cSrcweir case AUTOSAVE :
520cdf0e10cSrcweir bAutoSave = bTemp;
521cdf0e10cSrcweir bROAutoSave = pROStates[nProp];
522cdf0e10cSrcweir break;
523cdf0e10cSrcweir case PROMPT :
524cdf0e10cSrcweir bAutoSavePrompt = bTemp;
525cdf0e10cSrcweir bROAutoSavePrompt = pROStates[nProp];
526cdf0e10cSrcweir break;
527cdf0e10cSrcweir case EDITPROPERTY :
528cdf0e10cSrcweir bDocInfSave = bTemp;
529cdf0e10cSrcweir bRODocInfSave = pROStates[nProp];
530cdf0e10cSrcweir break;
531cdf0e10cSrcweir case SAVEWORKINGSET :
532cdf0e10cSrcweir bSaveWorkingSet = bTemp;
533cdf0e10cSrcweir bROSaveWorkingSet = pROStates[nProp];
534cdf0e10cSrcweir break;
535cdf0e10cSrcweir case SAVEVIEWINFO :
536cdf0e10cSrcweir bSaveDocView = bTemp;
537cdf0e10cSrcweir bROSaveDocView = pROStates[nProp];
538cdf0e10cSrcweir break;
539cdf0e10cSrcweir case FILESYSTEM :
540cdf0e10cSrcweir bSaveRelFSys = bTemp;
541cdf0e10cSrcweir bROSaveRelFSys = pROStates[nProp];
542cdf0e10cSrcweir break;
543cdf0e10cSrcweir case INTERNET :
544cdf0e10cSrcweir bSaveRelINet = bTemp;
545cdf0e10cSrcweir bROSaveRelINet = pROStates[nProp];
546cdf0e10cSrcweir break;
547cdf0e10cSrcweir case UNPACKED :
548cdf0e10cSrcweir bSaveUnpacked = bTemp;
549cdf0e10cSrcweir bROSaveUnpacked = pROStates[nProp];
550cdf0e10cSrcweir break;
551cdf0e10cSrcweir
552cdf0e10cSrcweir case PRETTYPRINTING:
553cdf0e10cSrcweir bDoPrettyPrinting = bTemp;
554cdf0e10cSrcweir bRODoPrettyPrinting = pROStates[nProp];
555cdf0e10cSrcweir break;
556cdf0e10cSrcweir
557cdf0e10cSrcweir case WARNALIENFORMAT:
558cdf0e10cSrcweir bWarnAlienFormat = bTemp;
559cdf0e10cSrcweir bROWarnAlienFormat = pROStates[nProp];
560cdf0e10cSrcweir break;
561cdf0e10cSrcweir
562cdf0e10cSrcweir case LOADDOCPRINTER:
563cdf0e10cSrcweir bLoadDocPrinter = bTemp;
564cdf0e10cSrcweir bROLoadDocPrinter = pROStates[nProp];
565cdf0e10cSrcweir break;
566cdf0e10cSrcweir
567cdf0e10cSrcweir case USESHA1INODF12:
568cdf0e10cSrcweir bUseSHA1InODF12 = bTemp;
569cdf0e10cSrcweir bROUseSHA1InODF12 = pROStates[nProp];
570cdf0e10cSrcweir break;
571cdf0e10cSrcweir
572cdf0e10cSrcweir case USEBLOWFISHINODF12:
573cdf0e10cSrcweir bUseBlowfishInODF12 = bTemp;
574cdf0e10cSrcweir bROUseBlowfishInODF12 = pROStates[nProp];
575cdf0e10cSrcweir break;
576cdf0e10cSrcweir
577cdf0e10cSrcweir default :
578cdf0e10cSrcweir DBG_ERRORFILE( "invalid index to load a path" );
579cdf0e10cSrcweir }
580cdf0e10cSrcweir }
581cdf0e10cSrcweir else
582cdf0e10cSrcweir {
583cdf0e10cSrcweir DBG_ERROR( "Wrong Type!" );
584cdf0e10cSrcweir }
585cdf0e10cSrcweir }
586cdf0e10cSrcweir }
587cdf0e10cSrcweir }
588cdf0e10cSrcweir }
589cdf0e10cSrcweir }
590cdf0e10cSrcweir
591cdf0e10cSrcweir try
592cdf0e10cSrcweir {
593cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > xCFG = ::comphelper::ConfigurationHelper::openConfig(
594cdf0e10cSrcweir ::utl::getProcessServiceFactory(),
595cdf0e10cSrcweir ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery"),
596cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY);
597cdf0e10cSrcweir
598cdf0e10cSrcweir ::comphelper::ConfigurationHelper::readRelativeKey(
599cdf0e10cSrcweir xCFG,
600cdf0e10cSrcweir ::rtl::OUString::createFromAscii("AutoSave"),
601cdf0e10cSrcweir ::rtl::OUString::createFromAscii("Enabled")) >>= bAutoSave;
602cdf0e10cSrcweir
603cdf0e10cSrcweir ::comphelper::ConfigurationHelper::readRelativeKey(
604cdf0e10cSrcweir xCFG,
605cdf0e10cSrcweir ::rtl::OUString::createFromAscii("AutoSave"),
606cdf0e10cSrcweir ::rtl::OUString::createFromAscii("TimeIntervall")) >>= nAutoSaveTime;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir catch(const css::uno::Exception&)
609cdf0e10cSrcweir { DBG_ERROR("Could not find needed informations for AutoSave feature."); }
610cdf0e10cSrcweir }
611cdf0e10cSrcweir
~SvtSaveOptions_Impl()612cdf0e10cSrcweir SvtSaveOptions_Impl::~SvtSaveOptions_Impl()
613cdf0e10cSrcweir {}
614cdf0e10cSrcweir
Commit()615cdf0e10cSrcweir void SvtSaveOptions_Impl::Commit()
616cdf0e10cSrcweir {
617cdf0e10cSrcweir Sequence< OUString > aOrgNames = GetPropertyNames();
618cdf0e10cSrcweir OUString* pOrgNames = aOrgNames.getArray();
619cdf0e10cSrcweir sal_Int32 nOrgCount = aOrgNames.getLength();
620cdf0e10cSrcweir
621cdf0e10cSrcweir Sequence< OUString > aNames( nOrgCount );
622cdf0e10cSrcweir Sequence< Any > aValues( nOrgCount );
623cdf0e10cSrcweir OUString* pNames = aNames.getArray();
624cdf0e10cSrcweir Any* pValues = aValues.getArray();
625cdf0e10cSrcweir sal_Int32 nRealCount = 0;
626cdf0e10cSrcweir
627cdf0e10cSrcweir for (sal_Int32 i=0; i<nOrgCount; ++i)
628cdf0e10cSrcweir {
629cdf0e10cSrcweir switch (i)
630cdf0e10cSrcweir {
631cdf0e10cSrcweir case FORMAT:
632cdf0e10cSrcweir // not supported anymore
633cdf0e10cSrcweir break;
634cdf0e10cSrcweir case TIMEINTERVALL :
635cdf0e10cSrcweir if (!bROAutoSaveTime)
636cdf0e10cSrcweir {
637cdf0e10cSrcweir pValues[nRealCount] <<= nAutoSaveTime;
638cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
639cdf0e10cSrcweir ++nRealCount;
640cdf0e10cSrcweir }
641cdf0e10cSrcweir break;
642cdf0e10cSrcweir case USEUSERDATA :
643cdf0e10cSrcweir if (!bROUseUserData)
644cdf0e10cSrcweir {
645cdf0e10cSrcweir pValues[nRealCount] <<= bUseUserData;
646cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
647cdf0e10cSrcweir ++nRealCount;
648cdf0e10cSrcweir }
649cdf0e10cSrcweir break;
650cdf0e10cSrcweir case CREATEBACKUP :
651cdf0e10cSrcweir if (!bROBackup)
652cdf0e10cSrcweir {
653cdf0e10cSrcweir pValues[nRealCount] <<= bBackup;
654cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
655cdf0e10cSrcweir ++nRealCount;
656cdf0e10cSrcweir }
657cdf0e10cSrcweir break;
658cdf0e10cSrcweir case AUTOSAVE :
659cdf0e10cSrcweir if (!bROAutoSave)
660cdf0e10cSrcweir {
661cdf0e10cSrcweir pValues[nRealCount] <<= bAutoSave;
662cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
663cdf0e10cSrcweir ++nRealCount;
664cdf0e10cSrcweir }
665cdf0e10cSrcweir break;
666cdf0e10cSrcweir case PROMPT :
667cdf0e10cSrcweir if (!bROAutoSavePrompt)
668cdf0e10cSrcweir {
669cdf0e10cSrcweir pValues[nRealCount] <<= bAutoSavePrompt;
670cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
671cdf0e10cSrcweir ++nRealCount;
672cdf0e10cSrcweir }
673cdf0e10cSrcweir break;
674cdf0e10cSrcweir case EDITPROPERTY :
675cdf0e10cSrcweir if (!bRODocInfSave)
676cdf0e10cSrcweir {
677cdf0e10cSrcweir pValues[nRealCount] <<= bDocInfSave;
678cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
679cdf0e10cSrcweir ++nRealCount;
680cdf0e10cSrcweir }
681cdf0e10cSrcweir break;
682cdf0e10cSrcweir case SAVEWORKINGSET :
683cdf0e10cSrcweir if (!bROSaveWorkingSet)
684cdf0e10cSrcweir {
685cdf0e10cSrcweir pValues[nRealCount] <<= bSaveWorkingSet;
686cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
687cdf0e10cSrcweir ++nRealCount;
688cdf0e10cSrcweir }
689cdf0e10cSrcweir break;
690cdf0e10cSrcweir case SAVEVIEWINFO :
691cdf0e10cSrcweir if (!bROSaveDocView)
692cdf0e10cSrcweir {
693cdf0e10cSrcweir pValues[nRealCount] <<= bSaveDocView;
694cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
695cdf0e10cSrcweir ++nRealCount;
696cdf0e10cSrcweir }
697cdf0e10cSrcweir break;
698cdf0e10cSrcweir case FILESYSTEM :
699cdf0e10cSrcweir if (!bROSaveRelFSys)
700cdf0e10cSrcweir {
701cdf0e10cSrcweir pValues[nRealCount] <<= bSaveRelFSys;
702cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
703cdf0e10cSrcweir ++nRealCount;
704cdf0e10cSrcweir }
705cdf0e10cSrcweir break;
706cdf0e10cSrcweir case INTERNET :
707cdf0e10cSrcweir if (!bROSaveRelINet)
708cdf0e10cSrcweir {
709cdf0e10cSrcweir pValues[nRealCount] <<= bSaveRelINet;
710cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
711cdf0e10cSrcweir ++nRealCount;
712cdf0e10cSrcweir }
713cdf0e10cSrcweir break;
714cdf0e10cSrcweir case UNPACKED :
715cdf0e10cSrcweir if (!bROSaveUnpacked)
716cdf0e10cSrcweir {
717cdf0e10cSrcweir pValues[nRealCount] <<= bSaveUnpacked;
718cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
719cdf0e10cSrcweir ++nRealCount;
720cdf0e10cSrcweir }
721cdf0e10cSrcweir break;
722cdf0e10cSrcweir case PRETTYPRINTING:
723cdf0e10cSrcweir if (!bRODoPrettyPrinting)
724cdf0e10cSrcweir {
725cdf0e10cSrcweir pValues[nRealCount] <<= bDoPrettyPrinting;
726cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
727cdf0e10cSrcweir ++nRealCount;
728cdf0e10cSrcweir }
729cdf0e10cSrcweir break;
730cdf0e10cSrcweir case WARNALIENFORMAT:
731cdf0e10cSrcweir if (!bROWarnAlienFormat)
732cdf0e10cSrcweir {
733cdf0e10cSrcweir pValues[nRealCount] <<= bWarnAlienFormat;
734cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
735cdf0e10cSrcweir ++nRealCount;
736cdf0e10cSrcweir }
737cdf0e10cSrcweir break;
738cdf0e10cSrcweir case LOADDOCPRINTER:
739cdf0e10cSrcweir if (!bROLoadDocPrinter)
740cdf0e10cSrcweir {
741cdf0e10cSrcweir pValues[nRealCount] <<= bLoadDocPrinter;
742cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
743cdf0e10cSrcweir ++nRealCount;
744cdf0e10cSrcweir }
745cdf0e10cSrcweir break;
746cdf0e10cSrcweir case ODFDEFAULTVERSION:
747cdf0e10cSrcweir if (!bROODFDefaultVersion)
748cdf0e10cSrcweir {
749cdf0e10cSrcweir pValues[nRealCount] <<= (eODFDefaultVersion == SvtSaveOptions::ODFVER_LATEST) ? sal_Int16( 3 ) : sal_Int16( eODFDefaultVersion );
750cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
751cdf0e10cSrcweir ++nRealCount;
752cdf0e10cSrcweir }
753cdf0e10cSrcweir break;
754cdf0e10cSrcweir case USESHA1INODF12:
755cdf0e10cSrcweir if (!bROUseSHA1InODF12)
756cdf0e10cSrcweir {
757cdf0e10cSrcweir pValues[nRealCount] <<= bUseSHA1InODF12;
758cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
759cdf0e10cSrcweir ++nRealCount;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir break;
762cdf0e10cSrcweir case USEBLOWFISHINODF12:
763cdf0e10cSrcweir if (!bROUseBlowfishInODF12)
764cdf0e10cSrcweir {
765cdf0e10cSrcweir pValues[nRealCount] <<= bUseBlowfishInODF12;
766cdf0e10cSrcweir pNames[nRealCount] = pOrgNames[i];
767cdf0e10cSrcweir ++nRealCount;
768cdf0e10cSrcweir }
769cdf0e10cSrcweir break;
770cdf0e10cSrcweir
771cdf0e10cSrcweir default:
772cdf0e10cSrcweir DBG_ERRORFILE( "invalid index to save a path" );
773cdf0e10cSrcweir }
774cdf0e10cSrcweir }
775cdf0e10cSrcweir
776cdf0e10cSrcweir aNames.realloc(nRealCount);
777cdf0e10cSrcweir aValues.realloc(nRealCount);
778cdf0e10cSrcweir PutProperties( aNames, aValues );
779cdf0e10cSrcweir
780cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > xCFG = ::comphelper::ConfigurationHelper::openConfig(
781cdf0e10cSrcweir ::utl::getProcessServiceFactory(),
782cdf0e10cSrcweir ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery"),
783cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_STANDARD);
784cdf0e10cSrcweir
785cdf0e10cSrcweir ::comphelper::ConfigurationHelper::writeRelativeKey(
786cdf0e10cSrcweir xCFG,
787cdf0e10cSrcweir ::rtl::OUString::createFromAscii("AutoSave"),
788cdf0e10cSrcweir ::rtl::OUString::createFromAscii("TimeIntervall"),
789cdf0e10cSrcweir css::uno::makeAny(nAutoSaveTime));
790cdf0e10cSrcweir
791cdf0e10cSrcweir ::comphelper::ConfigurationHelper::writeRelativeKey(
792cdf0e10cSrcweir xCFG,
793cdf0e10cSrcweir ::rtl::OUString::createFromAscii("AutoSave"),
794cdf0e10cSrcweir ::rtl::OUString::createFromAscii("Enabled"),
795cdf0e10cSrcweir css::uno::makeAny(bAutoSave));
796cdf0e10cSrcweir
797cdf0e10cSrcweir ::comphelper::ConfigurationHelper::flush(xCFG);
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
800cdf0e10cSrcweir // -----------------------------------------------------------------------
801cdf0e10cSrcweir
Notify(const Sequence<rtl::OUString> &)802cdf0e10cSrcweir void SvtSaveOptions_Impl::Notify( const Sequence<rtl::OUString>& )
803cdf0e10cSrcweir {
804cdf0e10cSrcweir }
805cdf0e10cSrcweir
806cdf0e10cSrcweir
807cdf0e10cSrcweir class SvtLoadOptions_Impl : public utl::ConfigItem
808cdf0e10cSrcweir {
809cdf0e10cSrcweir
810cdf0e10cSrcweir sal_Bool bLoadUserDefinedSettings;
811cdf0e10cSrcweir
812cdf0e10cSrcweir public:
813cdf0e10cSrcweir SvtLoadOptions_Impl();
814cdf0e10cSrcweir ~SvtLoadOptions_Impl();
815cdf0e10cSrcweir
816cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
817cdf0e10cSrcweir virtual void Commit();
818cdf0e10cSrcweir
SetLoadUserSettings(sal_Bool b)819cdf0e10cSrcweir void SetLoadUserSettings(sal_Bool b){bLoadUserDefinedSettings = b; SetModified();}
IsLoadUserSettings() const820cdf0e10cSrcweir sal_Bool IsLoadUserSettings() const {return bLoadUserDefinedSettings;}
821cdf0e10cSrcweir };
822cdf0e10cSrcweir // -----------------------------------------------------------------------
823cdf0e10cSrcweir const sal_Char cUserDefinedSettings[] = "UserDefinedSettings";
824cdf0e10cSrcweir
SvtLoadOptions_Impl()825cdf0e10cSrcweir SvtLoadOptions_Impl::SvtLoadOptions_Impl()
826cdf0e10cSrcweir : ConfigItem( OUString::createFromAscii("Office.Common/Load") )
827cdf0e10cSrcweir , bLoadUserDefinedSettings( sal_False )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir Sequence< OUString > aNames(1);
830cdf0e10cSrcweir aNames[0] = OUString::createFromAscii(cUserDefinedSettings);
831cdf0e10cSrcweir Sequence< Any > aValues = GetProperties( aNames );
832cdf0e10cSrcweir EnableNotification( aNames );
833cdf0e10cSrcweir const Any* pValues = aValues.getConstArray();
834cdf0e10cSrcweir DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
835cdf0e10cSrcweir if (pValues[0].getValueTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN)
836cdf0e10cSrcweir bLoadUserDefinedSettings = *(sal_Bool *)pValues[0].getValue();
837cdf0e10cSrcweir }
838cdf0e10cSrcweir // -----------------------------------------------------------------------
~SvtLoadOptions_Impl()839cdf0e10cSrcweir SvtLoadOptions_Impl::~SvtLoadOptions_Impl()
840cdf0e10cSrcweir {
841cdf0e10cSrcweir }
842cdf0e10cSrcweir // -----------------------------------------------------------------------
Commit()843cdf0e10cSrcweir void SvtLoadOptions_Impl::Commit()
844cdf0e10cSrcweir {
845cdf0e10cSrcweir Sequence< OUString > aNames(1);
846cdf0e10cSrcweir aNames[0] = OUString::createFromAscii(cUserDefinedSettings);
847cdf0e10cSrcweir Sequence< Any > aValues( 1 );
848cdf0e10cSrcweir aValues[0].setValue(&bLoadUserDefinedSettings, ::getBooleanCppuType());
849cdf0e10cSrcweir PutProperties( aNames, aValues );
850cdf0e10cSrcweir }
851cdf0e10cSrcweir // -----------------------------------------------------------------------
Notify(const Sequence<rtl::OUString> &)852cdf0e10cSrcweir void SvtLoadOptions_Impl::Notify( const Sequence<rtl::OUString>& )
853cdf0e10cSrcweir {
854cdf0e10cSrcweir DBG_ERRORFILE( "properties have been changed" );
855cdf0e10cSrcweir }
856cdf0e10cSrcweir // -----------------------------------------------------------------------
857cdf0e10cSrcweir
858cdf0e10cSrcweir namespace
859cdf0e10cSrcweir {
860cdf0e10cSrcweir class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton >
861cdf0e10cSrcweir {
862cdf0e10cSrcweir };
863cdf0e10cSrcweir }
864cdf0e10cSrcweir
865cdf0e10cSrcweir // -----------------------------------------------------------------------
SvtSaveOptions()866cdf0e10cSrcweir SvtSaveOptions::SvtSaveOptions()
867cdf0e10cSrcweir {
868cdf0e10cSrcweir // Global access, must be guarded (multithreading)
869cdf0e10cSrcweir ::osl::MutexGuard aGuard( LocalSingleton::get() );
870cdf0e10cSrcweir if ( !pOptions )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtSaveOptions_Impl::ctor()");
873cdf0e10cSrcweir pOptions = new SvtLoadSaveOptions_Impl;
874cdf0e10cSrcweir pOptions->pSaveOpt = new SvtSaveOptions_Impl;
875cdf0e10cSrcweir pOptions->pLoadOpt = new SvtLoadOptions_Impl;
876cdf0e10cSrcweir
877cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_SAVEOPTIONS);
878cdf0e10cSrcweir }
879cdf0e10cSrcweir ++nRefCount;
880cdf0e10cSrcweir pImp = pOptions;
881cdf0e10cSrcweir }
882cdf0e10cSrcweir
883cdf0e10cSrcweir // -----------------------------------------------------------------------
884cdf0e10cSrcweir
~SvtSaveOptions()885cdf0e10cSrcweir SvtSaveOptions::~SvtSaveOptions()
886cdf0e10cSrcweir {
887cdf0e10cSrcweir // Global access, must be guarded (multithreading)
888cdf0e10cSrcweir ::osl::MutexGuard aGuard( LocalSingleton::get() );
889cdf0e10cSrcweir if ( !--nRefCount )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir if ( pOptions->pSaveOpt->IsModified() )
892cdf0e10cSrcweir pOptions->pSaveOpt->Commit();
893cdf0e10cSrcweir if ( pOptions->pLoadOpt->IsModified() )
894cdf0e10cSrcweir pOptions->pLoadOpt->Commit();
895cdf0e10cSrcweir
896cdf0e10cSrcweir DELETEZ( pOptions->pLoadOpt );
897cdf0e10cSrcweir DELETEZ( pOptions->pSaveOpt );
898cdf0e10cSrcweir DELETEZ( pOptions );
899cdf0e10cSrcweir }
900cdf0e10cSrcweir }
901cdf0e10cSrcweir
SetAutoSaveTime(sal_Int32 n)902cdf0e10cSrcweir void SvtSaveOptions::SetAutoSaveTime( sal_Int32 n )
903cdf0e10cSrcweir {
904cdf0e10cSrcweir pImp->pSaveOpt->SetAutoSaveTime( n );
905cdf0e10cSrcweir }
906cdf0e10cSrcweir
GetAutoSaveTime() const907cdf0e10cSrcweir sal_Int32 SvtSaveOptions::GetAutoSaveTime() const
908cdf0e10cSrcweir {
909cdf0e10cSrcweir return pImp->pSaveOpt->GetAutoSaveTime();
910cdf0e10cSrcweir }
911cdf0e10cSrcweir
SetUseUserData(sal_Bool b)912cdf0e10cSrcweir void SvtSaveOptions::SetUseUserData( sal_Bool b )
913cdf0e10cSrcweir {
914cdf0e10cSrcweir pImp->pSaveOpt->SetUseUserData( b );
915cdf0e10cSrcweir }
916cdf0e10cSrcweir
IsUseUserData() const917cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsUseUserData() const
918cdf0e10cSrcweir {
919cdf0e10cSrcweir return pImp->pSaveOpt->IsUseUserData();
920cdf0e10cSrcweir }
921cdf0e10cSrcweir
SetBackup(sal_Bool b)922cdf0e10cSrcweir void SvtSaveOptions::SetBackup( sal_Bool b )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir pImp->pSaveOpt->SetBackup( b );
925cdf0e10cSrcweir }
926cdf0e10cSrcweir
IsBackup() const927cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsBackup() const
928cdf0e10cSrcweir {
929cdf0e10cSrcweir return pImp->pSaveOpt->IsBackup();
930cdf0e10cSrcweir }
931cdf0e10cSrcweir
SetAutoSave(sal_Bool b)932cdf0e10cSrcweir void SvtSaveOptions::SetAutoSave( sal_Bool b )
933cdf0e10cSrcweir {
934cdf0e10cSrcweir pImp->pSaveOpt->SetAutoSave( b );
935cdf0e10cSrcweir }
936cdf0e10cSrcweir
IsAutoSave() const937cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsAutoSave() const
938cdf0e10cSrcweir {
939cdf0e10cSrcweir return pImp->pSaveOpt->IsAutoSave();
940cdf0e10cSrcweir }
941cdf0e10cSrcweir
SetAutoSavePrompt(sal_Bool b)942cdf0e10cSrcweir void SvtSaveOptions::SetAutoSavePrompt( sal_Bool b )
943cdf0e10cSrcweir {
944cdf0e10cSrcweir pImp->pSaveOpt->SetAutoSavePrompt( b );
945cdf0e10cSrcweir }
946cdf0e10cSrcweir
IsAutoSavePrompt() const947cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsAutoSavePrompt() const
948cdf0e10cSrcweir {
949cdf0e10cSrcweir return pImp->pSaveOpt->IsAutoSavePrompt();
950cdf0e10cSrcweir }
951cdf0e10cSrcweir
SetDocInfoSave(sal_Bool b)952cdf0e10cSrcweir void SvtSaveOptions::SetDocInfoSave(sal_Bool b)
953cdf0e10cSrcweir {
954cdf0e10cSrcweir pImp->pSaveOpt->SetDocInfoSave( b );
955cdf0e10cSrcweir }
956cdf0e10cSrcweir
IsDocInfoSave() const957cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsDocInfoSave() const
958cdf0e10cSrcweir {
959cdf0e10cSrcweir return pImp->pSaveOpt->IsDocInfoSave();
960cdf0e10cSrcweir }
961cdf0e10cSrcweir
SetSaveWorkingSet(sal_Bool b)962cdf0e10cSrcweir void SvtSaveOptions::SetSaveWorkingSet( sal_Bool b )
963cdf0e10cSrcweir {
964cdf0e10cSrcweir pImp->pSaveOpt->SetSaveWorkingSet( b );
965cdf0e10cSrcweir }
966cdf0e10cSrcweir
IsSaveWorkingSet() const967cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveWorkingSet() const
968cdf0e10cSrcweir {
969cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveWorkingSet();
970cdf0e10cSrcweir }
971cdf0e10cSrcweir
SetSaveDocView(sal_Bool b)972cdf0e10cSrcweir void SvtSaveOptions::SetSaveDocView( sal_Bool b )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir pImp->pSaveOpt->SetSaveDocView( b );
975cdf0e10cSrcweir }
976cdf0e10cSrcweir
IsSaveDocView() const977cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveDocView() const
978cdf0e10cSrcweir {
979cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveDocView();
980cdf0e10cSrcweir }
981cdf0e10cSrcweir
SetSaveRelINet(sal_Bool b)982cdf0e10cSrcweir void SvtSaveOptions::SetSaveRelINet( sal_Bool b )
983cdf0e10cSrcweir {
984cdf0e10cSrcweir pImp->pSaveOpt->SetSaveRelINet( b );
985cdf0e10cSrcweir }
986cdf0e10cSrcweir
IsSaveRelINet() const987cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveRelINet() const
988cdf0e10cSrcweir {
989cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveRelINet();
990cdf0e10cSrcweir }
991cdf0e10cSrcweir
SetSaveRelFSys(sal_Bool b)992cdf0e10cSrcweir void SvtSaveOptions::SetSaveRelFSys( sal_Bool b )
993cdf0e10cSrcweir {
994cdf0e10cSrcweir pImp->pSaveOpt->SetSaveRelFSys( b );
995cdf0e10cSrcweir }
996cdf0e10cSrcweir
IsSaveRelFSys() const997cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveRelFSys() const
998cdf0e10cSrcweir {
999cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveRelFSys();
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir
SetSaveUnpacked(sal_Bool b)1002cdf0e10cSrcweir void SvtSaveOptions::SetSaveUnpacked( sal_Bool b )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir pImp->pSaveOpt->SetSaveUnpacked( b );
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir
IsSaveUnpacked() const1007cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsSaveUnpacked() const
1008cdf0e10cSrcweir {
1009cdf0e10cSrcweir return pImp->pSaveOpt->IsSaveUnpacked();
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir
SetLoadUserSettings(sal_Bool b)1012cdf0e10cSrcweir void SvtSaveOptions::SetLoadUserSettings(sal_Bool b)
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir pImp->pLoadOpt->SetLoadUserSettings(b);
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir
IsLoadUserSettings() const1017cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsLoadUserSettings() const
1018cdf0e10cSrcweir {
1019cdf0e10cSrcweir return pImp->pLoadOpt->IsLoadUserSettings();
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir
SetPrettyPrinting(sal_Bool _bEnable)1022cdf0e10cSrcweir void SvtSaveOptions::SetPrettyPrinting( sal_Bool _bEnable )
1023cdf0e10cSrcweir {
1024cdf0e10cSrcweir pImp->pSaveOpt->EnablePrettyPrinting( _bEnable );
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir
IsPrettyPrinting() const1027cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsPrettyPrinting() const
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir return pImp->pSaveOpt->IsPrettyPrintingEnabled();
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir
SetWarnAlienFormat(sal_Bool _bEnable)1032cdf0e10cSrcweir void SvtSaveOptions::SetWarnAlienFormat( sal_Bool _bEnable )
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir pImp->pSaveOpt->SetWarnAlienFormat( _bEnable );
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir
IsWarnAlienFormat() const1037cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsWarnAlienFormat() const
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir return pImp->pSaveOpt->IsWarnAlienFormat();
1040cdf0e10cSrcweir }
1041cdf0e10cSrcweir
SetLoadDocumentPrinter(sal_Bool _bEnable)1042cdf0e10cSrcweir void SvtSaveOptions::SetLoadDocumentPrinter( sal_Bool _bEnable )
1043cdf0e10cSrcweir {
1044cdf0e10cSrcweir pImp->pSaveOpt->SetLoadDocPrinter( _bEnable );
1045cdf0e10cSrcweir }
1046cdf0e10cSrcweir
IsLoadDocumentPrinter() const1047cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsLoadDocumentPrinter() const
1048cdf0e10cSrcweir {
1049cdf0e10cSrcweir return pImp->pSaveOpt->IsLoadDocPrinter();
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir
SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion eVersion)1052cdf0e10cSrcweir void SvtSaveOptions::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eVersion )
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir pImp->pSaveOpt->SetODFDefaultVersion( eVersion );
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir
GetODFDefaultVersion() const1057cdf0e10cSrcweir SvtSaveOptions::ODFDefaultVersion SvtSaveOptions::GetODFDefaultVersion() const
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir return pImp->pSaveOpt->GetODFDefaultVersion();
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir
SetUseSHA1InODF12(sal_Bool bUse)1062cdf0e10cSrcweir void SvtSaveOptions::SetUseSHA1InODF12( sal_Bool bUse )
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir pImp->pSaveOpt->SetUseSHA1InODF12( bUse );
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir
IsUseSHA1InODF12() const1067cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsUseSHA1InODF12() const
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir return pImp->pSaveOpt->IsUseSHA1InODF12();
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir
SetUseBlowfishInODF12(sal_Bool bUse)1072cdf0e10cSrcweir void SvtSaveOptions::SetUseBlowfishInODF12( sal_Bool bUse )
1073cdf0e10cSrcweir {
1074cdf0e10cSrcweir pImp->pSaveOpt->SetUseBlowfishInODF12( bUse );
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir
IsUseBlowfishInODF12() const1077cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsUseBlowfishInODF12() const
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir return pImp->pSaveOpt->IsUseBlowfishInODF12();
1080cdf0e10cSrcweir }
1081cdf0e10cSrcweir
IsReadOnly(SvtSaveOptions::EOption eOption) const1082cdf0e10cSrcweir sal_Bool SvtSaveOptions::IsReadOnly( SvtSaveOptions::EOption eOption ) const
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir return pImp->pSaveOpt->IsReadOnly(eOption);
1085cdf0e10cSrcweir }
1086cdf0e10cSrcweir
1087