Bump version to 4.3-4
[LibreOffice.git] / cui / source / options / optsave.cxx
blob59b95b50a8df795886282355ff9675ce30ec6312
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
24 #include "optsave.hrc"
25 #include <cuires.hrc>
27 #include "optsave.hxx"
28 #include <dialmgr.hxx>
29 #include <comphelper/processfactory.hxx>
30 #include <unotools/moduleoptions.hxx>
31 #include <unotools/saveopt.hxx>
32 #include <comphelper/sequenceasvector.hxx>
33 #include <comphelper/sequenceashashmap.hxx>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/container/XNameContainer.hpp>
36 #include <com/sun/star/container/XContainerQuery.hpp>
37 #include <com/sun/star/container/XEnumeration.hpp>
38 #include <com/sun/star/beans/PropertyValue.hpp>
39 #include <com/sun/star/util/XFlushable.hpp>
40 #include <sfx2/docfilt.hxx>
41 #include <svtools/stdctrl.hxx>
42 #include <vcl/fixed.hxx>
43 #include <unotools/configitem.hxx>
44 #include <unotools/optionsdlg.hxx>
46 #include <vcl/msgbox.hxx>
48 using namespace com::sun::star::uno;
49 using namespace com::sun::star::util;
50 using namespace com::sun::star::lang;
51 using namespace com::sun::star::beans;
52 using namespace com::sun::star::container;
53 using namespace comphelper;
55 #define CFG_PAGE_AND_GROUP OUString("General"), OUString("LoadSave")
59 struct SvxSaveTabPage_Impl
61 Reference< XNameContainer > xFact;
62 Sequence< OUString > aFilterArr[APP_COUNT];
63 Sequence< sal_Bool > aAlienArr[APP_COUNT];
64 Sequence< sal_Bool > aODFArr[APP_COUNT];
65 Sequence< OUString > aUIFilterArr[APP_COUNT];
66 OUString aDefaultArr[APP_COUNT];
67 sal_Bool aDefaultReadonlyArr[APP_COUNT];
68 bool bInitialized;
70 SvxSaveTabPage_Impl();
71 ~SvxSaveTabPage_Impl();
74 SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( false )
78 SvxSaveTabPage_Impl::~SvxSaveTabPage_Impl()
82 // class SvxSaveTabPage --------------------------------------------------
84 SfxSaveTabPage::SfxSaveTabPage( Window* pParent, const SfxItemSet& rCoreSet ) :
85 SfxTabPage( pParent, "OptSavePage", "cui/ui/optsavepage.ui", rCoreSet ),
86 pImpl ( new SvxSaveTabPage_Impl )
88 get(aLoadUserSettingsCB, "load_settings");
89 get(aLoadDocPrinterCB, "load_docprinter");
91 get(aDocInfoCB, "docinfo");
92 get(aBackupCB, "backup");
93 get(aAutoSaveCB, "autosave");
94 get(aAutoSaveEdit, "autosave_spin");
95 get(aMinuteFT, "autosave_mins");
96 get(aUserAutoSaveCB, "userautosave");
97 get(aRelativeFsysCB, "relative_fsys");
98 get(aRelativeInetCB, "relative_inet");
100 get(aODFVersionLB, "odfversion");
101 get(aWarnAlienFormatCB, "warnalienformat");
102 get(aDocTypeLB, "doctype");
103 get(aSaveAsFT, "saveas_label");
104 get(aSaveAsLB, "saveas");
105 get(aODFWarningFI, "odfwarning_image");
106 get(aODFWarningFT, "odfwarning_label");
109 aODFVersionLB->SetEntryData(0, (void*)2 ); // 1.0/1.1
110 aODFVersionLB->SetEntryData(1, (void*)4 ); // 1.2
111 aODFVersionLB->SetEntryData(2, (void*)8 ); // 1.2 Extended (compat mode)
112 aODFVersionLB->SetEntryData(3, (void*)0x7fffffff); // 1.2 Extended (recommended)
114 aDocTypeLB->SetEntryData(0, (void*)APP_WRITER );
115 aDocTypeLB->SetEntryData(1, (void*)APP_WRITER_WEB );
116 aDocTypeLB->SetEntryData(2, (void*)APP_WRITER_GLOBAL);
117 aDocTypeLB->SetEntryData(3, (void*)APP_CALC );
118 aDocTypeLB->SetEntryData(4, (void*)APP_IMPRESS );
119 aDocTypeLB->SetEntryData(5, (void*)APP_DRAW );
120 aDocTypeLB->SetEntryData(6, (void*)APP_MATH );
122 Link aLink = LINK( this, SfxSaveTabPage, AutoClickHdl_Impl );
123 aAutoSaveCB->SetClickHdl( aLink );
124 aAutoSaveEdit->SetMaxTextLen( 2 );
126 SvtModuleOptions aModuleOpt;
127 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
129 aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_MATH ));
130 aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_MATH ));
132 else
134 pImpl->aDefaultArr[APP_MATH] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH);
135 pImpl->aDefaultReadonlyArr[APP_MATH] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_MATH);
138 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
140 aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_DRAW ));
141 aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_DRAW ));
143 else
145 pImpl->aDefaultArr[APP_DRAW] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW);
146 pImpl->aDefaultReadonlyArr[APP_DRAW] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_DRAW);
149 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
151 aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_IMPRESS ));
152 aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_IMPRESS ));
154 else
156 pImpl->aDefaultArr[APP_IMPRESS] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS);
157 pImpl->aDefaultReadonlyArr[APP_IMPRESS] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_IMPRESS);
160 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
162 aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_CALC ));
163 aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_CALC ));
165 else
167 pImpl->aDefaultArr[APP_CALC] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC);
168 pImpl->aDefaultReadonlyArr[APP_CALC] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_CALC);
171 if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
173 aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_WRITER ));
174 aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_WRITER_WEB ));
175 aSaveAsLB->RemoveEntry(aSaveAsLB->GetEntryPos( (void*) APP_WRITER_GLOBAL ));
176 aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_WRITER ));
177 aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_WRITER_WEB ));
178 aDocTypeLB->RemoveEntry(aDocTypeLB->GetEntryPos( (void*) APP_WRITER_GLOBAL ));
180 else
182 pImpl->aDefaultArr[APP_WRITER] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER);
183 pImpl->aDefaultArr[APP_WRITER_WEB] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB);
184 pImpl->aDefaultArr[APP_WRITER_GLOBAL] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL);
185 pImpl->aDefaultReadonlyArr[APP_WRITER] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITER);
186 pImpl->aDefaultReadonlyArr[APP_WRITER_WEB] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERWEB);
187 pImpl->aDefaultReadonlyArr[APP_WRITER_GLOBAL] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_WRITERGLOBAL);
190 aLink = LINK( this, SfxSaveTabPage, ODFVersionHdl_Impl );
191 aODFVersionLB->SetSelectHdl( aLink );
192 aLink = LINK( this, SfxSaveTabPage, FilterHdl_Impl );
193 aDocTypeLB->SetSelectHdl( aLink );
194 aSaveAsLB->SetSelectHdl( aLink );
196 DetectHiddenControls();
201 SfxSaveTabPage::~SfxSaveTabPage()
203 delete pImpl;
208 SfxTabPage* SfxSaveTabPage::Create( Window* pParent,
209 const SfxItemSet& rAttrSet )
211 return ( new SfxSaveTabPage( pParent, rAttrSet ) );
215 void SfxSaveTabPage::DetectHiddenControls()
217 SvtOptionsDialogOptions aOptionsDlgOpt;
219 if ( aOptionsDlgOpt.IsOptionHidden( "Backup", CFG_PAGE_AND_GROUP ) )
221 // hide controls of "Backup"
222 aBackupCB->Hide();
225 if ( aOptionsDlgOpt.IsOptionHidden( "AutoSave", CFG_PAGE_AND_GROUP ) )
227 // hide controls of "AutoSave"
228 aAutoSaveCB->Hide();
229 aAutoSaveEdit->Hide();
230 aMinuteFT->Hide();
233 if ( aOptionsDlgOpt.IsOptionHidden( "UserAutoSave", CFG_PAGE_AND_GROUP ) )
235 // hide controls of "UserAutoSave"
236 aUserAutoSaveCB->Hide();
241 bool SfxSaveTabPage::FillItemSet( SfxItemSet& rSet )
243 bool bModified = false;
244 SvtSaveOptions aSaveOpt;
245 if(aLoadUserSettingsCB->IsValueChangedFromSaved())
247 aSaveOpt.SetLoadUserSettings(aLoadUserSettingsCB->IsChecked());
250 if ( aLoadDocPrinterCB->IsValueChangedFromSaved() )
251 aSaveOpt.SetLoadDocumentPrinter( aLoadDocPrinterCB->IsChecked() );
253 if ( aODFVersionLB->IsValueChangedFromSaved() )
255 sal_IntPtr nVersion = sal_IntPtr( aODFVersionLB->GetEntryData( aODFVersionLB->GetSelectEntryPos() ) );
256 aSaveOpt.SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion ) );
259 if ( aDocInfoCB->IsValueChangedFromSaved() )
261 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO ),
262 aDocInfoCB->IsChecked() ) );
263 bModified |= true;
266 if ( aBackupCB->IsEnabled() && aBackupCB->IsValueChangedFromSaved() )
268 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP ),
269 aBackupCB->IsChecked() ) );
270 bModified |= true;
273 if ( aAutoSaveCB->IsValueChangedFromSaved() )
275 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE ),
276 aAutoSaveCB->IsChecked() ) );
277 bModified |= true;
279 if ( aWarnAlienFormatCB->IsValueChangedFromSaved() )
281 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT ),
282 aWarnAlienFormatCB->IsChecked() ) );
283 bModified |= true;
286 if ( aAutoSaveEdit->IsValueChangedFromSaved() )
288 rSet.Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE ),
289 (sal_uInt16)aAutoSaveEdit->GetValue() ) );
290 bModified |= true;
293 if ( aUserAutoSaveCB->IsValueChangedFromSaved() )
295 rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_USERAUTOSAVE ),
296 aUserAutoSaveCB->IsChecked() ) );
297 bModified |= true;
299 // save relatively
300 if ( aRelativeFsysCB->IsValueChangedFromSaved() )
302 rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS ),
303 aRelativeFsysCB->IsChecked() ) );
304 bModified |= true;
307 if ( aRelativeInetCB->IsValueChangedFromSaved() )
309 rSet.Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET ),
310 aRelativeInetCB->IsChecked() ) );
311 bModified |= true;
314 SvtModuleOptions aModuleOpt;
315 if(!pImpl->aDefaultArr[APP_MATH].isEmpty() &&
316 pImpl->aDefaultArr[APP_MATH] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH))
317 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_MATH, pImpl->aDefaultArr[APP_MATH]);
319 if( !pImpl->aDefaultArr[APP_DRAW].isEmpty() &&
320 pImpl->aDefaultArr[APP_DRAW] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW))
321 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_DRAW, pImpl->aDefaultArr[APP_DRAW]);
323 if(!pImpl->aDefaultArr[APP_IMPRESS].isEmpty() &&
324 pImpl->aDefaultArr[APP_IMPRESS] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS))
325 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS, pImpl->aDefaultArr[APP_IMPRESS]);
327 if(!pImpl->aDefaultArr[APP_CALC].isEmpty() &&
328 pImpl->aDefaultArr[APP_CALC] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC))
329 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_CALC, pImpl->aDefaultArr[APP_CALC]);
331 if(!pImpl->aDefaultArr[APP_WRITER].isEmpty() &&
332 pImpl->aDefaultArr[APP_WRITER] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITER))
333 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITER, pImpl->aDefaultArr[APP_WRITER]);
335 if(!pImpl->aDefaultArr[APP_WRITER_WEB].isEmpty() &&
336 pImpl->aDefaultArr[APP_WRITER_WEB] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB))
337 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERWEB, pImpl->aDefaultArr[APP_WRITER_WEB]);
339 if(!pImpl->aDefaultArr[APP_WRITER_GLOBAL].isEmpty() &&
340 pImpl->aDefaultArr[APP_WRITER_GLOBAL] != aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL))
341 aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::E_WRITERGLOBAL, pImpl->aDefaultArr[APP_WRITER_GLOBAL]);
343 return bModified;
348 bool isODFFormat( const OUString& sFilter )
350 static const char* aODFFormats[] =
352 "writer8",
353 "writer8_template",
354 "writerglobal8",
355 "writerglobal8_writer",
356 "calc8",
357 "calc8_template",
358 "draw8",
359 "draw8_template",
360 "impress8",
361 "impress8_template",
362 "impress8_draw",
363 "chart8",
364 "math8",
365 NULL
368 bool bRet = false;
369 int i = 0;
370 while ( aODFFormats[i] != NULL )
372 if ( sFilter.equalsAscii( aODFFormats[i++] ) )
374 bRet = true;
375 break;
379 return bRet;
382 void SfxSaveTabPage::Reset( const SfxItemSet& )
384 SvtSaveOptions aSaveOpt;
385 aLoadUserSettingsCB->Check(aSaveOpt.IsLoadUserSettings());
386 aLoadUserSettingsCB->SaveValue();
387 aLoadDocPrinterCB->Check( aSaveOpt.IsLoadDocumentPrinter() );
388 aLoadDocPrinterCB->SaveValue();
390 if ( !pImpl->bInitialized )
394 Reference< XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory();
395 pImpl->xFact = Reference<XNameContainer>(
396 xMSF->createInstance("com.sun.star.document.FilterFactory"), UNO_QUERY);
398 DBG_ASSERT(pImpl->xFact.is(), "service com.sun.star.document.FilterFactory unavailable");
399 Reference< XContainerQuery > xQuery(pImpl->xFact, UNO_QUERY);
400 if(xQuery.is())
402 for(sal_uInt16 n = 0; n < aDocTypeLB->GetEntryCount(); n++)
404 sal_IntPtr nData = (sal_IntPtr) aDocTypeLB->GetEntryData(n);
405 OUString sCommand;
406 sCommand = "matchByDocumentService=%1:iflags=" +
407 OUString::number(SFX_FILTER_IMPORT|SFX_FILTER_EXPORT) +
408 ":eflags=" +
409 OUString::number(SFX_FILTER_NOTINFILEDLG) +
410 ":default_first";
411 OUString sReplace;
412 switch(nData)
414 case APP_WRITER : sReplace = "com.sun.star.text.TextDocument"; break;
415 case APP_WRITER_WEB : sReplace = "com.sun.star.text.WebDocument"; break;
416 case APP_WRITER_GLOBAL : sReplace = "com.sun.star.text.GlobalDocument"; break;
417 case APP_CALC : sReplace = "com.sun.star.sheet.SpreadsheetDocument";break;
418 case APP_IMPRESS : sReplace = "com.sun.star.presentation.PresentationDocument";break;
419 case APP_DRAW : sReplace = "com.sun.star.drawing.DrawingDocument";break;
420 case APP_MATH : sReplace = "com.sun.star.formula.FormulaProperties";break;
421 default: OSL_FAIL("illegal user data");
423 sCommand = sCommand.replaceFirst("%1", sReplace);
424 Reference< XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
425 SequenceAsVector< OUString > lList;
426 SequenceAsVector< sal_Bool > lAlienList;
427 SequenceAsVector< sal_Bool > lODFList;
428 while(xList->hasMoreElements())
430 SequenceAsHashMap aFilter(xList->nextElement());
431 OUString sFilter = aFilter.getUnpackedValueOrDefault("Name",OUString());
432 if (!sFilter.isEmpty())
434 sal_Int32 nFlags = aFilter.getUnpackedValueOrDefault("Flags",sal_Int32());
435 lList.push_back(sFilter);
436 lAlienList.push_back(0 != (nFlags & SFX_FILTER_ALIEN));
437 lODFList.push_back( isODFFormat( sFilter ) );
440 pImpl->aFilterArr[nData] = lList.getAsConstList();
441 pImpl->aAlienArr[nData] = lAlienList.getAsConstList();
442 pImpl->aODFArr[nData] = lODFList.getAsConstList();
445 aDocTypeLB->SelectEntryPos(0);
446 FilterHdl_Impl(aDocTypeLB);
448 catch(Exception& e)
450 (void) e;
451 OSL_FAIL(
452 OUStringToOString(
453 (OUString(
454 "exception in FilterFactory access: ") +
455 e.Message),
456 RTL_TEXTENCODING_UTF8).
457 getStr());
460 pImpl->bInitialized = true;
463 aDocInfoCB->Check(aSaveOpt.IsDocInfoSave());
465 aBackupCB->Check(aSaveOpt.IsBackup());
466 bool bBackupRO = aSaveOpt.IsReadOnly(SvtSaveOptions::E_BACKUP);
467 aBackupCB->Enable(!bBackupRO);
469 aAutoSaveCB->Check(aSaveOpt.IsAutoSave());
470 aUserAutoSaveCB->Check(aSaveOpt.IsUserAutoSave());
471 aWarnAlienFormatCB->Check(aSaveOpt.IsWarnAlienFormat());
472 aWarnAlienFormatCB->Enable(!aSaveOpt.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT));
474 aAutoSaveEdit->SetValue( aSaveOpt.GetAutoSaveTime() );
476 // save relatively
477 aRelativeFsysCB->Check( aSaveOpt.IsSaveRelFSys() );
479 aRelativeInetCB->Check( aSaveOpt.IsSaveRelINet() );
481 void* pDefaultVersion = (void*)sal_IntPtr( aSaveOpt.GetODFDefaultVersion() );
482 aODFVersionLB->SelectEntryPos( aODFVersionLB->GetEntryPos( pDefaultVersion ) );
484 AutoClickHdl_Impl( aAutoSaveCB );
485 ODFVersionHdl_Impl( aODFVersionLB );
487 aDocInfoCB->SaveValue();
488 aBackupCB->SaveValue();
489 aWarnAlienFormatCB->SaveValue();
490 aAutoSaveCB->SaveValue();
491 aAutoSaveEdit->SaveValue();
493 aUserAutoSaveCB->SaveValue();
495 aRelativeFsysCB->SaveValue();
496 aRelativeInetCB->SaveValue();
497 aODFVersionLB->SaveValue();
502 IMPL_LINK( SfxSaveTabPage, AutoClickHdl_Impl, CheckBox *, pBox )
504 if ( pBox == aAutoSaveCB )
506 if ( aAutoSaveCB->IsChecked() )
508 aAutoSaveEdit->Enable();
509 aMinuteFT->Enable();
510 aUserAutoSaveCB->Enable();
512 else
514 aAutoSaveEdit->Disable();
515 aMinuteFT->Disable();
516 aUserAutoSaveCB->Disable();
519 return 0;
522 static OUString lcl_ExtracUIName(const Sequence<PropertyValue> &rProperties)
524 OUString sName;
525 const PropertyValue* pPropVal = rProperties.getConstArray();
526 const PropertyValue* const pEnd = pPropVal + rProperties.getLength();
527 for( ; pPropVal != pEnd; pPropVal++ )
529 const OUString &rName = pPropVal->Name;
530 if (rName == "UIName")
532 OUString sUIName;
533 if ( ( pPropVal->Value >>= sUIName ) && sUIName.getLength() )
534 return sUIName;
536 else if (rName == "Name")
538 pPropVal->Value >>= sName;
542 OSL_ENSURE( false, "Filter without UIName!" );
544 return sName;
547 IMPL_LINK( SfxSaveTabPage, FilterHdl_Impl, ListBox *, pBox )
549 sal_uInt16 nCurPos = aDocTypeLB->GetSelectEntryPos();
551 sal_IntPtr nData = -1;
552 if(nCurPos < APP_COUNT)
553 nData = (sal_IntPtr) aDocTypeLB->GetEntryData(nCurPos);
555 if ( nData >= 0 && nData < APP_COUNT )
557 if(aDocTypeLB == pBox)
559 aSaveAsLB->Clear();
560 const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray();
561 if(!pImpl->aUIFilterArr[nData].getLength())
563 pImpl->aUIFilterArr[nData].realloc(pImpl->aFilterArr[nData].getLength());
564 OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray();
565 for(int nFilter = 0; nFilter < pImpl->aFilterArr[nData].getLength(); nFilter++)
567 Any aProps = pImpl->xFact->getByName(pFilters[nFilter]);
568 Sequence<PropertyValue> aProperties;
569 aProps >>= aProperties;
570 pUIFilters[nFilter] = lcl_ExtracUIName(aProperties);
573 const OUString* pUIFilters = pImpl->aUIFilterArr[nData].getConstArray();
574 OUString sSelect;
575 for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++)
577 sal_uInt16 nEntryPos = aSaveAsLB->InsertEntry(pUIFilters[i]);
578 if ( pImpl->aODFArr[nData][i] )
579 aSaveAsLB->SetEntryData( nEntryPos, (void*)pImpl );
580 if(pFilters[i] == pImpl->aDefaultArr[nData])
581 sSelect = pUIFilters[i];
583 if(!sSelect.isEmpty())
585 aSaveAsLB->SelectEntry(sSelect);
588 aSaveAsFT->Enable(!pImpl->aDefaultReadonlyArr[nData]);
589 aSaveAsLB->Enable(!pImpl->aDefaultReadonlyArr[nData]);
591 else
593 OUString sSelect = pBox->GetSelectEntry();
594 const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray();
595 OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray();
596 for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++)
597 if(pUIFilters[i] == sSelect)
599 sSelect = pFilters[i];
600 break;
603 pImpl->aDefaultArr[nData] = sSelect;
607 ODFVersionHdl_Impl( aSaveAsLB );
608 return 0;
611 IMPL_LINK_NOARG(SfxSaveTabPage, ODFVersionHdl_Impl)
613 sal_IntPtr nVersion = sal_IntPtr( aODFVersionLB->GetEntryData( aODFVersionLB->GetSelectEntryPos() ) );
614 bool bShown = SvtSaveOptions::ODFDefaultVersion( nVersion ) != SvtSaveOptions::ODFVER_LATEST;
615 if ( bShown )
617 bool bHasODFFormat = false;
618 sal_uInt16 i = 0, nCount = aSaveAsLB->GetEntryCount();
619 for ( ; i < nCount; ++ i )
621 if ( aSaveAsLB->GetEntryData(i) != NULL )
623 bHasODFFormat = true;
624 break;
628 bShown = !bHasODFFormat
629 || ( aSaveAsLB->GetEntryData( aSaveAsLB->GetSelectEntryPos() ) != NULL );
632 aODFWarningFI->Show( bShown );
633 aODFWarningFT->Show( bShown );
635 return 0;
638 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */