1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/shl.hxx>
21 #include <svl/eitem.hxx>
22 #include <svl/intitem.hxx>
23 #define _SVX_OPTSAVE_CXX
25 #include "optsave.hrc"
28 #include "optsave.hxx"
29 #include <dialmgr.hxx>
30 #include <comphelper/processfactory.hxx>
31 #include <unotools/moduleoptions.hxx>
32 #include <unotools/saveopt.hxx>
33 #include <comphelper/sequenceasvector.hxx>
34 #include <comphelper/sequenceashashmap.hxx>
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/container/XNameContainer.hpp>
37 #include <com/sun/star/container/XContainerQuery.hpp>
38 #include <com/sun/star/container/XEnumeration.hpp>
39 #include <com/sun/star/beans/PropertyValue.hpp>
40 #include <com/sun/star/util/XFlushable.hpp>
41 #include <sfx2/docfilt.hxx>
42 #include <svtools/stdctrl.hxx>
43 #include <vcl/fixed.hxx>
44 #include <unotools/configitem.hxx>
45 #include <unotools/optionsdlg.hxx>
47 #include <vcl/msgbox.hxx>
49 using namespace com::sun::star::uno
;
50 using namespace com::sun::star::util
;
51 using namespace com::sun::star::lang
;
52 using namespace com::sun::star::beans
;
53 using namespace com::sun::star::container
;
54 using namespace comphelper
;
56 #define C2S(cChar) String( RTL_CONSTASCII_USTRINGPARAM(cChar) )
57 #define CFG_PAGE_AND_GROUP C2S("General"), C2S("LoadSave")
58 // !! you have to update these index, if you changed the list of the child windows !!
59 #define WININDEX_AUTOSAVE ((sal_uInt16)6)
60 #define WININDEX_SAVEURL_RELFSYS ((sal_uInt16)9)
62 // ----------------------------------------------------------------------
64 struct SvxSaveTabPage_Impl
66 Reference
< XNameContainer
> xFact
;
67 Sequence
< OUString
> aFilterArr
[APP_COUNT
];
68 Sequence
< sal_Bool
> aAlienArr
[APP_COUNT
];
69 Sequence
< sal_Bool
> aODFArr
[APP_COUNT
];
70 Sequence
< OUString
> aUIFilterArr
[APP_COUNT
];
71 OUString aDefaultArr
[APP_COUNT
];
72 sal_Bool aDefaultReadonlyArr
[APP_COUNT
];
73 sal_Bool bInitialized
;
75 SvxSaveTabPage_Impl();
76 ~SvxSaveTabPage_Impl();
79 SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( sal_False
)
83 SvxSaveTabPage_Impl::~SvxSaveTabPage_Impl()
87 // class SvxSaveTabPage --------------------------------------------------
89 SfxSaveTabPage::SfxSaveTabPage( Window
* pParent
, const SfxItemSet
& rCoreSet
) :
91 SfxTabPage( pParent
, CUI_RES( RID_SFXPAGE_SAVE
), rCoreSet
),
93 aLoadFL ( this, CUI_RES( LB_LOAD
) ),
94 aLoadUserSettingsCB ( this, CUI_RES( CB_LOAD_SETTINGS
) ),
95 aLoadDocPrinterCB ( this, CUI_RES( CB_LOAD_DOCPRINTER
) ),
97 aSaveFL ( this, CUI_RES( GB_SAVE
) ),
98 aDocInfoCB ( this, CUI_RES( BTN_DOCINFO
) ),
99 aBackupFI ( this, CUI_RES( FI_BACKUP
) ),
100 aBackupCB ( this, CUI_RES( BTN_BACKUP
) ),
101 aAutoSaveCB ( this, CUI_RES( BTN_AUTOSAVE
) ),
102 aAutoSaveEdit ( this, CUI_RES( ED_AUTOSAVE
) ),
103 aMinuteFT ( this, CUI_RES( FT_MINUTE
) ),
104 aRelativeFsysCB ( this, CUI_RES( BTN_RELATIVE_FSYS
) ),
105 aRelativeInetCB ( this, CUI_RES( BTN_RELATIVE_INET
) ),
107 aDefaultFormatFL ( this, CUI_RES( FL_FILTER
) ),
108 aODFVersionFT ( this, CUI_RES( FT_ODF_VERSION
) ),
109 aODFVersionLB ( this, CUI_RES( LB_ODF_VERSION
) ),
110 aSizeOptimizationCB ( this, CUI_RES( BTN_NOPRETTYPRINTING
) ),
111 aWarnAlienFormatCB ( this, CUI_RES( BTN_WARNALIENFORMAT
) ),
112 aDocTypeFT ( this, CUI_RES( FT_APP
) ),
113 aDocTypeLB ( this, CUI_RES( LB_APP
) ),
114 aSaveAsFT ( this, CUI_RES( FT_FILTER
) ),
115 aSaveAsFI ( this, CUI_RES( FI_FILTER
) ),
116 aSaveAsLB ( this, CUI_RES( LB_FILTER
) ),
117 aODFWarningFI ( this, CUI_RES( FI_ODF_WARNING
) ),
118 aODFWarningFT ( this, CUI_RES( FT_WARN
) ),
120 pImpl ( new SvxSaveTabPage_Impl
)
123 aODFWarningFI
.SetImage( Image( CUI_RES( IMG_ODF_WARNING
)));
127 Link aLink
= LINK( this, SfxSaveTabPage
, AutoClickHdl_Impl
);
128 aAutoSaveCB
.SetClickHdl( aLink
);
129 aAutoSaveEdit
.SetMaxTextLen( 2 );
131 SvtModuleOptions aModuleOpt
;
132 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SMATH
) )
134 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_MATH
));
135 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_MATH
));
139 pImpl
->aDefaultArr
[APP_MATH
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH
);
140 pImpl
->aDefaultReadonlyArr
[APP_MATH
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_MATH
);
143 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SDRAW
) )
145 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_DRAW
));
146 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_DRAW
));
150 pImpl
->aDefaultArr
[APP_DRAW
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW
);
151 pImpl
->aDefaultReadonlyArr
[APP_DRAW
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_DRAW
);
154 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS
) )
156 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_IMPRESS
));
157 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_IMPRESS
));
161 pImpl
->aDefaultArr
[APP_IMPRESS
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS
);
162 pImpl
->aDefaultReadonlyArr
[APP_IMPRESS
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_IMPRESS
);
165 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SCALC
) )
167 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_CALC
));
168 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_CALC
));
172 pImpl
->aDefaultArr
[APP_CALC
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC
);
173 pImpl
->aDefaultReadonlyArr
[APP_CALC
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_CALC
);
176 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SWRITER
) )
178 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_WRITER
));
179 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_WRITER_WEB
));
180 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_WRITER_GLOBAL
));
181 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_WRITER
));
182 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_WRITER_WEB
));
183 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_WRITER_GLOBAL
));
187 pImpl
->aDefaultArr
[APP_WRITER
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER
);
188 pImpl
->aDefaultArr
[APP_WRITER_WEB
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB
);
189 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL
);
190 pImpl
->aDefaultReadonlyArr
[APP_WRITER
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITER
);
191 pImpl
->aDefaultReadonlyArr
[APP_WRITER_WEB
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERWEB
);
192 pImpl
->aDefaultReadonlyArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERGLOBAL
);
195 aLink
= LINK( this, SfxSaveTabPage
, ODFVersionHdl_Impl
);
196 aODFVersionLB
.SetSelectHdl( aLink
);
197 aLink
= LINK( this, SfxSaveTabPage
, FilterHdl_Impl
);
198 aDocTypeLB
.SetSelectHdl( aLink
);
199 aSaveAsLB
.SetSelectHdl( aLink
);
201 DetectHiddenControls();
204 // -----------------------------------------------------------------------
206 SfxSaveTabPage::~SfxSaveTabPage()
211 // -----------------------------------------------------------------------
213 SfxTabPage
* SfxSaveTabPage::Create( Window
* pParent
,
214 const SfxItemSet
& rAttrSet
)
216 return ( new SfxSaveTabPage( pParent
, rAttrSet
) );
219 // -----------------------------------------------------------------------
220 void SfxSaveTabPage::DetectHiddenControls()
223 // the index of the first child window which perhaps have to move upwards
224 sal_uInt16 nWinIndex
= WININDEX_SAVEURL_RELFSYS
;
225 SvtOptionsDialogOptions aOptionsDlgOpt
;
227 if ( aOptionsDlgOpt
.IsOptionHidden( C2S("Backup"), CFG_PAGE_AND_GROUP
) )
229 // hide controls of "Backup"
232 // the other controls have to move upwards the height of checkbox + space
233 nDelta
= aAutoSaveCB
.GetPosPixel().Y() - aBackupCB
.GetPosPixel().Y();
236 if ( aOptionsDlgOpt
.IsOptionHidden( C2S("AutoSave"), CFG_PAGE_AND_GROUP
) )
238 // hide controls of "AutoSave"
240 aAutoSaveEdit
.Hide();
242 // the other controls have to move upwards the height of checkbox + space
243 nDelta
+= aRelativeFsysCB
.GetPosPixel().Y() - aAutoSaveCB
.GetPosPixel().Y();
245 else if ( nDelta
> 0 )
246 // the "AutoSave" controls have to move upwards too
247 nWinIndex
= WININDEX_AUTOSAVE
;
251 sal_uInt16 i
, nChildCount
= GetChildCount();
252 for ( i
= nWinIndex
; i
< nChildCount
; ++i
)
254 Window
* pWin
= GetChild(i
);
255 Point aPos
= pWin
->GetPosPixel();
257 pWin
->SetPosPixel( aPos
);
261 // -----------------------------------------------------------------------
262 sal_Bool
SfxSaveTabPage::FillItemSet( SfxItemSet
& rSet
)
264 sal_Bool bModified
= sal_False
;
265 SvtSaveOptions aSaveOpt
;
266 if(aLoadUserSettingsCB
.IsChecked() != aLoadUserSettingsCB
.GetSavedValue())
268 aSaveOpt
.SetLoadUserSettings(aLoadUserSettingsCB
.IsChecked());
271 if ( aLoadDocPrinterCB
.IsChecked() != aLoadDocPrinterCB
.GetSavedValue() )
272 aSaveOpt
.SetLoadDocumentPrinter( aLoadDocPrinterCB
.IsChecked() );
274 if ( aODFVersionLB
.GetSelectEntryPos() != aODFVersionLB
.GetSavedValue() )
276 long nVersion
= long( aODFVersionLB
.GetEntryData( aODFVersionLB
.GetSelectEntryPos() ) );
277 aSaveOpt
.SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion
) );
280 if ( aDocInfoCB
.IsChecked() != aDocInfoCB
.GetSavedValue() )
282 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO
),
283 aDocInfoCB
.IsChecked() ) );
284 bModified
|= sal_True
;
287 if ( aBackupCB
.IsEnabled() && aBackupCB
.IsChecked() != aBackupCB
.GetSavedValue() )
289 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP
),
290 aBackupCB
.IsChecked() ) );
291 bModified
|= sal_True
;
294 if ( aSizeOptimizationCB
.IsChecked() != aSizeOptimizationCB
.GetSavedValue() )
296 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_PRETTYPRINTING
), !aSizeOptimizationCB
.IsChecked() ) );
297 bModified
|= sal_True
;
300 if ( aAutoSaveCB
.IsChecked() != aAutoSaveCB
.GetSavedValue() )
302 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE
),
303 aAutoSaveCB
.IsChecked() ) );
304 bModified
|= sal_True
;
306 if ( aWarnAlienFormatCB
.IsChecked() != aWarnAlienFormatCB
.GetSavedValue() )
308 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT
),
309 aWarnAlienFormatCB
.IsChecked() ) );
310 bModified
|= sal_True
;
313 if ( aAutoSaveEdit
.GetText() != aAutoSaveEdit
.GetSavedValue() )
315 rSet
.Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE
),
316 (sal_uInt16
)aAutoSaveEdit
.GetValue() ) );
317 bModified
|= sal_True
;
320 if ( aRelativeFsysCB
.IsChecked() != aRelativeFsysCB
.GetSavedValue() )
322 rSet
.Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS
),
323 aRelativeFsysCB
.IsChecked() ) );
324 bModified
|= sal_True
;
327 if ( aRelativeInetCB
.IsChecked() != aRelativeInetCB
.GetSavedValue() )
329 rSet
.Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET
),
330 aRelativeInetCB
.IsChecked() ) );
331 bModified
|= sal_True
;
334 SvtModuleOptions aModuleOpt
;
335 if(!pImpl
->aDefaultArr
[APP_MATH
].isEmpty() &&
336 pImpl
->aDefaultArr
[APP_MATH
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH
))
337 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_MATH
, pImpl
->aDefaultArr
[APP_MATH
]);
339 if( !pImpl
->aDefaultArr
[APP_DRAW
].isEmpty() &&
340 pImpl
->aDefaultArr
[APP_DRAW
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW
))
341 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_DRAW
, pImpl
->aDefaultArr
[APP_DRAW
]);
343 if(!pImpl
->aDefaultArr
[APP_IMPRESS
].isEmpty() &&
344 pImpl
->aDefaultArr
[APP_IMPRESS
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS
))
345 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS
, pImpl
->aDefaultArr
[APP_IMPRESS
]);
347 if(!pImpl
->aDefaultArr
[APP_CALC
].isEmpty() &&
348 pImpl
->aDefaultArr
[APP_CALC
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC
))
349 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_CALC
, pImpl
->aDefaultArr
[APP_CALC
]);
351 if(!pImpl
->aDefaultArr
[APP_WRITER
].isEmpty() &&
352 pImpl
->aDefaultArr
[APP_WRITER
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER
))
353 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITER
, pImpl
->aDefaultArr
[APP_WRITER
]);
355 if(!pImpl
->aDefaultArr
[APP_WRITER_WEB
].isEmpty() &&
356 pImpl
->aDefaultArr
[APP_WRITER_WEB
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB
))
357 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB
, pImpl
->aDefaultArr
[APP_WRITER_WEB
]);
359 if(!pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
].isEmpty() &&
360 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL
))
361 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL
, pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
]);
366 // -----------------------------------------------------------------------
368 sal_Bool
isODFFormat( OUString sFilter
)
370 static const char* aODFFormats
[] =
375 "writerglobal8_writer",
388 sal_Bool bRet
= sal_False
;
390 while ( aODFFormats
[i
] != NULL
)
392 if ( sFilter
.equalsAscii( aODFFormats
[i
++] ) )
402 void SfxSaveTabPage::Reset( const SfxItemSet
& )
404 SvtSaveOptions aSaveOpt
;
405 aLoadUserSettingsCB
.Check(aSaveOpt
.IsLoadUserSettings());
406 aLoadUserSettingsCB
.SaveValue();
407 aLoadDocPrinterCB
.Check( aSaveOpt
.IsLoadDocumentPrinter() );
408 aLoadDocPrinterCB
.SaveValue();
410 if ( !pImpl
->bInitialized
)
414 Reference
< XMultiServiceFactory
> xMSF
= comphelper::getProcessServiceFactory();
415 pImpl
->xFact
= Reference
<XNameContainer
>(
416 xMSF
->createInstance("com.sun.star.document.FilterFactory"), UNO_QUERY
);
418 DBG_ASSERT(pImpl
->xFact
.is(), "service com.sun.star.document.FilterFactory unavailable");
419 Reference
< XContainerQuery
> xQuery(pImpl
->xFact
, UNO_QUERY
);
422 for(sal_uInt16 n
= 0; n
< aDocTypeLB
.GetEntryCount(); n
++)
424 long nData
= (long) aDocTypeLB
.GetEntryData(n
);
426 sCommand
= "matchByDocumentService=%1:iflags=";
427 sCommand
+= String::CreateFromInt32(SFX_FILTER_IMPORT
|SFX_FILTER_EXPORT
);
428 sCommand
+= ":eflags=";
429 sCommand
+= String::CreateFromInt32(SFX_FILTER_NOTINFILEDLG
);
430 sCommand
+= ":default_first";
434 case APP_WRITER
: sReplace
= "com.sun.star.text.TextDocument"; break;
435 case APP_WRITER_WEB
: sReplace
= "com.sun.star.text.WebDocument"; break;
436 case APP_WRITER_GLOBAL
: sReplace
= "com.sun.star.text.GlobalDocument"; break;
437 case APP_CALC
: sReplace
= "com.sun.star.sheet.SpreadsheetDocument";break;
438 case APP_IMPRESS
: sReplace
= "com.sun.star.presentation.PresentationDocument";break;
439 case APP_DRAW
: sReplace
= "com.sun.star.drawing.DrawingDocument";break;
440 case APP_MATH
: sReplace
= "com.sun.star.formula.FormulaProperties";break;
441 default: OSL_FAIL("illegal user data");
443 String
sTmp(sCommand
);
444 sTmp
.SearchAndReplaceAscii("%1", sReplace
);
446 Reference
< XEnumeration
> xList
= xQuery
->createSubSetEnumerationByQuery(sCommand
);
447 SequenceAsVector
< OUString
> lList
;
448 SequenceAsVector
< sal_Bool
> lAlienList
;
449 SequenceAsVector
< sal_Bool
> lODFList
;
450 while(xList
->hasMoreElements())
452 SequenceAsHashMap
aFilter(xList
->nextElement());
453 OUString sFilter
= aFilter
.getUnpackedValueOrDefault(OUString(RTL_CONSTASCII_USTRINGPARAM("Name")),OUString());
454 if (!sFilter
.isEmpty())
456 sal_Int32 nFlags
= aFilter
.getUnpackedValueOrDefault(OUString(RTL_CONSTASCII_USTRINGPARAM("Flags")),sal_Int32());
457 lList
.push_back(sFilter
);
458 lAlienList
.push_back(0 != (nFlags
& SFX_FILTER_ALIEN
));
459 lODFList
.push_back( isODFFormat( sFilter
) );
462 pImpl
->aFilterArr
[nData
] = lList
.getAsConstList();
463 pImpl
->aAlienArr
[nData
] = lAlienList
.getAsConstList();
464 pImpl
->aODFArr
[nData
] = lODFList
.getAsConstList();
467 aDocTypeLB
.SelectEntryPos(0);
468 FilterHdl_Impl(&aDocTypeLB
);
474 rtl::OUStringToOString(
476 RTL_CONSTASCII_USTRINGPARAM(
477 "exception in FilterFactory access: ")) +
479 RTL_TEXTENCODING_UTF8
).
483 pImpl
->bInitialized
= sal_True
;
486 aDocInfoCB
.Check(aSaveOpt
.IsDocInfoSave());
488 aBackupCB
.Check(aSaveOpt
.IsBackup());
489 sal_Bool bBackupRO
= aSaveOpt
.IsReadOnly(SvtSaveOptions::E_BACKUP
);
490 aBackupCB
.Enable(!bBackupRO
);
491 aBackupFI
.Show(bBackupRO
);
493 aAutoSaveCB
.Check(aSaveOpt
.IsAutoSave());
494 aWarnAlienFormatCB
.Check(aSaveOpt
.IsWarnAlienFormat());
495 aWarnAlienFormatCB
.Enable(!aSaveOpt
.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT
));
497 // the pretty printing
498 aSizeOptimizationCB
.Check( !aSaveOpt
.IsPrettyPrinting());
500 aAutoSaveEdit
.SetValue( aSaveOpt
.GetAutoSaveTime() );
503 aRelativeFsysCB
.Check( aSaveOpt
.IsSaveRelFSys() );
505 aRelativeInetCB
.Check( aSaveOpt
.IsSaveRelINet() );
507 void* pDefaultVersion
= (void*)long( aSaveOpt
.GetODFDefaultVersion() );
508 aODFVersionLB
.SelectEntryPos( aODFVersionLB
.GetEntryPos( pDefaultVersion
) );
510 AutoClickHdl_Impl( &aAutoSaveCB
);
511 ODFVersionHdl_Impl( &aODFVersionLB
);
513 aDocInfoCB
.SaveValue();
514 aBackupCB
.SaveValue();
515 aWarnAlienFormatCB
.SaveValue();
516 aSizeOptimizationCB
.SaveValue();
517 aAutoSaveCB
.SaveValue();
518 aAutoSaveEdit
.SaveValue();
520 aRelativeFsysCB
.SaveValue();
521 aRelativeInetCB
.SaveValue();
522 aODFVersionLB
.SaveValue();
525 // -----------------------------------------------------------------------
527 IMPL_LINK( SfxSaveTabPage
, AutoClickHdl_Impl
, CheckBox
*, pBox
)
529 if ( pBox
== &aAutoSaveCB
)
531 if ( aAutoSaveCB
.IsChecked() )
533 aAutoSaveEdit
.Enable();
538 aAutoSaveEdit
.Disable();
545 static OUString
lcl_ExtracUIName(const Sequence
<PropertyValue
> rProperties
)
548 const PropertyValue
* pProperties
= rProperties
.getConstArray();
549 for(int nProp
= 0; nProp
< rProperties
.getLength(); nProp
++)
551 if(!pProperties
[nProp
].Name
.compareToAscii("UIName"))
553 pProperties
[nProp
].Value
>>= sRet
;
556 else if(!pProperties
[nProp
].Name
.compareToAscii("Name"))
558 pProperties
[nProp
].Value
>>= sRet
;
564 IMPL_LINK( SfxSaveTabPage
, FilterHdl_Impl
, ListBox
*, pBox
)
566 sal_uInt16 nCurPos
= aDocTypeLB
.GetSelectEntryPos();
569 if(nCurPos
< APP_COUNT
)
570 nData
= (long) aDocTypeLB
.GetEntryData(nCurPos
);
572 if ( nData
>= 0 && nData
< APP_COUNT
)
574 if(&aDocTypeLB
== pBox
)
577 const OUString
* pFilters
= pImpl
->aFilterArr
[nData
].getConstArray();
578 if(!pImpl
->aUIFilterArr
[nData
].getLength())
580 pImpl
->aUIFilterArr
[nData
].realloc(pImpl
->aFilterArr
[nData
].getLength());
581 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nData
].getArray();
582 for(int nFilter
= 0; nFilter
< pImpl
->aFilterArr
[nData
].getLength(); nFilter
++)
584 Any aProps
= pImpl
->xFact
->getByName(pFilters
[nFilter
]);
585 Sequence
<PropertyValue
> aProperties
;
586 aProps
>>= aProperties
;
587 pUIFilters
[nFilter
] = lcl_ExtracUIName(aProperties
);
590 const OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nData
].getConstArray();
592 for(int i
= 0; i
< pImpl
->aUIFilterArr
[nData
].getLength(); i
++)
594 sal_uInt16 nEntryPos
= aSaveAsLB
.InsertEntry(pUIFilters
[i
]);
595 if ( pImpl
->aODFArr
[nData
][i
] )
596 aSaveAsLB
.SetEntryData( nEntryPos
, (void*)pImpl
);
597 if(pFilters
[i
] == pImpl
->aDefaultArr
[nData
])
598 sSelect
= pUIFilters
[i
];
600 if(!sSelect
.isEmpty())
601 aSaveAsLB
.SelectEntry(sSelect
);
602 aSaveAsFI
.Show(pImpl
->aDefaultReadonlyArr
[nData
]);
603 aSaveAsFT
.Enable(!pImpl
->aDefaultReadonlyArr
[nData
]);
604 aSaveAsLB
.Enable(!pImpl
->aDefaultReadonlyArr
[nData
]);
608 OUString sSelect
= pBox
->GetSelectEntry();
609 const OUString
* pFilters
= pImpl
->aFilterArr
[nData
].getConstArray();
610 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nData
].getArray();
611 for(int i
= 0; i
< pImpl
->aUIFilterArr
[nData
].getLength(); i
++)
612 if(pUIFilters
[i
] == sSelect
)
614 sSelect
= pFilters
[i
];
618 pImpl
->aDefaultArr
[nData
] = sSelect
;
622 ODFVersionHdl_Impl( &aSaveAsLB
);
626 IMPL_LINK_NOARG(SfxSaveTabPage
, ODFVersionHdl_Impl
)
628 long nVersion
= long( aODFVersionLB
.GetEntryData( aODFVersionLB
.GetSelectEntryPos() ) );
629 bool bShown
= SvtSaveOptions::ODFDefaultVersion( nVersion
) != SvtSaveOptions::ODFVER_LATEST
;
632 bool bHasODFFormat
= false;
633 sal_uInt16 i
= 0, nCount
= aSaveAsLB
.GetEntryCount();
634 for ( ; i
< nCount
; ++ i
)
636 if ( aSaveAsLB
.GetEntryData(i
) != NULL
)
638 bHasODFFormat
= true;
643 bShown
= !bHasODFFormat
644 || ( aSaveAsLB
.GetEntryData( aSaveAsLB
.GetSelectEntryPos() ) != NULL
);
647 aODFWarningFI
.Show( bShown
);
648 aODFWarningFT
.Show( bShown
);
653 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */