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 <svl/eitem.hxx>
21 #include <svl/intitem.hxx>
23 #include "optsave.hrc"
26 #include "optsave.hxx"
27 #include <dialmgr.hxx>
28 #include <comphelper/processfactory.hxx>
29 #include <unotools/moduleoptions.hxx>
30 #include <unotools/saveopt.hxx>
31 #include <comphelper/sequence.hxx>
32 #include <comphelper/sequenceashashmap.hxx>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/container/XNameContainer.hpp>
35 #include <com/sun/star/container/XContainerQuery.hpp>
36 #include <com/sun/star/container/XEnumeration.hpp>
37 #include <com/sun/star/beans/PropertyValue.hpp>
38 #include <com/sun/star/util/XFlushable.hpp>
39 #include <sfx2/docfilt.hxx>
40 #include <svtools/stdctrl.hxx>
41 #include <vcl/fixed.hxx>
42 #include <unotools/configitem.hxx>
43 #include <unotools/optionsdlg.hxx>
45 #include <vcl/msgbox.hxx>
47 using namespace com::sun::star::uno
;
48 using namespace com::sun::star::util
;
49 using namespace com::sun::star::lang
;
50 using namespace com::sun::star::beans
;
51 using namespace com::sun::star::container
;
52 using namespace comphelper
;
54 #define CFG_PAGE_AND_GROUP OUString("General"), OUString("LoadSave")
58 struct SvxSaveTabPage_Impl
60 Reference
< XNameContainer
> xFact
;
61 Sequence
< OUString
> aFilterArr
[APP_COUNT
];
62 Sequence
< sal_Bool
> aAlienArr
[APP_COUNT
];
63 Sequence
< sal_Bool
> aODFArr
[APP_COUNT
];
64 Sequence
< OUString
> aUIFilterArr
[APP_COUNT
];
65 OUString aDefaultArr
[APP_COUNT
];
66 sal_Bool aDefaultReadonlyArr
[APP_COUNT
];
69 SvxSaveTabPage_Impl();
70 ~SvxSaveTabPage_Impl();
73 SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( false )
77 SvxSaveTabPage_Impl::~SvxSaveTabPage_Impl()
81 // class SvxSaveTabPage --------------------------------------------------
83 SfxSaveTabPage::SfxSaveTabPage( vcl::Window
* pParent
, const SfxItemSet
& rCoreSet
) :
84 SfxTabPage( pParent
, "OptSavePage", "cui/ui/optsavepage.ui", &rCoreSet
),
85 pImpl ( new SvxSaveTabPage_Impl
)
87 get(aLoadUserSettingsCB
, "load_settings");
88 get(aLoadDocPrinterCB
, "load_docprinter");
90 get(aDocInfoCB
, "docinfo");
91 get(aBackupCB
, "backup");
92 get(aAutoSaveCB
, "autosave");
93 get(aAutoSaveEdit
, "autosave_spin");
94 get(aMinuteFT
, "autosave_mins");
95 get(aUserAutoSaveCB
, "userautosave");
96 get(aRelativeFsysCB
, "relative_fsys");
97 get(aRelativeInetCB
, "relative_inet");
99 get(aODFVersionLB
, "odfversion");
100 get(aWarnAlienFormatCB
, "warnalienformat");
101 get(aDocTypeLB
, "doctype");
102 get(aSaveAsFT
, "saveas_label");
103 get(aSaveAsLB
, "saveas");
104 get(aODFWarningFI
, "odfwarning_image");
105 get(aODFWarningFT
, "odfwarning_label");
108 aODFVersionLB
->SetEntryData(0, reinterpret_cast<void*>(2 )); // 1.0/1.1
109 aODFVersionLB
->SetEntryData(1, reinterpret_cast<void*>(4 )); // 1.2
110 aODFVersionLB
->SetEntryData(2, reinterpret_cast<void*>(8 )); // 1.2 Extended (compatibility mode)
111 aODFVersionLB
->SetEntryData(3, reinterpret_cast<void*>(0x7fffffff)); // 1.2 Extended (recommended)
113 aDocTypeLB
->SetEntryData(0, reinterpret_cast<void*>(APP_WRITER
) );
114 aDocTypeLB
->SetEntryData(1, reinterpret_cast<void*>(APP_WRITER_WEB
) );
115 aDocTypeLB
->SetEntryData(2, reinterpret_cast<void*>(APP_WRITER_GLOBAL
));
116 aDocTypeLB
->SetEntryData(3, reinterpret_cast<void*>(APP_CALC
) );
117 aDocTypeLB
->SetEntryData(4, reinterpret_cast<void*>(APP_IMPRESS
) );
118 aDocTypeLB
->SetEntryData(5, reinterpret_cast<void*>(APP_DRAW
) );
119 aDocTypeLB
->SetEntryData(6, reinterpret_cast<void*>(APP_MATH
) );
121 Link
<> aLink
= LINK( this, SfxSaveTabPage
, AutoClickHdl_Impl
);
122 aAutoSaveCB
->SetClickHdl( aLink
);
123 aAutoSaveEdit
->SetMaxTextLen( 2 );
125 SvtModuleOptions aModuleOpt
;
126 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::MATH
) )
128 aSaveAsLB
->RemoveEntry(aSaveAsLB
->GetEntryPos( reinterpret_cast<void*>(APP_MATH
) ));
129 aDocTypeLB
->RemoveEntry(aDocTypeLB
->GetEntryPos( reinterpret_cast<void*>(APP_MATH
) ));
133 pImpl
->aDefaultArr
[APP_MATH
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::MATH
);
134 pImpl
->aDefaultReadonlyArr
[APP_MATH
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::MATH
);
137 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::DRAW
) )
139 aSaveAsLB
->RemoveEntry(aSaveAsLB
->GetEntryPos( reinterpret_cast<void*>(APP_DRAW
) ));
140 aDocTypeLB
->RemoveEntry(aDocTypeLB
->GetEntryPos( reinterpret_cast<void*>(APP_DRAW
) ));
144 pImpl
->aDefaultArr
[APP_DRAW
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::DRAW
);
145 pImpl
->aDefaultReadonlyArr
[APP_DRAW
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::DRAW
);
148 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::IMPRESS
) )
150 aSaveAsLB
->RemoveEntry(aSaveAsLB
->GetEntryPos( reinterpret_cast<void*>(APP_IMPRESS
) ));
151 aDocTypeLB
->RemoveEntry(aDocTypeLB
->GetEntryPos( reinterpret_cast<void*>(APP_IMPRESS
) ));
155 pImpl
->aDefaultArr
[APP_IMPRESS
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::IMPRESS
);
156 pImpl
->aDefaultReadonlyArr
[APP_IMPRESS
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::IMPRESS
);
159 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::CALC
) )
161 aSaveAsLB
->RemoveEntry(aSaveAsLB
->GetEntryPos( reinterpret_cast<void*>(APP_CALC
) ));
162 aDocTypeLB
->RemoveEntry(aDocTypeLB
->GetEntryPos( reinterpret_cast<void*>(APP_CALC
) ));
166 pImpl
->aDefaultArr
[APP_CALC
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::CALC
);
167 pImpl
->aDefaultReadonlyArr
[APP_CALC
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::CALC
);
170 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::WRITER
) )
172 aSaveAsLB
->RemoveEntry(aSaveAsLB
->GetEntryPos( reinterpret_cast<void*>(APP_WRITER
) ));
173 aSaveAsLB
->RemoveEntry(aSaveAsLB
->GetEntryPos( reinterpret_cast<void*>(APP_WRITER_WEB
) ));
174 aSaveAsLB
->RemoveEntry(aSaveAsLB
->GetEntryPos( reinterpret_cast<void*>(APP_WRITER_GLOBAL
) ));
175 aDocTypeLB
->RemoveEntry(aDocTypeLB
->GetEntryPos( reinterpret_cast<void*>(APP_WRITER
) ));
176 aDocTypeLB
->RemoveEntry(aDocTypeLB
->GetEntryPos( reinterpret_cast<void*>(APP_WRITER_WEB
) ));
177 aDocTypeLB
->RemoveEntry(aDocTypeLB
->GetEntryPos( reinterpret_cast<void*>(APP_WRITER_GLOBAL
) ));
181 pImpl
->aDefaultArr
[APP_WRITER
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITER
);
182 pImpl
->aDefaultArr
[APP_WRITER_WEB
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERWEB
);
183 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERGLOBAL
);
184 pImpl
->aDefaultReadonlyArr
[APP_WRITER
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::WRITER
);
185 pImpl
->aDefaultReadonlyArr
[APP_WRITER_WEB
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::WRITERWEB
);
186 pImpl
->aDefaultReadonlyArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::WRITERGLOBAL
);
189 aLink
= LINK( this, SfxSaveTabPage
, ODFVersionHdl_Impl
);
190 aODFVersionLB
->SetSelectHdl( aLink
);
191 aLink
= LINK( this, SfxSaveTabPage
, FilterHdl_Impl
);
192 aDocTypeLB
->SetSelectHdl( aLink
);
193 aSaveAsLB
->SetSelectHdl( aLink
);
195 DetectHiddenControls();
200 SfxSaveTabPage::~SfxSaveTabPage()
205 void SvxSaveTabPage::dispose()
209 aLoadUserSettingsCB
.clear();
210 aLoadDocPrinterCB
.clear();
214 aAutoSaveEdit
.clear();
216 aUserAutoSaveCB
.clear();
217 aRelativeFsysCB
.clear();
218 aRelativeInetCB
.clear();
219 aODFVersionLB
.clear();
220 aWarnAlienFormatCB
.clear();
224 aODFWarningFI
.clear();
225 aODFWarningFT
.clear();
226 SfxTabPage::dispose();
229 VclPtr
<SfxTabPage
> SfxSaveTabPage::Create( vcl::Window
* pParent
,
230 const SfxItemSet
* rAttrSet
)
232 return VclPtr
<SfxSaveTabPage
>::Create( pParent
, *rAttrSet
);
235 void SfxSaveTabPage::DetectHiddenControls()
237 SvtOptionsDialogOptions aOptionsDlgOpt
;
239 if ( aOptionsDlgOpt
.IsOptionHidden( "Backup", CFG_PAGE_AND_GROUP
) )
241 // hide controls of "Backup"
245 if ( aOptionsDlgOpt
.IsOptionHidden( "AutoSave", CFG_PAGE_AND_GROUP
) )
247 // hide controls of "AutoSave"
249 aAutoSaveEdit
->Hide();
253 if ( aOptionsDlgOpt
.IsOptionHidden( "UserAutoSave", CFG_PAGE_AND_GROUP
) )
255 // hide controls of "UserAutoSave"
256 aUserAutoSaveCB
->Hide();
261 bool SfxSaveTabPage::FillItemSet( SfxItemSet
* rSet
)
263 bool bModified
= false;
264 SvtSaveOptions aSaveOpt
;
265 if(aLoadUserSettingsCB
->IsValueChangedFromSaved())
267 aSaveOpt
.SetLoadUserSettings(aLoadUserSettingsCB
->IsChecked());
270 if ( aLoadDocPrinterCB
->IsValueChangedFromSaved() )
271 aSaveOpt
.SetLoadDocumentPrinter( aLoadDocPrinterCB
->IsChecked() );
273 if ( aODFVersionLB
->IsValueChangedFromSaved() )
275 sal_IntPtr nVersion
= sal_IntPtr( aODFVersionLB
->GetSelectEntryData() );
276 aSaveOpt
.SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion
) );
279 if ( aDocInfoCB
->IsValueChangedFromSaved() )
281 rSet
->Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO
),
282 aDocInfoCB
->IsChecked() ) );
286 if ( aBackupCB
->IsEnabled() && aBackupCB
->IsValueChangedFromSaved() )
288 rSet
->Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP
),
289 aBackupCB
->IsChecked() ) );
293 if ( aAutoSaveCB
->IsValueChangedFromSaved() )
295 rSet
->Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE
),
296 aAutoSaveCB
->IsChecked() ) );
299 if ( aWarnAlienFormatCB
->IsValueChangedFromSaved() )
301 rSet
->Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT
),
302 aWarnAlienFormatCB
->IsChecked() ) );
306 if ( aAutoSaveEdit
->IsValueChangedFromSaved() )
308 rSet
->Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE
),
309 (sal_uInt16
)aAutoSaveEdit
->GetValue() ) );
313 if ( aUserAutoSaveCB
->IsValueChangedFromSaved() )
315 rSet
->Put( SfxBoolItem( GetWhich( SID_ATTR_USERAUTOSAVE
),
316 aUserAutoSaveCB
->IsChecked() ) );
320 if ( aRelativeFsysCB
->IsValueChangedFromSaved() )
322 rSet
->Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS
),
323 aRelativeFsysCB
->IsChecked() ) );
327 if ( aRelativeInetCB
->IsValueChangedFromSaved() )
329 rSet
->Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET
),
330 aRelativeInetCB
->IsChecked() ) );
334 SvtModuleOptions aModuleOpt
;
335 if(!pImpl
->aDefaultArr
[APP_MATH
].isEmpty() &&
336 pImpl
->aDefaultArr
[APP_MATH
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::MATH
))
337 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::MATH
, pImpl
->aDefaultArr
[APP_MATH
]);
339 if( !pImpl
->aDefaultArr
[APP_DRAW
].isEmpty() &&
340 pImpl
->aDefaultArr
[APP_DRAW
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::DRAW
))
341 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::DRAW
, pImpl
->aDefaultArr
[APP_DRAW
]);
343 if(!pImpl
->aDefaultArr
[APP_IMPRESS
].isEmpty() &&
344 pImpl
->aDefaultArr
[APP_IMPRESS
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::IMPRESS
))
345 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::IMPRESS
, pImpl
->aDefaultArr
[APP_IMPRESS
]);
347 if(!pImpl
->aDefaultArr
[APP_CALC
].isEmpty() &&
348 pImpl
->aDefaultArr
[APP_CALC
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::CALC
))
349 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::CALC
, pImpl
->aDefaultArr
[APP_CALC
]);
351 if(!pImpl
->aDefaultArr
[APP_WRITER
].isEmpty() &&
352 pImpl
->aDefaultArr
[APP_WRITER
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITER
))
353 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITER
, pImpl
->aDefaultArr
[APP_WRITER
]);
355 if(!pImpl
->aDefaultArr
[APP_WRITER_WEB
].isEmpty() &&
356 pImpl
->aDefaultArr
[APP_WRITER_WEB
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERWEB
))
357 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERWEB
, pImpl
->aDefaultArr
[APP_WRITER_WEB
]);
359 if(!pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
].isEmpty() &&
360 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERGLOBAL
))
361 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERGLOBAL
, pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
]);
368 bool isODFFormat( const OUString
& sFilter
)
370 static const char* aODFFormats
[] =
375 "writerglobal8_writer",
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 sal_IntPtr nData
= reinterpret_cast<sal_IntPtr
>(aDocTypeLB
->GetEntryData(n
));
426 sCommand
= "matchByDocumentService=%1:iflags=" +
427 OUString::number(static_cast<int>(SfxFilterFlags::IMPORT
|SfxFilterFlags::EXPORT
)) +
429 OUString::number(static_cast<int>(SfxFilterFlags::NOTINFILEDLG
)) +
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 sCommand
= sCommand
.replaceFirst("%1", sReplace
);
444 Reference
< XEnumeration
> xList
= xQuery
->createSubSetEnumerationByQuery(sCommand
);
445 std::vector
< OUString
> lList
;
446 std::vector
< sal_Bool
> lAlienList
;
447 std::vector
< sal_Bool
> lODFList
;
448 while(xList
->hasMoreElements())
450 SequenceAsHashMap
aFilter(xList
->nextElement());
451 OUString sFilter
= aFilter
.getUnpackedValueOrDefault("Name",OUString());
452 if (!sFilter
.isEmpty())
454 SfxFilterFlags nFlags
= static_cast<SfxFilterFlags
>(aFilter
.getUnpackedValueOrDefault("Flags",sal_Int32()));
455 lList
.push_back(sFilter
);
456 lAlienList
.push_back(bool(nFlags
& SfxFilterFlags::ALIEN
));
457 lODFList
.push_back( isODFFormat( sFilter
) );
460 pImpl
->aFilterArr
[nData
] = comphelper::containerToSequence(lList
);
461 pImpl
->aAlienArr
[nData
] = comphelper::containerToSequence(lAlienList
);
462 pImpl
->aODFArr
[nData
] = comphelper::containerToSequence(lODFList
);
465 aDocTypeLB
->SelectEntryPos(0);
466 FilterHdl_Impl(aDocTypeLB
);
473 "exception in FilterFactory access: " + e
.Message
,
474 RTL_TEXTENCODING_UTF8
).
478 pImpl
->bInitialized
= true;
481 aDocInfoCB
->Check(aSaveOpt
.IsDocInfoSave());
483 aBackupCB
->Check(aSaveOpt
.IsBackup());
484 bool bBackupRO
= aSaveOpt
.IsReadOnly(SvtSaveOptions::E_BACKUP
);
485 aBackupCB
->Enable(!bBackupRO
);
487 aAutoSaveCB
->Check(aSaveOpt
.IsAutoSave());
488 aUserAutoSaveCB
->Check(aSaveOpt
.IsUserAutoSave());
489 aWarnAlienFormatCB
->Check(aSaveOpt
.IsWarnAlienFormat());
490 aWarnAlienFormatCB
->Enable(!aSaveOpt
.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT
));
492 aAutoSaveEdit
->SetValue( aSaveOpt
.GetAutoSaveTime() );
495 aRelativeFsysCB
->Check( aSaveOpt
.IsSaveRelFSys() );
497 aRelativeInetCB
->Check( aSaveOpt
.IsSaveRelINet() );
499 void* pDefaultVersion
= reinterpret_cast<void*>( aSaveOpt
.GetODFDefaultVersion() );
500 aODFVersionLB
->SelectEntryPos( aODFVersionLB
->GetEntryPos( pDefaultVersion
) );
502 AutoClickHdl_Impl( aAutoSaveCB
);
503 ODFVersionHdl_Impl( aODFVersionLB
);
505 aDocInfoCB
->SaveValue();
506 aBackupCB
->SaveValue();
507 aWarnAlienFormatCB
->SaveValue();
508 aAutoSaveCB
->SaveValue();
509 aAutoSaveEdit
->SaveValue();
511 aUserAutoSaveCB
->SaveValue();
513 aRelativeFsysCB
->SaveValue();
514 aRelativeInetCB
->SaveValue();
515 aODFVersionLB
->SaveValue();
520 IMPL_LINK( SfxSaveTabPage
, AutoClickHdl_Impl
, CheckBox
*, pBox
)
522 if ( pBox
== aAutoSaveCB
)
524 if ( aAutoSaveCB
->IsChecked() )
526 aAutoSaveEdit
->Enable();
528 aUserAutoSaveCB
->Enable();
532 aAutoSaveEdit
->Disable();
533 aMinuteFT
->Disable();
534 aUserAutoSaveCB
->Disable();
540 static OUString
lcl_ExtracUIName(const Sequence
<PropertyValue
> &rProperties
)
543 const PropertyValue
* pPropVal
= rProperties
.getConstArray();
544 const PropertyValue
* const pEnd
= pPropVal
+ rProperties
.getLength();
545 for( ; pPropVal
!= pEnd
; pPropVal
++ )
547 const OUString
&rName
= pPropVal
->Name
;
548 if (rName
== "UIName")
551 if ( ( pPropVal
->Value
>>= sUIName
) && sUIName
.getLength() )
554 else if (rName
== "Name")
556 pPropVal
->Value
>>= sName
;
560 OSL_ENSURE( false, "Filter without UIName!" );
565 IMPL_LINK( SfxSaveTabPage
, FilterHdl_Impl
, ListBox
*, pBox
)
567 sal_uInt16 nCurPos
= aDocTypeLB
->GetSelectEntryPos();
569 sal_IntPtr nData
= -1;
570 if(nCurPos
< APP_COUNT
)
571 nData
= reinterpret_cast<sal_IntPtr
>( aDocTypeLB
->GetEntryData(nCurPos
) );
573 if ( nData
>= 0 && nData
< APP_COUNT
)
575 if(aDocTypeLB
== pBox
)
578 const OUString
* pFilters
= pImpl
->aFilterArr
[nData
].getConstArray();
579 if(!pImpl
->aUIFilterArr
[nData
].getLength())
581 pImpl
->aUIFilterArr
[nData
].realloc(pImpl
->aFilterArr
[nData
].getLength());
582 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nData
].getArray();
583 for(int nFilter
= 0; nFilter
< pImpl
->aFilterArr
[nData
].getLength(); nFilter
++)
585 Any aProps
= pImpl
->xFact
->getByName(pFilters
[nFilter
]);
586 Sequence
<PropertyValue
> aProperties
;
587 aProps
>>= aProperties
;
588 pUIFilters
[nFilter
] = lcl_ExtracUIName(aProperties
);
591 const OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nData
].getConstArray();
593 for(int i
= 0; i
< pImpl
->aUIFilterArr
[nData
].getLength(); i
++)
595 sal_uInt16 nEntryPos
= aSaveAsLB
->InsertEntry(pUIFilters
[i
]);
596 if ( pImpl
->aODFArr
[nData
][i
] )
597 aSaveAsLB
->SetEntryData( nEntryPos
, (void*)pImpl
);
598 if(pFilters
[i
] == pImpl
->aDefaultArr
[nData
])
599 sSelect
= pUIFilters
[i
];
601 if(!sSelect
.isEmpty())
603 aSaveAsLB
->SelectEntry(sSelect
);
606 aSaveAsFT
->Enable(!pImpl
->aDefaultReadonlyArr
[nData
]);
607 aSaveAsLB
->Enable(!pImpl
->aDefaultReadonlyArr
[nData
]);
611 OUString sSelect
= pBox
->GetSelectEntry();
612 const OUString
* pFilters
= pImpl
->aFilterArr
[nData
].getConstArray();
613 OUString
* pUIFilters
= pImpl
->aUIFilterArr
[nData
].getArray();
614 for(int i
= 0; i
< pImpl
->aUIFilterArr
[nData
].getLength(); i
++)
615 if(pUIFilters
[i
] == sSelect
)
617 sSelect
= pFilters
[i
];
621 pImpl
->aDefaultArr
[nData
] = sSelect
;
625 ODFVersionHdl_Impl( aSaveAsLB
);
629 IMPL_LINK_NOARG(SfxSaveTabPage
, ODFVersionHdl_Impl
)
631 sal_IntPtr nVersion
= sal_IntPtr( aODFVersionLB
->GetSelectEntryData() );
632 bool bShown
= SvtSaveOptions::ODFDefaultVersion( nVersion
) != SvtSaveOptions::ODFVER_LATEST
;
635 bool bHasODFFormat
= false;
636 sal_uInt16 i
= 0, nCount
= aSaveAsLB
->GetEntryCount();
637 for ( ; i
< nCount
; ++ i
)
639 if ( aSaveAsLB
->GetEntryData(i
) != NULL
)
641 bHasODFFormat
= true;
646 bShown
= !bHasODFFormat
647 || ( aSaveAsLB
->GetSelectEntryData() != NULL
);
650 aODFWarningFI
->Show( bShown
);
651 aODFWarningFT
->Show( bShown
);
656 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */