31#include <officecfg/Office/Common.hxx>
36#include <com/sun/star/lang/XMultiServiceFactory.hpp>
37#include <com/sun/star/container/XNameContainer.hpp>
38#include <com/sun/star/container/XContainerQuery.hpp>
39#include <com/sun/star/container/XEnumeration.hpp>
40#include <com/sun/star/beans/PropertyValue.hpp>
41#include <sfx2/sfxsids.hrc>
44#include <osl/diagnose.h>
46#include <officecfg/Office/Recovery.hxx>
58#define CFG_PAGE_AND_GROUP u"General", u"LoadSave"
81 :
SfxTabPage( pPage, pController,
"cui/ui/optsavepage.ui",
"OptSavePage", &rCoreSet )
83 , m_xLoadViewPosAnyUserCB(m_xBuilder->weld_check_button(
"load_anyuser"))
84 , m_xLoadUserSettingsCB(m_xBuilder->weld_check_button(
"load_settings"))
85 , m_xLoadDocPrinterCB(m_xBuilder->weld_check_button(
"load_docprinter"))
86 , m_xDocInfoCB(m_xBuilder->weld_check_button(
"docinfo"))
87 , m_xBackupCB(m_xBuilder->weld_check_button(
"backup"))
88 , m_xBackupIntoDocumentFolderCB(m_xBuilder->weld_check_button(
"backupintodocumentfolder"))
89 , m_xAutoSaveCB(m_xBuilder->weld_check_button(
"autosave"))
90 , m_xAutoSaveEdit(m_xBuilder->weld_spin_button(
"autosave_spin"))
91 , m_xMinuteFT(m_xBuilder->weld_label(
"autosave_mins"))
92 , m_xUserAutoSaveCB(m_xBuilder->weld_check_button(
"userautosave"))
93 , m_xRelativeFsysCB(m_xBuilder->weld_check_button(
"relative_fsys"))
94 , m_xRelativeInetCB(m_xBuilder->weld_check_button(
"relative_inet"))
95 , m_xODFVersionLB(m_xBuilder->weld_combo_box(
"odfversion"))
96 , m_xWarnAlienFormatCB(m_xBuilder->weld_check_button(
"warnalienformat"))
97 , m_xDocTypeLB(m_xBuilder->weld_combo_box(
"doctype"))
98 , m_xSaveAsFT(m_xBuilder->weld_label(
"saveas_label"))
99 , m_xSaveAsLB(m_xBuilder->weld_combo_box(
"saveas"))
100 , m_xODFWarningFI(m_xBuilder->weld_widget(
"odfwarning_image"))
101 , m_xODFWarningFT(m_xBuilder->weld_label(
"odfwarning_label"))
115 "org.openoffice.Office.UI/FilterClassification/GlobalFilters/Classes",
120 m_xDocTypeLB->append(OUString::number(
APP_WRITER), aFilterClassesNode.getNodeValue(
"com.sun.star.text.TextDocument/DisplayName").get<OUString>());
121 m_xDocTypeLB->append(OUString::number(
APP_WRITER_WEB), aFilterClassesNode.getNodeValue(
"com.sun.star.text.WebDocument/DisplayName").get<OUString>());
122 m_xDocTypeLB->append(OUString::number(
APP_WRITER_GLOBAL), aFilterClassesNode.getNodeValue(
"com.sun.star.text.GlobalDocument/DisplayName").get<OUString>());
123 m_xDocTypeLB->append(OUString::number(
APP_CALC), aFilterClassesNode.getNodeValue(
"com.sun.star.sheet.SpreadsheetDocument/DisplayName").get<OUString>());
124 m_xDocTypeLB->append(OUString::number(
APP_IMPRESS), aFilterClassesNode.getNodeValue(
"com.sun.star.presentation.PresentationDocument/DisplayName").get<OUString>());
125 m_xDocTypeLB->append(OUString::number(
APP_DRAW), aFilterClassesNode.getNodeValue(
"com.sun.star.drawing.DrawingDocument/DisplayName").get<OUString>());
126 m_xDocTypeLB->append(OUString::number(
APP_MATH), aFilterClassesNode.getNodeValue(
"com.sun.star.formula.FormulaProperties/DisplayName").get<OUString>());
211 return std::make_unique<SvxSaveTabPage>(pPage, pController, *rAttrSet);
244 bool bModified =
false;
250 officecfg::Office::Common::Load::UserDefinedSettings::set(
m_xLoadUserSettingsCB->get_active(), xChanges);
253 officecfg::Office::Common::Save::Document::LoadPrinter::set(
m_xLoadDocPrinterCB->get_active(), xChanges);
358 static const char* aODFFormats[] =
363 "writerglobal8_writer",
378 while ( aODFFormats[
i] !=
nullptr )
394 m_xLoadViewPosAnyUserCB->set_sensitive(!officecfg::Office::Common::Load::ViewPositionForAnyUser::isReadOnly());
397 m_xLoadUserSettingsCB->set_sensitive(!officecfg::Office::Common::Load::UserDefinedSettings::isReadOnly());
398 m_xLoadDocPrinterCB->set_active( officecfg::Office::Common::Save::Document::LoadPrinter::get() );
400 m_xLoadDocPrinterCB->set_sensitive(!officecfg::Office::Common::Save::Document::LoadPrinter::isReadOnly());
402 if ( !
pImpl->bInitialized )
407 pImpl->xFact.set(xMSF->createInstance(
"com.sun.star.document.FilterFactory"), UNO_QUERY);
409 DBG_ASSERT(
pImpl->xFact.is(),
"service com.sun.star.document.FilterFactory unavailable");
413 for (sal_Int32
n = 0, nEntryCount =
m_xDocTypeLB->get_count();
n < nEntryCount; ++
n)
416 OUString sCommand =
"getSortedFilterList():module=%1:iflags=" +
417 OUString::number(
static_cast<int>(SfxFilterFlags::IMPORT|SfxFilterFlags::EXPORT)) +
419 OUString::number(
static_cast<int>(SfxFilterFlags::NOTINFILEDLG));
423 case APP_WRITER : sReplace =
"com.sun.star.text.TextDocument";
break;
424 case APP_WRITER_WEB : sReplace =
"com.sun.star.text.WebDocument";
break;
426 case APP_CALC : sReplace =
"com.sun.star.sheet.SpreadsheetDocument";
break;
427 case APP_IMPRESS : sReplace =
"com.sun.star.presentation.PresentationDocument";
break;
428 case APP_DRAW : sReplace =
"com.sun.star.drawing.DrawingDocument";
break;
429 case APP_MATH : sReplace =
"com.sun.star.formula.FormulaProperties";
break;
430 default:
SAL_WARN(
"cui.options",
"illegal user data");
432 sCommand = sCommand.replaceFirst(
"%1", sReplace);
434 std::vector< OUString > lList;
435 std::vector<bool> lODFList;
436 while(xList->hasMoreElements())
440 if (!sFilter.isEmpty())
442 lList.push_back(sFilter);
446 pImpl->aFilterArr[nData] = lList;
447 pImpl->aODFArr[nData] = lODFList;
452 if (sModule ==
"com.sun.star.text.TextDocument")
454 else if (sModule ==
"com.sun.star.text.WebDocument")
456 else if (sModule ==
"com.sun.star.text.GlobalDocument")
458 else if (sModule ==
"com.sun.star.sheet.SpreadsheetDocument")
460 else if (sModule ==
"com.sun.star.presentation.PresentationDocument")
462 else if (sModule ==
"com.sun.star.drawing.DrawingDocument")
464 else if (sModule ==
"com.sun.star.formula.FormulaProperties")
474 pImpl->bInitialized =
true;
477 m_xDocInfoCB->set_active(officecfg::Office::Common::Save::Document::EditProperty::get());
478 m_xDocInfoCB->set_sensitive(!officecfg::Office::Common::Save::Document::EditProperty::isReadOnly());
480 m_xBackupCB->set_active(officecfg::Office::Common::Save::Document::CreateBackup::get());
481 m_xBackupCB->set_sensitive(!officecfg::Office::Common::Save::Document::CreateBackup::isReadOnly());
484 officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::get());
486 !officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::isReadOnly()
489 m_xAutoSaveCB->set_active(officecfg::Office::Recovery::AutoSave::Enabled::get());
490 m_xAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::Enabled::isReadOnly());
492 m_xUserAutoSaveCB->set_active(officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get());
493 m_xUserAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::isReadOnly());
495 m_xWarnAlienFormatCB->set_active(officecfg::Office::Common::Save::Document::WarnAlienFormat::get());
496 m_xWarnAlienFormatCB->set_sensitive(!officecfg::Office::Common::Save::Document::WarnAlienFormat::isReadOnly());
498 m_xAutoSaveEdit->set_value(officecfg::Office::Recovery::AutoSave::TimeIntervall::get());
499 m_xAutoSaveEdit->set_sensitive(!officecfg::Office::Recovery::AutoSave::TimeIntervall::isReadOnly());
502 m_xRelativeFsysCB->set_active(officecfg::Office::Common::Save::URL::FileSystem::get());
503 m_xRelativeFsysCB->set_sensitive(!officecfg::Office::Common::Save::URL::FileSystem::isReadOnly());
505 m_xRelativeInetCB->set_active(officecfg::Office::Common::Save::URL::Internet::get());
506 m_xRelativeInetCB->set_sensitive(!officecfg::Office::Common::Save::URL::Internet::isReadOnly());
510 m_xODFVersionLB->set_sensitive(!officecfg::Office::Common::Save::ODF::DefaultVersion::isReadOnly());
531 if (&rBox != m_xAutoSaveCB.get())
534 if (m_xAutoSaveCB->get_active())
536 m_xAutoSaveEdit->set_sensitive(
true);
537 m_xMinuteFT->set_sensitive(
true);
538 m_xUserAutoSaveCB->set_sensitive(
true);
542 m_xAutoSaveEdit->set_sensitive(
false);
543 m_xMinuteFT->set_sensitive(
false);
544 m_xUserAutoSaveCB->set_sensitive(
false);
550 m_xBackupIntoDocumentFolderCB->set_sensitive(m_xBackupCB->get_active());
556 const PropertyValue* pPropVal = rProperties.getConstArray();
557 const PropertyValue*
const pEnd = pPropVal + rProperties.getLength();
558 for( ; pPropVal != pEnd; pPropVal++ )
560 const OUString &rName = pPropVal->Name;
561 if (rName ==
"UIName")
564 if ( ( pPropVal->Value >>= sUIName ) && sUIName.getLength() )
566 if (!rExtension.empty())
568 return sUIName +
" (" + rExtension +
")";
576 else if (rName ==
"Name")
578 pPropVal->Value >>=
sName;
582 OSL_ENSURE(
false,
"Filter without UIName!" );
589 const int nCurPos = m_xDocTypeLB->get_active();
593 nData = m_xDocTypeLB->get_id(nCurPos).toInt32();
597 if(m_xDocTypeLB.get() == &rBox)
599 m_xSaveAsLB->clear();
600 auto & rFilters = pImpl->aFilterArr[nData];
601 if(pImpl->aUIFilterArr[nData].empty())
603 pImpl->aUIFilterArr[nData].resize(pImpl->aFilterArr[nData].size());
604 auto & rUIFilters = pImpl->aUIFilterArr[nData];
605 for(
size_t nFilter = 0; nFilter < pImpl->aFilterArr[nData].size(); nFilter++)
607 Any aProps = pImpl->xFact->getByName(rFilters[nFilter]);
614 extension = pFilter->GetWildcard().getGlob().getToken(0,
';');
621 auto const & rUIFilters = pImpl->aUIFilterArr[nData];
623 for(
size_t i = 0;
i < pImpl->aUIFilterArr[nData].size();
i++)
626 if (pImpl->aODFArr[nData][
i])
628 m_xSaveAsLB->append(
sId, rUIFilters[
i]);
629 if (rFilters[
i] == pImpl->aDefaultArr[nData])
630 sSelect = rUIFilters[
i];
632 if (!sSelect.isEmpty())
634 m_xSaveAsLB->set_active_text(sSelect);
637 m_xSaveAsFT->set_sensitive(!pImpl->aDefaultReadonlyArr[nData]);
638 m_xSaveAsLB->set_sensitive(!pImpl->aDefaultReadonlyArr[nData]);
642 OUString sSelect = rBox.get_active_text();
643 auto const & rFilters = pImpl->aFilterArr[nData];
644 auto const & rUIFilters = pImpl->aUIFilterArr[nData];
645 for(
size_t i = 0;
i < pImpl->aUIFilterArr[nData].size();
i++)
646 if(rUIFilters[
i] == sSelect)
648 sSelect = rFilters[
i];
652 pImpl->aDefaultArr[nData] = sSelect;
656 ODFVersionHdl_Impl( *m_xSaveAsLB );
661 sal_Int32
nVersion = m_xODFVersionLB->get_active_id().toInt32();
665 bool bHasODFFormat =
false;
666 const int nCount = m_xSaveAsLB->get_count();
669 if ( m_xSaveAsLB->get_id(
i).toInt64() != 0 )
671 bHasODFFormat =
true;
676 bShown = !bHasODFFormat
677 || ( m_xSaveAsLB->get_active_id().toInt64() != 0);
680 m_xODFWarningFI->set_visible(bShown);
681 m_xODFWarningFT->set_visible(bShown);
PropertiesInfo aProperties
static OUString getCurrentFactory_Impl(const css::uno::Reference< css::frame::XFrame > &_xFrame)
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
css::uno::Reference< css::frame::XFrame > GetFrame() const
bool IsModuleInstalled(EModule eModule) const
bool IsDefaultFilterReadonly(EFactory eFactory) const
void SetFactoryDefaultFilter(EFactory eFactory, const OUString &sFilter)
OUString GetFactoryDefaultFilter(EFactory eFactory) const
bool IsOptionHidden(std::u16string_view _rOption, std::u16string_view _rPage, std::u16string_view _rGroup) const
void DetectHiddenControls()
std::unique_ptr< SvxSaveTabPage_Impl > pImpl
std::unique_ptr< weld::CheckButton > m_xLoadUserSettingsCB
std::unique_ptr< weld::CheckButton > m_xAutoSaveCB
std::unique_ptr< weld::CheckButton > m_xLoadDocPrinterCB
std::unique_ptr< weld::ComboBox > m_xSaveAsLB
std::unique_ptr< weld::CheckButton > m_xLoadViewPosAnyUserCB
std::unique_ptr< weld::SpinButton > m_xAutoSaveEdit
std::unique_ptr< weld::ComboBox > m_xDocTypeLB
std::unique_ptr< weld::CheckButton > m_xRelativeInetCB
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::CheckButton > m_xBackupCB
std::unique_ptr< weld::Label > m_xMinuteFT
std::unique_ptr< weld::CheckButton > m_xDocInfoCB
std::unique_ptr< weld::CheckButton > m_xRelativeFsysCB
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
virtual ~SvxSaveTabPage() override
SvxSaveTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
std::unique_ptr< weld::CheckButton > m_xWarnAlienFormatCB
virtual void Reset(const SfxItemSet *rSet) override
std::unique_ptr< weld::CheckButton > m_xBackupIntoDocumentFolderCB
std::unique_ptr< weld::ComboBox > m_xODFVersionLB
std::unique_ptr< weld::CheckButton > m_xUserAutoSaveCB
static std::shared_ptr< ConfigurationChanges > create()
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
static OConfigurationTreeRoot createWithComponentContext(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const OUString &_rPath, sal_Int32 _nDepth=-1, CREATION_MODE _eMode=CM_UPDATABLE)
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
bool equalsAscii(std::u16string_view s1, std::string_view s2)
OUString toId(const void *pValue)
#define CFG_PAGE_AND_GROUP
static bool isODFFormat(std::u16string_view sFilter)
static OUString lcl_ExtracUIName(const Sequence< PropertyValue > &rProperties, std::u16string_view rExtension)
IMPL_LINK(SvxSaveTabPage, AutoClickHdl_Impl, weld::Toggleable &, rBox, void)
IMPL_LINK_NOARG(SvxSaveTabPage, BackupClickHdl_Impl, weld::Toggleable &, void)
#define APP_WRITER_GLOBAL
UNOTOOLS_DLLPUBLIC SvtSaveOptions::ODFDefaultVersion GetODFDefaultVersion()
UNOTOOLS_DLLPUBLIC void SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion eVersion)
std::vector< OUString > aUIFilterArr[APP_COUNT]
std::vector< OUString > aFilterArr[APP_COUNT]
std::vector< bool > aODFArr[APP_COUNT]
bool aDefaultReadonlyArr[APP_COUNT]
OUString aDefaultArr[APP_COUNT]
Reference< XNameContainer > xFact