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 <sal/config.h>
22 #include <string_view>
24 #include <o3tl/string_view.hxx>
25 #include <svl/eitem.hxx>
26 #include <svl/intitem.hxx>
27 #include "optsave.hxx"
28 #include <treeopt.hxx>
29 #include <officecfg/Office/Common.hxx>
30 #include <comphelper/processfactory.hxx>
31 #include <unotools/moduleoptions.hxx>
32 #include <unotools/saveopt.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 <sfx2/sfxsids.hrc>
40 #include <sfx2/docfilt.hxx>
41 #include <svtools/restartdialog.hxx>
42 #include <unotools/optionsdlg.hxx>
43 #include <osl/diagnose.h>
44 #include <comphelper/diagnose_ex.hxx>
45 #include <officecfg/Office/Recovery.hxx>
46 #include <unotools/confignode.hxx>
48 #include <sfx2/fcontnr.hxx>
50 using namespace com::sun::star::uno
;
51 using namespace com::sun::star::util
;
52 using namespace com::sun::star::lang
;
53 using namespace com::sun::star::beans
;
54 using namespace com::sun::star::container
;
55 using namespace comphelper
;
57 #define CFG_PAGE_AND_GROUP u"General", u"LoadSave"
60 struct SvxSaveTabPage_Impl
62 Reference
< XNameContainer
> xFact
;
63 std::vector
< OUString
> aFilterArr
[APP_COUNT
];
64 std::vector
< bool > aODFArr
[APP_COUNT
];
65 std::vector
< OUString
> aUIFilterArr
[APP_COUNT
];
66 OUString aDefaultArr
[APP_COUNT
];
67 bool aDefaultReadonlyArr
[APP_COUNT
];
70 SvxSaveTabPage_Impl();
73 SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( false )
77 // class SvxSaveTabPage --------------------------------------------------
79 SvxSaveTabPage::SvxSaveTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rCoreSet
)
80 : SfxTabPage( pPage
, pController
, "cui/ui/optsavepage.ui", "OptSavePage", &rCoreSet
)
81 , pImpl(new SvxSaveTabPage_Impl
)
82 , m_xLoadViewPosAnyUserCB(m_xBuilder
->weld_check_button("load_anyuser"))
83 , m_xLoadUserSettingsCB(m_xBuilder
->weld_check_button("load_settings"))
84 , m_xLoadDocPrinterCB(m_xBuilder
->weld_check_button("load_docprinter"))
85 , m_xDocInfoCB(m_xBuilder
->weld_check_button("docinfo"))
86 , m_xBackupCB(m_xBuilder
->weld_check_button("backup"))
87 , m_xAutoSaveCB(m_xBuilder
->weld_check_button("autosave"))
88 , m_xAutoSaveEdit(m_xBuilder
->weld_spin_button("autosave_spin"))
89 , m_xMinuteFT(m_xBuilder
->weld_label("autosave_mins"))
90 , m_xUserAutoSaveCB(m_xBuilder
->weld_check_button("userautosave"))
91 , m_xRelativeFsysCB(m_xBuilder
->weld_check_button("relative_fsys"))
92 , m_xRelativeInetCB(m_xBuilder
->weld_check_button("relative_inet"))
93 , m_xODFVersionLB(m_xBuilder
->weld_combo_box("odfversion"))
94 , m_xWarnAlienFormatCB(m_xBuilder
->weld_check_button("warnalienformat"))
95 , m_xDocTypeLB(m_xBuilder
->weld_combo_box("doctype"))
96 , m_xSaveAsFT(m_xBuilder
->weld_label("saveas_label"))
97 , m_xSaveAsLB(m_xBuilder
->weld_combo_box("saveas"))
98 , m_xODFWarningFI(m_xBuilder
->weld_widget("odfwarning_image"))
99 , m_xODFWarningFT(m_xBuilder
->weld_label("odfwarning_label"))
101 m_xAutoSaveEdit
->set_max_length(2);
103 m_xODFVersionLB
->set_id(0, OUString::number(SvtSaveOptions::ODFVER_011
)); // 1.0/1.1
104 m_xODFVersionLB
->set_id(1, OUString::number(SvtSaveOptions::ODFVER_012
)); // 1.2
105 m_xODFVersionLB
->set_id(2, OUString::number(SvtSaveOptions::ODFVER_012_EXT_COMPAT
)); // 1.2 Extended (compatibility mode)
106 m_xODFVersionLB
->set_id(3, OUString::number(SvtSaveOptions::ODFVER_012_EXTENDED
)); // 1.2 Extended
107 m_xODFVersionLB
->set_id(4, OUString::number(SvtSaveOptions::ODFVER_013
)); // 1.3
108 m_xODFVersionLB
->set_id(5, OUString::number(SvtSaveOptions::ODFVER_LATEST
)); // 1.3 Extended (recommended)
110 auto aFilterClassesNode
= utl::OConfigurationTreeRoot::createWithComponentContext(
111 comphelper::getProcessComponentContext(),
112 "org.openoffice.Office.UI/FilterClassification/GlobalFilters/Classes",
114 utl::OConfigurationTreeRoot::CM_READONLY
117 m_xDocTypeLB
->append(OUString::number(APP_WRITER
), aFilterClassesNode
.getNodeValue("com.sun.star.text.TextDocument/DisplayName").get
<OUString
>());
118 m_xDocTypeLB
->append(OUString::number(APP_WRITER_WEB
), aFilterClassesNode
.getNodeValue("com.sun.star.text.WebDocument/DisplayName").get
<OUString
>());
119 m_xDocTypeLB
->append(OUString::number(APP_WRITER_GLOBAL
), aFilterClassesNode
.getNodeValue("com.sun.star.text.GlobalDocument/DisplayName").get
<OUString
>());
120 m_xDocTypeLB
->append(OUString::number(APP_CALC
), aFilterClassesNode
.getNodeValue("com.sun.star.sheet.SpreadsheetDocument/DisplayName").get
<OUString
>());
121 m_xDocTypeLB
->append(OUString::number(APP_IMPRESS
), aFilterClassesNode
.getNodeValue("com.sun.star.presentation.PresentationDocument/DisplayName").get
<OUString
>());
122 m_xDocTypeLB
->append(OUString::number(APP_DRAW
), aFilterClassesNode
.getNodeValue("com.sun.star.drawing.DrawingDocument/DisplayName").get
<OUString
>());
123 m_xDocTypeLB
->append(OUString::number(APP_MATH
), aFilterClassesNode
.getNodeValue("com.sun.star.formula.FormulaProperties/DisplayName").get
<OUString
>());
125 m_xAutoSaveCB
->connect_toggled( LINK( this, SvxSaveTabPage
, AutoClickHdl_Impl
) );
127 SvtModuleOptions aModuleOpt
;
128 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::MATH
) )
130 m_xSaveAsLB
->remove_id(OUString::number(APP_MATH
));
131 m_xDocTypeLB
->remove_id(OUString::number(APP_MATH
));
135 pImpl
->aDefaultArr
[APP_MATH
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::MATH
);
136 pImpl
->aDefaultReadonlyArr
[APP_MATH
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::MATH
);
139 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::DRAW
) )
141 m_xSaveAsLB
->remove_id(OUString::number(APP_DRAW
));
142 m_xDocTypeLB
->remove_id(OUString::number(APP_DRAW
));
146 pImpl
->aDefaultArr
[APP_DRAW
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::DRAW
);
147 pImpl
->aDefaultReadonlyArr
[APP_DRAW
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::DRAW
);
150 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::IMPRESS
) )
152 m_xSaveAsLB
->remove_id(OUString::number(APP_IMPRESS
));
153 m_xDocTypeLB
->remove_id(OUString::number(APP_IMPRESS
));
157 pImpl
->aDefaultArr
[APP_IMPRESS
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::IMPRESS
);
158 pImpl
->aDefaultReadonlyArr
[APP_IMPRESS
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::IMPRESS
);
161 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::CALC
) )
163 m_xSaveAsLB
->remove_id(OUString::number(APP_CALC
));
164 m_xDocTypeLB
->remove_id(OUString::number(APP_CALC
));
168 pImpl
->aDefaultArr
[APP_CALC
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::CALC
);
169 pImpl
->aDefaultReadonlyArr
[APP_CALC
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::CALC
);
172 if ( !aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::WRITER
) )
174 m_xSaveAsLB
->remove_id(OUString::number(APP_WRITER
));
175 m_xSaveAsLB
->remove_id(OUString::number(APP_WRITER_WEB
));
176 m_xSaveAsLB
->remove_id(OUString::number(APP_WRITER_GLOBAL
));
177 m_xDocTypeLB
->remove_id(OUString::number(APP_WRITER
));
178 m_xDocTypeLB
->remove_id(OUString::number(APP_WRITER_WEB
));
179 m_xDocTypeLB
->remove_id(OUString::number(APP_WRITER_GLOBAL
));
183 pImpl
->aDefaultArr
[APP_WRITER
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITER
);
184 pImpl
->aDefaultArr
[APP_WRITER_WEB
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERWEB
);
185 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERGLOBAL
);
186 pImpl
->aDefaultReadonlyArr
[APP_WRITER
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::WRITER
);
187 pImpl
->aDefaultReadonlyArr
[APP_WRITER_WEB
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::WRITERWEB
);
188 pImpl
->aDefaultReadonlyArr
[APP_WRITER_GLOBAL
] = aModuleOpt
.IsDefaultFilterReadonly(SvtModuleOptions::EFactory::WRITERGLOBAL
);
191 Link
<weld::ComboBox
&,void> aLink
= LINK( this, SvxSaveTabPage
, ODFVersionHdl_Impl
);
192 m_xODFVersionLB
->connect_changed( aLink
);
193 aLink
= LINK( this, SvxSaveTabPage
, FilterHdl_Impl
);
194 m_xDocTypeLB
->connect_changed( aLink
);
195 m_xSaveAsLB
->connect_changed( aLink
);
197 DetectHiddenControls();
200 SvxSaveTabPage::~SvxSaveTabPage()
204 std::unique_ptr
<SfxTabPage
> SvxSaveTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
,
205 const SfxItemSet
* rAttrSet
)
207 return std::make_unique
<SvxSaveTabPage
>(pPage
, pController
, *rAttrSet
);
210 void SvxSaveTabPage::DetectHiddenControls()
212 SvtOptionsDialogOptions aOptionsDlgOpt
;
214 if ( aOptionsDlgOpt
.IsOptionHidden( u
"Backup", CFG_PAGE_AND_GROUP
) )
216 // hide controls of "Backup"
220 if ( aOptionsDlgOpt
.IsOptionHidden( u
"AutoSave", CFG_PAGE_AND_GROUP
) )
222 // hide controls of "AutoSave"
223 m_xAutoSaveCB
->hide();
224 m_xAutoSaveEdit
->hide();
228 if ( aOptionsDlgOpt
.IsOptionHidden( u
"UserAutoSave", CFG_PAGE_AND_GROUP
) )
230 // hide controls of "UserAutoSave"
231 m_xUserAutoSaveCB
->hide();
236 bool SvxSaveTabPage::FillItemSet( SfxItemSet
* rSet
)
238 auto xChanges
= comphelper::ConfigurationChanges::create();
239 bool bModified
= false, bRequestRestart
= false;
240 if (m_xLoadViewPosAnyUserCB
->get_state_changed_from_saved())
242 officecfg::Office::Common::Load::ViewPositionForAnyUser::set(m_xLoadViewPosAnyUserCB
->get_active(), xChanges
);
244 if(m_xLoadUserSettingsCB
->get_state_changed_from_saved())
245 officecfg::Office::Common::Load::UserDefinedSettings::set(m_xLoadUserSettingsCB
->get_active(), xChanges
);
247 if ( m_xLoadDocPrinterCB
->get_state_changed_from_saved() )
248 officecfg::Office::Common::Save::Document::LoadPrinter::set(m_xLoadDocPrinterCB
->get_active(), xChanges
);
250 if ( m_xODFVersionLB
->get_value_changed_from_saved() )
252 sal_Int32 nVersion
= m_xODFVersionLB
->get_active_id().toInt32();
253 SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion( nVersion
), xChanges
);
256 if ( m_xDocInfoCB
->get_state_changed_from_saved() )
258 rSet
->Put( SfxBoolItem( SID_ATTR_DOCINFO
,
259 m_xDocInfoCB
->get_active() ) );
263 if ( m_xBackupCB
->get_sensitive() && m_xBackupCB
->get_state_changed_from_saved() )
265 rSet
->Put( SfxBoolItem( SID_ATTR_BACKUP
, m_xBackupCB
->get_active() ) );
269 if ( m_xAutoSaveCB
->get_state_changed_from_saved() )
271 rSet
->Put( SfxBoolItem( SID_ATTR_AUTOSAVE
,
272 m_xAutoSaveCB
->get_active() ) );
273 bModified
= bRequestRestart
= true;
275 if ( m_xWarnAlienFormatCB
->get_state_changed_from_saved() )
277 rSet
->Put( SfxBoolItem( SID_ATTR_WARNALIENFORMAT
,
278 m_xWarnAlienFormatCB
->get_active() ) );
282 if ( m_xAutoSaveEdit
->get_value_changed_from_saved() )
284 rSet
->Put( SfxUInt16Item( SID_ATTR_AUTOSAVEMINUTE
,
285 static_cast<sal_uInt16
>(m_xAutoSaveEdit
->get_value()) ) );
286 bModified
= bRequestRestart
= true;
289 if ( m_xUserAutoSaveCB
->get_state_changed_from_saved() )
291 rSet
->Put( SfxBoolItem( SID_ATTR_USERAUTOSAVE
,
292 m_xUserAutoSaveCB
->get_active() ) );
296 if ( m_xRelativeFsysCB
->get_state_changed_from_saved() )
298 rSet
->Put( SfxBoolItem( SID_SAVEREL_FSYS
,
299 m_xRelativeFsysCB
->get_active() ) );
303 if ( m_xRelativeInetCB
->get_state_changed_from_saved() )
305 rSet
->Put( SfxBoolItem( SID_SAVEREL_INET
,
306 m_xRelativeInetCB
->get_active() ) );
310 SvtModuleOptions aModuleOpt
;
311 if(!pImpl
->aDefaultArr
[APP_MATH
].isEmpty() &&
312 pImpl
->aDefaultArr
[APP_MATH
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::MATH
))
313 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::MATH
, pImpl
->aDefaultArr
[APP_MATH
]);
315 if( !pImpl
->aDefaultArr
[APP_DRAW
].isEmpty() &&
316 pImpl
->aDefaultArr
[APP_DRAW
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::DRAW
))
317 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::DRAW
, pImpl
->aDefaultArr
[APP_DRAW
]);
319 if(!pImpl
->aDefaultArr
[APP_IMPRESS
].isEmpty() &&
320 pImpl
->aDefaultArr
[APP_IMPRESS
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::IMPRESS
))
321 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::IMPRESS
, pImpl
->aDefaultArr
[APP_IMPRESS
]);
323 if(!pImpl
->aDefaultArr
[APP_CALC
].isEmpty() &&
324 pImpl
->aDefaultArr
[APP_CALC
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::CALC
))
325 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::CALC
, pImpl
->aDefaultArr
[APP_CALC
]);
327 if(!pImpl
->aDefaultArr
[APP_WRITER
].isEmpty() &&
328 pImpl
->aDefaultArr
[APP_WRITER
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITER
))
329 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITER
, pImpl
->aDefaultArr
[APP_WRITER
]);
331 if(!pImpl
->aDefaultArr
[APP_WRITER_WEB
].isEmpty() &&
332 pImpl
->aDefaultArr
[APP_WRITER_WEB
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERWEB
))
333 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERWEB
, pImpl
->aDefaultArr
[APP_WRITER_WEB
]);
335 if(!pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
].isEmpty() &&
336 pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
] != aModuleOpt
.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERGLOBAL
))
337 aModuleOpt
.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERGLOBAL
, pImpl
->aDefaultArr
[APP_WRITER_GLOBAL
]);
343 OfaTreeOptionsDialog
* pParentDlg(static_cast<OfaTreeOptionsDialog
*>(GetDialogController()));
345 pParentDlg
->SetNeedsRestart(svtools::RESTART_REASON_SAVE
);
351 static bool isODFFormat( std::u16string_view sFilter
)
353 static const char* aODFFormats
[] =
358 "writerglobal8_writer",
373 while ( aODFFormats
[i
] != nullptr )
375 if ( o3tl::equalsAscii( sFilter
, aODFFormats
[i
++] ) )
385 void SvxSaveTabPage::Reset( const SfxItemSet
* )
387 m_xLoadViewPosAnyUserCB
->set_active(officecfg::Office::Common::Load::ViewPositionForAnyUser::get());
388 m_xLoadViewPosAnyUserCB
->save_state();
389 m_xLoadViewPosAnyUserCB
->set_sensitive(!officecfg::Office::Common::Load::ViewPositionForAnyUser::isReadOnly());
390 m_xLoadUserSettingsCB
->set_active(officecfg::Office::Common::Load::UserDefinedSettings::get());
391 m_xLoadUserSettingsCB
->save_state();
392 m_xLoadUserSettingsCB
->set_sensitive(!officecfg::Office::Common::Load::UserDefinedSettings::isReadOnly());
393 m_xLoadDocPrinterCB
->set_active( officecfg::Office::Common::Save::Document::LoadPrinter::get() );
394 m_xLoadDocPrinterCB
->save_state();
395 m_xLoadDocPrinterCB
->set_sensitive(!officecfg::Office::Common::Save::Document::LoadPrinter::isReadOnly());
397 if ( !pImpl
->bInitialized
)
401 Reference
< XMultiServiceFactory
> xMSF
= comphelper::getProcessServiceFactory();
402 pImpl
->xFact
.set(xMSF
->createInstance("com.sun.star.document.FilterFactory"), UNO_QUERY
);
404 DBG_ASSERT(pImpl
->xFact
.is(), "service com.sun.star.document.FilterFactory unavailable");
405 Reference
< XContainerQuery
> xQuery(pImpl
->xFact
, UNO_QUERY
);
408 for (sal_Int32 n
= 0, nEntryCount
= m_xDocTypeLB
->get_count(); n
< nEntryCount
; ++n
)
410 unsigned int nData
= m_xDocTypeLB
->get_id(n
).toUInt32();
411 OUString sCommand
= "getSortedFilterList():module=%1:iflags=" +
412 OUString::number(static_cast<int>(SfxFilterFlags::IMPORT
|SfxFilterFlags::EXPORT
)) +
414 OUString::number(static_cast<int>(SfxFilterFlags::NOTINFILEDLG
));
418 case APP_WRITER
: sReplace
= "com.sun.star.text.TextDocument"; break;
419 case APP_WRITER_WEB
: sReplace
= "com.sun.star.text.WebDocument"; break;
420 case APP_WRITER_GLOBAL
: sReplace
= "com.sun.star.text.GlobalDocument"; break;
421 case APP_CALC
: sReplace
= "com.sun.star.sheet.SpreadsheetDocument";break;
422 case APP_IMPRESS
: sReplace
= "com.sun.star.presentation.PresentationDocument";break;
423 case APP_DRAW
: sReplace
= "com.sun.star.drawing.DrawingDocument";break;
424 case APP_MATH
: sReplace
= "com.sun.star.formula.FormulaProperties";break;
425 default: SAL_WARN("cui.options", "illegal user data");
427 sCommand
= sCommand
.replaceFirst("%1", sReplace
);
428 Reference
< XEnumeration
> xList
= xQuery
->createSubSetEnumerationByQuery(sCommand
);
429 std::vector
< OUString
> lList
;
430 std::vector
<bool> lODFList
;
431 while(xList
->hasMoreElements())
433 SequenceAsHashMap
aFilter(xList
->nextElement());
434 OUString sFilter
= aFilter
.getUnpackedValueOrDefault("Name",OUString());
435 if (!sFilter
.isEmpty())
437 lList
.push_back(sFilter
);
438 lODFList
.push_back( isODFFormat( sFilter
) );
441 pImpl
->aFilterArr
[nData
] = lList
;
442 pImpl
->aODFArr
[nData
] = lODFList
;
445 OUString sModule
= OfaTreeOptionsDialog::getCurrentFactory_Impl(GetFrame());
447 if (sModule
== "com.sun.star.text.TextDocument")
449 else if (sModule
== "com.sun.star.text.WebDocument")
450 docId
= APP_WRITER_WEB
;
451 else if (sModule
== "com.sun.star.text.GlobalDocument")
452 docId
= APP_WRITER_GLOBAL
;
453 else if (sModule
== "com.sun.star.sheet.SpreadsheetDocument")
455 else if (sModule
== "com.sun.star.presentation.PresentationDocument")
457 else if (sModule
== "com.sun.star.drawing.DrawingDocument")
459 else if (sModule
== "com.sun.star.formula.FormulaProperties")
461 m_xDocTypeLB
->set_active_id(OUString::number(docId
));
462 FilterHdl_Impl(*m_xDocTypeLB
);
464 catch(Exception
const &)
466 TOOLS_WARN_EXCEPTION( "cui.options", "exception in FilterFactory access" );
469 pImpl
->bInitialized
= true;
472 m_xDocInfoCB
->set_active(officecfg::Office::Common::Save::Document::EditProperty::get());
473 m_xDocInfoCB
->set_sensitive(!officecfg::Office::Common::Save::Document::EditProperty::isReadOnly());
475 m_xBackupCB
->set_active(officecfg::Office::Common::Save::Document::CreateBackup::get());
476 m_xBackupCB
->set_sensitive(!officecfg::Office::Common::Save::Document::CreateBackup::isReadOnly());
478 m_xAutoSaveCB
->set_active(officecfg::Office::Common::Save::Document::AutoSave::get());
479 m_xAutoSaveCB
->set_sensitive(!officecfg::Office::Common::Save::Document::AutoSave::isReadOnly());
481 m_xUserAutoSaveCB
->set_active(officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get());
482 m_xUserAutoSaveCB
->set_sensitive(!officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::isReadOnly());
484 m_xWarnAlienFormatCB
->set_active(officecfg::Office::Common::Save::Document::WarnAlienFormat::get());
485 m_xWarnAlienFormatCB
->set_sensitive(!officecfg::Office::Common::Save::Document::WarnAlienFormat::isReadOnly());
487 m_xAutoSaveEdit
->set_value(officecfg::Office::Common::Save::Document::AutoSaveTimeIntervall::get());
488 m_xAutoSaveEdit
->set_sensitive(!officecfg::Office::Common::Save::Document::AutoSaveTimeIntervall::isReadOnly());
491 m_xRelativeFsysCB
->set_active(officecfg::Office::Common::Save::URL::FileSystem::get());
492 m_xRelativeFsysCB
->set_sensitive(!officecfg::Office::Common::Save::URL::FileSystem::isReadOnly());
494 m_xRelativeInetCB
->set_active(officecfg::Office::Common::Save::URL::Internet::get());
495 m_xRelativeInetCB
->set_sensitive(!officecfg::Office::Common::Save::URL::Internet::isReadOnly());
497 sal_Int32 nDefaultVersion
= GetODFDefaultVersion();
498 m_xODFVersionLB
->set_active_id(OUString::number(nDefaultVersion
));
499 m_xODFVersionLB
->set_sensitive(!officecfg::Office::Common::Save::ODF::DefaultVersion::isReadOnly());
501 AutoClickHdl_Impl(*m_xAutoSaveCB
);
502 ODFVersionHdl_Impl(*m_xODFVersionLB
);
504 m_xDocInfoCB
->save_state();
505 m_xBackupCB
->save_state();
506 m_xWarnAlienFormatCB
->save_state();
507 m_xAutoSaveCB
->save_state();
508 m_xAutoSaveEdit
->save_value();
510 m_xUserAutoSaveCB
->save_state();
512 m_xRelativeFsysCB
->save_state();
513 m_xRelativeInetCB
->save_state();
514 m_xODFVersionLB
->save_value();
517 IMPL_LINK(SvxSaveTabPage
, AutoClickHdl_Impl
, weld::Toggleable
&, rBox
, void)
519 if (&rBox
!= m_xAutoSaveCB
.get())
522 if (m_xAutoSaveCB
->get_active())
524 m_xAutoSaveEdit
->set_sensitive(true);
525 m_xMinuteFT
->set_sensitive(true);
526 m_xUserAutoSaveCB
->set_sensitive(true);
530 m_xAutoSaveEdit
->set_sensitive(false);
531 m_xMinuteFT
->set_sensitive(false);
532 m_xUserAutoSaveCB
->set_sensitive(false);
536 static OUString
lcl_ExtracUIName(const Sequence
<PropertyValue
> &rProperties
, std::u16string_view rExtension
)
539 const PropertyValue
* pPropVal
= rProperties
.getConstArray();
540 const PropertyValue
* const pEnd
= pPropVal
+ rProperties
.getLength();
541 for( ; pPropVal
!= pEnd
; pPropVal
++ )
543 const OUString
&rName
= pPropVal
->Name
;
544 if (rName
== "UIName")
547 if ( ( pPropVal
->Value
>>= sUIName
) && sUIName
.getLength() )
549 if (!rExtension
.empty())
551 return sUIName
+ " (" + rExtension
+ ")";
559 else if (rName
== "Name")
561 pPropVal
->Value
>>= sName
;
565 OSL_ENSURE( false, "Filter without UIName!" );
570 IMPL_LINK( SvxSaveTabPage
, FilterHdl_Impl
, weld::ComboBox
&, rBox
, void )
572 const int nCurPos
= m_xDocTypeLB
->get_active();
575 if (nCurPos
< APP_COUNT
)
576 nData
= m_xDocTypeLB
->get_id(nCurPos
).toInt32();
578 if ( nData
>= 0 && nData
< APP_COUNT
)
580 if(m_xDocTypeLB
.get() == &rBox
)
582 m_xSaveAsLB
->clear();
583 auto & rFilters
= pImpl
->aFilterArr
[nData
];
584 if(pImpl
->aUIFilterArr
[nData
].empty())
586 pImpl
->aUIFilterArr
[nData
].resize(pImpl
->aFilterArr
[nData
].size());
587 auto & rUIFilters
= pImpl
->aUIFilterArr
[nData
];
588 for(size_t nFilter
= 0; nFilter
< pImpl
->aFilterArr
[nData
].size(); nFilter
++)
590 Any aProps
= pImpl
->xFact
->getByName(rFilters
[nFilter
]);
591 // get the extension of the filter
593 SfxFilterMatcher matcher
;
594 std::shared_ptr
<const SfxFilter
> pFilter
= matcher
.GetFilter4FilterName(rFilters
[nFilter
]);
597 extension
= pFilter
->GetWildcard().getGlob().getToken(0, ';');
599 Sequence
<PropertyValue
> aProperties
;
600 aProps
>>= aProperties
;
601 rUIFilters
[nFilter
] = lcl_ExtracUIName(aProperties
, extension
);
604 auto const & rUIFilters
= pImpl
->aUIFilterArr
[nData
];
606 for(size_t i
= 0; i
< pImpl
->aUIFilterArr
[nData
].size(); i
++)
609 if (pImpl
->aODFArr
[nData
][i
])
610 sId
= weld::toId(pImpl
.get());
611 m_xSaveAsLB
->append(sId
, rUIFilters
[i
]);
612 if (rFilters
[i
] == pImpl
->aDefaultArr
[nData
])
613 sSelect
= rUIFilters
[i
];
615 if (!sSelect
.isEmpty())
617 m_xSaveAsLB
->set_active_text(sSelect
);
620 m_xSaveAsFT
->set_sensitive(!pImpl
->aDefaultReadonlyArr
[nData
]);
621 m_xSaveAsLB
->set_sensitive(!pImpl
->aDefaultReadonlyArr
[nData
]);
625 OUString sSelect
= rBox
.get_active_text();
626 auto const & rFilters
= pImpl
->aFilterArr
[nData
];
627 auto const & rUIFilters
= pImpl
->aUIFilterArr
[nData
];
628 for(size_t i
= 0; i
< pImpl
->aUIFilterArr
[nData
].size(); i
++)
629 if(rUIFilters
[i
] == sSelect
)
631 sSelect
= rFilters
[i
];
635 pImpl
->aDefaultArr
[nData
] = sSelect
;
639 ODFVersionHdl_Impl( *m_xSaveAsLB
);
642 IMPL_LINK_NOARG(SvxSaveTabPage
, ODFVersionHdl_Impl
, weld::ComboBox
&, void)
644 sal_Int32 nVersion
= m_xODFVersionLB
->get_active_id().toInt32();
645 bool bShown
= SvtSaveOptions::ODFDefaultVersion(nVersion
) != SvtSaveOptions::ODFVER_LATEST
;
648 bool bHasODFFormat
= false;
649 const int nCount
= m_xSaveAsLB
->get_count();
650 for (int i
= 0; i
< nCount
; ++i
)
652 if ( m_xSaveAsLB
->get_id(i
).toInt64() != 0 )
654 bHasODFFormat
= true;
659 bShown
= !bHasODFFormat
660 || ( m_xSaveAsLB
->get_active_id().toInt64() != 0);
663 m_xODFWarningFI
->set_visible(bShown
);
664 m_xODFWarningFT
->set_visible(bShown
);
667 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */