formula/source/core/api/FormulaCompiler.cxx |   22 ++++++++++++++++++----
 include/formula/FormulaCompiler.hxx         |    1 +
 sc/inc/compiler.hxx                         |    1 +
 sc/source/core/tool/compiler.cxx            |    5 +++++
 4 files changed, 25 insertions(+), 4 deletions(-)

New commits:
commit 044980edc41544dd5973d5aa57f134d4bfe6d0e7
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Thu Aug 29 17:50:41 2024 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Fri Aug 30 03:04:44 2024 +0200

    Resolves: tdf#161599 Write Add-In CompatibilityName (if any) to OOXML
    
    First "en-US" (preferred) or "en" or any first if no "en-US" nor "en".
    
    Change-Id: Ifdb60547b588f224ee9ddca39af2352a87385bd0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172604
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/formula/source/core/api/FormulaCompiler.cxx 
b/formula/source/core/api/FormulaCompiler.cxx
index ecd7f60a28d2..2d192e0bd5f2 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -2699,11 +2699,20 @@ const FormulaToken* 
FormulaCompiler::CreateStringFromToken( OUStringBuffer& rBuf
                 bool bMapped = mxSymbols->isPODF();     // ODF 1.1 directly 
uses programmatical name
                 if (!bMapped && mxSymbols->hasExternals())
                 {
-                    ExternalHashMap::const_iterator iLook = 
mxSymbols->getReverseExternalHashMap().find( aAddIn);
-                    if (iLook != mxSymbols->getReverseExternalHashMap().end())
+                    if (mxSymbols->isOOXML())
                     {
-                        aAddIn = (*iLook).second;
-                        bMapped = true;
+                        // Write compatibility name, if any.
+                        if (GetExcelName( aAddIn))
+                            bMapped = true;
+                    }
+                    if (!bMapped)
+                    {
+                        ExternalHashMap::const_iterator iLook = 
mxSymbols->getReverseExternalHashMap().find( aAddIn);
+                        if (iLook != 
mxSymbols->getReverseExternalHashMap().end())
+                        {
+                            aAddIn = (*iLook).second;
+                            bMapped = true;
+                        }
                     }
                 }
                 if (!bMapped && !mxSymbols->isEnglish())
@@ -3002,6 +3011,11 @@ void FormulaCompiler::LocalizeString( OUString& 
/*rName*/ ) const
 {
 }
 
+bool FormulaCompiler::GetExcelName( OUString& /*rName*/ ) const
+{
+    return false;
+}
+
 formula::ParamClass FormulaCompiler::GetForceArrayParameter( const 
FormulaToken* /*pToken*/, sal_uInt16 /*nParam*/ ) const
 {
     return ParamClass::Unknown;
diff --git a/include/formula/FormulaCompiler.hxx 
b/include/formula/FormulaCompiler.hxx
index 2c4d816053d1..7e4477b53d6d 100644
--- a/include/formula/FormulaCompiler.hxx
+++ b/include/formula/FormulaCompiler.hxx
@@ -357,6 +357,7 @@ protected:
     virtual void CreateStringFromMatrix( OUStringBuffer& rBuffer, const 
FormulaToken* pToken ) const;
     virtual void CreateStringFromIndex( OUStringBuffer& rBuffer, const 
FormulaToken* pToken ) const;
     virtual void LocalizeString( OUString& rName ) const;   // modify rName - 
input: exact name
+    virtual bool GetExcelName( OUString& rName ) const;     // modify rName - 
input: exact name
 
     bool   GetToken();
     OpCode NextToken();
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index d0305bf474e2..33fe7ca97361 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -533,6 +533,7 @@ private:
     virtual void CreateStringFromMatrix( OUStringBuffer& rBuffer, const 
formula::FormulaToken* pToken ) const override;
     virtual void CreateStringFromIndex( OUStringBuffer& rBuffer, const 
formula::FormulaToken* pToken ) const override;
     virtual void LocalizeString( OUString& rName ) const override;   // modify 
rName - input: exact name
+    virtual bool GetExcelName( OUString& rName ) const override;    // modify 
rName - input: exact name
 
     virtual formula::ParamClass GetForceArrayParameter( const 
formula::FormulaToken* pToken, sal_uInt16 nParam ) const override;
 
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 1226f13b4e17..3d30f10fb0ed 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5599,6 +5599,11 @@ void ScCompiler::LocalizeString( OUString& rName ) const
     ScGlobal::GetAddInCollection()->LocalizeString( rName );
 }
 
+bool ScCompiler::GetExcelName( OUString& rName ) const
+{
+    return ScGlobal::GetAddInCollection()->GetExcelName( rName, 
LANGUAGE_ENGLISH_US, rName);
+}
+
 FormulaTokenRef ScCompiler::ExtendRangeReference( FormulaToken & rTok1, 
FormulaToken & rTok2 )
 {
     return extendRangeReference( rDoc.GetSheetLimits(), rTok1, rTok2, aPos, 
true/*bReuseDoubleRef*/ );

Reply via email to