1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
32 #include <tools/shl.hxx>
33 #include <svl/eitem.hxx>
34 #include <svl/intitem.hxx>
35 #define _SVX_OPTSAVE_CXX
37 #include "optsave.hrc"
40 #include "optsave.hxx"
41 #include <dialmgr.hxx>
42 #include <comphelper/processfactory.hxx>
43 #include <comphelper/sequenceasvector.hxx>
44 #include <comphelper/sequenceashashmap.hxx>
45 #include <unotools/moduleoptions.hxx>
46 #include <unotools/saveopt.hxx>
47 #include <comphelper/sequenceasvector.hxx>
48 #include <comphelper/sequenceashashmap.hxx>
49 #include <com/sun/star/container/XContainerQuery.hpp>
50 #include <com/sun/star/container/XEnumeration.hpp>
51 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
52 #include <com/sun/star/container/XNameContainer.hpp>
53 #include <com/sun/star/container/XContainerQuery.hpp>
54 #include <com/sun/star/container/XEnumeration.hpp>
55 #include <com/sun/star/beans/PropertyValue.hpp>
56 #include <com/sun/star/util/XFlushable.hpp>
57 #include <sfx2/docfilt.hxx>
58 #include <svtools/stdctrl.hxx>
59 #include <vcl/fixed.hxx>
60 #include <vcl/msgbox.hxx>
61 #include <unotools/configitem.hxx>
62 #include <unotools/optionsdlg.hxx>
64 #include <vcl/msgbox.hxx>
66 using namespace com::sun::star::uno
;
67 using namespace com::sun::star::util
;
68 using namespace com::sun::star::lang
;
69 using namespace com::sun::star::beans
;
70 using namespace com::sun::star::container
;
71 using namespace comphelper
;
74 #define C2U(cChar) OUString::createFromAscii(cChar)
75 #define C2S(cChar) String( RTL_CONSTASCII_STRINGPARAM(cChar) )
76 #define CFG_PAGE_AND_GROUP C2S("General"), C2S("LoadSave")
77 // !! you have to update these index, if you changed the list of the child windows !!
78 #define WININDEX_AUTOSAVE ((sal_uInt16)6)
79 #define WININDEX_SAVEURL_RELFSYS ((sal_uInt16)9)
81 // ----------------------------------------------------------------------
82 #ifdef FILTER_WARNING_ENABLED
83 class SvxAlienFilterWarningConfig_Impl
: public utl::ConfigItem
86 com::sun::star::uno::Sequence
< OUString
> aPropNames
;
89 SvxAlienFilterWarningConfig_Impl();
90 ~SvxAlienFilterWarningConfig_Impl();
92 virtual void Commit();
99 ConfigItem::SetModified();
103 sal_Bool
IsWarning()const{return bWarning
;}
105 // ----------------------------------------------------------------------
106 SvxAlienFilterWarningConfig_Impl::SvxAlienFilterWarningConfig_Impl() :
107 ConfigItem(C2U("TypeDetection.Misc/Defaults"),
108 CONFIG_MODE_IMMEDIATE_UPDATE
),
112 aPropNames
.getArray()[0] = C2U("ShowAlienFilterWarning");
113 Sequence
<Any
> aValues
= GetProperties(aPropNames
);
114 const Any
* pValues
= aValues
.getConstArray();
115 DBG_ASSERT(aValues
.getLength() == aPropNames
.getLength(), "GetProperties failed");
116 if(aValues
.getLength() == aPropNames
.getLength() &&
117 pValues
[0].hasValue() &&
118 pValues
[0].getValueType() == ::getBooleanCppuType())
119 bWarning
= *(sal_Bool
*)pValues
[0].getValue();
121 // ----------------------------------------------------------------------
122 SvxAlienFilterWarningConfig_Impl::~SvxAlienFilterWarningConfig_Impl()
127 // ----------------------------------------------------------------------
128 void SvxAlienFilterWarningConfig_Impl::Commit()
130 Sequence
<Any
> aValues(aPropNames
.getLength());
131 Any
* pValues
= aValues
.getArray();
132 pValues
[0].setValue(&bWarning
, ::getBooleanCppuType());
133 PutProperties(aPropNames
, aValues
);
135 #endif // FILTER_WARNING_ENABLED
136 // ----------------------------------------------------------------------
137 // ----------------------------------------------------------------------
139 struct SvxSaveTabPage_Impl
141 Reference
< XNameContainer
> xFact
;
142 Sequence
< OUString
> aFilterArr
[APP_COUNT
];
143 Sequence
< sal_Bool
> aAlienArr
[APP_COUNT
];
144 Sequence
< sal_Bool
> aODFArr
[APP_COUNT
];
145 Sequence
< OUString
> aUIFilterArr
[APP_COUNT
];
146 OUString aDefaultArr
[APP_COUNT
];
147 sal_Bool aDefaultReadonlyArr
[APP_COUNT
];
148 sal_Bool bInitialized
;
150 SvxSaveTabPage_Impl();
151 ~SvxSaveTabPage_Impl();
154 SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( sal_False
)
158 SvxSaveTabPage_Impl::~SvxSaveTabPage_Impl()
162 // class SvxSaveTabPage --------------------------------------------------
164 SfxSaveTabPage::SfxSaveTabPage( Window
* pParent
, const SfxItemSet
& rCoreSet
) :
166 SfxTabPage( pParent
, CUI_RES( RID_SFXPAGE_SAVE
), rCoreSet
),
168 aLoadFL ( this, CUI_RES( LB_LOAD
) ),
169 aLoadUserSettingsCB ( this, CUI_RES( CB_LOAD_SETTINGS
) ),
170 aLoadDocPrinterCB ( this, CUI_RES( CB_LOAD_DOCPRINTER
) ),
172 aSaveFL ( this, CUI_RES( GB_SAVE
) ),
173 aDocInfoCB ( this, CUI_RES( BTN_DOCINFO
) ),
174 aBackupFI ( this, CUI_RES( FI_BACKUP
) ),
175 aBackupCB ( this, CUI_RES( BTN_BACKUP
) ),
176 aAutoSaveCB ( this, CUI_RES( BTN_AUTOSAVE
) ),
177 aAutoSaveEdit ( this, CUI_RES( ED_AUTOSAVE
) ),
178 aMinuteFT ( this, CUI_RES( FT_MINUTE
) ),
179 aRelativeFsysCB ( this, CUI_RES( BTN_RELATIVE_FSYS
) ),
180 aRelativeInetCB ( this, CUI_RES( BTN_RELATIVE_INET
) ),
182 aDefaultFormatFL ( this, CUI_RES( FL_FILTER
) ),
183 aODFVersionFT ( this, CUI_RES( FT_ODF_VERSION
) ),
184 aODFVersionLB ( this, CUI_RES( LB_ODF_VERSION
) ),
185 aSizeOptimizationCB ( this, CUI_RES( BTN_NOPRETTYPRINTING
) ),
186 aWarnAlienFormatCB ( this, CUI_RES( BTN_WARNALIENFORMAT
) ),
187 aDocTypeFT ( this, CUI_RES( FT_APP
) ),
188 aDocTypeLB ( this, CUI_RES( LB_APP
) ),
189 aSaveAsFT ( this, CUI_RES( FT_FILTER
) ),
190 aSaveAsFI ( this, CUI_RES( FI_FILTER
) ),
191 aSaveAsLB ( this, CUI_RES( LB_FILTER
) ),
192 aODFWarningFI ( this, CUI_RES( FI_ODF_WARNING
) ),
193 aODFWarningFT ( this, CUI_RES( FT_WARN
) ),
195 pImpl ( new SvxSaveTabPage_Impl
)
198 sal_Bool bHighContrast
= GetSettings().GetStyleSettings().GetHighContrastMode();
199 aODFWarningFI
.SetImage(
200 Image( CUI_RES( bHighContrast
? IMG_ODF_WARNING_HC
: IMG_ODF_WARNING
) ) );
204 Link aLink
= LINK( this, SfxSaveTabPage
, AutoClickHdl_Impl
);
205 aAutoSaveCB
.SetClickHdl( aLink
);
206 aAutoSaveEdit
.SetMaxTextLen( 2 );
208 SvtModuleOptions aModuleOpt
;
209 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SMATH
) )
211 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_MATH
));
212 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_MATH
));
216 pImpl
->aDefaultArr
[APP_MATH
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH
);
217 pImpl
->aDefaultReadonlyArr
[APP_MATH
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_MATH
);
220 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SDRAW
) )
222 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_DRAW
));
223 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_DRAW
));
227 pImpl
->aDefaultArr
[APP_DRAW
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW
);
228 pImpl
->aDefaultReadonlyArr
[APP_DRAW
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_DRAW
);
231 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS
) )
233 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_IMPRESS
));
234 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_IMPRESS
));
238 pImpl
->aDefaultArr
[APP_IMPRESS
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS
);
239 pImpl
->aDefaultReadonlyArr
[APP_IMPRESS
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_IMPRESS
);
242 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SCALC
) )
244 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_CALC
));
245 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_CALC
));
249 pImpl
->aDefaultArr
[APP_CALC
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC
);
250 pImpl
->aDefaultReadonlyArr
[APP_CALC
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_CALC
);
253 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SWRITER
) )
255 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_WRITER
));
256 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_WRITER_WEB
));
257 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_WRITER_GLOBAL
));
258 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_WRITER
));
259 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_WRITER_WEB
));
260 aDocTypeLB
.RemoveEntry(aDocTypeLB
.GetEntryPos( (void*) APP_WRITER_GLOBAL
));
264 pImpl
->aDefaultArr
[APP_WRITER
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER
);
265 pImpl
->aDefaultArr
[APP_WRITER_WEB
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB
);
266 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL
);
267 pImpl
->aDefaultReadonlyArr
[APP_WRITER
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITER
);
268 pImpl
->aDefaultReadonlyArr
[APP_WRITER_WEB
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERWEB
);
269 pImpl
->aDefaultReadonlyArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERGLOBAL
);
272 aLink
= LINK( this, SfxSaveTabPage
, ODFVersionHdl_Impl
);
273 aODFVersionLB
.SetSelectHdl( aLink
);
274 aLink
= LINK( this, SfxSaveTabPage
, FilterHdl_Impl
);
275 aDocTypeLB
.SetSelectHdl( aLink
);
276 aSaveAsLB
.SetSelectHdl( aLink
);
278 DetectHiddenControls();
281 // -----------------------------------------------------------------------
283 SfxSaveTabPage::~SfxSaveTabPage()
288 // -----------------------------------------------------------------------
290 SfxTabPage
* SfxSaveTabPage::Create( Window
* pParent
,
291 const SfxItemSet
& rAttrSet
)
293 return ( new SfxSaveTabPage( pParent
, rAttrSet
) );
296 // -----------------------------------------------------------------------
297 bool SfxSaveTabPage::AcceptFilter( sal_uInt16 nPos
)
299 const OUString
* pFilters
= pImpl
->aFilterArr
[nPos
].getConstArray();
300 sal_Bool bAlien
= sal_False
, bODF
= sal_False
;
301 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nPos
].getArray();
303 for(int nFilter
= 0; nFilter
< pImpl
->aFilterArr
[nPos
].getLength(); nFilter
++)
305 if( pImpl
->aDefaultArr
[nPos
] == pFilters
[nFilter
] )
307 bAlien
= pImpl
->aAlienArr
[nPos
][nFilter
];
308 bODF
= pImpl
->aODFArr
[nPos
][nFilter
];
309 sUIName
= pUIFilters
[nFilter
];;
316 // -----------------------------------------------------------------------
317 void SfxSaveTabPage::DetectHiddenControls()
320 // the index of the first child window which perhaps have to move upwards
321 sal_uInt16 nWinIndex
= WININDEX_SAVEURL_RELFSYS
;
322 SvtOptionsDialogOptions aOptionsDlgOpt
;
324 if ( aOptionsDlgOpt
.IsOptionHidden( C2S("Backup"), CFG_PAGE_AND_GROUP
) )
326 // hide controls of "Backup"
329 // the other controls have to move upwards the height of checkbox + space
330 nDelta
= aAutoSaveCB
.GetPosPixel().Y() - aBackupCB
.GetPosPixel().Y();
333 if ( aOptionsDlgOpt
.IsOptionHidden( C2S("AutoSave"), CFG_PAGE_AND_GROUP
) )
335 // hide controls of "AutoSave"
337 aAutoSaveEdit
.Hide();
339 // the other controls have to move upwards the height of checkbox + space
340 nDelta
+= aRelativeFsysCB
.GetPosPixel().Y() - aAutoSaveCB
.GetPosPixel().Y();
342 else if ( nDelta
> 0 )
343 // the "AutoSave" controls have to move upwards too
344 nWinIndex
= WININDEX_AUTOSAVE
;
348 sal_uInt16 i
, nChildCount
= GetChildCount();
349 for ( i
= nWinIndex
; i
< nChildCount
; ++i
)
351 Window
* pWin
= GetChild(i
);
352 Point aPos
= pWin
->GetPosPixel();
354 pWin
->SetPosPixel( aPos
);
358 // -----------------------------------------------------------------------
359 sal_Bool
SfxSaveTabPage::FillItemSet( SfxItemSet
& rSet
)
361 sal_Bool bModified
= sal_False
;
362 SvtSaveOptions aSaveOpt
;
363 if(aLoadUserSettingsCB
.IsChecked() != aLoadUserSettingsCB
.GetSavedValue())
365 aSaveOpt
.SetLoadUserSettings(aLoadUserSettingsCB
.IsChecked());
368 if ( aLoadDocPrinterCB
.IsChecked() != aLoadDocPrinterCB
.GetSavedValue() )
369 aSaveOpt
.SetLoadDocumentPrinter( aLoadDocPrinterCB
.IsChecked() );
371 if ( aODFVersionLB
.GetSelectEntryPos() != aODFVersionLB
.GetSavedValue() )
373 long nVersion
= long( aODFVersionLB
.GetEntryData( aODFVersionLB
.GetSelectEntryPos() ) );
374 aSaveOpt
.SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion
) );
377 if ( aDocInfoCB
.IsChecked() != aDocInfoCB
.GetSavedValue() )
379 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO
),
380 aDocInfoCB
.IsChecked() ) );
381 bModified
|= sal_True
;
384 if ( aBackupCB
.IsEnabled() && aBackupCB
.IsChecked() != aBackupCB
.GetSavedValue() )
386 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP
),
387 aBackupCB
.IsChecked() ) );
388 bModified
|= sal_True
;
391 if ( aSizeOptimizationCB
.IsChecked() != aSizeOptimizationCB
.GetSavedValue() )
393 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_PRETTYPRINTING
), !aSizeOptimizationCB
.IsChecked() ) );
394 bModified
|= sal_True
;
397 if ( aAutoSaveCB
.IsChecked() != aAutoSaveCB
.GetSavedValue() )
399 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE
),
400 aAutoSaveCB
.IsChecked() ) );
401 bModified
|= sal_True
;
403 if ( aWarnAlienFormatCB
.IsChecked() != aWarnAlienFormatCB
.GetSavedValue() )
405 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT
),
406 aWarnAlienFormatCB
.IsChecked() ) );
407 bModified
|= sal_True
;
410 if ( aAutoSaveEdit
.GetText() != aAutoSaveEdit
.GetSavedValue() )
412 rSet
.Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE
),
413 (sal_uInt16
)aAutoSaveEdit
.GetValue() ) );
414 bModified
|= sal_True
;
417 if ( aRelativeFsysCB
.IsChecked() != aRelativeFsysCB
.GetSavedValue() )
419 rSet
.Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS
),
420 aRelativeFsysCB
.IsChecked() ) );
421 bModified
|= sal_True
;
424 if ( aRelativeInetCB
.IsChecked() != aRelativeInetCB
.GetSavedValue() )
426 rSet
.Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET
),
427 aRelativeInetCB
.IsChecked() ) );
428 bModified
|= sal_True
;
431 SvtModuleOptions aModuleOpt
;
432 if(pImpl
->aDefaultArr
[APP_MATH
].getLength() &&
433 pImpl
->aDefaultArr
[APP_MATH
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH
) &&
434 AcceptFilter( APP_MATH
))
435 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_MATH
, pImpl
->aDefaultArr
[APP_MATH
]);
437 if( pImpl
->aDefaultArr
[APP_DRAW
].getLength() &&
438 pImpl
->aDefaultArr
[APP_DRAW
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW
) &&
439 AcceptFilter( APP_DRAW
))
440 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_DRAW
, pImpl
->aDefaultArr
[APP_DRAW
]);
442 if(pImpl
->aDefaultArr
[APP_IMPRESS
].getLength() &&
443 pImpl
->aDefaultArr
[APP_IMPRESS
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS
)&&
444 AcceptFilter( APP_IMPRESS
))
445 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS
, pImpl
->aDefaultArr
[APP_IMPRESS
]);
447 if(pImpl
->aDefaultArr
[APP_CALC
].getLength() &&
448 pImpl
->aDefaultArr
[APP_CALC
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC
)&&
449 AcceptFilter( APP_CALC
))
450 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_CALC
, pImpl
->aDefaultArr
[APP_CALC
]);
452 if(pImpl
->aDefaultArr
[APP_WRITER
].getLength() &&
453 pImpl
->aDefaultArr
[APP_WRITER
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER
)&&
454 AcceptFilter( APP_WRITER
))
455 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITER
, pImpl
->aDefaultArr
[APP_WRITER
]);
457 if(pImpl
->aDefaultArr
[APP_WRITER_WEB
].getLength() &&
458 pImpl
->aDefaultArr
[APP_WRITER_WEB
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB
)&&
459 AcceptFilter( APP_WRITER_WEB
))
460 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB
, pImpl
->aDefaultArr
[APP_WRITER_WEB
]);
462 if(pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
].getLength() &&
463 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL
)&&
464 AcceptFilter( APP_WRITER_GLOBAL
))
465 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL
, pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
]);
470 // -----------------------------------------------------------------------
472 sal_Bool
isODFFormat( OUString sFilter
)
474 static const char* aODFFormats
[] =
479 "writerglobal8_writer",
492 sal_Bool bRet
= sal_False
;
494 while ( aODFFormats
[i
] != NULL
)
496 if ( sFilter
.equalsAscii( aODFFormats
[i
++] ) )
506 void SfxSaveTabPage::Reset( const SfxItemSet
& )
508 SvtSaveOptions aSaveOpt
;
509 aLoadUserSettingsCB
.Check(aSaveOpt
.IsLoadUserSettings());
510 aLoadUserSettingsCB
.SaveValue();
511 aLoadDocPrinterCB
.Check( aSaveOpt
.IsLoadDocumentPrinter() );
512 aLoadDocPrinterCB
.SaveValue();
514 if ( !pImpl
->bInitialized
)
518 Reference
< XMultiServiceFactory
> xMSF
= comphelper::getProcessServiceFactory();
519 pImpl
->xFact
= Reference
<XNameContainer
>(
520 xMSF
->createInstance(C2U("com.sun.star.document.FilterFactory")), UNO_QUERY
);
522 DBG_ASSERT(pImpl
->xFact
.is(), "service com.sun.star.document.FilterFactory unavailable");
523 Reference
< XContainerQuery
> xQuery(pImpl
->xFact
, UNO_QUERY
);
526 for(sal_uInt16 n
= 0; n
< aDocTypeLB
.GetEntryCount(); n
++)
528 long nData
= (long) aDocTypeLB
.GetEntryData(n
);
530 sCommand
= C2U("matchByDocumentService=%1:iflags=");
531 sCommand
+= String::CreateFromInt32(SFX_FILTER_IMPORT
|SFX_FILTER_EXPORT
);
532 sCommand
+= C2U(":eflags=");
533 sCommand
+= String::CreateFromInt32(SFX_FILTER_NOTINFILEDLG
);
534 sCommand
+= C2U(":default_first");
538 case APP_WRITER
: sReplace
= C2U("com.sun.star.text.TextDocument"); break;
539 case APP_WRITER_WEB
: sReplace
= C2U("com.sun.star.text.WebDocument"); break;
540 case APP_WRITER_GLOBAL
: sReplace
= C2U("com.sun.star.text.GlobalDocument"); break;
541 case APP_CALC
: sReplace
= C2U("com.sun.star.sheet.SpreadsheetDocument");break;
542 case APP_IMPRESS
: sReplace
= C2U("com.sun.star.presentation.PresentationDocument");break;
543 case APP_DRAW
: sReplace
= C2U("com.sun.star.drawing.DrawingDocument");break;
544 case APP_MATH
: sReplace
= C2U("com.sun.star.formula.FormulaProperties");break;
545 default: DBG_ERROR("illegal user data");
547 String
sTmp(sCommand
);
548 sTmp
.SearchAndReplaceAscii("%1", sReplace
);
550 Reference
< XEnumeration
> xList
= xQuery
->createSubSetEnumerationByQuery(sCommand
);
551 SequenceAsVector
< OUString
> lList
;
552 SequenceAsVector
< sal_Bool
> lAlienList
;
553 SequenceAsVector
< sal_Bool
> lODFList
;
554 while(xList
->hasMoreElements())
556 SequenceAsHashMap
aFilter(xList
->nextElement());
557 OUString sFilter
= aFilter
.getUnpackedValueOrDefault(OUString::createFromAscii("Name"),OUString());
558 if (sFilter
.getLength())
560 sal_Int32 nFlags
= aFilter
.getUnpackedValueOrDefault(OUString::createFromAscii("Flags"),sal_Int32());
561 lList
.push_back(sFilter
);
562 lAlienList
.push_back(0 != (nFlags
& SFX_FILTER_ALIEN
));
563 lODFList
.push_back( isODFFormat( sFilter
) );
566 pImpl
->aFilterArr
[nData
] = lList
.getAsConstList();
567 pImpl
->aAlienArr
[nData
] = lAlienList
.getAsConstList();
568 pImpl
->aODFArr
[nData
] = lODFList
.getAsConstList();
571 aDocTypeLB
.SelectEntryPos(0);
572 FilterHdl_Impl(&aDocTypeLB
);
578 rtl::OUStringToOString(
580 RTL_CONSTASCII_USTRINGPARAM(
581 "exception in FilterFactory access: ")) +
583 RTL_TEXTENCODING_UTF8
).
587 pImpl
->bInitialized
= sal_True
;
590 aDocInfoCB
.Check(aSaveOpt
.IsDocInfoSave());
591 // aDocInfoCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE));
593 aBackupCB
.Check(aSaveOpt
.IsBackup());
594 sal_Bool bBackupRO
= aSaveOpt
.IsReadOnly(SvtSaveOptions::E_BACKUP
);
595 aBackupCB
.Enable(!bBackupRO
);
596 aBackupFI
.Show(bBackupRO
);
598 aAutoSaveCB
.Check(aSaveOpt
.IsAutoSave());
599 aWarnAlienFormatCB
.Check(aSaveOpt
.IsWarnAlienFormat());
600 aWarnAlienFormatCB
.Enable(!aSaveOpt
.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT
));
601 // aAutoSaveCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_AUTOSAVE));
603 // the pretty printing
604 aSizeOptimizationCB
.Check( !aSaveOpt
.IsPrettyPrinting());
605 // aSizeOptimizationCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING ));
608 aAutoSaveEdit
.SetValue( aSaveOpt
.GetAutoSaveTime() );
609 // aAutoSaveEdit.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME));
612 aRelativeFsysCB
.Check( aSaveOpt
.IsSaveRelFSys() );
613 // aRelativeFsysCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS));
615 aRelativeInetCB
.Check( aSaveOpt
.IsSaveRelINet() );
616 // aRelativeInetCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_SAVERELINET));
618 void* pDefaultVersion
= (void*)long( aSaveOpt
.GetODFDefaultVersion() );
619 aODFVersionLB
.SelectEntryPos( aODFVersionLB
.GetEntryPos( pDefaultVersion
) );
621 AutoClickHdl_Impl( &aAutoSaveCB
);
622 ODFVersionHdl_Impl( &aODFVersionLB
);
624 aDocInfoCB
.SaveValue();
625 aBackupCB
.SaveValue();
626 aWarnAlienFormatCB
.SaveValue();
627 aSizeOptimizationCB
.SaveValue();
628 aAutoSaveCB
.SaveValue();
629 aAutoSaveEdit
.SaveValue();
630 // aAutoSavePromptBtn.SaveValue();
632 aRelativeFsysCB
.SaveValue();
633 aRelativeInetCB
.SaveValue();
634 aODFVersionLB
.SaveValue();
637 // -----------------------------------------------------------------------
639 IMPL_LINK( SfxSaveTabPage
, AutoClickHdl_Impl
, CheckBox
*, pBox
)
641 if ( pBox
== &aAutoSaveCB
)
643 if ( aAutoSaveCB
.IsChecked() )
645 aAutoSaveEdit
.Enable();
647 // aAutoSavePromptBtn.Enable();
648 aAutoSaveEdit
.GrabFocus();
652 aAutoSaveEdit
.Disable();
654 // aAutoSavePromptBtn.Disable();
659 /* -----------------------------05.04.01 13:10--------------------------------
661 ---------------------------------------------------------------------------*/
662 OUString
lcl_ExtracUIName(const Sequence
<PropertyValue
> rProperties
)
666 const PropertyValue
* pProperties
= rProperties
.getConstArray();
667 for(int nProp
= 0; nProp
< rProperties
.getLength(); nProp
++)
669 if(!pProperties
[nProp
].Name
.compareToAscii("UIName"))
671 pProperties
[nProp
].Value
>>= sRet
;
674 else if(!pProperties
[nProp
].Name
.compareToAscii("Flags"))
676 if ( pProperties
[nProp
].Value
>>= nFlags
)
681 else if(!pProperties
[nProp
].Name
.compareToAscii("Name"))
683 pProperties
[nProp
].Value
>>= sRet
;
688 /* -----------------------------05.04.01 13:37--------------------------------
690 ---------------------------------------------------------------------------*/
691 IMPL_LINK( SfxSaveTabPage
, FilterHdl_Impl
, ListBox
*, pBox
)
693 sal_uInt16 nCurPos
= aDocTypeLB
.GetSelectEntryPos();
696 if(nCurPos
< APP_COUNT
)
697 nData
= (long) aDocTypeLB
.GetEntryData(nCurPos
);
699 if ( nData
>= 0 && nData
< APP_COUNT
)
701 if(&aDocTypeLB
== pBox
)
704 const OUString
* pFilters
= pImpl
->aFilterArr
[nData
].getConstArray();
705 if(!pImpl
->aUIFilterArr
[nData
].getLength())
707 pImpl
->aUIFilterArr
[nData
].realloc(pImpl
->aFilterArr
[nData
].getLength());
708 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nData
].getArray();
709 for(int nFilter
= 0; nFilter
< pImpl
->aFilterArr
[nData
].getLength(); nFilter
++)
711 Any aProps
= pImpl
->xFact
->getByName(pFilters
[nFilter
]);
712 Sequence
<PropertyValue
> aProperties
;
713 aProps
>>= aProperties
;
714 pUIFilters
[nFilter
] = lcl_ExtracUIName(aProperties
);
717 const OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nData
].getConstArray();
719 for(int i
= 0; i
< pImpl
->aUIFilterArr
[nData
].getLength(); i
++)
721 sal_uInt16 nEntryPos
= aSaveAsLB
.InsertEntry(pUIFilters
[i
]);
722 if ( pImpl
->aODFArr
[nData
][i
] )
723 aSaveAsLB
.SetEntryData( nEntryPos
, (void*)pImpl
);
724 if(pFilters
[i
] == pImpl
->aDefaultArr
[nData
])
725 sSelect
= pUIFilters
[i
];
727 if(sSelect
.getLength())
728 aSaveAsLB
.SelectEntry(sSelect
);
729 aSaveAsFI
.Show(pImpl
->aDefaultReadonlyArr
[nData
]);
730 aSaveAsFT
.Enable(!pImpl
->aDefaultReadonlyArr
[nData
]);
731 aSaveAsLB
.Enable(!pImpl
->aDefaultReadonlyArr
[nData
]);
735 OUString sSelect
= pBox
->GetSelectEntry();
736 const OUString
* pFilters
= pImpl
->aFilterArr
[nData
].getConstArray();
737 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nData
].getArray();
738 for(int i
= 0; i
< pImpl
->aUIFilterArr
[nData
].getLength(); i
++)
739 if(pUIFilters
[i
] == sSelect
)
741 sSelect
= pFilters
[i
];
745 pImpl
->aDefaultArr
[nData
] = sSelect
;
749 ODFVersionHdl_Impl( &aSaveAsLB
);
753 IMPL_LINK( SfxSaveTabPage
, ODFVersionHdl_Impl
, ListBox
*, EMPTYARG
)
755 long nVersion
= long( aODFVersionLB
.GetEntryData( aODFVersionLB
.GetSelectEntryPos() ) );
756 bool bShown
= SvtSaveOptions::ODFDefaultVersion( nVersion
) != SvtSaveOptions::ODFVER_LATEST
;
759 bool bHasODFFormat
= false;
760 sal_uInt16 i
= 0, nCount
= aSaveAsLB
.GetEntryCount();
761 for ( ; i
< nCount
; ++ i
)
763 if ( aSaveAsLB
.GetEntryData(i
) != NULL
)
765 bHasODFFormat
= true;
770 bShown
= !bHasODFFormat
771 || ( aSaveAsLB
.GetEntryData( aSaveAsLB
.GetSelectEntryPos() ) != NULL
);
774 aODFWarningFI
.Show( bShown
);
775 aODFWarningFT
.Show( bShown
);