1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26
27 // include ---------------------------------------------------------------
28 #include <tools/shl.hxx>
29 #include <svl/eitem.hxx>
30 #include <svl/intitem.hxx>
31 #define _SVX_OPTSAVE_CXX
32
33 #include "optsave.hrc"
34 #include <cuires.hrc>
35
36 #include "optsave.hxx"
37 #include <dialmgr.hxx>
38 #include <comphelper/processfactory.hxx>
39 #include <comphelper/sequenceasvector.hxx>
40 #include <comphelper/sequenceashashmap.hxx>
41 #include <unotools/moduleoptions.hxx>
42 #include <unotools/saveopt.hxx>
43 #include <comphelper/sequenceasvector.hxx>
44 #include <comphelper/sequenceashashmap.hxx>
45 #include <com/sun/star/container/XContainerQuery.hpp>
46 #include <com/sun/star/container/XEnumeration.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #include <com/sun/star/container/XNameContainer.hpp>
49 #include <com/sun/star/container/XContainerQuery.hpp>
50 #include <com/sun/star/container/XEnumeration.hpp>
51 #include <com/sun/star/beans/PropertyValue.hpp>
52 #include <com/sun/star/util/XFlushable.hpp>
53 #include <sfx2/docfilt.hxx>
54 #include <svtools/stdctrl.hxx>
55 #include <vcl/fixed.hxx>
56 #include <vcl/msgbox.hxx>
57 #include <unotools/configitem.hxx>
58 #include <unotools/optionsdlg.hxx>
59
60 #include <vcl/msgbox.hxx>
61
62 using namespace com::sun::star::uno;
63 using namespace com::sun::star::util;
64 using namespace com::sun::star::lang;
65 using namespace com::sun::star::beans;
66 using namespace com::sun::star::container;
67 using namespace comphelper;
68 using rtl::OUString;
69
70 #define C2U(cChar) OUString::createFromAscii(cChar)
71 #define C2S(cChar) String( RTL_CONSTASCII_STRINGPARAM(cChar) )
72 #define CFG_PAGE_AND_GROUP C2S("General"), C2S("LoadSave")
73 // !! you have to update these index, if you changed the list of the child windows !!
74 #define WININDEX_AUTOSAVE ((sal_uInt16)6)
75 #define WININDEX_SAVEURL_RELFSYS ((sal_uInt16)9)
76
77 // ----------------------------------------------------------------------
78 #ifdef FILTER_WARNING_ENABLED
79 class SvxAlienFilterWarningConfig_Impl : public utl::ConfigItem
80 {
81 sal_Bool bWarning;
82 com::sun::star::uno::Sequence< OUString > aPropNames;
83
84 public:
85 SvxAlienFilterWarningConfig_Impl();
86 ~SvxAlienFilterWarningConfig_Impl();
87
88 virtual void Commit();
89
ResetWarning()90 void ResetWarning()
91 {
92 if(bWarning)
93 {
94 bWarning = sal_False;
95 ConfigItem::SetModified();
96 }
97
98 }
IsWarning() const99 sal_Bool IsWarning()const{return bWarning;}
100 };
101 // ----------------------------------------------------------------------
SvxAlienFilterWarningConfig_Impl()102 SvxAlienFilterWarningConfig_Impl::SvxAlienFilterWarningConfig_Impl() :
103 ConfigItem(C2U("TypeDetection.Misc/Defaults"),
104 CONFIG_MODE_IMMEDIATE_UPDATE),
105 aPropNames(1),
106 bWarning(sal_True)
107 {
108 aPropNames.getArray()[0] = C2U("ShowAlienFilterWarning");
109 Sequence<Any> aValues = GetProperties(aPropNames);
110 const Any* pValues = aValues.getConstArray();
111 DBG_ASSERT(aValues.getLength() == aPropNames.getLength(), "GetProperties failed");
112 if(aValues.getLength() == aPropNames.getLength() &&
113 pValues[0].hasValue() &&
114 pValues[0].getValueType() == ::getBooleanCppuType())
115 bWarning = *(sal_Bool*)pValues[0].getValue();
116 }
117 // ----------------------------------------------------------------------
~SvxAlienFilterWarningConfig_Impl()118 SvxAlienFilterWarningConfig_Impl::~SvxAlienFilterWarningConfig_Impl()
119 {
120 if(IsModified())
121 Commit();
122 }
123 // ----------------------------------------------------------------------
Commit()124 void SvxAlienFilterWarningConfig_Impl::Commit()
125 {
126 Sequence<Any> aValues(aPropNames.getLength());
127 Any* pValues = aValues.getArray();
128 pValues[0].setValue(&bWarning, ::getBooleanCppuType());
129 PutProperties(aPropNames, aValues);
130 }
131 #endif // FILTER_WARNING_ENABLED
132 // ----------------------------------------------------------------------
133 // ----------------------------------------------------------------------
134
135 struct SvxSaveTabPage_Impl
136 {
137 Reference< XNameContainer > xFact;
138 Sequence< OUString > aFilterArr[APP_COUNT];
139 Sequence< sal_Bool > aAlienArr[APP_COUNT];
140 Sequence< sal_Bool > aODFArr[APP_COUNT];
141 Sequence< OUString > aUIFilterArr[APP_COUNT];
142 OUString aDefaultArr[APP_COUNT];
143 sal_Bool aDefaultReadonlyArr[APP_COUNT];
144 sal_Bool bInitialized;
145
146 SvxSaveTabPage_Impl();
147 ~SvxSaveTabPage_Impl();
148 };
149
SvxSaveTabPage_Impl()150 SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( sal_False )
151 {
152 }
153
~SvxSaveTabPage_Impl()154 SvxSaveTabPage_Impl::~SvxSaveTabPage_Impl()
155 {
156 }
157
158 // class SvxSaveTabPage --------------------------------------------------
159
SfxSaveTabPage(Window * pParent,const SfxItemSet & rCoreSet)160 SfxSaveTabPage::SfxSaveTabPage( Window* pParent, const SfxItemSet& rCoreSet ) :
161
162 SfxTabPage( pParent, CUI_RES( RID_SFXPAGE_SAVE ), rCoreSet ),
163
164 aLoadFL ( this, CUI_RES( LB_LOAD ) ),
165 aLoadUserSettingsCB ( this, CUI_RES( CB_LOAD_SETTINGS ) ),
166 aLoadDocPrinterCB ( this, CUI_RES( CB_LOAD_DOCPRINTER ) ),
167
168 aSaveFL ( this, CUI_RES( GB_SAVE ) ),
169 aDocInfoCB ( this, CUI_RES( BTN_DOCINFO ) ),
170 aBackupFI ( this, CUI_RES( FI_BACKUP ) ),
171 aBackupCB ( this, CUI_RES( BTN_BACKUP ) ),
172 aAutoSaveCB ( this, CUI_RES( BTN_AUTOSAVE ) ),
173 aAutoSaveEdit ( this, CUI_RES( ED_AUTOSAVE ) ),
174 aMinuteFT ( this, CUI_RES( FT_MINUTE ) ),
175 aRelativeFsysCB ( this, CUI_RES( BTN_RELATIVE_FSYS ) ),
176 aRelativeInetCB ( this, CUI_RES( BTN_RELATIVE_INET ) ),
177
178 aDefaultFormatFL ( this, CUI_RES( FL_FILTER ) ),
179 aODFVersionFT ( this, CUI_RES( FT_ODF_VERSION ) ),
180 aODFVersionLB ( this, CUI_RES( LB_ODF_VERSION ) ),
181 aSizeOptimizationCB ( this, CUI_RES( BTN_NOPRETTYPRINTING ) ),
182 aWarnAlienFormatCB ( this, CUI_RES( BTN_WARNALIENFORMAT ) ),
183 aDocTypeFT ( this, CUI_RES( FT_APP ) ),
184 aDocTypeLB ( this, CUI_RES( LB_APP ) ),
185 aSaveAsFT ( this, CUI_RES( FT_FILTER ) ),
186 aSaveAsFI ( this, CUI_RES( FI_FILTER ) ),
187 aSaveAsLB ( this, CUI_RES( LB_FILTER ) ),
188 aODFWarningFI ( this, CUI_RES( FI_ODF_WARNING ) ),
189 aODFWarningFT ( this, CUI_RES( FT_WARN ) ),
190
191 pImpl ( new SvxSaveTabPage_Impl )
192
193 {
194 sal_Bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
195 aODFWarningFI.SetImage(
196 Image( CUI_RES( bHighContrast ? IMG_ODF_WARNING_HC : IMG_ODF_WARNING ) ) );
197
198 FreeResource();
199
200 Link aLink = LINK( this, SfxSaveTabPage, AutoClickHdl_Impl );
201 aAutoSaveCB.SetClickHdl( aLink );
202 aAutoSaveEdit.SetMaxTextLen( 2 );
203
204 SvtModuleOptions aModuleOpt;
205 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
206 {
207 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_MATH ));
208 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_MATH ));
209 }
210 else
211 {
212 pImpl->aDefaultArr[APP_MATH] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH);
213 pImpl->aDefaultReadonlyArr[APP_MATH] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_MATH);
214 }
215
216 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
217 {
218 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_DRAW ));
219 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_DRAW ));
220 }
221 else
222 {
223 pImpl->aDefaultArr[APP_DRAW] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW);
224 pImpl->aDefaultReadonlyArr[APP_DRAW] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_DRAW);
225 }
226
227 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
228 {
229 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_IMPRESS ));
230 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_IMPRESS ));
231 }
232 else
233 {
234 pImpl->aDefaultArr[APP_IMPRESS] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS);
235 pImpl->aDefaultReadonlyArr[APP_IMPRESS] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_IMPRESS);
236 }
237
238 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
239 {
240 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_CALC ));
241 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_CALC ));
242 }
243 else
244 {
245 pImpl->aDefaultArr[APP_CALC] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC);
246 pImpl->aDefaultReadonlyArr[APP_CALC] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_CALC);
247 }
248
249 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
250 {
251 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER ));
252 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER_WEB ));
253 aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER_GLOBAL ));
254 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER ));
255 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER_WEB ));
256 aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER_GLOBAL ));
257 }
258 else
259 {
260 pImpl->aDefaultArr[APP_WRITER] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER);
261 pImpl->aDefaultArr[APP_WRITER_WEB] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB);
262 pImpl->aDefaultArr[APP_WRITER_GLOBAL] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL);
263 pImpl->aDefaultReadonlyArr[APP_WRITER] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITER);
264 pImpl->aDefaultReadonlyArr[APP_WRITER_WEB] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERWEB);
265 pImpl->aDefaultReadonlyArr[APP_WRITER_GLOBAL] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERGLOBAL);
266 }
267
268 aLink = LINK( this, SfxSaveTabPage, ODFVersionHdl_Impl );
269 aODFVersionLB.SetSelectHdl( aLink );
270 aLink = LINK( this, SfxSaveTabPage, FilterHdl_Impl );
271 aDocTypeLB.SetSelectHdl( aLink );
272 aSaveAsLB.SetSelectHdl( aLink );
273
274 DetectHiddenControls();
275 }
276
277 // -----------------------------------------------------------------------
278
~SfxSaveTabPage()279 SfxSaveTabPage::~SfxSaveTabPage()
280 {
281 delete pImpl;
282 }
283
284 // -----------------------------------------------------------------------
285
Create(Window * pParent,const SfxItemSet & rAttrSet)286 SfxTabPage* SfxSaveTabPage::Create( Window* pParent,
287 const SfxItemSet& rAttrSet )
288 {
289 return ( new SfxSaveTabPage( pParent, rAttrSet ) );
290 }
291
292 // -----------------------------------------------------------------------
AcceptFilter(sal_uInt16 nPos)293 bool SfxSaveTabPage::AcceptFilter( sal_uInt16 nPos )
294 {
295 const OUString* pFilters = pImpl->aFilterArr[nPos].getConstArray();
296 sal_Bool bAlien = sal_False, bODF = sal_False;
297 OUString* pUIFilters = pImpl->aUIFilterArr[nPos].getArray();
298 OUString sUIName;
299 for(int nFilter = 0; nFilter < pImpl->aFilterArr[nPos].getLength(); nFilter++)
300 {
301 if( pImpl->aDefaultArr[nPos] == pFilters[nFilter] )
302 {
303 bAlien = pImpl->aAlienArr[nPos][nFilter];
304 bODF = pImpl->aODFArr[nPos][nFilter];
305 sUIName = pUIFilters[nFilter];;
306 break;
307 }
308 }
309 bool bSet = true;
310 return bSet;
311 }
312 // -----------------------------------------------------------------------
DetectHiddenControls()313 void SfxSaveTabPage::DetectHiddenControls()
314 {
315 long nDelta = 0;
316 // the index of the first child window which perhaps have to move upwards
317 sal_uInt16 nWinIndex = WININDEX_SAVEURL_RELFSYS;
318 SvtOptionsDialogOptions aOptionsDlgOpt;
319
320 if ( aOptionsDlgOpt.IsOptionHidden( C2S("Backup"), CFG_PAGE_AND_GROUP ) )
321 {
322 // hide controls of "Backup"
323 aBackupFI.Hide();
324 aBackupCB.Hide();
325 // the other controls have to move upwards the height of checkbox + space
326 nDelta = aAutoSaveCB.GetPosPixel().Y() - aBackupCB.GetPosPixel().Y();
327 }
328
329 if ( aOptionsDlgOpt.IsOptionHidden( C2S("AutoSave"), CFG_PAGE_AND_GROUP ) )
330 {
331 // hide controls of "AutoSave"
332 aAutoSaveCB.Hide();
333 aAutoSaveEdit.Hide();
334 aMinuteFT.Hide();
335 // the other controls have to move upwards the height of checkbox + space
336 nDelta += aRelativeFsysCB.GetPosPixel().Y() - aAutoSaveCB.GetPosPixel().Y();
337 }
338 else if ( nDelta > 0 )
339 // the "AutoSave" controls have to move upwards too
340 nWinIndex = WININDEX_AUTOSAVE;
341
342 if ( nDelta > 0 )
343 {
344 sal_uInt16 i, nChildCount = GetChildCount();
345 for ( i = nWinIndex; i < nChildCount; ++i )
346 {
347 Window* pWin = GetChild(i);
348 Point aPos = pWin->GetPosPixel();
349 aPos.Y() -= nDelta;
350 pWin->SetPosPixel( aPos );
351 }
352 }
353 }
354 // -----------------------------------------------------------------------
FillItemSet(SfxItemSet & rSet)355 sal_Bool SfxSaveTabPage::FillItemSet( SfxItemSet& rSet )
356 {
357 sal_Bool bModified = sal_False;
358 SvtSaveOptions aSaveOpt;
359 if(aLoadUserSettingsCB.IsChecked() != aLoadUserSettingsCB.GetSavedValue())
360 {
361 aSaveOpt.SetLoadUserSettings(aLoadUserSettingsCB.IsChecked());
362 }
363
364 if ( aLoadDocPrinterCB.IsChecked() != aLoadDocPrinterCB.GetSavedValue() )
365 aSaveOpt.SetLoadDocumentPrinter( aLoadDocPrinterCB.IsChecked() );
366
367 if ( aODFVersionLB.GetSelectEntryPos() != aODFVersionLB.GetSavedValue() )
368 {
369 long nVersion = long( aODFVersionLB.GetEntryData( aODFVersionLB.GetSelectEntryPos() ) );
370 aSaveOpt.SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion ) );
371 }
372
373 if ( aDocInfoCB.IsChecked() != aDocInfoCB.GetSavedValue() )
374 {
375 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO ),
376 aDocInfoCB.IsChecked() ) );
377 bModified |= sal_True;
378 }
379
380 if ( aBackupCB.IsEnabled() && aBackupCB.IsChecked() != aBackupCB.GetSavedValue() )
381 {
382 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP ),
383 aBackupCB.IsChecked() ) );
384 bModified |= sal_True;
385 }
386
387 if ( aSizeOptimizationCB.IsChecked() != aSizeOptimizationCB.GetSavedValue() )
388 {
389 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_PRETTYPRINTING ), !aSizeOptimizationCB.IsChecked() ) );
390 bModified |= sal_True;
391 }
392
393 if ( aAutoSaveCB.IsChecked() != aAutoSaveCB.GetSavedValue() )
394 {
395 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE ),
396 aAutoSaveCB.IsChecked() ) );
397 bModified |= sal_True;
398 }
399 if ( aWarnAlienFormatCB.IsChecked() != aWarnAlienFormatCB.GetSavedValue() )
400 {
401 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT ),
402 aWarnAlienFormatCB.IsChecked() ) );
403 bModified |= sal_True;
404 }
405
406 if ( aAutoSaveEdit.GetText() != aAutoSaveEdit.GetSavedValue() )
407 {
408 rSet.Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE ),
409 (sal_uInt16)aAutoSaveEdit.GetValue() ) );
410 bModified |= sal_True;
411 }
412 // relativ speichern
413 if ( aRelativeFsysCB.IsChecked() != aRelativeFsysCB.GetSavedValue() )
414 {
415 rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS ),
416 aRelativeFsysCB.IsChecked() ) );
417 bModified |= sal_True;
418 }
419
420 if ( aRelativeInetCB.IsChecked() != aRelativeInetCB.GetSavedValue() )
421 {
422 rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET ),
423 aRelativeInetCB.IsChecked() ) );
424 bModified |= sal_True;
425 }
426
427 SvtModuleOptions aModuleOpt;
428 if(pImpl->aDefaultArr[APP_MATH].getLength() &&
429 pImpl->aDefaultArr[APP_MATH] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH) &&
430 AcceptFilter( APP_MATH ))
431 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_MATH, pImpl->aDefaultArr[APP_MATH]);
432
433 if( pImpl->aDefaultArr[APP_DRAW].getLength() &&
434 pImpl->aDefaultArr[APP_DRAW] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW) &&
435 AcceptFilter( APP_DRAW ))
436 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_DRAW, pImpl->aDefaultArr[APP_DRAW]);
437
438 if(pImpl->aDefaultArr[APP_IMPRESS].getLength() &&
439 pImpl->aDefaultArr[APP_IMPRESS] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS)&&
440 AcceptFilter( APP_IMPRESS ))
441 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS, pImpl->aDefaultArr[APP_IMPRESS]);
442
443 if(pImpl->aDefaultArr[APP_CALC].getLength() &&
444 pImpl->aDefaultArr[APP_CALC] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC)&&
445 AcceptFilter( APP_CALC ))
446 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_CALC, pImpl->aDefaultArr[APP_CALC]);
447
448 if(pImpl->aDefaultArr[APP_WRITER].getLength() &&
449 pImpl->aDefaultArr[APP_WRITER] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER)&&
450 AcceptFilter( APP_WRITER))
451 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITER, pImpl->aDefaultArr[APP_WRITER]);
452
453 if(pImpl->aDefaultArr[APP_WRITER_WEB].getLength() &&
454 pImpl->aDefaultArr[APP_WRITER_WEB] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB)&&
455 AcceptFilter( APP_WRITER_WEB ))
456 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB, pImpl->aDefaultArr[APP_WRITER_WEB]);
457
458 if(pImpl->aDefaultArr[APP_WRITER_GLOBAL].getLength() &&
459 pImpl->aDefaultArr[APP_WRITER_GLOBAL] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL)&&
460 AcceptFilter( APP_WRITER_GLOBAL ))
461 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL, pImpl->aDefaultArr[APP_WRITER_GLOBAL]);
462
463 return bModified;
464 }
465
466 // -----------------------------------------------------------------------
467
isODFFormat(OUString sFilter)468 sal_Bool isODFFormat( OUString sFilter )
469 {
470 static const char* aODFFormats[] =
471 {
472 "writer8",
473 "writer8_template",
474 "writerglobal8",
475 "writerglobal8_writer",
476 "calc8",
477 "calc8_template",
478 "draw8",
479 "draw8_template",
480 "impress8",
481 "impress8_template",
482 "impress8_draw",
483 "chart8",
484 "math8",
485 NULL
486 };
487
488 sal_Bool bRet = sal_False;
489 int i = 0;
490 while ( aODFFormats[i] != NULL )
491 {
492 if ( sFilter.equalsAscii( aODFFormats[i++] ) )
493 {
494 bRet = sal_True;
495 break;
496 }
497 }
498
499 return bRet;
500 }
501
Reset(const SfxItemSet &)502 void SfxSaveTabPage::Reset( const SfxItemSet& )
503 {
504 SvtSaveOptions aSaveOpt;
505 aLoadUserSettingsCB.Check(aSaveOpt.IsLoadUserSettings());
506 aLoadUserSettingsCB.SaveValue();
507 aLoadDocPrinterCB.Check( aSaveOpt.IsLoadDocumentPrinter() );
508 aLoadDocPrinterCB.SaveValue();
509
510 if ( !pImpl->bInitialized )
511 {
512 try
513 {
514 Reference< XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory();
515 pImpl->xFact = Reference<XNameContainer>(
516 xMSF->createInstance(C2U("com.sun.star.document.FilterFactory")), UNO_QUERY);
517
518 DBG_ASSERT(pImpl->xFact.is(), "service com.sun.star.document.FilterFactory unavailable");
519 Reference< XContainerQuery > xQuery(pImpl->xFact, UNO_QUERY);
520 if(xQuery.is())
521 {
522 for(sal_uInt16 n = 0; n < aDocTypeLB.GetEntryCount(); n++)
523 {
524 long nData = (long) aDocTypeLB.GetEntryData(n);
525 OUString sCommand;
526 sCommand = C2U("matchByDocumentService=%1:iflags=");
527 sCommand += String::CreateFromInt32(SFX_FILTER_IMPORT|SFX_FILTER_EXPORT);
528 sCommand += C2U(":eflags=");
529 sCommand += String::CreateFromInt32(SFX_FILTER_NOTINFILEDLG);
530 sCommand += C2U(":default_first");
531 String sReplace;
532 switch(nData)
533 {
534 case APP_WRITER : sReplace = C2U("com.sun.star.text.TextDocument"); break;
535 case APP_WRITER_WEB : sReplace = C2U("com.sun.star.text.WebDocument"); break;
536 case APP_WRITER_GLOBAL : sReplace = C2U("com.sun.star.text.GlobalDocument"); break;
537 case APP_CALC : sReplace = C2U("com.sun.star.sheet.SpreadsheetDocument");break;
538 case APP_IMPRESS : sReplace = C2U("com.sun.star.presentation.PresentationDocument");break;
539 case APP_DRAW : sReplace = C2U("com.sun.star.drawing.DrawingDocument");break;
540 case APP_MATH : sReplace = C2U("com.sun.star.formula.FormulaProperties");break;
541 default: DBG_ERROR("illegal user data");
542 }
543 String sTmp(sCommand);
544 sTmp.SearchAndReplaceAscii("%1", sReplace);
545 sCommand = sTmp;
546 Reference< XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
547 SequenceAsVector< OUString > lList;
548 SequenceAsVector< sal_Bool > lAlienList;
549 SequenceAsVector< sal_Bool > lODFList;
550 while(xList->hasMoreElements())
551 {
552 SequenceAsHashMap aFilter(xList->nextElement());
553 OUString sFilter = aFilter.getUnpackedValueOrDefault(OUString::createFromAscii("Name"),OUString());
554 if (sFilter.getLength())
555 {
556 sal_Int32 nFlags = aFilter.getUnpackedValueOrDefault(OUString::createFromAscii("Flags"),sal_Int32());
557 lList.push_back(sFilter);
558 lAlienList.push_back(0 != (nFlags & SFX_FILTER_ALIEN));
559 lODFList.push_back( isODFFormat( sFilter ) );
560 }
561 }
562 pImpl->aFilterArr[nData] = lList.getAsConstList();
563 pImpl->aAlienArr[nData] = lAlienList.getAsConstList();
564 pImpl->aODFArr[nData] = lODFList.getAsConstList();
565 }
566 }
567 aDocTypeLB.SelectEntryPos(0);
568 FilterHdl_Impl(&aDocTypeLB);
569 }
570 catch(Exception& e)
571 {
572 (void) e;
573 DBG_ERROR(
574 rtl::OUStringToOString(
575 (rtl::OUString(
576 RTL_CONSTASCII_USTRINGPARAM(
577 "exception in FilterFactory access: ")) +
578 e.Message),
579 RTL_TEXTENCODING_UTF8).
580 getStr());
581 }
582
583 pImpl->bInitialized = sal_True;
584 }
585
586 aDocInfoCB.Check(aSaveOpt.IsDocInfoSave());
587 // aDocInfoCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE));
588
589 aBackupCB.Check(aSaveOpt.IsBackup());
590 sal_Bool bBackupRO = aSaveOpt.IsReadOnly(SvtSaveOptions::E_BACKUP);
591 aBackupCB.Enable(!bBackupRO);
592 aBackupFI.Show(bBackupRO);
593
594 aAutoSaveCB.Check(aSaveOpt.IsAutoSave());
595 aWarnAlienFormatCB.Check(aSaveOpt.IsWarnAlienFormat());
596 aWarnAlienFormatCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT));
597 // aAutoSaveCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_AUTOSAVE));
598
599 // the pretty printing
600 aSizeOptimizationCB.Check( !aSaveOpt.IsPrettyPrinting());
601 // aSizeOptimizationCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING ));
602
603
604 aAutoSaveEdit.SetValue( aSaveOpt.GetAutoSaveTime() );
605 // aAutoSaveEdit.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME));
606
607 // relativ speichern
608 aRelativeFsysCB.Check( aSaveOpt.IsSaveRelFSys() );
609 // aRelativeFsysCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS));
610
611 aRelativeInetCB.Check( aSaveOpt.IsSaveRelINet() );
612 // aRelativeInetCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_SAVERELINET));
613
614 void* pDefaultVersion = (void*)long( aSaveOpt.GetODFDefaultVersion() );
615 aODFVersionLB.SelectEntryPos( aODFVersionLB.GetEntryPos( pDefaultVersion ) );
616
617 AutoClickHdl_Impl( &aAutoSaveCB );
618 ODFVersionHdl_Impl( &aODFVersionLB );
619
620 aDocInfoCB.SaveValue();
621 aBackupCB.SaveValue();
622 aWarnAlienFormatCB.SaveValue();
623 aSizeOptimizationCB.SaveValue();
624 aAutoSaveCB.SaveValue();
625 aAutoSaveEdit.SaveValue();
626 // aAutoSavePromptBtn.SaveValue();
627
628 aRelativeFsysCB.SaveValue();
629 aRelativeInetCB.SaveValue();
630 aODFVersionLB.SaveValue();
631 }
632
633 // -----------------------------------------------------------------------
634
IMPL_LINK(SfxSaveTabPage,AutoClickHdl_Impl,CheckBox *,pBox)635 IMPL_LINK( SfxSaveTabPage, AutoClickHdl_Impl, CheckBox *, pBox )
636 {
637 if ( pBox == &aAutoSaveCB )
638 {
639 if ( aAutoSaveCB.IsChecked() )
640 {
641 aAutoSaveEdit.Enable();
642 aMinuteFT.Enable();
643 // aAutoSavePromptBtn.Enable();
644 aAutoSaveEdit.GrabFocus();
645 }
646 else
647 {
648 aAutoSaveEdit.Disable();
649 aMinuteFT.Disable();
650 // aAutoSavePromptBtn.Disable();
651 }
652 }
653 return 0;
654 }
655 /* -----------------------------05.04.01 13:10--------------------------------
656
657 ---------------------------------------------------------------------------*/
lcl_ExtracUIName(const Sequence<PropertyValue> & rProperties)658 OUString lcl_ExtracUIName(const Sequence<PropertyValue> &rProperties)
659 {
660 OUString sName;
661 const PropertyValue* pPropVal = rProperties.getConstArray();
662 const PropertyValue* const pEnd = pPropVal + rProperties.getLength();
663 for( ; pPropVal != pEnd; pPropVal++ )
664 {
665 const OUString &rName = pPropVal->Name;
666 if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "UIName" ) ) )
667 {
668 OUString sUIName;
669 if ( ( pPropVal->Value >>= sUIName ) && sUIName.getLength() )
670 return sUIName;
671 }
672 else if( rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" ) ) )
673 {
674 pPropVal->Value >>= sName;
675 }
676 }
677
678 OSL_ENSURE( false, "Filter without UIName!" );
679
680 return sName;
681 }
682 /* -----------------------------05.04.01 13:37--------------------------------
683
684 ---------------------------------------------------------------------------*/
IMPL_LINK(SfxSaveTabPage,FilterHdl_Impl,ListBox *,pBox)685 IMPL_LINK( SfxSaveTabPage, FilterHdl_Impl, ListBox *, pBox )
686 {
687 sal_uInt16 nCurPos = aDocTypeLB.GetSelectEntryPos();
688
689 long nData = -1;
690 if(nCurPos < APP_COUNT)
691 nData = (long) aDocTypeLB.GetEntryData(nCurPos);
692
693 if ( nData >= 0 && nData < APP_COUNT )
694 {
695 if(&aDocTypeLB == pBox)
696 {
697 aSaveAsLB.Clear();
698 const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray();
699 if(!pImpl->aUIFilterArr[nData].getLength())
700 {
701 pImpl->aUIFilterArr[nData].realloc(pImpl->aFilterArr[nData].getLength());
702 OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray();
703 for(int nFilter = 0; nFilter < pImpl->aFilterArr[nData].getLength(); nFilter++)
704 {
705 Any aProps = pImpl->xFact->getByName(pFilters[nFilter]);
706 Sequence<PropertyValue> aProperties;
707 aProps >>= aProperties;
708 pUIFilters[nFilter] = lcl_ExtracUIName(aProperties);
709 }
710 }
711 const OUString* pUIFilters = pImpl->aUIFilterArr[nData].getConstArray();
712 OUString sSelect;
713 for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++)
714 {
715 sal_uInt16 nEntryPos = aSaveAsLB.InsertEntry(pUIFilters[i]);
716 if ( pImpl->aODFArr[nData][i] )
717 aSaveAsLB.SetEntryData( nEntryPos, (void*)pImpl );
718 if(pFilters[i] == pImpl->aDefaultArr[nData])
719 sSelect = pUIFilters[i];
720 }
721 if(sSelect.getLength())
722 aSaveAsLB.SelectEntry(sSelect);
723 aSaveAsFI.Show(pImpl->aDefaultReadonlyArr[nData]);
724 aSaveAsFT.Enable(!pImpl->aDefaultReadonlyArr[nData]);
725 aSaveAsLB.Enable(!pImpl->aDefaultReadonlyArr[nData]);
726 }
727 else
728 {
729 OUString sSelect = pBox->GetSelectEntry();
730 const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray();
731 OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray();
732 for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++)
733 if(pUIFilters[i] == sSelect)
734 {
735 sSelect = pFilters[i];
736 break;
737 }
738
739 pImpl->aDefaultArr[nData] = sSelect;
740 }
741 }
742
743 ODFVersionHdl_Impl( &aSaveAsLB );
744 return 0;
745 };
746
IMPL_LINK(SfxSaveTabPage,ODFVersionHdl_Impl,ListBox *,EMPTYARG)747 IMPL_LINK( SfxSaveTabPage, ODFVersionHdl_Impl, ListBox *, EMPTYARG )
748 {
749 long nVersion = long( aODFVersionLB.GetEntryData( aODFVersionLB.GetSelectEntryPos() ) );
750 bool bShown = SvtSaveOptions::ODFDefaultVersion( nVersion ) != SvtSaveOptions::ODFVER_LATEST;
751 if ( bShown )
752 {
753 bool bHasODFFormat = false;
754 sal_uInt16 i = 0, nCount = aSaveAsLB.GetEntryCount();
755 for ( ; i < nCount; ++ i )
756 {
757 if ( aSaveAsLB.GetEntryData(i) != NULL )
758 {
759 bHasODFFormat = true;
760 break;
761 }
762 }
763
764 bShown = !bHasODFFormat
765 || ( aSaveAsLB.GetEntryData( aSaveAsLB.GetSelectEntryPos() ) != NULL );
766 }
767
768 aODFWarningFI.Show( bShown );
769 aODFWarningFT.Show( bShown );
770
771 return 0;
772 }
773
774