22 #include <string_view>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/container/XNameContainer.hpp>
33 #include <com/sun/star/container/XContainerQuery.hpp>
34 #include <com/sun/star/container/XEnumeration.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <sfx2/sfxsids.hrc>
39 #include <osl/diagnose.h>
51 #define CFG_PAGE_AND_GROUP u"General", u"LoadSave"
74 :
SfxTabPage( pPage, pController,
"cui/ui/optsavepage.ui",
"OptSavePage", &rCoreSet )
76 , m_xLoadUserSettingsCB(m_xBuilder->weld_check_button(
"load_settings"))
77 , m_xLoadDocPrinterCB(m_xBuilder->weld_check_button(
"load_docprinter"))
78 , m_xDocInfoCB(m_xBuilder->weld_check_button(
"docinfo"))
79 , m_xBackupCB(m_xBuilder->weld_check_button(
"backup"))
80 , m_xAutoSaveCB(m_xBuilder->weld_check_button(
"autosave"))
81 , m_xAutoSaveEdit(m_xBuilder->weld_spin_button(
"autosave_spin"))
82 , m_xMinuteFT(m_xBuilder->weld_label(
"autosave_mins"))
83 , m_xUserAutoSaveCB(m_xBuilder->weld_check_button(
"userautosave"))
84 , m_xRelativeFsysCB(m_xBuilder->weld_check_button(
"relative_fsys"))
85 , m_xRelativeInetCB(m_xBuilder->weld_check_button(
"relative_inet"))
86 , m_xODFVersionLB(m_xBuilder->weld_combo_box(
"odfversion"))
87 , m_xWarnAlienFormatCB(m_xBuilder->weld_check_button(
"warnalienformat"))
88 , m_xDocTypeLB(m_xBuilder->weld_combo_box(
"doctype"))
89 , m_xSaveAsFT(m_xBuilder->weld_label(
"saveas_label"))
90 , m_xSaveAsLB(m_xBuilder->weld_combo_box(
"saveas"))
91 , m_xODFWarningFI(m_xBuilder->weld_widget(
"odfwarning_image"))
92 , m_xODFWarningFT(m_xBuilder->weld_label(
"odfwarning_label"))
191 return std::make_unique<SvxSaveTabPage>(pPage, pController, *rAttrSet);
222 bool bModified =
false;
327 static const char* aODFFormats[] =
332 "writerglobal8_writer",
347 while ( aODFFormats[i] !=
nullptr )
349 if ( sFilter.equalsAscii( aODFFormats[i++] ) )
369 if ( !
pImpl->bInitialized )
374 pImpl->xFact.set(xMSF->createInstance(
"com.sun.star.document.FilterFactory"), UNO_QUERY);
376 DBG_ASSERT(
pImpl->xFact.is(),
"service com.sun.star.document.FilterFactory unavailable");
380 for (sal_Int32
n = 0, nEntryCount =
m_xDocTypeLB->get_count();
n < nEntryCount; ++
n)
383 OUString sCommand =
"getSortedFilterList():module=%1:iflags=" +
384 OUString::number(static_cast<int>(SfxFilterFlags::IMPORT|SfxFilterFlags::EXPORT)) +
386 OUString::number(static_cast<int>(SfxFilterFlags::NOTINFILEDLG));
390 case APP_WRITER : sReplace =
"com.sun.star.text.TextDocument";
break;
391 case APP_WRITER_WEB : sReplace =
"com.sun.star.text.WebDocument";
break;
393 case APP_CALC : sReplace =
"com.sun.star.sheet.SpreadsheetDocument";
break;
394 case APP_IMPRESS : sReplace =
"com.sun.star.presentation.PresentationDocument";
break;
395 case APP_DRAW : sReplace =
"com.sun.star.drawing.DrawingDocument";
break;
396 case APP_MATH : sReplace =
"com.sun.star.formula.FormulaProperties";
break;
397 default: OSL_FAIL(
"illegal user data");
399 sCommand = sCommand.replaceFirst(
"%1", sReplace);
401 std::vector< OUString > lList;
402 std::vector<bool> lODFList;
403 while(xList->hasMoreElements())
407 if (!sFilter.isEmpty())
409 lList.push_back(sFilter);
413 pImpl->aFilterArr[nData] = lList;
414 pImpl->aODFArr[nData] = lODFList;
425 pImpl->bInitialized =
true;
475 if (&rBox != m_xAutoSaveCB.get())
478 if (m_xAutoSaveCB->get_active())
480 m_xAutoSaveEdit->set_sensitive(
true);
481 m_xMinuteFT->set_sensitive(
true);
482 m_xUserAutoSaveCB->set_sensitive(
true);
486 m_xAutoSaveEdit->set_sensitive(
false);
487 m_xMinuteFT->set_sensitive(
false);
488 m_xUserAutoSaveCB->set_sensitive(
false);
495 const PropertyValue* pPropVal = rProperties.getConstArray();
496 const PropertyValue*
const pEnd = pPropVal + rProperties.getLength();
497 for( ; pPropVal != pEnd; pPropVal++ )
499 const OUString &rName = pPropVal->Name;
500 if (rName ==
"UIName")
503 if ( ( pPropVal->Value >>= sUIName ) && sUIName.getLength() )
505 if (!rExtension.empty())
507 return sUIName +
" (" + rExtension +
")";
515 else if (rName ==
"Name")
517 pPropVal->Value >>= sName;
521 OSL_ENSURE(
false,
"Filter without UIName!" );
528 const int nCurPos = m_xDocTypeLB->get_active();
532 nData = m_xDocTypeLB->get_id(nCurPos).toInt32();
536 if(m_xDocTypeLB.get() == &rBox)
538 m_xSaveAsLB->clear();
539 auto & rFilters = pImpl->aFilterArr[nData];
540 if(pImpl->aUIFilterArr[nData].empty())
542 pImpl->aUIFilterArr[nData].resize(pImpl->aFilterArr[nData].size());
543 auto & rUIFilters = pImpl->aUIFilterArr[nData];
544 for(
size_t nFilter = 0; nFilter < pImpl->aFilterArr[nData].size(); nFilter++)
546 Any aProps = pImpl->xFact->getByName(rFilters[nFilter]);
553 extension = pFilter->GetWildcard().getGlob().getToken(0,
';');
556 aProps >>= aProperties;
560 auto const & rUIFilters = pImpl->aUIFilterArr[nData];
562 for(
size_t i = 0;
i < pImpl->aUIFilterArr[nData].size();
i++)
565 if (pImpl->aODFArr[nData][
i])
566 sId = OUString::number(reinterpret_cast<sal_Int64>(pImpl.get()));
567 m_xSaveAsLB->append(sId, rUIFilters[i]);
568 if (rFilters[i] == pImpl->aDefaultArr[nData])
569 sSelect = rUIFilters[i];
571 if (!sSelect.isEmpty())
573 m_xSaveAsLB->set_active_text(sSelect);
576 m_xSaveAsFT->set_sensitive(!pImpl->aDefaultReadonlyArr[nData]);
577 m_xSaveAsLB->set_sensitive(!pImpl->aDefaultReadonlyArr[nData]);
581 OUString sSelect = rBox.get_active_text();
582 auto const & rFilters = pImpl->aFilterArr[nData];
583 auto const & rUIFilters = pImpl->aUIFilterArr[nData];
584 for(
size_t i = 0;
i < pImpl->aUIFilterArr[nData].size();
i++)
585 if(rUIFilters[
i] == sSelect)
587 sSelect = rFilters[
i];
591 pImpl->aDefaultArr[nData] = sSelect;
595 ODFVersionHdl_Impl( *m_xSaveAsLB );
600 sal_Int32
nVersion = m_xODFVersionLB->get_active_id().toInt32();
604 bool bHasODFFormat =
false;
605 const int nCount = m_xSaveAsLB->get_count();
606 for (
int i = 0;
i < nCount; ++
i )
608 if ( m_xSaveAsLB->get_id(
i).toInt64() != 0 )
610 bHasODFFormat =
true;
615 bShown = !bHasODFFormat
616 || ( m_xSaveAsLB->get_active_id().toInt64() != 0);
619 m_xODFWarningFI->set_visible(bShown);
620 m_xODFWarningFT->set_visible(bShown);
#define LINK(Instance, Class, Member)
static OUString lcl_ExtracUIName(const Sequence< PropertyValue > &rProperties, std::u16string_view rExtension)
void SetLoadDocumentPrinter(bool _bEnable)
void DetectHiddenControls()
bool IsSaveRelFSys() const
std::unique_ptr< weld::CheckButton > m_xBackupCB
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
bool IsModuleInstalled(EModule eModule) const
bool IsDefaultFilterReadonly(EFactory eFactory) const
void SetFactoryDefaultFilter(EFactory eFactory, const OUString &sFilter)
bool IsReadOnly(EOption eOption) const
std::unique_ptr< weld::ComboBox > m_xODFVersionLB
bool IsWarnAlienFormat() const
bool IsDocInfoSave() const
std::unique_ptr< weld::ComboBox > m_xDocTypeLB
bool IsLoadUserSettings() const
std::unique_ptr< weld::CheckButton > m_xRelativeInetCB
static bool isODFFormat(const OUString &sFilter)
PropertiesInfo aProperties
std::unique_ptr< weld::SpinButton > m_xAutoSaveEdit
std::unique_ptr< SvxSaveTabPage_Impl > pImpl
std::unique_ptr< weld::CheckButton > m_xDocInfoCB
std::unique_ptr< weld::CheckButton > m_xLoadDocPrinterCB
std::unique_ptr< weld::Label > m_xMinuteFT
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_ASSERT(sCon, aError)
std::unique_ptr< weld::CheckButton > m_xAutoSaveCB
#define APP_WRITER_GLOBAL
void SetLoadUserSettings(bool b)
bool IsUserAutoSave() const
std::unique_ptr< weld::ComboBox > m_xSaveAsLB
ODFDefaultVersion GetODFDefaultVersion() const
bool IsSaveRelINet() const
IMPL_LINK_NOARG(SvxSaveTabPage, ODFVersionHdl_Impl, weld::ComboBox &, void)
std::unique_ptr< weld::CheckButton > m_xRelativeFsysCB
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
Reference< XMultiServiceFactory > getProcessServiceFactory()
bool IsOptionHidden(std::u16string_view _rOption, std::u16string_view _rPage, std::u16string_view _rGroup) const
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
OUString GetFactoryDefaultFilter(EFactory eFactory) const
sal_Int32 GetAutoSaveTime() const
void SetODFDefaultVersion(ODFDefaultVersion eVersion)
virtual void Reset(const SfxItemSet *rSet) override
virtual bool FillItemSet(SfxItemSet *rSet) override
Reference< XNameContainer > xFact
IMPL_LINK(SvxSaveTabPage, AutoClickHdl_Impl, weld::Button &, rBox, void)
#define CFG_PAGE_AND_GROUP
std::unique_ptr< weld::CheckButton > m_xWarnAlienFormatCB
std::unique_ptr< weld::CheckButton > m_xLoadUserSettingsCB
virtual ~SvxSaveTabPage() override
bool IsLoadDocumentPrinter() const
SvxSaveTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
std::unique_ptr< weld::CheckButton > m_xUserAutoSaveCB