diff options
author | Baole Fang <baole.fang@gmail.com> | 2023-05-06 22:35:17 -0400 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-05-27 09:00:08 +0200 |
commit | 9e92437cbb2180d51fdabc0d5efff24b530ba27a (patch) | |
tree | d60f34cc933af27f9d3a532bcfddad9ea5aa4e91 /cui | |
parent | 38e0e78998153463caf9c3c72ef7f4549ddff0e8 (diff) |
tdf#148756: Fix document type in option dialog
Change-Id: I16ef2adbb5c77960c18426ef6b2211d230adf410
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151455
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/treeopt.hxx | 2 | ||||
-rw-r--r-- | cui/source/options/optsave.cxx | 40 | ||||
-rw-r--r-- | cui/source/options/treeopt.cxx | 4 | ||||
-rw-r--r-- | cui/uiconfig/ui/optsavepage.ui | 9 |
4 files changed, 37 insertions, 18 deletions
diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx index 69278a1b5349..74ca73944b66 100644 --- a/cui/source/inc/treeopt.hxx +++ b/cui/source/inc/treeopt.hxx @@ -142,6 +142,7 @@ private: css::uno::Reference < css::awt::XContainerWindowProvider > m_xContainerWinProvider; + css::uno::Reference<css::frame::XFrame> m_xFrame; static LastPageSaver* pLastPageSaver; @@ -193,6 +194,7 @@ public: // helper functions to call the language settings TabPage from the SpellDialog static void ApplyLanguageOptions(const SfxItemSet& rSet); + static OUString getCurrentFactory_Impl( const css::uno::Reference< css::frame::XFrame >& _xFrame ); void SetNeedsRestart( svtools::RestartReason eReason ); }; diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx index 9b2aee019476..7799da84c8b6 100644 --- a/cui/source/options/optsave.cxx +++ b/cui/source/options/optsave.cxx @@ -43,6 +43,7 @@ #include <osl/diagnose.h> #include <comphelper/diagnose_ex.hxx> #include <officecfg/Office/Recovery.hxx> +#include <unotools/confignode.hxx> #include <sfx2/fcontnr.hxx> @@ -106,13 +107,20 @@ SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* p m_xODFVersionLB->set_id(4, OUString::number(SvtSaveOptions::ODFVER_013)); // 1.3 m_xODFVersionLB->set_id(5, OUString::number(SvtSaveOptions::ODFVER_LATEST)); // 1.3 Extended (recommended) - m_xDocTypeLB->set_id(0, OUString::number(APP_WRITER) ); - m_xDocTypeLB->set_id(1, OUString::number(APP_WRITER_WEB) ); - m_xDocTypeLB->set_id(2, OUString::number(APP_WRITER_GLOBAL)); - m_xDocTypeLB->set_id(3, OUString::number(APP_CALC) ); - m_xDocTypeLB->set_id(4, OUString::number(APP_IMPRESS) ); - m_xDocTypeLB->set_id(5, OUString::number(APP_DRAW) ); - m_xDocTypeLB->set_id(6, OUString::number(APP_MATH) ); + auto aFilterClassesNode = utl::OConfigurationTreeRoot::createWithComponentContext( + comphelper::getProcessComponentContext(), + "org.openoffice.Office.UI/FilterClassification/GlobalFilters/Classes", + -1, + utl::OConfigurationTreeRoot::CM_READONLY + ); + + m_xDocTypeLB->append(OUString::number(APP_WRITER), aFilterClassesNode.getNodeValue("com.sun.star.text.TextDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_WRITER_WEB), aFilterClassesNode.getNodeValue("com.sun.star.text.WebDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_WRITER_GLOBAL), aFilterClassesNode.getNodeValue("com.sun.star.text.GlobalDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_CALC), aFilterClassesNode.getNodeValue("com.sun.star.sheet.SpreadsheetDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_IMPRESS), aFilterClassesNode.getNodeValue("com.sun.star.presentation.PresentationDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_DRAW), aFilterClassesNode.getNodeValue("com.sun.star.drawing.DrawingDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_MATH), aFilterClassesNode.getNodeValue("com.sun.star.formula.FormulaProperties/DisplayName").get<OUString>()); m_xAutoSaveCB->connect_toggled( LINK( this, SvxSaveTabPage, AutoClickHdl_Impl ) ); @@ -434,7 +442,23 @@ void SvxSaveTabPage::Reset( const SfxItemSet* ) pImpl->aODFArr[nData] = lODFList; } } - m_xDocTypeLB->set_active(0); + OUString sModule = OfaTreeOptionsDialog::getCurrentFactory_Impl(GetFrame()); + sal_Int32 docId = 0; + if (sModule == "com.sun.star.text.TextDocument") + docId = APP_WRITER; + else if (sModule == "com.sun.star.text.WebDocument") + docId = APP_WRITER_WEB; + else if (sModule == "com.sun.star.text.GlobalDocument") + docId = APP_WRITER_GLOBAL; + else if (sModule == "com.sun.star.sheet.SpreadsheetDocument") + docId = APP_CALC; + else if (sModule == "com.sun.star.presentation.PresentationDocument") + docId = APP_IMPRESS; + else if (sModule == "com.sun.star.drawing.DrawingDocument") + docId = APP_DRAW; + else if (sModule == "com.sun.star.formula.FormulaProperties") + docId = APP_MATH; + m_xDocTypeLB->set_active_id(OUString::number(docId)); FilterHdl_Impl(*m_xDocTypeLB); } catch(Exception const &) diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index be7bcda79227..c32fb8d5fa7e 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -930,6 +930,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 ); } } @@ -1276,7 +1277,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 ); @@ -1308,6 +1309,7 @@ static OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame ) void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) { + m_xFrame = _xFrame; sal_uInt16 nGroup = 0; SvtOptionsDialogOptions aOptionsDlgOpt; diff --git a/cui/uiconfig/ui/optsavepage.ui b/cui/uiconfig/ui/optsavepage.ui index be612ec3b775..82c9910dcf72 100644 --- a/cui/uiconfig/ui/optsavepage.ui +++ b/cui/uiconfig/ui/optsavepage.ui @@ -418,15 +418,6 @@ <object class="GtkComboBoxText" id="doctype"> <property name="visible">True</property> <property name="can_focus">False</property> - <items> - <item translatable="yes" context="optsavepage|doctype">Text document</item> - <item translatable="yes" context="optsavepage|doctype">HTML document</item> - <item translatable="yes" context="optsavepage|doctype">Master document</item> - <item translatable="yes" context="optsavepage|doctype">Spreadsheet</item> - <item translatable="yes" context="optsavepage|doctype">Presentation</item> - <item translatable="yes" context="optsavepage|doctype">Drawing</item> - <item translatable="yes" context="optsavepage|doctype">Formula</item> - </items> <child internal-child="accessible"> <object class="AtkObject" id="doctype-atkobject"> <property name="AtkObject::accessible-description" translatable="yes" context="doctype">Specifies the document type for which you want to define the default file format.</property> |