starmath/source/ooxmlimport.cxx |   29 ++++++++++++++++++++++++++++-
 starmath/source/ooxmlimport.hxx |    1 +
 2 files changed, 29 insertions(+), 1 deletion(-)

New commits:
commit f325e0de3447c0403656ebb2a2fe4789aa59e78e
Author:     Pranam Lashkari <[email protected]>
AuthorDate: Wed Dec 24 18:24:16 2025 +0530
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sat Dec 27 17:45:58 2025 +0100

    tdf#169843 math: OOXML set letter not interpreted correctly
    
    problem:
    OOXML has special property to define set names
    m:scr with value "double-struck" means text should be
    interpreted as set names and double-struck letters should be used
    
    Change-Id: I8acefb369694ae901fc4df2505a85d0691a2cb16
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196199
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index f5752d736c85..6fe2e367f40f 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -21,6 +21,7 @@
 #include <sal/log.hxx>
 #include <o3tl/string_view.hxx>
 #include <parse5.hxx>
+#include <unordered_set>
 
 using namespace oox::formulaimport;
 
@@ -580,6 +581,7 @@ OUString SmOoxmlImport::handleR()
     m_rStream.ensureOpeningTag( M_TOKEN( r ));
     bool normal = false;
     bool literal = false;
+    OUString scrString;
     if( XmlStream::Tag rPr = m_rStream.checkOpeningTag( M_TOKEN( rPr )))
     {
         if( XmlStream::Tag litTag = m_rStream.checkOpeningTag( M_TOKEN( lit )))
@@ -592,6 +594,11 @@ OUString SmOoxmlImport::handleR()
             normal = norTag.attribute( M_TOKEN( val ), true );
             m_rStream.ensureClosingTag( M_TOKEN( nor ));
         }
+        if (XmlStream::Tag srcTag = m_rStream.checkOpeningTag( M_TOKEN( scr )))
+        {
+            scrString = srcTag.attribute( M_TOKEN( val ), scrString );
+            m_rStream.ensureClosingTag( M_TOKEN( scr ));
+        }
         m_rStream.ensureClosingTag( M_TOKEN( rPr ));
     }
     OUStringBuffer text;
@@ -605,6 +612,10 @@ OUString SmOoxmlImport::handleR()
                 isTagT = true;
                 XmlStream::Tag rtag = m_rStream.ensureOpeningTag( M_TOKEN( t 
));
                 OUString sTagText = rtag.text;
+                if (scrString == "double-struck")
+                {
+                    sTagText = SmOoxmlImport::handleSetString(sTagText);
+                }
                 if( rtag.attribute( OOX_TOKEN( xml, space )) != "preserve" )
                     sTagText = o3tl::trim(sTagText);
                 text.append(sTagText);
@@ -617,13 +628,29 @@ OUString SmOoxmlImport::handleR()
         }
     }
     m_rStream.ensureClosingTag( M_TOKEN( r ));
-    if (normal || literal || isTagT)
+    if (scrString.isEmpty() && (normal || literal || isTagT))
     {
         return encloseOrEscapeLiteral(text.makeStringAndClear(), normal || 
literal);
     }
     return text.makeStringAndClear();
 }
 
+OUString SmOoxmlImport::handleSetString(const OUString& setOUstring)
+{
+    std::unordered_set<sal_Unicode> setList= {'C', 'N', 'Q', 'R', 'Z', 'c', 
'n', 'q', 'r', 'z'};
+    OUString result;
+    for (sal_Int32 i = 0; i < setOUstring.getLength(); i++)
+    {
+        if (setList.contains(setOUstring[i]))
+        {
+            result += OUString::Concat(" set" ) + OUStringChar(setOUstring[i]) 
+ OUString::Concat(" ");
+        }
+        else
+            result += OUStringChar(setOUstring[i]);
+    }
+    return result;
+}
+
 OUString SmOoxmlImport::handleRad()
 {
     m_rStream.ensureOpeningTag( M_TOKEN( rad ));
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 4f8df14bfd16..e3621fdc0dec 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -44,6 +44,7 @@ private:
     OUString handleSsup();
     OUString readOMathArg( int stoptoken );
     OUString readOMathArgInElement( int token );
+    static OUString handleSetString(const OUString& setOUstring);
 
     oox::formulaimport::XmlStream& m_rStream;
 };

Reply via email to