diff options
Diffstat (limited to 'cui/source/options/treeopt.cxx')
-rw-r--r-- | cui/source/options/treeopt.cxx | 1073 |
1 files changed, 845 insertions, 228 deletions
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index a3d2fc54819d..6ab767bb8044 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -26,10 +26,10 @@ #include <config_gpgme.h> #include <officecfg/Office/Common.hxx> +#include <officecfg/Office/Writer.hxx> #include <svx/dialogs.hrc> #include <svx/svxids.hrc> -#include <unotools/resmgr.hxx> #include <treeopt.hrc> #include <helpids.h> @@ -63,6 +63,13 @@ #include "personalization.hxx" #include <treeopt.hxx> #include "optbasic.hxx" +#include "optlanguagetool.hxx" +#include "optdeepl.hxx" + +// include search util +#include <com/sun/star/util/SearchFlags.hpp> +#include <com/sun/star/util/SearchAlgorithms2.hpp> +#include <unotools/textsearch.hxx> #include <com/sun/star/awt/XContainerWindowEventHandler.hpp> #include <com/sun/star/awt/ContainerWindowProvider.hpp> @@ -73,13 +80,13 @@ #include <com/sun/star/frame/UnknownModuleException.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/linguistic2/LinguProperties.hpp> -#include <com/sun/star/setup/UpdateCheck.hpp> #include <comphelper/getexpandeduri.hxx> #include <comphelper/processfactory.hxx> #include <editeng/langitem.hxx> #include <editeng/optitems.hxx> #include <editeng/unolingu.hxx> #include <linguistic/misc.hxx> +#include <o3tl/deleter.hxx> #include <officecfg/Office/OptionsDialog.hxx> #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> @@ -90,17 +97,17 @@ #include <sfx2/viewfrm.hxx> #include <svl/flagitem.hxx> #include <svl/intitem.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> #include <svx/databaseregistrationui.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <tools/urlobj.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <unotools/configmgr.hxx> #include <unotools/moduleoptions.hxx> #include <unotools/optionsdlg.hxx> #include <unotools/viewoptions.hxx> +#include <utility> #include <vcl/help.hxx> #include <vcl/svapp.hxx> #include <vcl/weldutils.hxx> @@ -108,7 +115,6 @@ #include <sal/log.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; @@ -119,7 +125,7 @@ using namespace ::com::sun::star::util; LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = nullptr; // some stuff for easier changes for SvtViewOptions -constexpr OUStringLiteral VIEWOPT_DATANAME = u"page data"; +constexpr OUString VIEWOPT_DATANAME = u"page data"_ustr; static void SetViewOptUserItem( SvtViewOptions& rOpt, const OUString& rData ) { @@ -228,42 +234,12 @@ static sal_uInt16 getGroupNodeId( std::u16string_view rModule ) namespace { -class MailMergeCfg_Impl : public utl::ConfigItem +bool MailMergeCfgIsEmailSupported() { -private: - // variables - bool bIsEmailSupported; - - virtual void ImplCommit() override; - -public: - MailMergeCfg_Impl(); - - virtual void Notify( const css::uno::Sequence< OUString >& _rPropertyNames) override; - - bool IsEmailSupported() const {return bIsEmailSupported;} - -}; - -} - -MailMergeCfg_Impl::MailMergeCfg_Impl() : - utl::ConfigItem("Office.Writer/MailMergeWizard"), - bIsEmailSupported(false) -{ - Sequence<OUString> aNames { "EMailSupported" }; - const Sequence< Any > aValues = GetProperties(aNames); - const Any* pValues = aValues.getConstArray(); - if(aValues.hasElements() && pValues[0].hasValue()) - pValues[0] >>= bIsEmailSupported; + std::optional<bool> b = officecfg::Office::Writer::MailMergeWizard::EMailSupported::get(); + return b.has_value() && *b; } -void MailMergeCfg_Impl::ImplCommit() -{ -} - -void MailMergeCfg_Impl::Notify( const css::uno::Sequence< OUString >& ) -{ } //typedef SfxTabPage* (*FNCreateTabPage)(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rAttrSet); @@ -297,6 +273,8 @@ static std::unique_ptr<SfxTabPage> CreateGeneralTabPage(sal_uInt16 nId, weld::Co case SID_SB_DBREGISTEROPTIONS: fnCreate = &svx::DbRegistrationOptionsPage::Create; break; case RID_SVXPAGE_ACCESSIBILITYCONFIG: fnCreate = &SvxAccessibilityOptionsTabPage::Create; break; case RID_SVXPAGE_OPTIONS_CTL: fnCreate = &SvxCTLOptionsPage::Create ; break; + case RID_SVXPAGE_LANGTOOL_OPTIONS: fnCreate = &OptLanguageToolTabPage::Create ; break; + case RID_SVXPAGE_DEEPL_OPTIONS: fnCreate = &OptDeeplTabPage::Create ; break; case RID_SVXPAGE_OPTIONS_JAVA: fnCreate = &SvxJavaOptionsPage::Create ; break; #if HAVE_FEATURE_OPENCL case RID_SVXPAGE_OPENCL: fnCreate = &SvxOpenCLTabPage::Create ; break; @@ -464,22 +442,42 @@ struct OptionsGroupInfo m_pModule( pMod ), m_nDialogId( nId ) {} }; -#define INI_LIST() \ - , m_pParent ( pParent )\ - , sTitle ( m_xDialog->get_title() )\ - , bForgetSelection ( false )\ - , bIsFromExtensionManager( false ) \ - , bIsForSetDocumentLanguage( false ) \ - , bNeedsRestart ( false ) \ - , eRestartReason( svtools::RESTART_REASON_NONE ) - -void OfaTreeOptionsDialog::InitWidgets() -{ - xOkPB = m_xBuilder->weld_button("ok"); - xApplyPB = m_xBuilder->weld_button("apply"); - xBackPB = m_xBuilder->weld_button("revert"); - xTreeLB = m_xBuilder->weld_tree_view("pages"); - xTabBox = m_xBuilder->weld_container("box"); +struct OptionsPageIdInfo +{ + OUString m_sParentName; + OUString m_sPageName; + sal_uInt16 m_nParentId; + sal_uInt16 m_nPageId; + + OptionsPageIdInfo(OUString sParentName, OUString sPageName, sal_uInt16 nParentId, + sal_uInt16 nPageId) + : m_sParentName(std::move(sParentName)) + , m_sPageName(std::move(sPageName)) + , m_nParentId(nParentId) + , m_nPageId(nPageId) + { + } +}; + +// Basic ctor with common initialization +OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, bool fromExtensionManager) + : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog") + , xOkPB(m_xBuilder->weld_button("ok")) + , xApplyPB(m_xBuilder->weld_button("apply")) + , xBackPB(m_xBuilder->weld_button("revert")) + , xTreeLB(m_xBuilder->weld_tree_view("pages")) + , xTabBox(m_xBuilder->weld_container("box")) + , m_xSearchEdit(m_xBuilder->weld_entry("searchEntry")) + , m_pParent(pParent) + , m_aUpdateDataTimer("OfaTreeOptionsDialog UpdateDataTimer") + , bIsFirtsInitialize(true) + , sTitle(m_xDialog->get_title()) + , bForgetSelection(false) + , bIsFromExtensionManager(fromExtensionManager) + , bIsForSetDocumentLanguage(false) + , bNeedsRestart(false) + , eRestartReason(svtools::RESTART_REASON_NONE) +{ Size aSize(xTreeLB->get_approximate_digit_width() * 82, xTreeLB->get_height_rows(30)); #if HAVE_FEATURE_GPGME // tdf#115015: make enough space for crypto settings (approx. 14 text edits + padding) @@ -487,38 +485,48 @@ void OfaTreeOptionsDialog::InitWidgets() #endif xTabBox->set_size_request(aSize.Width(), aSize.Height()); xTreeLB->set_size_request(xTreeLB->get_approximate_digit_width() * 35, aSize.Height()); + + // Init tree and handler + xTreeLB->set_help_id(HID_OFADLG_TREELISTBOX); + xTreeLB->connect_changed(LINK(this, OfaTreeOptionsDialog, ShowPageHdl_Impl)); + xBackPB->connect_clicked(LINK(this, OfaTreeOptionsDialog, BackHdl_Impl)); + xApplyPB->connect_clicked(LINK(this, OfaTreeOptionsDialog, ApplyHdl_Impl)); + xOkPB->connect_clicked(LINK(this, OfaTreeOptionsDialog, ApplyHdl_Impl)); + m_xSearchEdit->connect_changed(LINK(this, OfaTreeOptionsDialog, SearchUpdateHdl)); + m_xSearchEdit->connect_focus_out(LINK(this, OfaTreeOptionsDialog, FocusOut_Impl)); + m_xDialog->connect_help(LINK(this, OfaTreeOptionsDialog, HelpHdl_Impl)); + + m_aUpdateDataTimer.SetInvokeHandler(LINK(this, OfaTreeOptionsDialog, ImplUpdateDataHdl)); + m_aUpdateDataTimer.SetTimeout(EDIT_UPDATEDATA_TIMEOUT); + + // Initialize search util + m_options.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE; + m_options.transliterateFlags |= TransliterationFlags::IGNORE_CASE; + m_options.searchFlag + |= (util::SearchFlags::REG_NOT_BEGINOFLINE | util::SearchFlags::REG_NOT_ENDOFLINE); + + xTreeLB->set_accessible_name(sTitle); } // Ctor() with Frame ----------------------------------------------------- OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, const Reference< XFrame >& _xFrame, bool bActivateLastSelection) - : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog") - INI_LIST() + : OfaTreeOptionsDialog(pParent, false) { - InitWidgets(); - - InitTreeAndHandler(); Initialize( _xFrame ); LoadExtensionOptions( u"" ); if (bActivateLastSelection) ActivateLastSelection(); - - xTreeLB->set_accessible_name(m_xDialog->get_title()); } // Ctor() with ExtensionId ----------------------------------------------- OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, std::u16string_view rExtensionId) - : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog") - INI_LIST() + : OfaTreeOptionsDialog(pParent, !rExtensionId.empty()) { - InitWidgets(); - - bIsFromExtensionManager = ( !rExtensionId.empty() ); - InitTreeAndHandler(); LoadExtensionOptions( rExtensionId ); ActivateLastSelection(); } -OfaTreeOptionsDialog::~OfaTreeOptionsDialog() +void OfaTreeOptionsDialog::ImplDestroy() { xCurrentPageEntry.reset(); @@ -530,7 +538,7 @@ OfaTreeOptionsDialog::~OfaTreeOptionsDialog() // if Child (has parent), then OptionsPageInfo if (xTreeLB->get_iter_depth(*xEntry)) { - OptionsPageInfo *pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xEntry).toInt64()); + OptionsPageInfo *pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); if(pPageInfo->m_xPage) { pPageInfo->m_xPage->FillUserData(); @@ -566,7 +574,7 @@ OfaTreeOptionsDialog::~OfaTreeOptionsDialog() { if (!xTreeLB->get_iter_depth(*xEntry)) { - OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry).toInt64()); + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry)); delete pGroupInfo; } bEntry = xTreeLB->iter_next(*xEntry); @@ -574,6 +582,11 @@ OfaTreeOptionsDialog::~OfaTreeOptionsDialog() deleteGroupNames(); } +OfaTreeOptionsDialog::~OfaTreeOptionsDialog() +{ + suppress_fun_call_w_exception(ImplDestroy()); +} + OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage( sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup ) { @@ -583,7 +596,7 @@ OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage( xTreeLB->iter_nth_sibling(*xParent, nGroup); OptionsPageInfo* pPageInfo = new OptionsPageInfo( nId ); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pPageInfo))); + OUString sId(weld::toId(pPageInfo)); xTreeLB->insert(xParent.get(), -1, &rPageName, &sId, nullptr, nullptr, false, nullptr); return pPageInfo; } @@ -596,7 +609,7 @@ sal_uInt16 OfaTreeOptionsDialog::AddGroup(const OUString& rGroupName, { OptionsGroupInfo* pInfo = new OptionsGroupInfo( pCreateShell, pCreateModule, nDialogId ); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pInfo))); + OUString sId(weld::toId(pInfo)); xTreeLB->append(sId, rGroupName); sal_uInt16 nRet = 0; @@ -621,13 +634,13 @@ void OfaTreeOptionsDialog::ResetCurrentPageFromConfig() if (!(xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry))) return; - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry)); if (pPageInfo->m_xPage) { std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator(xCurrentPageEntry.get()); xTreeLB->iter_parent(*xParent); OptionsGroupInfo* pGroupInfo = - reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64()); + weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); pPageInfo->m_xPage->Reset( &*pGroupInfo->m_pInItemSet ); } else if ( pPageInfo->m_xExtPage ) @@ -647,13 +660,13 @@ void OfaTreeOptionsDialog::ApplyOptions() { if (xTreeLB->get_iter_depth(*xEntry)) { - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xEntry).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); if ( pPageInfo->m_xPage && !pPageInfo->m_xPage->HasExchangeSupport() ) { std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator(xEntry.get()); xTreeLB->iter_parent(*xParent); OptionsGroupInfo* pGroupInfo = - reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64()); + weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); pPageInfo->m_xPage->FillItemSet(pGroupInfo->m_pOutItemSet.get()); } @@ -677,11 +690,11 @@ IMPL_LINK_NOARG(OfaTreeOptionsDialog, HelpHdl_Impl, weld::Widget&, bool) Help* pHelp = Application::GetHelp(); if (pHelp && xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry)) { - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry)); if (pPageInfo->m_xPage) { - OString sHelpId(pPageInfo->m_xPage->GetHelpId()); - pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), m_xDialog.get()); + OUString sHelpId(pPageInfo->m_xPage->GetHelpId()); + pHelp->Start(sHelpId, m_xDialog.get()); return false; } } @@ -696,13 +709,13 @@ IMPL_LINK(OfaTreeOptionsDialog, ApplyHdl_Impl, weld::Button&, rButton, void) if (xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry)) { - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry)); if ( pPageInfo->m_xPage ) { std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator(xCurrentPageEntry.get()); xTreeLB->iter_parent(*xParent); - pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64()); + pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId && pPageInfo->m_xPage->HasExchangeSupport() ) { @@ -766,6 +779,306 @@ IMPL_LINK(OfaTreeOptionsDialog, ApplyHdl_Impl, weld::Button&, rButton, void) m_xDialog->response(RET_OK); } +IMPL_LINK_NOARG(OfaTreeOptionsDialog, FocusOut_Impl, weld::Widget&, void) +{ + if (m_aUpdateDataTimer.IsActive()) + { + m_aUpdateDataTimer.Stop(); + m_aUpdateDataTimer.Invoke(); + } +} + +IMPL_LINK_NOARG(OfaTreeOptionsDialog, SearchUpdateHdl, weld::Entry&, void) +{ + m_aUpdateDataTimer.Start(); +} + +IMPL_LINK_NOARG(OfaTreeOptionsDialog, ImplUpdateDataHdl, Timer*, void) +{ + // initializeFirstNDialog() can take a long time, show wait cursor and disable input + std::unique_ptr<weld::WaitObject> xWait(m_pParent ? new weld::WaitObject(m_pParent) : nullptr); + + // Pause redraw + xTreeLB->freeze(); + + if (bIsFirtsInitialize) + { + m_xSearchEdit->freeze(); + xTreeLB->hide(); + + initializeFirstNDialog(); + + m_xSearchEdit->thaw(); + xTreeLB->show(); + bIsFirtsInitialize = false; + } + + // Apply the search filter + OUString aSearchTerm(m_xSearchEdit->get_text()); + int nMatchFound = applySearchFilter(aSearchTerm); + + // Resume redraw + xTreeLB->thaw(); + + // select first child of first node after the search done + if (nMatchFound != -1) + selectFirstEntry(); +} + +void OfaTreeOptionsDialog::selectFirstEntry() +{ + std::unique_ptr<weld::TreeIter> xTemp = xTreeLB->make_iterator(); + bool bTemp = xTreeLB->get_iter_first(*xTemp); + + while (bTemp) + { + // select only the first child + if (xTreeLB->get_iter_depth(*xTemp) && xTreeLB->get_id(*xTemp).toInt64()) + { + std::unique_ptr<weld::TreeIter> xEntry(xTreeLB->make_iterator(xTemp.get())); + + std::unique_ptr<weld::TreeIter> xParent(xTreeLB->make_iterator(xEntry.get())); + xTreeLB->iter_parent(*xParent); + xTreeLB->expand_row(*xParent); + xTreeLB->scroll_to_row(*xParent); + xTreeLB->scroll_to_row(*xEntry); + xTreeLB->set_cursor(*xEntry); + xTreeLB->select(*xEntry); + SelectHdl_Impl(); + + break; + } + bTemp = xTreeLB->iter_next(*xTemp); + } +} + +void OfaTreeOptionsDialog::initializeFirstNDialog(sal_Int16 nNumberOfNode) +{ + std::unique_ptr<weld::TreeIter> xEntry; + sal_Int16 nCount = 0; + + std::unique_ptr<weld::TreeIter> xTemp = xTreeLB->make_iterator(); + bool bTemp = xTreeLB->get_iter_first(*xTemp); + + while (bTemp) + { + if (xTreeLB->get_iter_depth(*xTemp) && xTreeLB->get_id(*xTemp).toInt64()) + { + if (!(xEntry = xTreeLB->make_iterator(xTemp.get()))) + { + xEntry = xTreeLB->make_iterator(); + if (!xTreeLB->get_iter_first(*xEntry) || !xTreeLB->iter_next(*xEntry)) + xEntry.reset(); + } + + if (!xEntry) + return; + + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); + if (TreeOptHelper::getStringsFromDialog(pPageInfo->m_nPageId).isEmpty()) + { + SolarMutexGuard aGuard; + initializeCurrentDialog(pPageInfo, xEntry); + } + } + + /* if nNumberOfNode is -1 (which is the default value if no parameter provided), + this function will initialize all dialogs since nCount always greater than -1 */ + if (nCount == nNumberOfNode) + break; + + ++nCount; + bTemp = xTreeLB->iter_next(*xTemp); + } +} + +void OfaTreeOptionsDialog::clearOptionsDialog() +{ + // clear and reset + std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator(); + bool bEntry = xTreeLB->get_iter_first(*xEntry); + + while (bEntry) + { + if (xTreeLB->get_iter_depth(*xEntry)) + { + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); + if (pPageInfo->m_xPage) + pPageInfo->m_xPage.reset(); + } + bEntry = xTreeLB->iter_next(*xEntry); + } + xCurrentPageEntry.reset(); +} + +// store Options tree with their page names +void OfaTreeOptionsDialog::storeOptionsTree() +{ + m_aTreePageIds.clear(); + + sal_uInt16 aParentId = 0; + OUString sParentName; + + std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator(); + bool bEntry = xTreeLB->get_iter_first(*xEntry); + + while (bEntry) + { + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry)); + bool bIsParentNode = !xTreeLB->get_iter_depth(*xEntry); + + if (bIsParentNode) + { + // Parent node + sParentName = xTreeLB->get_text(*xEntry); + aParentId = pGroupInfo->m_nDialogId; + m_aTreePageIds.push_back(new OptionsPageIdInfo(sParentName, sParentName, aParentId, 0)); + } + else + { + // Child node + OUString sChildName = xTreeLB->get_text(*xEntry); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); + m_aTreePageIds.push_back( + new OptionsPageIdInfo(sParentName, sChildName, aParentId, pPageInfo->m_nPageId)); + } + bEntry = xTreeLB->iter_next(*xEntry); + } +} + +int OfaTreeOptionsDialog::applySearchFilter(const OUString& rSearchTerm) +{ + if (rSearchTerm.isEmpty()) + { + clearOptionsDialog(); + xTreeLB->clear(); + Initialize(m_xFrame); + + return 0; + } + + m_options.searchString = rSearchTerm; + utl::TextSearch textSearch(m_options); + + clearOptionsDialog(); + + if (xTreeLB->n_children() > 0) + xTreeLB->clear(); + + std::vector<std::pair<sal_uInt16, std::vector<sal_uInt16>>> aFoundIdsVector; + + for (std::size_t i = 0; i < m_aTreePageIds.size(); ++i) + { + const OUString sParentName = m_aTreePageIds[i]->m_sParentName; + const OUString sPageName = m_aTreePageIds[i]->m_sPageName; + const sal_uInt16 nParentId = m_aTreePageIds[i]->m_nParentId; + const sal_uInt16 nPageId = m_aTreePageIds[i]->m_nPageId; + + const OUString sPageStrings = TreeOptHelper::getStringsFromDialog(nPageId); + const OUString sPageNameAndStrings = sParentName + " " + sPageName + " " + sPageStrings; + + sal_Int32 aStartPos = 0; + sal_Int32 aEndPos = sPageNameAndStrings.getLength(); + + // check if rSearchTerm matches with sPageNameAndStrings + if (textSearch.SearchForward(sPageNameAndStrings, &aStartPos, &aEndPos)) + { + bool isFound = false; + for (auto& aEntryId : aFoundIdsVector) + { + if (aEntryId.first == nParentId) + { + isFound = true; + aEntryId.second.push_back(nPageId); + } + } + + if (!isFound) + aFoundIdsVector.push_back({ nParentId, { nPageId } }); + } + } + + showDialog(aFoundIdsVector); + + // if treeview is empty, return -1 + return xTreeLB->n_children() ? 0 : -1; +} + +void OfaTreeOptionsDialog::showDialog(VectorOfMatchedIds& pSearchIds) +{ + // + // void generalOptions(); // SID_GENERAL_OPTIONS + // void loadAndSaveOptions(); // SID_FILTER_DLG + // void languageOptions(); // SID_LANGUAGE_OPTIONS + // void writerOptions(); // SID_SW_EDITOPTIONS + // void writerWebOptions(); // SID_SW_ONLINEOPTIONS + // void calcOptions(); // SID_SC_EDITOPTIONS + // void impressOptions(); // SID_SD_EDITOPTIONS + // void drawOptions(); // SID_SD_GRAPHIC_OPTIONS + // void mathOptions(); // SID_SM_EDITOPTIONS + // void databaseOptions(); // SID_SB_STARBASEOPTIONS + // void chartOptions(); // SID_SCH_EDITOPTIONS + // void internetOptions(); // SID_INET_DLG + // + + for (auto& aEntryId : pSearchIds) + { + switch (aEntryId.first) + { + case SID_GENERAL_OPTIONS: + generalOptions(aEntryId.second); + break; + + case SID_FILTER_DLG: + loadAndSaveOptions(aEntryId.second); + break; + + case SID_LANGUAGE_OPTIONS: + languageOptions(aEntryId.second); + break; + + case SID_SW_EDITOPTIONS: + writerOptions(aEntryId.second); + break; + + case SID_SW_ONLINEOPTIONS: + writerWebOptions(aEntryId.second); + break; + + case SID_SC_EDITOPTIONS: + calcOptions(aEntryId.second); + break; + + case SID_SD_EDITOPTIONS: + impressOptions(aEntryId.second); + break; + + case SID_SD_GRAPHIC_OPTIONS: + drawOptions(aEntryId.second); + break; + + case SID_SM_EDITOPTIONS: + mathOptions(aEntryId.second); + break; + + case SID_SB_STARBASEOPTIONS: + databaseOptions(aEntryId.second); + break; + + case SID_SCH_EDITOPTIONS: + chartOptions(aEntryId.second); + break; + + case SID_INET_DLG: + internetOptions(aEntryId.second); + break; + + default: + break; + } + } +} + void OfaTreeOptionsDialog::ApplyItemSets() { std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator(); @@ -774,7 +1087,7 @@ void OfaTreeOptionsDialog::ApplyItemSets() { if (!xTreeLB->get_iter_depth(*xEntry)) { - OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry).toInt64()); + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry)); if(pGroupInfo->m_pOutItemSet) { if(pGroupInfo->m_pShell) @@ -787,16 +1100,6 @@ void OfaTreeOptionsDialog::ApplyItemSets() } } -void OfaTreeOptionsDialog::InitTreeAndHandler() -{ - xTreeLB->set_help_id(HID_OFADLG_TREELISTBOX); - xTreeLB->connect_changed( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) ); - xBackPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) ); - xApplyPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, ApplyHdl_Impl ) ); - xOkPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, ApplyHdl_Impl ) ); - m_xDialog->connect_help( LINK( this, OfaTreeOptionsDialog, HelpHdl_Impl ) ); -} - void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId ) { bIsForSetDocumentLanguage = false; @@ -850,7 +1153,7 @@ void OfaTreeOptionsDialog::ActivateLastSelection() // restore only selection of a leaf if (xTreeLB->get_iter_depth(*xTemp) && xTreeLB->get_id(*xTemp).toInt64()) { - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xTemp).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xTemp)); OUString sPageURL = pPageInfo->m_sPageURL; if ( bMustExpand ) { @@ -887,7 +1190,16 @@ void OfaTreeOptionsDialog::ActivateLastSelection() xTreeLB->scroll_to_row(*xEntry); xTreeLB->set_cursor(*xEntry); xTreeLB->select(*xEntry); - xTreeLB->grab_focus(); + m_xSearchEdit->grab_focus(); + SelectHdl_Impl(); + + // initializeFirstNDialog() can take a long time, show wait cursor + std::unique_ptr<weld::WaitObject> xWait(m_pParent ? new weld::WaitObject(m_pParent) : nullptr); + + /* initialize first 25 dialogs which are almost half of the dialogs + in a row while Options dialog opens. then clear&reselect to avoid UI test failures. */ + initializeFirstNDialog(25); + clearOptionsDialog(); SelectHdl_Impl(); } @@ -903,6 +1215,70 @@ void OfaTreeOptionsDialog::InitItemSets(OptionsGroupInfo& rGroupInfo) rGroupInfo.m_pInItemSet->GetRanges()); } +void OfaTreeOptionsDialog::initializeCurrentDialog(OptionsPageInfo*& pPageInfo, + std::unique_ptr<weld::TreeIter>& xEntry) +{ + std::unique_ptr<weld::TreeIter> xParent(xTreeLB->make_iterator(xEntry.get())); + bool bParent = xTreeLB->iter_parent(*xParent); + + if (!bParent) + return; + + if (pPageInfo->m_xPage) + { + TreeOptHelper::storeStringsOfDialog(pPageInfo->m_nPageId, + pPageInfo->m_xPage->GetAllStrings()); + return; + } + + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); + + if (!pPageInfo->m_xPage && pPageInfo->m_nPageId > 0) + { + InitItemSets(*pGroupInfo); + + pPageInfo->m_xPage = ::CreateGeneralTabPage(pPageInfo->m_nPageId, xTabBox.get(), this, + *pGroupInfo->m_pInItemSet); + + if (!pPageInfo->m_xPage && pGroupInfo->m_pModule) + pPageInfo->m_xPage = pGroupInfo->m_pModule->CreateTabPage( + pPageInfo->m_nPageId, xTabBox.get(), this, *pGroupInfo->m_pInItemSet); + + DBG_ASSERT(pPageInfo->m_xPage, "tabpage could not created"); + if (pPageInfo->m_xPage) + { + SvtViewOptions aTabPageOpt(EViewType::TabPage, OUString::number(pPageInfo->m_nPageId)); + pPageInfo->m_xPage->SetUserData(GetViewOptUserItem(aTabPageOpt)); + pPageInfo->m_xPage->SetFrame(m_xFrame); + pPageInfo->m_xPage->Reset(&*pGroupInfo->m_pInItemSet); + } + + TreeOptHelper::storeStringsOfDialog(pPageInfo->m_nPageId, + pPageInfo->m_xPage->GetAllStrings()); + + pPageInfo->m_xPage->set_visible(false); + } + else if (0 == pPageInfo->m_nPageId && !pPageInfo->m_xExtPage) + { + if (!m_xContainerWinProvider.is()) + m_xContainerWinProvider + = awt::ContainerWindowProvider::create(::comphelper::getProcessComponentContext()); + + pPageInfo->m_xExtPage = std::make_unique<ExtensionsTabPage>( + xTabBox.get(), pPageInfo->m_sPageURL, pPageInfo->m_sEventHdl, m_xContainerWinProvider); + + pPageInfo->m_xExtPage->Hide(); + } + + BuilderPage* pNewPage = pPageInfo->m_xPage.get(); + + // fdo#58170 use current page's layout child HelpId, unless there isn't a current page + OUString sHelpId(pNewPage ? pNewPage->GetHelpId() : OUString()); + if (sHelpId.isEmpty()) + sHelpId = HID_OFADLG_TREELISTBOX; + xTreeLB->set_help_id(sHelpId); +} + void OfaTreeOptionsDialog::SelectHdl_Impl() { std::unique_ptr<weld::TreeIter> xEntry(xTreeLB->make_iterator()); @@ -923,14 +1299,14 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() BuilderPage* pNewPage = nullptr; OptionsPageInfo* pOptPageInfo = (xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry)) - ? reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64()) : nullptr; + ? weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry)) : nullptr; if (pOptPageInfo && pOptPageInfo->m_xPage && pOptPageInfo->m_xPage->IsVisible()) { std::unique_ptr<weld::TreeIter> xCurParent(xTreeLB->make_iterator(xCurrentPageEntry.get())); xTreeLB->iter_parent(*xCurParent); - OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xCurParent).toInt64()); + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xCurParent)); DeactivateRC nLeave = DeactivateRC::LeavePage; if ( RID_SVXPAGE_COLOR != pOptPageInfo->m_nPageId && pOptPageInfo->m_xPage->HasExchangeSupport() ) nLeave = pOptPageInfo->m_xPage->DeactivatePage( pGroupInfo->m_pOutItemSet.get() ); @@ -951,8 +1327,8 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() pOptPageInfo->m_xExtPage->DeactivatePage(); } - OptionsPageInfo *pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xEntry).toInt64()); - OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64()); + OptionsPageInfo *pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); if(!pPageInfo->m_xPage && pPageInfo->m_nPageId > 0) { InitItemSets(*pGroupInfo); @@ -967,6 +1343,7 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() { SvtViewOptions aTabPageOpt( EViewType::TabPage, OUString::number( pPageInfo->m_nPageId) ); pPageInfo->m_xPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) ); + pPageInfo->m_xPage->SetFrame( m_xFrame ); pPageInfo->m_xPage->Reset( &*pGroupInfo->m_pInItemSet ); } } @@ -1022,7 +1399,7 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() pNewPage = pPageInfo->m_xPage.get(); // fdo#58170 use current page's layout child HelpId, unless there isn't a current page - OString sHelpId(pNewPage ? pNewPage->GetHelpId() : OString()); + OUString sHelpId(pNewPage ? pNewPage->GetHelpId() : OUString()); if (sHelpId.isEmpty()) sHelpId = HID_OFADLG_TREELISTBOX; xTreeLB->set_help_id(sHelpId); @@ -1046,18 +1423,19 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) SID_ATTR_YEAR2000, SID_ATTR_YEAR2000> ); SfxItemSetFixed<SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER> aOptSet( SfxGetpApp()->GetPool() ); - SfxGetpApp()->GetOptions(aOptSet); + SfxApplication::GetOptions(aOptSet); pRet->Put(aOptSet); SfxViewFrame* pViewFrame = SfxViewFrame::Current(); if ( pViewFrame ) { - const SfxPoolItem* pItem = nullptr; - SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); + SfxPoolItemHolder aResult; + const SfxItemState aState(pViewFrame->GetDispatcher()->QueryState(SID_ATTR_YEAR2000, aResult)); + const SfxUInt16Item* pItem(static_cast<const SfxUInt16Item*>(aResult.getItem())); // miscellaneous - Year2000 - if( SfxItemState::DEFAULT <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) ) - pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, static_cast<const SfxUInt16Item*>(pItem)->GetValue() ) ); + if(SfxItemState::DEFAULT <= aState && nullptr != pItem) + pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, pItem->GetValue() ) ); else pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, officecfg::Office::Common::DateFormat::TwoDigitYear::get() ) ); } @@ -1102,31 +1480,28 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) SfxViewFrame* pViewFrame = SfxViewFrame::Current(); if ( pViewFrame ) { - const SfxPoolItem* pItem = nullptr; - SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem)) - pRet->Put( - SvxLanguageItem( - (static_cast<const SvxLanguageItem*>(pItem) - ->GetLanguage()), - SID_ATTR_LANGUAGE)); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem)) - pRet->Put( - SvxLanguageItem( - (static_cast<const SvxLanguageItem*>(pItem) - ->GetLanguage()), - SID_ATTR_CHAR_CJK_LANGUAGE)); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem)) - pRet->Put( - SvxLanguageItem( - (static_cast<const SvxLanguageItem*>(pItem) - ->GetLanguage()), - SID_ATTR_CHAR_CTL_LANGUAGE)); + SfxPoolItemHolder aResult; + SfxDispatcher* pDispatch(pViewFrame->GetDispatcher()); + + SfxItemState aState(pDispatch->QueryState(SID_ATTR_LANGUAGE, aResult)); + if(SfxItemState::DEFAULT <= aState) + pRet->Put(*aResult.getItem()); + + aState = pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, aResult); + if(SfxItemState::DEFAULT <= aState) + pRet->Put(*aResult.getItem()); + + aState = pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, aResult); + if(SfxItemState::DEFAULT <= aState) + pRet->Put(*aResult.getItem()); pRet->Put(aHyphen); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem)) + + aState = pDispatch->QueryState(SID_AUTOSPELL_CHECK, aResult); + if(SfxItemState::DEFAULT <= aState) { - pRet->Put(std::unique_ptr<SfxPoolItem>(pItem->Clone())); + pRet->Put(*aResult.getItem()); // allow share/refcounting + // pRet->Put(std::unique_ptr<SfxPoolItem>(aResult.getItem()->Clone())); } else { @@ -1147,9 +1522,9 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) svl::Items< //SID_OPTIONS_START - ..END SID_SAVEREL_INET, SID_SAVEREL_FSYS, - SID_INET_NOPROXY, SID_INET_FTP_PROXY_PORT, + SID_INET_NOPROXY, SID_INET_HTTP_PROXY_PORT, SID_SECURE_URL, SID_SECURE_URL> ); - SfxGetpApp()->GetOptions(*pRet); + SfxApplication::GetOptions(*pRet); break; case SID_FILTER_DLG: pRet.emplace( @@ -1159,7 +1534,7 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) SID_ATTR_DOCINFO, SID_ATTR_AUTOSAVEMINUTE, SID_SAVEREL_INET, SID_SAVEREL_FSYS, SID_ATTR_PRETTYPRINTING, SID_ATTR_PRETTYPRINTING> ); - SfxGetpApp()->GetOptions(*pRet); + SfxApplication::GetOptions(*pRet); break; case SID_SB_STARBASEOPTIONS: @@ -1171,9 +1546,8 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) case SID_SCH_EDITOPTIONS: { - SvxChartOptions aChartOpt; pRet.emplace( SfxGetpApp()->GetPool(), svl::Items<SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS> ); - pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) ); + pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, SvxChartOptions::GetDefaultColors() ) ); break; } } @@ -1188,36 +1562,35 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet { std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); - const SfxPoolItem* pItem = nullptr; SfxItemSetFixed<SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER> aOptSet(SfxGetpApp()->GetPool()); aOptSet.Put(rSet); if(aOptSet.Count()) - SfxGetpApp()->SetOptions( aOptSet ); + SfxApplication::SetOptions( aOptSet ); // get dispatcher anew, because SetOptions() might have destroyed the dispatcher SfxViewFrame *pViewFrame = SfxViewFrame::Current(); // evaluate Year2000 sal_uInt16 nY2K = USHRT_MAX; - if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_YEAR2000, false, &pItem ) ) - nY2K = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + const SfxUInt16Item* pYearItem = rSet.GetItemIfSet( SID_ATTR_YEAR2000, false ); + if( pYearItem ) + nY2K = pYearItem->GetValue(); if( USHRT_MAX != nY2K ) { if ( pViewFrame ) { SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); pDispatch->ExecuteList(SID_ATTR_YEAR2000, - SfxCallMode::ASYNCHRON, { pItem }); + SfxCallMode::ASYNCHRON, { pYearItem }); } officecfg::Office::Common::DateFormat::TwoDigitYear::set(nY2K, batch); } // evaluate print - if(SfxItemState::SET == rSet.GetItemState(SID_PRINTER_NOTFOUND_WARN, false, &pItem)) - officecfg::Office::Common::Print::Warning::NotFound::set(static_cast<const SfxBoolItem*>(pItem)->GetValue(), batch); + if(const SfxBoolItem* pWarnItem = rSet.GetItemIfSet(SID_PRINTER_NOTFOUND_WARN, false)) + officecfg::Office::Common::Print::Warning::NotFound::set(pWarnItem->GetValue(), batch); - if(SfxItemState::SET == rSet.GetItemState(SID_PRINTER_CHANGESTODOC, false, &pItem)) + if(const SfxFlagItem* pFlag = rSet.GetItemIfSet(SID_PRINTER_CHANGESTODOC, false)) { - const SfxFlagItem* pFlag = static_cast<const SfxFlagItem*>(pItem); bool bPaperSizeWarning = bool(static_cast<SfxPrinterChangeFlags>(pFlag->GetValue()) & SfxPrinterChangeFlags::CHG_SIZE); officecfg::Office::Common::Print::Warning::PaperSize::set(bPaperSizeWarning, batch); bool bPaperOrientationWarning = bool(static_cast<SfxPrinterChangeFlags>(pFlag->GetValue()) & SfxPrinterChangeFlags::CHG_ORIENTATION); @@ -1242,7 +1615,7 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet break; case SID_INET_DLG : case SID_FILTER_DLG: - SfxGetpApp()->SetOptions( rSet ); + SfxApplication::SetOptions( rSet ); break; case SID_SB_STARBASEOPTIONS: @@ -1256,7 +1629,7 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet default: { - OSL_FAIL( "Unhandled option in ApplyItemSet" ); + SAL_WARN("cui.options", "Unhandled option in ApplyItemSet"); } break; } @@ -1269,10 +1642,8 @@ void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet) Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); Reference< XLinguProperties > xProp = LinguProperties::create( xContext ); - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_HYPHENREGION, false, &pItem ) ) + if ( const SfxHyphenRegionItem* pHyphenItem = rSet.GetItemIfSet(SID_ATTR_HYPHENREGION, false ) ) { - const SfxHyphenRegionItem* pHyphenItem = static_cast<const SfxHyphenRegionItem*>(pItem); - xProp->setHyphMinLeading( static_cast<sal_Int16>(pHyphenItem->GetMinLead()) ); xProp->setHyphMinTrailing( static_cast<sal_Int16>(pHyphenItem->GetMinTrail()) ); bSaveSpellCheck = true; @@ -1328,7 +1699,7 @@ void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet) } } -static OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame ) +OUString OfaTreeOptionsDialog::getCurrentFactory_Impl( const Reference< XFrame >& _xFrame ) { OUString sIdentifier; Reference < XFrame > xCurrentFrame( _xFrame ); @@ -1358,19 +1729,17 @@ static OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame ) return sIdentifier; } -void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) +void OfaTreeOptionsDialog::generalOptions(const std::vector<sal_uInt16>& vPageId) { sal_uInt16 nGroup = 0; - SvtOptionsDialogOptions aOptionsDlgOpt; - sal_uInt16 nPageId; + sal_uInt16 nPageId = 0; - // %PRODUCTNAME options if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS, aOptionsDlgOpt ) ) { setGroupName(u"ProductName", CuiResId(SID_GENERAL_OPTIONS_RES[0].first)); nGroup = AddGroup(CuiResId(SID_GENERAL_OPTIONS_RES[0].first), nullptr, nullptr, SID_GENERAL_OPTIONS ); - const sal_uInt16 nEnd = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_GENERAL_OPTIONS_RES)); + const sal_uInt16 nEnd = static_cast<sal_uInt16>(std::size(SID_GENERAL_OPTIONS_RES)); for (sal_uInt16 i = 1; i < nEnd; ++i) { @@ -1379,67 +1748,101 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; - // Disable Online Update page if service not installed - if( RID_SVXPAGE_ONLINEUPDATE == nPageId ) + // Disable Online Update page if neither mode is available + if( RID_SVXPAGE_ONLINEUPDATE == nPageId + && !(SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateAvailable() + || SvxOnlineUpdateTabPage::isMarOnlineUpdateAvailable()) ) { - try - { - Reference < XInterface > xService( setup::UpdateCheck::create( ::comphelper::getProcessComponentContext() ) ); - if( ! xService.is() ) - continue; - } - catch ( css::uno::DeploymentException& ) - { - continue; - } + continue; } - // Disable Basic IDE options, if experimental features are not enabled - if( RID_SVXPAGE_BASICIDE_OPTIONS == nPageId ) + if (!vPageId.empty()) { - if( ! officecfg::Office::Common::Misc::ExperimentalMode::get() ) - continue; + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, sNewTitle, nGroup); } - - AddTabPage( nPageId, sNewTitle, nGroup ); + else + AddTabPage(nPageId, sNewTitle, nGroup); } } +} + +void OfaTreeOptionsDialog::loadAndSaveOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - // Load and Save options if ( !lcl_isOptionHidden( SID_FILTER_DLG, aOptionsDlgOpt ) ) { setGroupName( u"LoadSave", CuiResId(SID_FILTER_DLG_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_FILTER_DLG_RES[0].first), nullptr, nullptr, SID_FILTER_DLG ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_FILTER_DLG_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_FILTER_DLG_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_FILTER_DLG_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage( nPageId, CuiResId(SID_FILTER_DLG_RES[i].first), nGroup ); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_FILTER_DLG_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_FILTER_DLG_RES[i].first), nGroup); + } } } +} + +void OfaTreeOptionsDialog::languageOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - // Language options SvtCTLOptions aCTLLanguageOptions; if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS, aOptionsDlgOpt ) ) { setGroupName(u"LanguageSettings", CuiResId(SID_LANGUAGE_OPTIONS_RES[0].first)); nGroup = AddGroup(CuiResId(SID_LANGUAGE_OPTIONS_RES[0].first), nullptr, nullptr, SID_LANGUAGE_OPTIONS ); - for (size_t i = 1; i < SAL_N_ELEMENTS(SID_LANGUAGE_OPTIONS_RES); ++i) + for (size_t i = 1; i < std::size(SID_LANGUAGE_OPTIONS_RES); ++i) { nPageId = static_cast<sal_uInt16>(SID_LANGUAGE_OPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; + + // Disable DeepL translation settings, if experimental mode is not enabled + if( RID_SVXPAGE_DEEPL_OPTIONS == nPageId ) + { + if( ! officecfg::Office::Common::Misc::ExperimentalMode::get() ) + continue; + } + if ( ( RID_SVXPAGE_JSEARCH_OPTIONS != nPageId || SvtCJKOptions::IsJapaneseFindEnabled() ) && ( RID_SVXPAGE_ASIAN_LAYOUT != nPageId || SvtCJKOptions::IsAsianTypographyEnabled() ) && - ( RID_SVXPAGE_OPTIONS_CTL != nPageId || aCTLLanguageOptions.IsCTLFontEnabled() ) ) - AddTabPage(nPageId, CuiResId(SID_LANGUAGE_OPTIONS_RES[i].first), nGroup); + ( RID_SVXPAGE_OPTIONS_CTL != nPageId || SvtCTLOptions::IsCTLFontEnabled() ) ) + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_LANGUAGE_OPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_LANGUAGE_OPTIONS_RES[i].first), nGroup); + } } } +} + +void OfaTreeOptionsDialog::writerOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - OUString aFactory = getCurrentFactory_Impl( _xFrame ); - DBG_ASSERT( GetModuleIdentifier( _xFrame ) == aFactory, "S H I T!!!" ); + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); - // Writer and Writer/Web options SvtModuleOptions aModuleOpt; if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::WRITER ) ) { @@ -1456,38 +1859,105 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) else setGroupName( u"Writer", CuiResId(SID_SW_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup(CuiResId(SID_SW_EDITOPTIONS_RES[0].first), pSwMod, pSwMod, SID_SW_EDITOPTIONS ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SW_EDITOPTIONS_RES); ++i ) + SvtCTLOptions aCTLLanguageOptions; + for ( size_t i = 1; i < std::size(SID_SW_EDITOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SW_EDITOPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; if ( ( RID_SW_TP_STD_FONT_CJK != nPageId || SvtCJKOptions::IsCJKFontEnabled() ) && - ( RID_SW_TP_STD_FONT_CTL != nPageId || aCTLLanguageOptions.IsCTLFontEnabled() ) && - ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfg_Impl().IsEmailSupported() ) ) - AddTabPage( nPageId, CuiResId(SID_SW_EDITOPTIONS_RES[i].first), nGroup ); + ( RID_SW_TP_STD_FONT_CTL != nPageId || SvtCTLOptions::IsCTLFontEnabled() ) && + ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfgIsEmailSupported() ) ) + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SW_EDITOPTIONS_RES[i].first), + nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SW_EDITOPTIONS_RES[i].first), nGroup); + } } #ifdef DBG_UTIL - AddTabPage( RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), RID_SW_TP_OPTTEST_PAGE) + != vPageId.end()) + AddTabPage(RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup); + } + else + AddTabPage(RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup); #endif } + } + } +} + +void OfaTreeOptionsDialog::writerWebOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + + SvtModuleOptions aModuleOpt; + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::WRITER ) ) + { + // text document + if ( aFactory == "com.sun.star.text.TextDocument" + || aFactory == "com.sun.star.text.WebDocument" + || aFactory == "com.sun.star.text.GlobalDocument" ) + { + SfxModule* pSwMod = SfxApplication::GetModule(SfxToolsModule::Writer); // HTML documents if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS, aOptionsDlgOpt ) ) { nGroup = AddGroup(CuiResId(SID_SW_ONLINEOPTIONS_RES[0].first), pSwMod, pSwMod, SID_SW_ONLINEOPTIONS ); - for( size_t i = 1; i < SAL_N_ELEMENTS(SID_SW_ONLINEOPTIONS_RES); ++i ) + for( size_t i = 1; i < std::size(SID_SW_ONLINEOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SW_ONLINEOPTIONS_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage(nPageId, CuiResId(SID_SW_ONLINEOPTIONS_RES[i].first), nGroup); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SW_ONLINEOPTIONS_RES[i].first), + nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SW_ONLINEOPTIONS_RES[i].first), + nGroup); + } } #ifdef DBG_UTIL - AddTabPage( RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), RID_SW_TP_OPTTEST_PAGE) + != vPageId.end()) + AddTabPage(RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup); + } + else + AddTabPage(RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup); #endif } } } +} + +void OfaTreeOptionsDialog::calcOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + SvtModuleOptions aModuleOpt; // Calc options if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::CALC ) ) { @@ -1498,18 +1968,35 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) SfxModule* pScMod = SfxApplication::GetModule( SfxToolsModule::Calc ); setGroupName( u"Calc", CuiResId(SID_SC_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SC_EDITOPTIONS_RES[0].first), pScMod, pScMod, SID_SC_EDITOPTIONS ); - const sal_uInt16 nCount = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_SC_EDITOPTIONS_RES)); + const sal_uInt16 nCount = static_cast<sal_uInt16>(std::size(SID_SC_EDITOPTIONS_RES)); for ( sal_uInt16 i = 1; i < nCount; ++i ) { nPageId = static_cast<sal_uInt16>(SID_SC_EDITOPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; - AddTabPage( nPageId, CuiResId(SID_SC_EDITOPTIONS_RES[i].first), nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SC_EDITOPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SC_EDITOPTIONS_RES[i].first), nGroup); } } } } +} + +void OfaTreeOptionsDialog::impressOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + SvtModuleOptions aModuleOpt; // Impress options SfxModule* pSdMod = SfxApplication::GetModule( SfxToolsModule::Draw ); @@ -1521,20 +2008,38 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) { setGroupName( u"Impress", CuiResId(SID_SD_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SD_EDITOPTIONS_RES[0].first), pSdMod, pSdMod, SID_SD_EDITOPTIONS ); - const sal_uInt16 nCount = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_SD_EDITOPTIONS_RES)); + const sal_uInt16 nCount = static_cast<sal_uInt16>(std::size(SID_SD_EDITOPTIONS_RES)); for ( sal_uInt16 i = 1; i < nCount; ++i ) { nPageId = static_cast<sal_uInt16>(SID_SD_EDITOPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; - AddTabPage( nPageId, CuiResId(SID_SD_EDITOPTIONS_RES[i].first), nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SD_EDITOPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SD_EDITOPTIONS_RES[i].first), nGroup); } } } } +} + +void OfaTreeOptionsDialog::drawOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + SvtModuleOptions aModuleOpt; // Draw options + SfxModule* pSdMod = SfxApplication::GetModule(SfxToolsModule::Draw); if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::DRAW ) ) { if ( aFactory == "com.sun.star.drawing.DrawingDocument" ) @@ -1543,18 +2048,36 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) { setGroupName( u"Draw", CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[0].first), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS ); - const sal_uInt16 nCount = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_SD_GRAPHIC_OPTIONS_RES)); + const sal_uInt16 nCount = static_cast<sal_uInt16>(std::size(SID_SD_GRAPHIC_OPTIONS_RES)); for ( sal_uInt16 i = 1; i < nCount; ++i ) { nPageId = static_cast<sal_uInt16>(SID_SD_GRAPHIC_OPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; - AddTabPage( nPageId, CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[i].first), nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[i].first), + nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[i].first), nGroup); } } } } +} + +void OfaTreeOptionsDialog::mathOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + SvtModuleOptions aModuleOpt; // Math options if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::MATH ) ) @@ -1566,15 +2089,33 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) SfxModule* pSmMod = SfxApplication::GetModule(SfxToolsModule::Math); setGroupName( u"Math", CuiResId(SID_SM_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup(CuiResId(SID_SM_EDITOPTIONS_RES[0].first), pSmMod, pSmMod, SID_SM_EDITOPTIONS ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SM_EDITOPTIONS_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_SM_EDITOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SM_EDITOPTIONS_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage( nPageId, CuiResId(SID_SM_EDITOPTIONS_RES[i].first), nGroup ); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SM_EDITOPTIONS_RES[i].first), + nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SM_EDITOPTIONS_RES[i].first), nGroup); + } } } } } +} + +void OfaTreeOptionsDialog::databaseOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + SvtModuleOptions aModuleOpt; // Database - needed only if there is an application which integrates with databases if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS, aOptionsDlgOpt ) && @@ -1585,35 +2126,63 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) { setGroupName( u"Base", CuiResId(SID_SB_STARBASEOPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SB_STARBASEOPTIONS_RES[0].first), nullptr, nullptr, SID_SB_STARBASEOPTIONS ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SB_STARBASEOPTIONS_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_SB_STARBASEOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SB_STARBASEOPTIONS_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage( nPageId, CuiResId(SID_SB_STARBASEOPTIONS_RES[i].first), nGroup ); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SB_STARBASEOPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SB_STARBASEOPTIONS_RES[i].first), nGroup); + } } } +} + +void OfaTreeOptionsDialog::chartOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - // Chart options (always installed and active) if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS, aOptionsDlgOpt ) ) { setGroupName( u"Charts", CuiResId(SID_SCH_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SCH_EDITOPTIONS_RES[0].first), nullptr, nullptr, SID_SCH_EDITOPTIONS ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SCH_EDITOPTIONS_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_SCH_EDITOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SCH_EDITOPTIONS_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage( nPageId, CuiResId(SID_SCH_EDITOPTIONS_RES[i].first), nGroup ); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SCH_EDITOPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SCH_EDITOPTIONS_RES[i].first), nGroup); + } } } +} + +void OfaTreeOptionsDialog::internetOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - // Internet options if ( lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) ) return; setGroupName(u"Internet", CuiResId(SID_INET_DLG_RES[0].first)); nGroup = AddGroup(CuiResId(SID_INET_DLG_RES[0].first), nullptr, nullptr, SID_INET_DLG ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_INET_DLG_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_INET_DLG_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_INET_DLG_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) @@ -1623,33 +2192,82 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) if ( nPageId == RID_SVXPAGE_INET_MAIL ) continue; #endif - AddTabPage( nPageId, CuiResId(SID_INET_DLG_RES[i].first), nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_INET_DLG_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_INET_DLG_RES[i].first), nGroup); } } +void OfaTreeOptionsDialog::Initialize(const Reference<XFrame>& _xFrame) +{ + m_xFrame = _xFrame; + + // %PRODUCTNAME options + generalOptions(); + + // Load and Save options + loadAndSaveOptions(); + + // Language options + languageOptions(); + + // Writer and Writer/Web options + writerOptions(); + writerWebOptions(); + + // Calc options + calcOptions(); + + // Impress options + impressOptions(); + + // Draw options + drawOptions(); + + // Math options + mathOptions(); + + // Database - needed only if there is an application which integrates with databases + databaseOptions(); + + // Chart options (always installed and active) + chartOptions(); + + // Internet options + internetOptions(); + + // store Options Dialogs with their page names and strings + // in order to use them when searching + storeOptionsTree(); +} + static bool isNodeActive( OptionsNode const * pNode, Module* pModule ) { - if ( pNode ) - { - // Node for all modules active? - if ( pNode->m_bAllModules ) - return true; + if ( !pNode ) + return false; - // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted - if ( !getGroupName( pNode->m_sId, false ).isEmpty() ) - return true; + // Node for all modules active? + if ( pNode->m_bAllModules ) + return true; - // no module -> not active - if ( !pModule ) - return false; + // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted + if ( !getGroupName( pNode->m_sId, false ).isEmpty() ) + return true; - // search node in active module - if ( pModule->m_bActive ) - { - for (auto const& j : pModule->m_aNodeList) - if ( j->m_sId == pNode->m_sId ) - return true; - } + // no module -> not active + if ( !pModule ) + return false; + + // search node in active module + if ( pModule->m_bActive ) + { + for (auto const& j : pModule->m_aNodeList) + if ( j->m_sId == pNode->m_sId ) + return true; } return false; } @@ -1961,8 +2579,7 @@ short OfaTreeOptionsDialog::run() if ( !bIsFromExtensionManager ) { // collect all DictionaryList Events while the dialog is executed - Reference<css::linguistic2::XSearchableDictionaryList> xDictionaryList(LinguMgr::GetDictionaryList()); - pClamp.reset( new SvxDicListChgClamp( xDictionaryList ) ); + pClamp.reset(new SvxDicListChgClamp(LinguMgr::GetDictionaryList())); } return SfxOkDialogController::run(); @@ -1970,11 +2587,11 @@ short OfaTreeOptionsDialog::run() // class ExtensionsTabPage ----------------------------------------------- ExtensionsTabPage::ExtensionsTabPage( - weld::Container* pParent, const OUString& rPageURL, - const OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) + weld::Container* pParent, OUString aPageURL, + OUString aEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) : m_pContainer(pParent) - , m_sPageURL(rPageURL) - , m_sEventHdl(rEvtHdl) + , m_sPageURL(std::move(aPageURL)) + , m_sEventHdl(std::move(aEvtHdl)) , m_xWinProvider(rProvider) { } |