cui/source/inc/treeopt.hxx                           |    2 
 cui/source/options/optsave.cxx                       |   40 +++++++++++++++----
 cui/source/options/treeopt.cxx                       |    4 +
 cui/uiconfig/ui/optsavepage.ui                       |    9 ----
 officecfg/registry/data/org/openoffice/Office/UI.xcu |   16 +++----
 5 files changed, 45 insertions(+), 26 deletions(-)

New commits:
commit 9e92437cbb2180d51fdabc0d5efff24b530ba27a
Author:     Baole Fang <baole.f...@gmail.com>
AuthorDate: Sat May 6 22:35:17 2023 -0400
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat May 27 09:00:08 2023 +0200

    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.kagan...@collabora.com>

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>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI.xcu
index f7919aa37c9f..2d403745d778 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI.xcu
@@ -23,7 +23,7 @@
       <node oor:name="Classes">
         <node oor:name="com.sun.star.text.TextDocument" oor:op="replace">
           <prop oor:name="DisplayName">
-            <value xml:lang="en-US">Text documents</value>
+            <value xml:lang="en-US">Text documents (Writer)</value>
           </prop>
           <prop oor:name="Filters">
             <value oor:separator=";">AportisDoc Palm DB;HTML 
(StarWriter);LotusWordPro;MS Word 2003 XML;MS Word 2007 XML;MS Word 2007 XML 
Template;MS Word 97;MS Word 97 Vorlage;MS_Works;Office Open XML Text;Office 
Open XML Text Template;OpenDocument Text Flat XML;PocketWord File;Rich Text 
Format;StarOffice XML 
(Writer);Text;WordPerfect;WordPerfect;writer_MIZI_Hwp_97;writer_StarOffice_XML_Writer_Template;writer8;writer8_template;writerglobal8;writerweb8_writer_template</value>
@@ -31,7 +31,7 @@
         </node>
         <node oor:name="com.sun.star.sheet.SpreadsheetDocument" 
oor:op="replace">
           <prop oor:name="DisplayName">
-            <value xml:lang="en-US">Spreadsheets</value>
+            <value xml:lang="en-US">Spreadsheets (Calc)</value>
           </prop>
           <prop oor:name="Filters">
             <value oor:separator=";">ADO Rowset XML;Calc MS Excel 2007 
Binary;Calc MS Excel 2007 XML;Calc MS Excel 2007 XML 
Template;calc_StarOffice_XML_Calc_Template;calc8;calc8_template;chart8;DIF;Lotus;MiniCalc
 (Palm);MS Excel 2003 XML;MS Excel 97;MS Excel 97 Vorlage/Template;OpenDocument 
Spreadsheet Flat XML;Pocket Excel;Quattro Pro 6.0;StarOffice XML 
(Calc);StarOffice XML (Chart);Text - txt - csv (StarCalc)</value>
@@ -39,7 +39,7 @@
         </node>
         <node oor:name="com.sun.star.presentation.PresentationDocument" 
oor:op="replace">
           <prop oor:name="DisplayName">
-            <value xml:lang="en-US">Presentations</value>
+            <value xml:lang="en-US">Presentations (Impress)</value>
           </prop>
           <prop oor:name="Filters">
             <value oor:separator=";">Impress MS PowerPoint 2007 XML;Impress MS 
PowerPoint 2007 XML AutoPlay;Impress MS PowerPoint 2007 XML 
Template;impress_StarOffice_XML_Draw;impress_StarOffice_XML_Impress_Template;impress8;impress8_template;MS
 PowerPoint 97;MS PowerPoint 97 AutoPlay;MS PowerPoint 97 Vorlage;OpenDocument 
Presentation Flat XML</value>
@@ -47,7 +47,7 @@
         </node>
         <node oor:name="com.sun.star.drawing.DrawingDocument" oor:op="replace">
           <prop oor:name="DisplayName">
-            <value xml:lang="en-US">Drawings</value>
+            <value xml:lang="en-US">Drawings (Draw)</value>
           </prop>
           <prop oor:name="Filters">
             <value 
oor:separator=";">draw_StarOffice_XML_Draw_Template;StarOffice XML 
(Draw);draw8;draw8_template;Visio Document;SVG - Scalable Vector Graphics;Corel 
Draw Document;Publisher Document</value>
@@ -55,7 +55,7 @@
         </node>
         <node oor:name="com.sun.star.text.WebDocument" oor:op="replace">
           <prop oor:name="DisplayName">
-            <value xml:lang="en-US">Web pages</value>
+            <value xml:lang="en-US">Web pages (Writer)</value>
           </prop>
           <prop oor:name="Filters">
             <value 
oor:separator=";">HTML;writer_web_StarOffice_XML_Writer_Web_Template;writerweb8_writer_template</value>
@@ -63,7 +63,7 @@
         </node>
         <node oor:name="com.sun.star.text.GlobalDocument" oor:op="replace">
           <prop oor:name="DisplayName">
-            <value xml:lang="en-US">Master documents</value>
+            <value xml:lang="en-US">Master documents (Writer)</value>
           </prop>
           <prop oor:name="Filters">
             <value 
oor:separator=";">writer_globaldocument_StarOffice_XML_Writer_GlobalDocument;writerglobal8</value>
@@ -71,7 +71,7 @@
         </node>
         <node oor:name="com.sun.star.formula.FormulaProperties" 
oor:op="replace">
           <prop oor:name="DisplayName">
-            <value xml:lang="en-US">Formulas</value>
+            <value xml:lang="en-US">Formulas (Math)</value>
           </prop>
           <prop oor:name="Filters">
             <value oor:separator=";">MathML XML (Math);MathType 3.x;StarOffice 
XML (Math);math8</value>
@@ -79,7 +79,7 @@
         </node>
         <node oor:name="com.sun.star.sdb.OfficeDatabaseDocument" 
oor:op="replace">
           <prop oor:name="DisplayName">
-            <value xml:lang="en-US">Database documents</value>
+            <value xml:lang="en-US">Database documents (Base)</value>
           </prop>
           <prop oor:name="Filters">
             <value oor:separator=";">StarOffice XML (Base)</value>

Reply via email to