Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <tools/shl.hxx>
30 : : #include <svl/eitem.hxx>
31 : : #include <svl/intitem.hxx>
32 : : #define _SVX_OPTSAVE_CXX
33 : :
34 : : #include "optsave.hrc"
35 : : #include <cuires.hrc>
36 : :
37 : : #include "optsave.hxx"
38 : : #include <dialmgr.hxx>
39 : : #include <comphelper/processfactory.hxx>
40 : : #include <unotools/moduleoptions.hxx>
41 : : #include <unotools/saveopt.hxx>
42 : : #include <comphelper/sequenceasvector.hxx>
43 : : #include <comphelper/sequenceashashmap.hxx>
44 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 : : #include <com/sun/star/container/XNameContainer.hpp>
46 : : #include <com/sun/star/container/XContainerQuery.hpp>
47 : : #include <com/sun/star/container/XEnumeration.hpp>
48 : : #include <com/sun/star/beans/PropertyValue.hpp>
49 : : #include <com/sun/star/util/XFlushable.hpp>
50 : : #include <sfx2/docfilt.hxx>
51 : : #include <svtools/stdctrl.hxx>
52 : : #include <vcl/fixed.hxx>
53 : : #include <unotools/configitem.hxx>
54 : : #include <unotools/optionsdlg.hxx>
55 : :
56 : : #include <vcl/msgbox.hxx>
57 : :
58 : : using namespace com::sun::star::uno;
59 : : using namespace com::sun::star::util;
60 : : using namespace com::sun::star::lang;
61 : : using namespace com::sun::star::beans;
62 : : using namespace com::sun::star::container;
63 : : using namespace comphelper;
64 : : using rtl::OUString;
65 : :
66 : : #define C2U(cChar) OUString::createFromAscii(cChar)
67 : : #define C2S(cChar) String( RTL_CONSTASCII_USTRINGPARAM(cChar) )
68 : : #define CFG_PAGE_AND_GROUP C2S("General"), C2S("LoadSave")
69 : : // !! you have to update these index, if you changed the list of the child windows !!
70 : : #define WININDEX_AUTOSAVE ((sal_uInt16)6)
71 : : #define WININDEX_SAVEURL_RELFSYS ((sal_uInt16)9)
72 : :
73 : : // ----------------------------------------------------------------------
74 : :
75 : : struct SvxSaveTabPage_Impl
76 : : {
77 : : Reference< XNameContainer > xFact;
78 : : Sequence< OUString > aFilterArr[APP_COUNT];
79 : : Sequence< sal_Bool > aAlienArr[APP_COUNT];
80 : : Sequence< sal_Bool > aODFArr[APP_COUNT];
81 : : Sequence< OUString > aUIFilterArr[APP_COUNT];
82 : : OUString aDefaultArr[APP_COUNT];
83 : : sal_Bool aDefaultReadonlyArr[APP_COUNT];
84 : : sal_Bool bInitialized;
85 : :
86 : : SvxSaveTabPage_Impl();
87 : : ~SvxSaveTabPage_Impl();
88 : : };
89 : :
90 [ # # ][ # # ]: 0 : SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( sal_False )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # #
# # # # #
# # # # ]
91 : : {
92 [ # # # # : 0 : }
# # # # #
# # # ]
93 : :
94 [ # # ][ # # ]: 0 : SvxSaveTabPage_Impl::~SvxSaveTabPage_Impl()
[ # # ][ # # ]
95 : : {
96 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # #
# # # ]
97 : :
98 : : // class SvxSaveTabPage --------------------------------------------------
99 : :
100 : 0 : SfxSaveTabPage::SfxSaveTabPage( Window* pParent, const SfxItemSet& rCoreSet ) :
101 : :
102 : 0 : SfxTabPage( pParent, CUI_RES( RID_SFXPAGE_SAVE ), rCoreSet ),
103 : :
104 [ # # ]: 0 : aLoadFL ( this, CUI_RES( LB_LOAD ) ),
105 [ # # ]: 0 : aLoadUserSettingsCB ( this, CUI_RES( CB_LOAD_SETTINGS ) ),
106 [ # # ]: 0 : aLoadDocPrinterCB ( this, CUI_RES( CB_LOAD_DOCPRINTER ) ),
107 : :
108 [ # # ]: 0 : aSaveFL ( this, CUI_RES( GB_SAVE ) ),
109 [ # # ]: 0 : aDocInfoCB ( this, CUI_RES( BTN_DOCINFO ) ),
110 [ # # ]: 0 : aBackupFI ( this, CUI_RES( FI_BACKUP ) ),
111 [ # # ]: 0 : aBackupCB ( this, CUI_RES( BTN_BACKUP ) ),
112 [ # # ]: 0 : aAutoSaveCB ( this, CUI_RES( BTN_AUTOSAVE ) ),
113 [ # # ]: 0 : aAutoSaveEdit ( this, CUI_RES( ED_AUTOSAVE ) ),
114 [ # # ]: 0 : aMinuteFT ( this, CUI_RES( FT_MINUTE ) ),
115 [ # # ]: 0 : aRelativeFsysCB ( this, CUI_RES( BTN_RELATIVE_FSYS ) ),
116 [ # # ]: 0 : aRelativeInetCB ( this, CUI_RES( BTN_RELATIVE_INET ) ),
117 : :
118 [ # # ]: 0 : aDefaultFormatFL ( this, CUI_RES( FL_FILTER ) ),
119 [ # # ]: 0 : aODFVersionFT ( this, CUI_RES( FT_ODF_VERSION ) ),
120 [ # # ]: 0 : aODFVersionLB ( this, CUI_RES( LB_ODF_VERSION ) ),
121 [ # # ]: 0 : aSizeOptimizationCB ( this, CUI_RES( BTN_NOPRETTYPRINTING ) ),
122 [ # # ]: 0 : aWarnAlienFormatCB ( this, CUI_RES( BTN_WARNALIENFORMAT ) ),
123 [ # # ]: 0 : aDocTypeFT ( this, CUI_RES( FT_APP ) ),
124 [ # # ]: 0 : aDocTypeLB ( this, CUI_RES( LB_APP ) ),
125 [ # # ]: 0 : aSaveAsFT ( this, CUI_RES( FT_FILTER ) ),
126 [ # # ]: 0 : aSaveAsFI ( this, CUI_RES( FI_FILTER ) ),
127 [ # # ]: 0 : aSaveAsLB ( this, CUI_RES( LB_FILTER ) ),
128 [ # # ]: 0 : aODFWarningFI ( this, CUI_RES( FI_ODF_WARNING ) ),
129 [ # # ]: 0 : aODFWarningFT ( this, CUI_RES( FT_WARN ) ),
130 : :
131 [ # # ][ # # ]: 0 : pImpl ( new SvxSaveTabPage_Impl )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
132 : :
133 : : {
134 [ # # ][ # # ]: 0 : aODFWarningFI.SetImage( Image( CUI_RES( IMG_ODF_WARNING )));
[ # # ][ # # ]
135 : :
136 [ # # ]: 0 : FreeResource();
137 : :
138 [ # # ]: 0 : Link aLink = LINK( this, SfxSaveTabPage, AutoClickHdl_Impl );
139 : 0 : aAutoSaveCB.SetClickHdl( aLink );
140 [ # # ]: 0 : aAutoSaveEdit.SetMaxTextLen( 2 );
141 : :
142 [ # # ]: 0 : SvtModuleOptions aModuleOpt;
143 [ # # ][ # # ]: 0 : if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
144 : : {
145 [ # # ][ # # ]: 0 : aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_MATH ));
146 [ # # ][ # # ]: 0 : aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_MATH ));
147 : : }
148 : : else
149 : : {
150 [ # # ]: 0 : pImpl->aDefaultArr[APP_MATH] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH);
151 [ # # ]: 0 : pImpl->aDefaultReadonlyArr[APP_MATH] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_MATH);
152 : : }
153 : :
154 [ # # ][ # # ]: 0 : if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
155 : : {
156 [ # # ][ # # ]: 0 : aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_DRAW ));
157 [ # # ][ # # ]: 0 : aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_DRAW ));
158 : : }
159 : : else
160 : : {
161 [ # # ]: 0 : pImpl->aDefaultArr[APP_DRAW] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW);
162 [ # # ]: 0 : pImpl->aDefaultReadonlyArr[APP_DRAW] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_DRAW);
163 : : }
164 : :
165 [ # # ][ # # ]: 0 : if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
166 : : {
167 [ # # ][ # # ]: 0 : aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_IMPRESS ));
168 [ # # ][ # # ]: 0 : aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_IMPRESS ));
169 : : }
170 : : else
171 : : {
172 [ # # ]: 0 : pImpl->aDefaultArr[APP_IMPRESS] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS);
173 [ # # ]: 0 : pImpl->aDefaultReadonlyArr[APP_IMPRESS] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_IMPRESS);
174 : : }
175 : :
176 [ # # ][ # # ]: 0 : if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
177 : : {
178 [ # # ][ # # ]: 0 : aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_CALC ));
179 [ # # ][ # # ]: 0 : aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_CALC ));
180 : : }
181 : : else
182 : : {
183 [ # # ]: 0 : pImpl->aDefaultArr[APP_CALC] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC);
184 [ # # ]: 0 : pImpl->aDefaultReadonlyArr[APP_CALC] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_CALC);
185 : : }
186 : :
187 [ # # ][ # # ]: 0 : if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
188 : : {
189 [ # # ][ # # ]: 0 : aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER ));
190 [ # # ][ # # ]: 0 : aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER_WEB ));
191 [ # # ][ # # ]: 0 : aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER_GLOBAL ));
192 [ # # ][ # # ]: 0 : aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER ));
193 [ # # ][ # # ]: 0 : aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER_WEB ));
194 [ # # ][ # # ]: 0 : aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER_GLOBAL ));
195 : : }
196 : : else
197 : : {
198 [ # # ]: 0 : pImpl->aDefaultArr[APP_WRITER] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER);
199 [ # # ]: 0 : pImpl->aDefaultArr[APP_WRITER_WEB] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB);
200 [ # # ]: 0 : pImpl->aDefaultArr[APP_WRITER_GLOBAL] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL);
201 [ # # ]: 0 : pImpl->aDefaultReadonlyArr[APP_WRITER] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITER);
202 [ # # ]: 0 : pImpl->aDefaultReadonlyArr[APP_WRITER_WEB] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERWEB);
203 [ # # ]: 0 : pImpl->aDefaultReadonlyArr[APP_WRITER_GLOBAL] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERGLOBAL);
204 : : }
205 : :
206 [ # # ]: 0 : aLink = LINK( this, SfxSaveTabPage, ODFVersionHdl_Impl );
207 : 0 : aODFVersionLB.SetSelectHdl( aLink );
208 [ # # ]: 0 : aLink = LINK( this, SfxSaveTabPage, FilterHdl_Impl );
209 : 0 : aDocTypeLB.SetSelectHdl( aLink );
210 : 0 : aSaveAsLB.SetSelectHdl( aLink );
211 : :
212 [ # # ][ # # ]: 0 : DetectHiddenControls();
213 : 0 : }
214 : :
215 : : // -----------------------------------------------------------------------
216 : :
217 [ # # ][ # # ]: 0 : SfxSaveTabPage::~SfxSaveTabPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
218 : : {
219 [ # # ][ # # ]: 0 : delete pImpl;
220 [ # # ]: 0 : }
221 : :
222 : : // -----------------------------------------------------------------------
223 : :
224 : 0 : SfxTabPage* SfxSaveTabPage::Create( Window* pParent,
225 : : const SfxItemSet& rAttrSet )
226 : : {
227 [ # # ]: 0 : return ( new SfxSaveTabPage( pParent, rAttrSet ) );
228 : : }
229 : :
230 : : // -----------------------------------------------------------------------
231 : 0 : void SfxSaveTabPage::DetectHiddenControls()
232 : : {
233 : 0 : long nDelta = 0;
234 : : // the index of the first child window which perhaps have to move upwards
235 : 0 : sal_uInt16 nWinIndex = WININDEX_SAVEURL_RELFSYS;
236 [ # # ]: 0 : SvtOptionsDialogOptions aOptionsDlgOpt;
237 : :
238 [ # # ][ # # ]: 0 : if ( aOptionsDlgOpt.IsOptionHidden( C2S("Backup"), CFG_PAGE_AND_GROUP ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
239 : : {
240 : : // hide controls of "Backup"
241 [ # # ]: 0 : aBackupFI.Hide();
242 [ # # ]: 0 : aBackupCB.Hide();
243 : : // the other controls have to move upwards the height of checkbox + space
244 [ # # ][ # # ]: 0 : nDelta = aAutoSaveCB.GetPosPixel().Y() - aBackupCB.GetPosPixel().Y();
245 : : }
246 : :
247 [ # # ][ # # ]: 0 : if ( aOptionsDlgOpt.IsOptionHidden( C2S("AutoSave"), CFG_PAGE_AND_GROUP ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
248 : : {
249 : : // hide controls of "AutoSave"
250 [ # # ]: 0 : aAutoSaveCB.Hide();
251 [ # # ]: 0 : aAutoSaveEdit.Hide();
252 [ # # ]: 0 : aMinuteFT.Hide();
253 : : // the other controls have to move upwards the height of checkbox + space
254 [ # # ][ # # ]: 0 : nDelta += aRelativeFsysCB.GetPosPixel().Y() - aAutoSaveCB.GetPosPixel().Y();
255 : : }
256 [ # # ]: 0 : else if ( nDelta > 0 )
257 : : // the "AutoSave" controls have to move upwards too
258 : 0 : nWinIndex = WININDEX_AUTOSAVE;
259 : :
260 [ # # ]: 0 : if ( nDelta > 0 )
261 : : {
262 [ # # ]: 0 : sal_uInt16 i, nChildCount = GetChildCount();
263 [ # # ]: 0 : for ( i = nWinIndex; i < nChildCount; ++i )
264 : : {
265 [ # # ]: 0 : Window* pWin = GetChild(i);
266 [ # # ]: 0 : Point aPos = pWin->GetPosPixel();
267 : 0 : aPos.Y() -= nDelta;
268 [ # # ]: 0 : pWin->SetPosPixel( aPos );
269 : : }
270 [ # # ]: 0 : }
271 : 0 : }
272 : : // -----------------------------------------------------------------------
273 : 0 : sal_Bool SfxSaveTabPage::FillItemSet( SfxItemSet& rSet )
274 : : {
275 : 0 : sal_Bool bModified = sal_False;
276 [ # # ]: 0 : SvtSaveOptions aSaveOpt;
277 [ # # ][ # # ]: 0 : if(aLoadUserSettingsCB.IsChecked() != aLoadUserSettingsCB.GetSavedValue())
278 : : {
279 [ # # ][ # # ]: 0 : aSaveOpt.SetLoadUserSettings(aLoadUserSettingsCB.IsChecked());
280 : : }
281 : :
282 [ # # ][ # # ]: 0 : if ( aLoadDocPrinterCB.IsChecked() != aLoadDocPrinterCB.GetSavedValue() )
283 [ # # ][ # # ]: 0 : aSaveOpt.SetLoadDocumentPrinter( aLoadDocPrinterCB.IsChecked() );
284 : :
285 [ # # ][ # # ]: 0 : if ( aODFVersionLB.GetSelectEntryPos() != aODFVersionLB.GetSavedValue() )
286 : : {
287 [ # # ][ # # ]: 0 : long nVersion = long( aODFVersionLB.GetEntryData( aODFVersionLB.GetSelectEntryPos() ) );
288 [ # # ]: 0 : aSaveOpt.SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion ) );
289 : : }
290 : :
291 [ # # ][ # # ]: 0 : if ( aDocInfoCB.IsChecked() != aDocInfoCB.GetSavedValue() )
292 : : {
293 [ # # ]: 0 : rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO ),
294 [ # # ][ # # ]: 0 : aDocInfoCB.IsChecked() ) );
[ # # ][ # # ]
295 : 0 : bModified |= sal_True;
296 : : }
297 : :
298 [ # # ][ # # ]: 0 : if ( aBackupCB.IsEnabled() && aBackupCB.IsChecked() != aBackupCB.GetSavedValue() )
[ # # ][ # # ]
[ # # ]
299 : : {
300 [ # # ]: 0 : rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP ),
301 [ # # ][ # # ]: 0 : aBackupCB.IsChecked() ) );
[ # # ][ # # ]
302 : 0 : bModified |= sal_True;
303 : : }
304 : :
305 [ # # ][ # # ]: 0 : if ( aSizeOptimizationCB.IsChecked() != aSizeOptimizationCB.GetSavedValue() )
306 : : {
307 [ # # ][ # # ]: 0 : rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_PRETTYPRINTING ), !aSizeOptimizationCB.IsChecked() ) );
[ # # ][ # # ]
[ # # ]
308 : 0 : bModified |= sal_True;
309 : : }
310 : :
311 [ # # ][ # # ]: 0 : if ( aAutoSaveCB.IsChecked() != aAutoSaveCB.GetSavedValue() )
312 : : {
313 [ # # ]: 0 : rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE ),
314 [ # # ][ # # ]: 0 : aAutoSaveCB.IsChecked() ) );
[ # # ][ # # ]
315 : 0 : bModified |= sal_True;
316 : : }
317 [ # # ][ # # ]: 0 : if ( aWarnAlienFormatCB.IsChecked() != aWarnAlienFormatCB.GetSavedValue() )
318 : : {
319 [ # # ]: 0 : rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT ),
320 [ # # ][ # # ]: 0 : aWarnAlienFormatCB.IsChecked() ) );
[ # # ][ # # ]
321 : 0 : bModified |= sal_True;
322 : : }
323 : :
324 [ # # ][ # # ]: 0 : if ( aAutoSaveEdit.GetText() != aAutoSaveEdit.GetSavedValue() )
[ # # ][ # # ]
325 : : {
326 [ # # ]: 0 : rSet.Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE ),
327 [ # # ][ # # ]: 0 : (sal_uInt16)aAutoSaveEdit.GetValue() ) );
[ # # ][ # # ]
328 : 0 : bModified |= sal_True;
329 : : }
330 : : // save relatively
331 [ # # ][ # # ]: 0 : if ( aRelativeFsysCB.IsChecked() != aRelativeFsysCB.GetSavedValue() )
332 : : {
333 [ # # ]: 0 : rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS ),
334 [ # # ][ # # ]: 0 : aRelativeFsysCB.IsChecked() ) );
[ # # ][ # # ]
335 : 0 : bModified |= sal_True;
336 : : }
337 : :
338 [ # # ][ # # ]: 0 : if ( aRelativeInetCB.IsChecked() != aRelativeInetCB.GetSavedValue() )
339 : : {
340 [ # # ]: 0 : rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET ),
341 [ # # ][ # # ]: 0 : aRelativeInetCB.IsChecked() ) );
[ # # ][ # # ]
342 : 0 : bModified |= sal_True;
343 : : }
344 : :
345 [ # # ]: 0 : SvtModuleOptions aModuleOpt;
346 [ # # # # ]: 0 : if(!pImpl->aDefaultArr[APP_MATH].isEmpty() &&
[ # # ]
347 [ # # ][ # # ]: 0 : pImpl->aDefaultArr[APP_MATH] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH))
[ # # ]
348 [ # # ]: 0 : aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_MATH, pImpl->aDefaultArr[APP_MATH]);
349 : :
350 [ # # # # ]: 0 : if( !pImpl->aDefaultArr[APP_DRAW].isEmpty() &&
[ # # ]
351 [ # # ][ # # ]: 0 : pImpl->aDefaultArr[APP_DRAW] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW))
[ # # ]
352 [ # # ]: 0 : aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_DRAW, pImpl->aDefaultArr[APP_DRAW]);
353 : :
354 [ # # # # ]: 0 : if(!pImpl->aDefaultArr[APP_IMPRESS].isEmpty() &&
[ # # ]
355 [ # # ][ # # ]: 0 : pImpl->aDefaultArr[APP_IMPRESS] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS))
[ # # ]
356 [ # # ]: 0 : aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS, pImpl->aDefaultArr[APP_IMPRESS]);
357 : :
358 [ # # # # ]: 0 : if(!pImpl->aDefaultArr[APP_CALC].isEmpty() &&
[ # # ]
359 [ # # ][ # # ]: 0 : pImpl->aDefaultArr[APP_CALC] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC))
[ # # ]
360 [ # # ]: 0 : aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_CALC, pImpl->aDefaultArr[APP_CALC]);
361 : :
362 [ # # # # ]: 0 : if(!pImpl->aDefaultArr[APP_WRITER].isEmpty() &&
[ # # ]
363 [ # # ][ # # ]: 0 : pImpl->aDefaultArr[APP_WRITER] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER))
[ # # ]
364 [ # # ]: 0 : aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITER, pImpl->aDefaultArr[APP_WRITER]);
365 : :
366 [ # # # # ]: 0 : if(!pImpl->aDefaultArr[APP_WRITER_WEB].isEmpty() &&
[ # # ]
367 [ # # ][ # # ]: 0 : pImpl->aDefaultArr[APP_WRITER_WEB] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB))
[ # # ]
368 [ # # ]: 0 : aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB, pImpl->aDefaultArr[APP_WRITER_WEB]);
369 : :
370 [ # # # # ]: 0 : if(!pImpl->aDefaultArr[APP_WRITER_GLOBAL].isEmpty() &&
[ # # ]
371 [ # # ][ # # ]: 0 : pImpl->aDefaultArr[APP_WRITER_GLOBAL] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL))
[ # # ]
372 [ # # ]: 0 : aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL, pImpl->aDefaultArr[APP_WRITER_GLOBAL]);
373 : :
374 [ # # ][ # # ]: 0 : return bModified;
375 : : }
376 : :
377 : : // -----------------------------------------------------------------------
378 : :
379 : 0 : sal_Bool isODFFormat( OUString sFilter )
380 : : {
381 : : static const char* aODFFormats[] =
382 : : {
383 : : "writer8",
384 : : "writer8_template",
385 : : "writerglobal8",
386 : : "writerglobal8_writer",
387 : : "calc8",
388 : : "calc8_template",
389 : : "draw8",
390 : : "draw8_template",
391 : : "impress8",
392 : : "impress8_template",
393 : : "impress8_draw",
394 : : "chart8",
395 : : "math8",
396 : : NULL
397 : : };
398 : :
399 : 0 : sal_Bool bRet = sal_False;
400 : 0 : int i = 0;
401 [ # # ]: 0 : while ( aODFFormats[i] != NULL )
402 : : {
403 [ # # ]: 0 : if ( sFilter.equalsAscii( aODFFormats[i++] ) )
404 : : {
405 : 0 : bRet = sal_True;
406 : 0 : break;
407 : : }
408 : : }
409 : :
410 : 0 : return bRet;
411 : : }
412 : :
413 : 0 : void SfxSaveTabPage::Reset( const SfxItemSet& )
414 : : {
415 [ # # ]: 0 : SvtSaveOptions aSaveOpt;
416 [ # # ][ # # ]: 0 : aLoadUserSettingsCB.Check(aSaveOpt.IsLoadUserSettings());
417 : 0 : aLoadUserSettingsCB.SaveValue();
418 [ # # ][ # # ]: 0 : aLoadDocPrinterCB.Check( aSaveOpt.IsLoadDocumentPrinter() );
419 : 0 : aLoadDocPrinterCB.SaveValue();
420 : :
421 [ # # ]: 0 : if ( !pImpl->bInitialized )
422 : : {
423 : : try
424 : : {
425 [ # # ]: 0 : Reference< XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory();
426 : : pImpl->xFact = Reference<XNameContainer>(
427 [ # # ][ # # ]: 0 : xMSF->createInstance(C2U("com.sun.star.document.FilterFactory")), UNO_QUERY);
[ # # ][ # # ]
428 : :
429 : : DBG_ASSERT(pImpl->xFact.is(), "service com.sun.star.document.FilterFactory unavailable");
430 [ # # ]: 0 : Reference< XContainerQuery > xQuery(pImpl->xFact, UNO_QUERY);
431 [ # # ]: 0 : if(xQuery.is())
432 : : {
433 [ # # ][ # # ]: 0 : for(sal_uInt16 n = 0; n < aDocTypeLB.GetEntryCount(); n++)
434 : : {
435 [ # # ]: 0 : long nData = (long) aDocTypeLB.GetEntryData(n);
436 : 0 : OUString sCommand;
437 : 0 : sCommand = C2U("matchByDocumentService=%1:iflags=");
438 [ # # ][ # # ]: 0 : sCommand += String::CreateFromInt32(SFX_FILTER_IMPORT|SFX_FILTER_EXPORT);
[ # # ]
439 : 0 : sCommand += C2U(":eflags=");
440 [ # # ][ # # ]: 0 : sCommand += String::CreateFromInt32(SFX_FILTER_NOTINFILEDLG);
[ # # ]
441 : 0 : sCommand += C2U(":default_first");
442 [ # # ]: 0 : String sReplace;
443 [ # # # # : 0 : switch(nData)
# # # # ]
444 : : {
445 [ # # ]: 0 : case APP_WRITER : sReplace = C2U("com.sun.star.text.TextDocument"); break;
446 [ # # ]: 0 : case APP_WRITER_WEB : sReplace = C2U("com.sun.star.text.WebDocument"); break;
447 [ # # ]: 0 : case APP_WRITER_GLOBAL : sReplace = C2U("com.sun.star.text.GlobalDocument"); break;
448 [ # # ]: 0 : case APP_CALC : sReplace = C2U("com.sun.star.sheet.SpreadsheetDocument");break;
449 [ # # ]: 0 : case APP_IMPRESS : sReplace = C2U("com.sun.star.presentation.PresentationDocument");break;
450 [ # # ]: 0 : case APP_DRAW : sReplace = C2U("com.sun.star.drawing.DrawingDocument");break;
451 [ # # ]: 0 : case APP_MATH : sReplace = C2U("com.sun.star.formula.FormulaProperties");break;
452 : : default: OSL_FAIL("illegal user data");
453 : : }
454 [ # # ]: 0 : String sTmp(sCommand);
455 [ # # ]: 0 : sTmp.SearchAndReplaceAscii("%1", sReplace);
456 [ # # ]: 0 : sCommand = sTmp;
457 [ # # ][ # # ]: 0 : Reference< XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
458 [ # # ]: 0 : SequenceAsVector< OUString > lList;
459 [ # # ]: 0 : SequenceAsVector< sal_Bool > lAlienList;
460 [ # # ]: 0 : SequenceAsVector< sal_Bool > lODFList;
461 [ # # ][ # # ]: 0 : while(xList->hasMoreElements())
[ # # ]
462 : : {
463 [ # # ][ # # ]: 0 : SequenceAsHashMap aFilter(xList->nextElement());
[ # # ]
464 [ # # ][ # # ]: 0 : OUString sFilter = aFilter.getUnpackedValueOrDefault(OUString(RTL_CONSTASCII_USTRINGPARAM("Name")),OUString());
465 [ # # ]: 0 : if (!sFilter.isEmpty())
466 : : {
467 [ # # ][ # # ]: 0 : sal_Int32 nFlags = aFilter.getUnpackedValueOrDefault(OUString(RTL_CONSTASCII_USTRINGPARAM("Flags")),sal_Int32());
468 [ # # ]: 0 : lList.push_back(sFilter);
469 [ # # ]: 0 : lAlienList.push_back(0 != (nFlags & SFX_FILTER_ALIEN));
470 [ # # ]: 0 : lODFList.push_back( isODFFormat( sFilter ) );
471 : : }
472 [ # # ]: 0 : }
473 [ # # ][ # # ]: 0 : pImpl->aFilterArr[nData] = lList.getAsConstList();
[ # # ]
474 [ # # ][ # # ]: 0 : pImpl->aAlienArr[nData] = lAlienList.getAsConstList();
[ # # ]
475 [ # # ][ # # ]: 0 : pImpl->aODFArr[nData] = lODFList.getAsConstList();
[ # # ]
476 [ # # ][ # # ]: 0 : }
477 : : }
478 [ # # ]: 0 : aDocTypeLB.SelectEntryPos(0);
479 [ # # ][ # # ]: 0 : FilterHdl_Impl(&aDocTypeLB);
480 : : }
481 [ # # ]: 0 : catch(Exception& e)
482 : : {
483 : : (void) e;
484 : : OSL_FAIL(
485 : : rtl::OUStringToOString(
486 : : (rtl::OUString(
487 : : RTL_CONSTASCII_USTRINGPARAM(
488 : : "exception in FilterFactory access: ")) +
489 : : e.Message),
490 : : RTL_TEXTENCODING_UTF8).
491 : : getStr());
492 : : }
493 : :
494 : 0 : pImpl->bInitialized = sal_True;
495 : : }
496 : :
497 [ # # ][ # # ]: 0 : aDocInfoCB.Check(aSaveOpt.IsDocInfoSave());
498 : :
499 [ # # ][ # # ]: 0 : aBackupCB.Check(aSaveOpt.IsBackup());
500 [ # # ]: 0 : sal_Bool bBackupRO = aSaveOpt.IsReadOnly(SvtSaveOptions::E_BACKUP);
501 [ # # ]: 0 : aBackupCB.Enable(!bBackupRO);
502 [ # # ]: 0 : aBackupFI.Show(bBackupRO);
503 : :
504 [ # # ][ # # ]: 0 : aAutoSaveCB.Check(aSaveOpt.IsAutoSave());
505 [ # # ][ # # ]: 0 : aWarnAlienFormatCB.Check(aSaveOpt.IsWarnAlienFormat());
506 [ # # ][ # # ]: 0 : aWarnAlienFormatCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT));
507 : :
508 : : // the pretty printing
509 [ # # ][ # # ]: 0 : aSizeOptimizationCB.Check( !aSaveOpt.IsPrettyPrinting());
510 : :
511 [ # # ][ # # ]: 0 : aAutoSaveEdit.SetValue( aSaveOpt.GetAutoSaveTime() );
512 : :
513 : : // save relatively
514 [ # # ][ # # ]: 0 : aRelativeFsysCB.Check( aSaveOpt.IsSaveRelFSys() );
515 : :
516 [ # # ][ # # ]: 0 : aRelativeInetCB.Check( aSaveOpt.IsSaveRelINet() );
517 : :
518 [ # # ]: 0 : void* pDefaultVersion = (void*)long( aSaveOpt.GetODFDefaultVersion() );
519 [ # # ][ # # ]: 0 : aODFVersionLB.SelectEntryPos( aODFVersionLB.GetEntryPos( pDefaultVersion ) );
520 : :
521 [ # # ]: 0 : AutoClickHdl_Impl( &aAutoSaveCB );
522 [ # # ]: 0 : ODFVersionHdl_Impl( &aODFVersionLB );
523 : :
524 : 0 : aDocInfoCB.SaveValue();
525 : 0 : aBackupCB.SaveValue();
526 : 0 : aWarnAlienFormatCB.SaveValue();
527 : 0 : aSizeOptimizationCB.SaveValue();
528 : 0 : aAutoSaveCB.SaveValue();
529 [ # # ]: 0 : aAutoSaveEdit.SaveValue();
530 : :
531 : 0 : aRelativeFsysCB.SaveValue();
532 : 0 : aRelativeInetCB.SaveValue();
533 [ # # ][ # # ]: 0 : aODFVersionLB.SaveValue();
534 : 0 : }
535 : :
536 : : // -----------------------------------------------------------------------
537 : :
538 : 0 : IMPL_LINK( SfxSaveTabPage, AutoClickHdl_Impl, CheckBox *, pBox )
539 : : {
540 [ # # ]: 0 : if ( pBox == &aAutoSaveCB )
541 : : {
542 [ # # ]: 0 : if ( aAutoSaveCB.IsChecked() )
543 : : {
544 : 0 : aAutoSaveEdit.Enable();
545 : 0 : aMinuteFT.Enable();
546 : : }
547 : : else
548 : : {
549 : 0 : aAutoSaveEdit.Disable();
550 : 0 : aMinuteFT.Disable();
551 : : }
552 : : }
553 : 0 : return 0;
554 : : }
555 : :
556 : 0 : OUString lcl_ExtracUIName(const Sequence<PropertyValue> rProperties)
557 : : {
558 : 0 : OUString sRet;
559 : 0 : const PropertyValue* pProperties = rProperties.getConstArray();
560 [ # # ]: 0 : for(int nProp = 0; nProp < rProperties.getLength(); nProp++)
561 : : {
562 [ # # ]: 0 : if(!pProperties[nProp].Name.compareToAscii("UIName"))
563 : : {
564 : 0 : pProperties[nProp].Value >>= sRet;
565 : 0 : break;
566 : : }
567 [ # # ]: 0 : else if(!pProperties[nProp].Name.compareToAscii("Name"))
568 : : {
569 : 0 : pProperties[nProp].Value >>= sRet;
570 : : }
571 : : }
572 : 0 : return sRet;
573 : : }
574 : :
575 : 0 : IMPL_LINK( SfxSaveTabPage, FilterHdl_Impl, ListBox *, pBox )
576 : : {
577 : 0 : sal_uInt16 nCurPos = aDocTypeLB.GetSelectEntryPos();
578 : :
579 : 0 : long nData = -1;
580 [ # # ]: 0 : if(nCurPos < APP_COUNT)
581 : 0 : nData = (long) aDocTypeLB.GetEntryData(nCurPos);
582 : :
583 [ # # ][ # # ]: 0 : if ( nData >= 0 && nData < APP_COUNT )
584 : : {
585 [ # # ]: 0 : if(&aDocTypeLB == pBox)
586 : : {
587 [ # # ]: 0 : aSaveAsLB.Clear();
588 : 0 : const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray();
589 [ # # ]: 0 : if(!pImpl->aUIFilterArr[nData].getLength())
590 : : {
591 [ # # ]: 0 : pImpl->aUIFilterArr[nData].realloc(pImpl->aFilterArr[nData].getLength());
592 [ # # ]: 0 : OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray();
593 [ # # ]: 0 : for(int nFilter = 0; nFilter < pImpl->aFilterArr[nData].getLength(); nFilter++)
594 : : {
595 [ # # ][ # # ]: 0 : Any aProps = pImpl->xFact->getByName(pFilters[nFilter]);
596 [ # # ]: 0 : Sequence<PropertyValue> aProperties;
597 [ # # ]: 0 : aProps >>= aProperties;
598 [ # # ][ # # ]: 0 : pUIFilters[nFilter] = lcl_ExtracUIName(aProperties);
[ # # ]
599 [ # # ]: 0 : }
600 : : }
601 : 0 : const OUString* pUIFilters = pImpl->aUIFilterArr[nData].getConstArray();
602 : 0 : OUString sSelect;
603 [ # # ]: 0 : for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++)
604 : : {
605 [ # # ][ # # ]: 0 : sal_uInt16 nEntryPos = aSaveAsLB.InsertEntry(pUIFilters[i]);
[ # # ]
606 [ # # ][ # # ]: 0 : if ( pImpl->aODFArr[nData][i] )
607 [ # # ]: 0 : aSaveAsLB.SetEntryData( nEntryPos, (void*)pImpl );
608 [ # # ]: 0 : if(pFilters[i] == pImpl->aDefaultArr[nData])
609 : 0 : sSelect = pUIFilters[i];
610 : : }
611 [ # # ]: 0 : if(!sSelect.isEmpty())
612 [ # # ][ # # ]: 0 : aSaveAsLB.SelectEntry(sSelect);
[ # # ]
613 [ # # ]: 0 : aSaveAsFI.Show(pImpl->aDefaultReadonlyArr[nData]);
614 [ # # ]: 0 : aSaveAsFT.Enable(!pImpl->aDefaultReadonlyArr[nData]);
615 [ # # ]: 0 : aSaveAsLB.Enable(!pImpl->aDefaultReadonlyArr[nData]);
616 : : }
617 : : else
618 : : {
619 [ # # ][ # # ]: 0 : OUString sSelect = pBox->GetSelectEntry();
[ # # ]
620 : 0 : const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray();
621 [ # # ]: 0 : OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray();
622 [ # # ]: 0 : for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++)
623 [ # # ]: 0 : if(pUIFilters[i] == sSelect)
624 : : {
625 : 0 : sSelect = pFilters[i];
626 : 0 : break;
627 : : }
628 : :
629 : 0 : pImpl->aDefaultArr[nData] = sSelect;
630 : : }
631 : : }
632 : :
633 : 0 : ODFVersionHdl_Impl( &aSaveAsLB );
634 : 0 : return 0;
635 : : };
636 : :
637 : 0 : IMPL_LINK_NOARG(SfxSaveTabPage, ODFVersionHdl_Impl)
638 : : {
639 : 0 : long nVersion = long( aODFVersionLB.GetEntryData( aODFVersionLB.GetSelectEntryPos() ) );
640 : 0 : bool bShown = SvtSaveOptions::ODFDefaultVersion( nVersion ) != SvtSaveOptions::ODFVER_LATEST;
641 [ # # ]: 0 : if ( bShown )
642 : : {
643 : 0 : bool bHasODFFormat = false;
644 : 0 : sal_uInt16 i = 0, nCount = aSaveAsLB.GetEntryCount();
645 [ # # ]: 0 : for ( ; i < nCount; ++ i )
646 : : {
647 [ # # ]: 0 : if ( aSaveAsLB.GetEntryData(i) != NULL )
648 : : {
649 : 0 : bHasODFFormat = true;
650 : 0 : break;
651 : : }
652 : : }
653 : :
654 : 0 : bShown = !bHasODFFormat
655 [ # # ][ # # ]: 0 : || ( aSaveAsLB.GetEntryData( aSaveAsLB.GetSelectEntryPos() ) != NULL );
656 : : }
657 : :
658 : 0 : aODFWarningFI.Show( bShown );
659 : 0 : aODFWarningFT.Show( bShown );
660 : :
661 : 0 : return 0;
662 : : }
663 : :
664 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|