1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: optsave.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
38 // include ---------------------------------------------------------------
39 #include <tools/shl.hxx>
40 #include <svtools/eitem.hxx>
41 #include <svtools/intitem.hxx>
42 #define _SVX_OPTSAVE_CXX
44 #include "optsave.hrc"
45 #include <svx/dialogs.hrc>
47 #include "optsave.hxx"
48 #include <svx/dialmgr.hxx>
49 #include <comphelper/processfactory.hxx>
50 #include <comphelper/sequenceasvector.hxx>
51 #include <comphelper/sequenceashashmap.hxx>
52 #include <svtools/moduleoptions.hxx>
53 #include <svtools/saveopt.hxx>
54 #include <comphelper/sequenceasvector.hxx>
55 #include <comphelper/sequenceashashmap.hxx>
56 #include <com/sun/star/container/XContainerQuery.hpp>
57 #include <com/sun/star/container/XEnumeration.hpp>
58 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
59 #include <com/sun/star/container/XNameContainer.hpp>
60 #include <com/sun/star/container/XContainerQuery.hpp>
61 #include <com/sun/star/container/XEnumeration.hpp>
62 #include <com/sun/star/beans/PropertyValue.hpp>
63 #include <com/sun/star/util/XFlushable.hpp>
64 #include <sfx2/docfilt.hxx>
65 #include <svtools/stdctrl.hxx>
66 #include <vcl/fixed.hxx>
67 #include <vcl/msgbox.hxx>
68 #include <unotools/configitem.hxx>
69 #include <svtools/optionsdlg.hxx>
71 #include <vcl/msgbox.hxx>
73 using namespace com::sun::star::uno
;
74 using namespace com::sun::star::util
;
75 using namespace com::sun::star::lang
;
76 using namespace com::sun::star::beans
;
77 using namespace com::sun::star::container
;
78 using namespace comphelper
;
81 #define C2U(cChar) OUString::createFromAscii(cChar)
82 #define C2S(cChar) String( RTL_CONSTASCII_STRINGPARAM(cChar) )
83 #define CFG_PAGE_AND_GROUP C2S("General"), C2S("LoadSave")
84 // !! you have to update these index, if you changed the list of the child windows !!
85 #define WININDEX_AUTOSAVE ((USHORT)6)
86 #define WININDEX_SAVEURL_RELFSYS ((USHORT)9)
88 // -------------------- --------------------------------------------------
89 class FilterWarningDialog_Impl
: public ModalDialog
94 FixedInfo aFilterWarningFT
;
97 FilterWarningDialog_Impl(Window
* pParent
);
99 void SetFilterName(const String
& rFilterUIName
);
101 // ----------------------------------------------------------------------
102 FilterWarningDialog_Impl::FilterWarningDialog_Impl(Window
* pParent
) :
103 ModalDialog(pParent
, SVX_RES( RID_SVXDLG_FILTER_WARNING
) ),
104 aOk( this, SVX_RES(PB_OK
)),
105 aCancel( this, SVX_RES(PB_CANCEL
)),
106 aImage( this, SVX_RES(IMG_WARNING
)),
107 aFilterWarningFT( this, SVX_RES(FT_FILTER_WARNING
))
110 aImage
.SetImage(WarningBox::GetStandardImage());
112 // ----------------------------------------------------------------------
113 void FilterWarningDialog_Impl::SetFilterName(const String
& rFilterUIName
)
115 String
sTmp(aFilterWarningFT
.GetText());
116 sTmp
.SearchAndReplaceAscii("%1", rFilterUIName
);
117 aFilterWarningFT
.SetText(sTmp
);
119 // ----------------------------------------------------------------------
120 #ifdef FILTER_WARNING_ENABLED
121 class SvxAlienFilterWarningConfig_Impl
: public utl::ConfigItem
124 com::sun::star::uno::Sequence
< OUString
> aPropNames
;
127 SvxAlienFilterWarningConfig_Impl();
128 ~SvxAlienFilterWarningConfig_Impl();
130 virtual void Commit();
136 bWarning
= sal_False
;
137 ConfigItem::SetModified();
141 sal_Bool
IsWarning()const{return bWarning
;}
143 // ----------------------------------------------------------------------
144 SvxAlienFilterWarningConfig_Impl::SvxAlienFilterWarningConfig_Impl() :
145 ConfigItem(C2U("TypeDetection.Misc/Defaults"),
146 CONFIG_MODE_IMMEDIATE_UPDATE
),
150 aPropNames
.getArray()[0] = C2U("ShowAlienFilterWarning");
151 Sequence
<Any
> aValues
= GetProperties(aPropNames
);
152 const Any
* pValues
= aValues
.getConstArray();
153 DBG_ASSERT(aValues
.getLength() == aPropNames
.getLength(), "GetProperties failed");
154 if(aValues
.getLength() == aPropNames
.getLength() &&
155 pValues
[0].hasValue() &&
156 pValues
[0].getValueType() == ::getBooleanCppuType())
157 bWarning
= *(sal_Bool
*)pValues
[0].getValue();
159 // ----------------------------------------------------------------------
160 SvxAlienFilterWarningConfig_Impl::~SvxAlienFilterWarningConfig_Impl()
165 // ----------------------------------------------------------------------
166 void SvxAlienFilterWarningConfig_Impl::Commit()
168 Sequence
<Any
> aValues(aPropNames
.getLength());
169 Any
* pValues
= aValues
.getArray();
170 pValues
[0].setValue(&bWarning
, ::getBooleanCppuType());
171 PutProperties(aPropNames
, aValues
);
173 #endif // FILTER_WARNING_ENABLED
174 // ----------------------------------------------------------------------
175 // ----------------------------------------------------------------------
177 struct SvxSaveTabPage_Impl
179 Reference
< XNameContainer
> xFact
;
180 Sequence
< OUString
> aFilterArr
[APP_COUNT
];
181 Sequence
< sal_Bool
> aAlienArr
[APP_COUNT
];
182 Sequence
< sal_Bool
> aODFArr
[APP_COUNT
];
183 Sequence
< OUString
> aUIFilterArr
[APP_COUNT
];
184 OUString aDefaultArr
[APP_COUNT
];
185 sal_Bool aDefaultReadonlyArr
[APP_COUNT
];
186 sal_Bool bInitialized
;
188 SvxSaveTabPage_Impl();
189 ~SvxSaveTabPage_Impl();
192 SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( sal_False
)
196 SvxSaveTabPage_Impl::~SvxSaveTabPage_Impl()
200 // class SvxSaveTabPage --------------------------------------------------
202 SfxSaveTabPage::SfxSaveTabPage( Window
* pParent
, const SfxItemSet
& rCoreSet
) :
204 SfxTabPage( pParent
, SVX_RES( RID_SFXPAGE_SAVE
), rCoreSet
),
206 aLoadFL ( this, SVX_RES( LB_LOAD
) ),
207 aLoadUserSettingsCB ( this, SVX_RES( CB_LOAD_SETTINGS
) ),
208 aLoadDocPrinterCB ( this, SVX_RES( CB_LOAD_DOCPRINTER
) ),
210 aSaveFL ( this, SVX_RES( GB_SAVE
) ),
211 aDocInfoCB ( this, SVX_RES( BTN_DOCINFO
) ),
212 aBackupFI ( this, SVX_RES( FI_BACKUP
) ),
213 aBackupCB ( this, SVX_RES( BTN_BACKUP
) ),
214 aAutoSaveCB ( this, SVX_RES( BTN_AUTOSAVE
) ),
215 aAutoSaveEdit ( this, SVX_RES( ED_AUTOSAVE
) ),
216 aMinuteFT ( this, SVX_RES( FT_MINUTE
) ),
217 aRelativeFsysCB ( this, SVX_RES( BTN_RELATIVE_FSYS
) ),
218 aRelativeInetCB ( this, SVX_RES( BTN_RELATIVE_INET
) ),
220 aDefaultFormatFL ( this, SVX_RES( FL_FILTER
) ),
221 aODFVersionFT ( this, SVX_RES( FT_ODF_VERSION
) ),
222 aODFVersionLB ( this, SVX_RES( LB_ODF_VERSION
) ),
223 aSizeOptimizationCB ( this, SVX_RES( BTN_NOPRETTYPRINTING
) ),
224 aWarnAlienFormatCB ( this, SVX_RES( BTN_WARNALIENFORMAT
) ),
225 aDocTypeFT ( this, SVX_RES( FT_APP
) ),
226 aDocTypeLB ( this, SVX_RES( LB_APP
) ),
227 aSaveAsFT ( this, SVX_RES( FT_FILTER
) ),
228 aSaveAsFI ( this, SVX_RES( FI_FILTER
) ),
229 aSaveAsLB ( this, SVX_RES( LB_FILTER
) ),
230 aODFWarningFI ( this, SVX_RES( FI_ODF_WARNING
) ),
231 aODFWarningFT ( this, SVX_RES( FT_WARN
) ),
233 pImpl ( new SvxSaveTabPage_Impl
)
236 sal_Bool bHighContrast
= GetDisplayBackground().GetColor().IsDark();
237 aODFWarningFI
.SetImage(
238 Image( SVX_RES( bHighContrast
? IMG_ODF_WARNING_HC
: IMG_ODF_WARNING
) ) );
242 Link aLink
= LINK( this, SfxSaveTabPage
, AutoClickHdl_Impl
);
243 aAutoSaveCB
.SetClickHdl( aLink
);
244 aAutoSaveEdit
.SetMaxTextLen( 2 );
246 SvtModuleOptions aModuleOpt
;
247 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SMATH
) )
248 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_MATH
));
251 pImpl
->aDefaultArr
[APP_MATH
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH
);
252 pImpl
->aDefaultReadonlyArr
[APP_MATH
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_MATH
);
254 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SDRAW
) )
255 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_DRAW
));
258 pImpl
->aDefaultArr
[APP_DRAW
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW
);
259 pImpl
->aDefaultReadonlyArr
[APP_DRAW
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_DRAW
);
261 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS
) )
262 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_IMPRESS
));
265 pImpl
->aDefaultArr
[APP_IMPRESS
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS
);
266 pImpl
->aDefaultReadonlyArr
[APP_IMPRESS
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_IMPRESS
);
268 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SCALC
) )
269 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_CALC
));
272 pImpl
->aDefaultArr
[APP_CALC
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC
);
273 pImpl
->aDefaultReadonlyArr
[APP_CALC
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_CALC
);
275 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SWRITER
) )
277 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_WRITER
));
278 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_WRITER_WEB
));
279 aSaveAsLB
.RemoveEntry(aSaveAsLB
.GetEntryPos( (void*) APP_WRITER_GLOBAL
));
283 pImpl
->aDefaultArr
[APP_WRITER
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER
);
284 pImpl
->aDefaultArr
[APP_WRITER_WEB
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB
);
285 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL
);
286 pImpl
->aDefaultReadonlyArr
[APP_WRITER
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITER
);
287 pImpl
->aDefaultReadonlyArr
[APP_WRITER_WEB
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERWEB
);
288 pImpl
->aDefaultReadonlyArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERGLOBAL
);
291 aLink
= LINK( this, SfxSaveTabPage
, ODFVersionHdl_Impl
);
292 aODFVersionLB
.SetSelectHdl( aLink
);
293 aLink
= LINK( this, SfxSaveTabPage
, FilterHdl_Impl
);
294 aDocTypeLB
.SetSelectHdl( aLink
);
295 aSaveAsLB
.SetSelectHdl( aLink
);
297 DetectHiddenControls();
300 // -----------------------------------------------------------------------
302 SfxSaveTabPage::~SfxSaveTabPage()
307 // -----------------------------------------------------------------------
309 SfxTabPage
* SfxSaveTabPage::Create( Window
* pParent
,
310 const SfxItemSet
& rAttrSet
)
312 return ( new SfxSaveTabPage( pParent
, rAttrSet
) );
315 /* -----------------------------05.04.01 13:10--------------------------------
317 ---------------------------------------------------------------------------*/
318 OUString
lcl_ExtractUIName(const Sequence
<PropertyValue
> rProperties
)
321 const PropertyValue
* pProperties
= rProperties
.getConstArray();
322 for(int nProp
= 0; nProp
< rProperties
.getLength(); nProp
++)
324 if(!pProperties
[nProp
].Name
.compareToAscii("UIName"))
326 pProperties
[nProp
].Value
>>= sRet
;
332 // -----------------------------------------------------------------------
333 bool SfxSaveTabPage::AcceptFilter( USHORT nPos
)
335 const OUString
* pFilters
= pImpl
->aFilterArr
[nPos
].getConstArray();
336 sal_Bool bAlien
= sal_False
, bODF
= sal_False
;
337 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nPos
].getArray();
339 for(int nFilter
= 0; nFilter
< pImpl
->aFilterArr
[nPos
].getLength(); nFilter
++)
341 if( pImpl
->aDefaultArr
[nPos
] == pFilters
[nFilter
] )
343 bAlien
= pImpl
->aAlienArr
[nPos
][nFilter
];
344 bODF
= pImpl
->aODFArr
[nPos
][nFilter
];
345 sUIName
= pUIFilters
[nFilter
];;
352 // -----------------------------------------------------------------------
353 void SfxSaveTabPage::DetectHiddenControls()
356 // the index of the first child window which perhaps have to move upwards
357 USHORT nWinIndex
= WININDEX_SAVEURL_RELFSYS
;
358 SvtOptionsDialogOptions aOptionsDlgOpt
;
360 if ( aOptionsDlgOpt
.IsOptionHidden( C2S("Backup"), CFG_PAGE_AND_GROUP
) )
362 // hide controls of "Backup"
365 // the other controls have to move upwards the height of checkbox + space
366 nDelta
= aAutoSaveCB
.GetPosPixel().Y() - aBackupCB
.GetPosPixel().Y();
369 if ( aOptionsDlgOpt
.IsOptionHidden( C2S("AutoSave"), CFG_PAGE_AND_GROUP
) )
371 // hide controls of "AutoSave"
373 aAutoSaveEdit
.Hide();
375 // the other controls have to move upwards the height of checkbox + space
376 nDelta
+= aRelativeFsysCB
.GetPosPixel().Y() - aAutoSaveCB
.GetPosPixel().Y();
378 else if ( nDelta
> 0 )
379 // the "AutoSave" controls have to move upwards too
380 nWinIndex
= WININDEX_AUTOSAVE
;
384 USHORT i
, nChildCount
= GetChildCount();
385 for ( i
= nWinIndex
; i
< nChildCount
; ++i
)
387 Window
* pWin
= GetChild(i
);
388 Point aPos
= pWin
->GetPosPixel();
390 pWin
->SetPosPixel( aPos
);
394 // -----------------------------------------------------------------------
395 BOOL
SfxSaveTabPage::FillItemSet( SfxItemSet
& rSet
)
397 BOOL bModified
= FALSE
;
398 SvtSaveOptions aSaveOpt
;
399 if(aLoadUserSettingsCB
.IsChecked() != aLoadUserSettingsCB
.GetSavedValue())
401 aSaveOpt
.SetLoadUserSettings(aLoadUserSettingsCB
.IsChecked());
404 if ( aLoadDocPrinterCB
.IsChecked() != aLoadDocPrinterCB
.GetSavedValue() )
405 aSaveOpt
.SetLoadDocumentPrinter( aLoadDocPrinterCB
.IsChecked() );
407 if ( aODFVersionLB
.GetSelectEntryPos() != aODFVersionLB
.GetSavedValue() )
409 long nVersion
= long( aODFVersionLB
.GetEntryData( aODFVersionLB
.GetSelectEntryPos() ) );
410 aSaveOpt
.SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion
) );
413 if ( aDocInfoCB
.IsChecked() != aDocInfoCB
.GetSavedValue() )
415 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO
),
416 aDocInfoCB
.IsChecked() ) );
420 if ( aBackupCB
.IsEnabled() && aBackupCB
.IsChecked() != aBackupCB
.GetSavedValue() )
422 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP
),
423 aBackupCB
.IsChecked() ) );
427 if ( aSizeOptimizationCB
.IsChecked() != aSizeOptimizationCB
.GetSavedValue() )
429 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_PRETTYPRINTING
), !aSizeOptimizationCB
.IsChecked() ) );
433 if ( aAutoSaveCB
.IsChecked() != aAutoSaveCB
.GetSavedValue() )
435 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE
),
436 aAutoSaveCB
.IsChecked() ) );
439 if ( aWarnAlienFormatCB
.IsChecked() != aWarnAlienFormatCB
.GetSavedValue() )
441 rSet
.Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT
),
442 aWarnAlienFormatCB
.IsChecked() ) );
446 if ( aAutoSaveEdit
.GetText() != aAutoSaveEdit
.GetSavedValue() )
448 rSet
.Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE
),
449 (UINT16
)aAutoSaveEdit
.GetValue() ) );
453 if ( aRelativeFsysCB
.IsChecked() != aRelativeFsysCB
.GetSavedValue() )
455 rSet
.Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS
),
456 aRelativeFsysCB
.IsChecked() ) );
460 if ( aRelativeInetCB
.IsChecked() != aRelativeInetCB
.GetSavedValue() )
462 rSet
.Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET
),
463 aRelativeInetCB
.IsChecked() ) );
467 SvtModuleOptions aModuleOpt
;
468 if(pImpl
->aDefaultArr
[APP_MATH
].getLength() &&
469 pImpl
->aDefaultArr
[APP_MATH
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH
) &&
470 AcceptFilter( APP_MATH
))
471 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_MATH
, pImpl
->aDefaultArr
[APP_MATH
]);
473 if( pImpl
->aDefaultArr
[APP_DRAW
].getLength() &&
474 pImpl
->aDefaultArr
[APP_DRAW
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW
) &&
475 AcceptFilter( APP_DRAW
))
476 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_DRAW
, pImpl
->aDefaultArr
[APP_DRAW
]);
478 if(pImpl
->aDefaultArr
[APP_IMPRESS
].getLength() &&
479 pImpl
->aDefaultArr
[APP_IMPRESS
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS
)&&
480 AcceptFilter( APP_IMPRESS
))
481 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS
, pImpl
->aDefaultArr
[APP_IMPRESS
]);
483 if(pImpl
->aDefaultArr
[APP_CALC
].getLength() &&
484 pImpl
->aDefaultArr
[APP_CALC
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC
)&&
485 AcceptFilter( APP_CALC
))
486 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_CALC
, pImpl
->aDefaultArr
[APP_CALC
]);
488 if(pImpl
->aDefaultArr
[APP_WRITER
].getLength() &&
489 pImpl
->aDefaultArr
[APP_WRITER
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER
)&&
490 AcceptFilter( APP_WRITER
))
491 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITER
, pImpl
->aDefaultArr
[APP_WRITER
]);
493 if(pImpl
->aDefaultArr
[APP_WRITER_WEB
].getLength() &&
494 pImpl
->aDefaultArr
[APP_WRITER_WEB
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB
)&&
495 AcceptFilter( APP_WRITER_WEB
))
496 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB
, pImpl
->aDefaultArr
[APP_WRITER_WEB
]);
498 if(pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
].getLength() &&
499 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL
)&&
500 AcceptFilter( APP_WRITER_GLOBAL
))
501 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL
, pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
]);
506 // -----------------------------------------------------------------------
508 sal_Bool
isODFFormat( OUString sFilter
)
510 static const char* aODFFormats
[] =
515 "writerglobal8_writer",
528 sal_Bool bRet
= sal_False
;
530 while ( aODFFormats
[i
] != NULL
)
532 if ( sFilter
.equalsAscii( aODFFormats
[i
++] ) )
542 void SfxSaveTabPage::Reset( const SfxItemSet
& )
544 SvtSaveOptions aSaveOpt
;
545 aLoadUserSettingsCB
.Check(aSaveOpt
.IsLoadUserSettings());
546 aLoadUserSettingsCB
.SaveValue();
547 aLoadDocPrinterCB
.Check( aSaveOpt
.IsLoadDocumentPrinter() );
548 aLoadDocPrinterCB
.SaveValue();
550 if ( !pImpl
->bInitialized
)
554 Reference
< XMultiServiceFactory
> xMSF
= comphelper::getProcessServiceFactory();
555 pImpl
->xFact
= Reference
<XNameContainer
>(
556 xMSF
->createInstance(C2U("com.sun.star.document.FilterFactory")), UNO_QUERY
);
558 DBG_ASSERT(pImpl
->xFact
.is(), "service com.sun.star.document.FilterFactory unavailable");
559 Reference
< XContainerQuery
> xQuery(pImpl
->xFact
, UNO_QUERY
);
562 for(USHORT n
= 0; n
< aDocTypeLB
.GetEntryCount(); n
++)
564 long nData
= (long) aDocTypeLB
.GetEntryData(n
);
566 sCommand
= C2U("matchByDocumentService=%1:iflags=");
567 sCommand
+= String::CreateFromInt32(SFX_FILTER_IMPORT
|SFX_FILTER_EXPORT
);
568 sCommand
+= C2U(":eflags=");
569 sCommand
+= String::CreateFromInt32(SFX_FILTER_NOTINFILEDLG
);
570 sCommand
+= C2U(":default_first");
574 case APP_WRITER
: sReplace
= C2U("com.sun.star.text.TextDocument"); break;
575 case APP_WRITER_WEB
: sReplace
= C2U("com.sun.star.text.WebDocument"); break;
576 case APP_WRITER_GLOBAL
: sReplace
= C2U("com.sun.star.text.GlobalDocument"); break;
577 case APP_CALC
: sReplace
= C2U("com.sun.star.sheet.SpreadsheetDocument");break;
578 case APP_IMPRESS
: sReplace
= C2U("com.sun.star.presentation.PresentationDocument");break;
579 case APP_DRAW
: sReplace
= C2U("com.sun.star.drawing.DrawingDocument");break;
580 case APP_MATH
: sReplace
= C2U("com.sun.star.formula.FormulaProperties");break;
581 default: DBG_ERROR("illegal user data");
583 String
sTmp(sCommand
);
584 sTmp
.SearchAndReplaceAscii("%1", sReplace
);
586 Reference
< XEnumeration
> xList
= xQuery
->createSubSetEnumerationByQuery(sCommand
);
587 SequenceAsVector
< OUString
> lList
;
588 SequenceAsVector
< sal_Bool
> lAlienList
;
589 SequenceAsVector
< sal_Bool
> lODFList
;
590 while(xList
->hasMoreElements())
592 SequenceAsHashMap
aFilter(xList
->nextElement());
593 OUString sFilter
= aFilter
.getUnpackedValueOrDefault(OUString::createFromAscii("Name"),OUString());
594 if (sFilter
.getLength())
596 sal_Int32 nFlags
= aFilter
.getUnpackedValueOrDefault(OUString::createFromAscii("Flags"),sal_Int32());
597 lList
.push_back(sFilter
);
598 lAlienList
.push_back(0 != (nFlags
& SFX_FILTER_ALIEN
));
599 lODFList
.push_back( isODFFormat( sFilter
) );
602 pImpl
->aFilterArr
[nData
] = lList
.getAsConstList();
603 pImpl
->aAlienArr
[nData
] = lAlienList
.getAsConstList();
604 pImpl
->aODFArr
[nData
] = lODFList
.getAsConstList();
607 aDocTypeLB
.SelectEntryPos(0);
608 FilterHdl_Impl(&aDocTypeLB
);
612 DBG_ERROR("exception in FilterFactory access");
615 pImpl
->bInitialized
= sal_True
;
618 aDocInfoCB
.Check(aSaveOpt
.IsDocInfoSave());
619 // aDocInfoCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE));
621 aBackupCB
.Check(aSaveOpt
.IsBackup());
622 BOOL bBackupRO
= aSaveOpt
.IsReadOnly(SvtSaveOptions::E_BACKUP
);
623 aBackupCB
.Enable(!bBackupRO
);
624 aBackupFI
.Show(bBackupRO
);
626 aAutoSaveCB
.Check(aSaveOpt
.IsAutoSave());
627 aWarnAlienFormatCB
.Check(aSaveOpt
.IsWarnAlienFormat());
628 aWarnAlienFormatCB
.Enable(!aSaveOpt
.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT
));
629 // aAutoSaveCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_AUTOSAVE));
631 // the pretty printing
632 aSizeOptimizationCB
.Check( !aSaveOpt
.IsPrettyPrinting());
633 // aSizeOptimizationCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING ));
636 aAutoSaveEdit
.SetValue( aSaveOpt
.GetAutoSaveTime() );
637 // aAutoSaveEdit.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME));
640 aRelativeFsysCB
.Check( aSaveOpt
.IsSaveRelFSys() );
641 // aRelativeFsysCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS));
643 aRelativeInetCB
.Check( aSaveOpt
.IsSaveRelINet() );
644 // aRelativeInetCB.Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_SAVERELINET));
646 void* pDefaultVersion
= (void*)long( aSaveOpt
.GetODFDefaultVersion() );
647 aODFVersionLB
.SelectEntryPos( aODFVersionLB
.GetEntryPos( pDefaultVersion
) );
649 AutoClickHdl_Impl( &aAutoSaveCB
);
650 ODFVersionHdl_Impl( &aODFVersionLB
);
652 aDocInfoCB
.SaveValue();
653 aBackupCB
.SaveValue();
654 aWarnAlienFormatCB
.SaveValue();
655 aSizeOptimizationCB
.SaveValue();
656 aAutoSaveCB
.SaveValue();
657 aAutoSaveEdit
.SaveValue();
658 // aAutoSavePromptBtn.SaveValue();
660 aRelativeFsysCB
.SaveValue();
661 aRelativeInetCB
.SaveValue();
662 aODFVersionLB
.SaveValue();
665 // -----------------------------------------------------------------------
667 IMPL_LINK( SfxSaveTabPage
, AutoClickHdl_Impl
, CheckBox
*, pBox
)
669 if ( pBox
== &aAutoSaveCB
)
671 if ( aAutoSaveCB
.IsChecked() )
673 aAutoSaveEdit
.Enable();
675 // aAutoSavePromptBtn.Enable();
676 aAutoSaveEdit
.GrabFocus();
680 aAutoSaveEdit
.Disable();
682 // aAutoSavePromptBtn.Disable();
687 /* -----------------------------05.04.01 13:10--------------------------------
689 ---------------------------------------------------------------------------*/
690 OUString
lcl_ExtracUIName(const Sequence
<PropertyValue
> rProperties
)
694 const PropertyValue
* pProperties
= rProperties
.getConstArray();
695 for(int nProp
= 0; nProp
< rProperties
.getLength(); nProp
++)
697 if(!pProperties
[nProp
].Name
.compareToAscii("UIName"))
699 pProperties
[nProp
].Value
>>= sRet
;
702 else if(!pProperties
[nProp
].Name
.compareToAscii("Flags"))
704 if ( pProperties
[nProp
].Value
>>= nFlags
)
709 else if(!pProperties
[nProp
].Name
.compareToAscii("Name"))
711 pProperties
[nProp
].Value
>>= sRet
;
716 /* -----------------------------05.04.01 13:37--------------------------------
718 ---------------------------------------------------------------------------*/
719 IMPL_LINK( SfxSaveTabPage
, FilterHdl_Impl
, ListBox
*, pBox
)
721 if(&aDocTypeLB
== pBox
)
723 USHORT nAppPos
= pBox
->GetSelectEntryPos();
724 if ( nAppPos
< APP_COUNT
)
727 const OUString
* pFilters
= pImpl
->aFilterArr
[nAppPos
].getConstArray();
728 if(!pImpl
->aUIFilterArr
[nAppPos
].getLength())
730 pImpl
->aUIFilterArr
[nAppPos
].realloc(pImpl
->aFilterArr
[nAppPos
].getLength());
731 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nAppPos
].getArray();
732 for(int nFilter
= 0; nFilter
< pImpl
->aFilterArr
[nAppPos
].getLength(); nFilter
++)
734 Any aProps
= pImpl
->xFact
->getByName(pFilters
[nFilter
]);
735 Sequence
<PropertyValue
> aProperties
;
736 aProps
>>= aProperties
;
737 pUIFilters
[nFilter
] = lcl_ExtracUIName(aProperties
);
740 const OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nAppPos
].getConstArray();
742 for(int i
= 0; i
< pImpl
->aUIFilterArr
[nAppPos
].getLength(); i
++)
744 USHORT nEntryPos
= aSaveAsLB
.InsertEntry(pUIFilters
[i
]);
745 if ( pImpl
->aODFArr
[nAppPos
][i
] )
746 aSaveAsLB
.SetEntryData( nEntryPos
, (void*)pImpl
);
747 if(pFilters
[i
] == pImpl
->aDefaultArr
[nAppPos
])
748 sSelect
= pUIFilters
[i
];
750 if(sSelect
.getLength())
751 aSaveAsLB
.SelectEntry(sSelect
);
752 aSaveAsFI
.Show(pImpl
->aDefaultReadonlyArr
[nAppPos
]);
753 aSaveAsFT
.Enable(!pImpl
->aDefaultReadonlyArr
[nAppPos
]);
754 aSaveAsLB
.Enable(!pImpl
->aDefaultReadonlyArr
[nAppPos
]);
759 OUString sSelect
= pBox
->GetSelectEntry();
760 USHORT nPos
= aDocTypeLB
.GetSelectEntryPos();
761 const OUString
* pFilters
= pImpl
->aFilterArr
[nPos
].getConstArray();
762 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nPos
].getArray();
763 for(int i
= 0; i
< pImpl
->aUIFilterArr
[nPos
].getLength(); i
++)
764 if(pUIFilters
[i
] == sSelect
)
766 sSelect
= pFilters
[i
];
770 pImpl
->aDefaultArr
[nPos
] = sSelect
;
773 ODFVersionHdl_Impl( &aSaveAsLB
);
777 IMPL_LINK( SfxSaveTabPage
, ODFVersionHdl_Impl
, ListBox
*, EMPTYARG
)
779 long nVersion
= long( aODFVersionLB
.GetEntryData( aODFVersionLB
.GetSelectEntryPos() ) );
780 bool bShown
= SvtSaveOptions::ODFDefaultVersion( nVersion
) == SvtSaveOptions::ODFVER_012
;
783 bool bHasODFFormat
= false;
784 USHORT i
= 0, nCount
= aSaveAsLB
.GetEntryCount();
785 for ( ; i
< nCount
; ++ i
)
787 if ( aSaveAsLB
.GetEntryData(i
) != NULL
)
789 bHasODFFormat
= true;
794 bShown
= !bHasODFFormat
795 || ( aSaveAsLB
.GetEntryData( aSaveAsLB
.GetSelectEntryPos() ) != NULL
);
798 aODFWarningFI
.Show( !bShown
);
799 aODFWarningFT
.Show( !bShown
);