starmath/inc/parse5.hxx                             |    4 +
 starmath/source/ooxmlimport.cxx                     |   16 ++--
 starmath/source/parse5.cxx                          |   41 ++++++++++
 sw/qa/extras/ooxmlexport/data/tdf162070_export.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx           |   77 +++++++++++---------
 sw/qa/extras/rtfexport/data/math-mso2007.rtf        |   12 +--
 sw/qa/extras/rtfexport/rtfexport.cxx                |   48 ++++++------
 7 files changed, 129 insertions(+), 69 deletions(-)

New commits:
commit b9a4096062313a16a87f63402ecb1b4007a337e8
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Tue Nov 12 12:50:10 2024 +0530
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed Dec 4 15:17:51 2024 +0100

    tdf#162070: enclose delimiters in in formula inside quotes
    
    problem:
    1. some characters were not correctly interpreted inside formulas
    casuing them to appear as inverted question mark.
    2. when some special symbols like 'abs' were inserted as normal string
    were replaced with symbols and sometimes also causing to invalidate formula
    and add inverted question mark
    
    Change-Id: Id1b0cda36727c1749619adc858b27212057b37e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176421
    Reviewed-by: Pranam Lashkari <lpra...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/starmath/inc/parse5.hxx b/starmath/inc/parse5.hxx
index 92fc2a02917b..83978709985a 100644
--- a/starmath/inc/parse5.hxx
+++ b/starmath/inc/parse5.hxx
@@ -119,4 +119,8 @@ public:
 
 inline bool SmParser5::TokenInGroup(TG nGroup) { return 
bool(m_aCurToken.nGroup & nGroup); }
 
+const SmTokenTableEntry* GetTokenTableEntry(const OUString& rName);
+
+OUString encloseOrEscapeLiteral(const OUString& string, bool force);
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index b0932c43919c..8ef223dcabe7 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -20,6 +20,7 @@
 #include <rtl/ustrbuf.hxx>
 #include <sal/log.hxx>
 #include <o3tl/string_view.hxx>
+#include <parse5.hxx>
 
 using namespace oox::formulaimport;
 
@@ -594,17 +595,19 @@ OUString SmOoxmlImport::handleR()
         m_rStream.ensureClosingTag( M_TOKEN( rPr ));
     }
     OUStringBuffer text;
+    bool isTagT = false;
     while( !m_rStream.atEnd() && m_rStream.currentToken() != CLOSING( 
m_rStream.currentToken()))
     {
         switch( m_rStream.currentToken())
         {
             case OPENING( M_TOKEN( t )):
             {
+                isTagT = true;
                 XmlStream::Tag rtag = m_rStream.ensureOpeningTag( M_TOKEN( t 
));
+                OUString sTagText = rtag.text;
                 if( rtag.attribute( OOX_TOKEN( xml, space )) != "preserve" )
-                    text.append(o3tl::trim(rtag.text.replaceAll("(", 
"\(").replaceAll(")", "\)")));
-                else
-                    text.append(rtag.text.replaceAll("(", 
"\(").replaceAll(")", "\)"));
+                    sTagText = o3tl::trim(sTagText);
+                text.append(sTagText);
                 m_rStream.ensureClosingTag( M_TOKEN( t ));
                 break;
             }
@@ -614,12 +617,11 @@ OUString SmOoxmlImport::handleR()
         }
     }
     m_rStream.ensureClosingTag( M_TOKEN( r ));
-    if( normal || literal )
+    if (normal || literal || isTagT)
     {
-        text.insert(0, "\"");
-        text.append("\"");
+        return encloseOrEscapeLiteral(text.makeStringAndClear(), normal || 
literal);
     }
-    return text.makeStringAndClear().replaceAll("{", "\{").replaceAll("}", 
"\}");
+    return text.makeStringAndClear();
 }
 
 OUString SmOoxmlImport::handleRad()
diff --git a/starmath/source/parse5.cxx b/starmath/source/parse5.cxx
index 8f2815c3c3b4..39879a39334a 100644
--- a/starmath/source/parse5.cxx
+++ b/starmath/source/parse5.cxx
@@ -34,6 +34,7 @@
 #include <starmathdatabase.hxx>
 
 #include <stack>
+#include <unordered_set>
 
 using namespace ::com::sun::star::i18n;
 
@@ -323,7 +324,7 @@ static inline bool findCompare(const SmTokenTableEntry& 
lhs, const OUString& s)
 }
 
 //Returns the SmTokenTableEntry for a keyword
-static const SmTokenTableEntry* GetTokenTableEntry(const OUString& rName)
+const SmTokenTableEntry* GetTokenTableEntry(const OUString& rName)
 {
     if (rName.isEmpty())
         return nullptr; //avoid null pointer exceptions
@@ -335,6 +336,42 @@ static const SmTokenTableEntry* GetTokenTableEntry(const 
OUString& rName)
     return nullptr; //not found
 }
 
+OUString encloseOrEscapeLiteral(const OUString& string, bool force)
+{
+    if (force)
+        return "\"" + string + "\"";
+    OUStringBuffer result;
+    const std::unordered_set<sal_Unicode> DelimiterTable1{
+        //keeping " as first entry is important to not get into recursive 
replacement
+        ' ', ' ', '
', ' ', '+', '-', '*', '/', '=', '^',
+        '_', '#',  '%',  '>',  '<', '&', '|', '~', '`'
+    };
+    const std::unordered_set<sal_Unicode> DelimiterTable2{
+        //keeping " as first entry is important to not get into recursive 
replacement
+        '{', '}', '(', ')', '[', ']',
+    };
+    for (sal_Int32 i = 0; i < string.getLength(); i++)
+    {
+        if (string[i] == '"')
+            result.append("\"\\"\"");
+        else if (DelimiterTable1.find(string[i]) != DelimiterTable1.end())
+            result.append("\"" + OUStringChar(string[i]) + "\"");
+        else if (DelimiterTable2.find(string[i]) != DelimiterTable2.end())
+            result.append("\" + OUStringChar(string[i]));
+        else
+            result.append(string[i]);
+    }
+
+    OUString resultString = result.makeStringAndClear();
+    const SmTokenTableEntry* tkn = GetTokenTableEntry(resultString);
+    // excluding function and operator as they take arguments and can't treat 
them as litral or else arguments are not displayed correctly
+    if (tkn && tkn->nGroup != TG::Function && tkn->nGroup != TG::Oper)
+    {
+        resultString = "\"" + resultString + "\"";
+    }
+    return resultString;
+}
+
 static bool IsDelimiter(const OUString& rTxt, sal_Int32 nPos)
 { // returns 'true' iff cChar is '
 
@@ -344,7 +381,7 @@ static bool IsDelimiter(const OUString& rTxt, sal_Int32 
nPos)
     sal_Unicode cChar = rTxt[nPos];
 
     // check if 'cChar' is in the delimiter table
-    static const sal_Unicode aDelimiterTable[] = {
+    constexpr sal_Unicode aDelimiterTable[] = {
         ' ', '{', '}', '(', ')', '     ', '
', ' ', '+', '-',  '*', '/', '=', '[',
         ']', '^', '_', '#', '%', '>',  '<',  '&',  '|', '\', '"', '~', '`'
     }; //reordered by usage (by eye) for nanoseconds saving.
diff --git a/sw/qa/extras/ooxmlexport/data/tdf162070_export.docx 
b/sw/qa/extras/ooxmlexport/data/tdf162070_export.docx
new file mode 100644
index 000000000000..133edbd2d58f
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf162070_export.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index e18c1eebca5e..bc3c21ac1aba 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -261,7 +261,8 @@ CPPUNIT_TEST_FIXTURE(Test, testCommentsNested)
 CPPUNIT_TEST_FIXTURE(Test, testMathEscape)
 {
     loadAndReload("math-escape.docx");
-    CPPUNIT_ASSERT_EQUAL(OUString("\{ left [ right ] \( \) \}"), 
getFormula(getRun(getParagraph(1), 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("\{ \[ \] \( \) \}"),
+                         getFormula(getRun(getParagraph(1), 1)));
 }
 
 // Saving left and right for parentheses when importing not from the m:t tag 
(docx)
@@ -310,12 +311,13 @@ DECLARE_OOXMLEXPORT_TEST(testMathD, "math-d.docx")
 
 DECLARE_OOXMLEXPORT_TEST(testMathEscaping, "math-escaping.docx")
 {
-    CHECK_FORMULA( u"\u2212 \u221E < x < \u221E"_ustr, getFormula( getRun( 
getParagraph( 1 ), 1 )));
+    CHECK_FORMULA(u"\u2212 \u221E \"<\" x \"<\" \u221E"_ustr,
+                  getFormula(getRun(getParagraph(1), 1)));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testMathLim, "math-lim.docx")
 {
-    CHECK_FORMULA( u"lim from {x \u2192 1} {x}"_ustr, getFormula( getRun( 
getParagraph( 1 ), 1 )));
+    CHECK_FORMULA(u"lim from {x \u2192 1} {x}"_ustr, 
getFormula(getRun(getParagraph(1), 1)));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testMathMatrix, "math-matrix.docx")
@@ -326,38 +328,42 @@ DECLARE_OOXMLEXPORT_TEST(testMathMatrix, 
"math-matrix.docx")
 CPPUNIT_TEST_FIXTURE(Test, testMathMso2k7)
 {
     loadAndReload("math-mso2k7.docx");
-    CHECK_FORMULA( u"A = \u03C0 {r} ^ {2}"_ustr, getFormula( getRun( 
getParagraph( 1 ), 1 )));
-// TODO check the stack/binom difference
-//    CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left 
(binom {n} {k} right ) {x} ^ {k} {a} ^ {n-k}}",
-    CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left 
(stack {n # k} right ) {x} ^ {k} {a} ^ {n-k}}",
-        getFormula( getRun( getParagraph( 2 ), 1 )));
-    CHECK_FORMULA( u"{left (1+x right )} ^ {n} =1+ {nx} over {1!} + {n left 
(n-1 right ) {x} ^ {2}} over {2!} +\u2026"_ustr,
-        getFormula( getRun( getParagraph( 3 ), 1 )));
-// TODO check (cos/sin miss {})
-//    CHECK_FORMULA( "f left (x right ) = {a} rsub {0} + sum from {n=1} to 
{\xe2\x88\x9e} {left ({a} rsub {n} cos {{n\xcf\x80x} over {L}} + {b} rsub {n} 
sin {{n\xcf\x80x} over {L}} right )}",
-    CHECK_FORMULA( u"f left (x right ) = {a} rsub {0} + sum from {n=1} to 
{\u221E} {left ({a} rsub {n} cos {n\u03C0x} over {L} + {b} rsub {n} sin 
{n\u03C0x} over {L} right )}"_ustr,
-        getFormula( getRun( getParagraph( 4 ), 1 )));
-    CHECK_FORMULA( "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}", getFormula( getRun( 
getParagraph( 5 ), 1 )));
-    CHECK_FORMULA( u"x = {- b \u00B1 sqrt {{b} ^ {2} -4 ac}} over {2 a}"_ustr,
-        getFormula( getRun( getParagraph( 6 ), 1 )));
+    CHECK_FORMULA(u"A \"=\" \u03C0 {r} ^ {2}"_ustr, 
getFormula(getRun(getParagraph(1), 1)));
+    // TODO check the stack/binom difference
+    //    CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} 
{left (binom {n} {k} right ) {x} ^ {k} {a} ^ {n-k}}",
+    CHECK_FORMULA("{left (x\"+\"a right )} ^ {n} \"=\" sum from {k\"=\"0} to 
{n} {left (stack {n # "
+                  "k} right ) {x} ^ {k} {a} ^ {n\"-\"k}}",
+                  getFormula(getRun(getParagraph(2), 1)));
     CHECK_FORMULA(
-        u"{e} ^ {x} =1+ {x} over {1!} + {{x} ^ {2}} over {2!} + {{x} ^ {3}} 
over {3!} +\u2026,    -\u221E<x<\u221E"_ustr,
-        getFormula( getRun( getParagraph( 7 ), 1 )));
+        u"{left (1\"+\"x right )} ^ {n} \"=\"1\"+\" {nx} over {1!} \"+\" {n 
left (n\"-\"1 right ) {x} ^ {2}} over {2!} \"+\"\u2026"_ustr,
+        getFormula(getRun(getParagraph(3), 1)));
+    // TODO check (cos/sin miss {})
+    //    CHECK_FORMULA( "f left (x right ) = {a} rsub {0} + sum from {n=1} to 
{\xe2\x88\x9e} {left ({a} rsub {n} cos {{n\xcf\x80x} over {L}} + {b} rsub {n} 
sin {{n\xcf\x80x} over {L}} right )}",
     CHECK_FORMULA(
-//        "sin {\xce\xb1} \xc2\xb1 sin {\xce\xb2} =2 sin {{1} over {2} left 
(\xce\xb1\xc2\xb1\xce\xb2 right )} cos {{1} over {2} left 
(\xce\xb1\xe2\x88\x93\xce\xb2 right )}",
-// TODO check (cos/in miss {})
-        u"sin \u03B1 \u00B1 sin \u03B2 =2 sin {1} over {2} left 
(\u03B1\u00B1\u03B2 right ) cos {1} over {2} left (\u03B1\u2213\u03B2 right 
)"_ustr,
-        getFormula( getRun( getParagraph( 8 ), 1 )));
+        u"f left (x right ) \"=\" {a} rsub {0} \"+\" sum from {n\"=\"1} to 
{\u221E} {left ({a} rsub {n} cos {n\u03C0x} over {L} \"+\" {b} rsub {n} sin 
{n\u03C0x} over {L} right )}"_ustr,
+        getFormula(getRun(getParagraph(4), 1)));
+    CHECK_FORMULA("{a} ^ {2} \"+\" {b} ^ {2} \"=\" {c} ^ {2}",
+                  getFormula(getRun(getParagraph(5), 1)));
+    CHECK_FORMULA(u"x \"=\" {\"-\" b \u00B1 sqrt {{b} ^ {2} \"-\"4 ac}} over 
{2 a}"_ustr,
+                  getFormula(getRun(getParagraph(6), 1)));
     CHECK_FORMULA(
-//        "cos {\xce\xb1} + cos {\xce\xb2} =2 cos {{1} over {2} left 
(\xce\xb1+\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1-\xce\xb2 right )}",
-// TODO check (cos/sin miss {})
-        u"cos \u03B1 + cos \u03B2 =2 cos {1} over {2} left (\u03B1+\u03B2 
right ) cos {1} over {2} left (\u03B1-\u03B2 right )"_ustr,
-        getFormula( getRun( getParagraph( 9 ), 1 )));
+        u"{e} ^ {x} \"=\"1\"+\" {x} over {1!} \"+\" {{x} ^ {2}} over {2!} 
\"+\" {{x} ^ {3}} over {3!} \"+\"\u2026,\" \" \" \" 
\"-\"\u221E\"<\"x\"<\"\u221E"_ustr,
+        getFormula(getRun(getParagraph(7), 1)));
+    CHECK_FORMULA(
+        //        "sin {\xce\xb1} \xc2\xb1 sin {\xce\xb2} =2 sin {{1} over {2} 
left (\xce\xb1\xc2\xb1\xce\xb2 right )} cos {{1} over {2} left 
(\xce\xb1\xe2\x88\x93\xce\xb2 right )}",
+        // TODO check (cos/in miss {})
+        u"sin \u03B1 \u00B1 sin \u03B2 \"=\"2 sin {1} over {2} left 
(\u03B1\u00B1\u03B2 right ) cos {1} over {2} left (\u03B1\u2213\u03B2 right 
)"_ustr,
+        getFormula(getRun(getParagraph(8), 1)));
+    CHECK_FORMULA(
+        //        "cos {\xce\xb1} + cos {\xce\xb2} =2 cos {{1} over {2} left 
(\xce\xb1+\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1-\xce\xb2 right )}",
+        // TODO check (cos/sin miss {})
+        u"cos \u03B1 \"+\" cos \u03B2 \"=\"2 cos {1} over {2} left 
(\u03B1\"+\"\u03B2 right ) cos {1} over {2} left (\u03B1\"-\"\u03B2 right 
)"_ustr,
+        getFormula(getRun(getParagraph(9), 1)));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testMathNary, "math-nary.docx")
 {
-    CHECK_FORMULA( "lllint from {1} to {2} {x + 1}", getFormula( getRun( 
getParagraph( 1 ), 1 )));
+    CHECK_FORMULA("lllint from {1} to {2} {x \"+\" 1}", 
getFormula(getRun(getParagraph(1), 1)));
     CHECK_FORMULA( "prod from {a} {b}", getFormula( getRun( getParagraph( 1 ), 
2 )));
     CHECK_FORMULA( "sum to {2} {x}", getFormula( getRun( getParagraph( 1 ), 3 
)));
 }
@@ -381,12 +387,12 @@ DECLARE_OOXMLEXPORT_TEST(testMathPlaceholders, 
"math-placeholders.docx")
 DECLARE_OOXMLEXPORT_TEST(testMathRad, "math-rad.docx")
 {
     CHECK_FORMULA( "sqrt {4}", getFormula( getRun( getParagraph( 1 ), 1 )));
-    CHECK_FORMULA( "nroot {3} {x + 1}", getFormula( getRun( getParagraph( 1 ), 
2 )));
+    CHECK_FORMULA("nroot {3} {x \"+\" 1}", getFormula(getRun(getParagraph(1), 
2)));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testMathSubscripts, "math-subscripts.docx")
 {
-    CHECK_FORMULA( "{x} ^ {y} + {e} ^ {x}", getFormula( getRun( getParagraph( 
1 ), 1 )));
+    CHECK_FORMULA("{x} ^ {y} \"+\" {e} ^ {x}", 
getFormula(getRun(getParagraph(1), 1)));
     CHECK_FORMULA( "{x} ^ {b}", getFormula( getRun( getParagraph( 1 ), 2 )));
     CHECK_FORMULA( "{x} rsub {b}", getFormula( getRun( getParagraph( 1 ), 3 
)));
     CHECK_FORMULA( "{a} rsub {c} rsup {b}", getFormula( getRun( getParagraph( 
1 ), 4 )));
@@ -648,8 +654,9 @@ DECLARE_OOXMLEXPORT_TEST(testTableStylerPrSz, 
"table-style-rPr-sz.docx")
 
 DECLARE_OOXMLEXPORT_TEST(testMathLiteral, "math-literal.docx")
 {
-    CHECK_FORMULA( u"iiint from {V} to <?> {\"div\" \"F\"}  dV= llint from {S} 
to <?> {\"F\" \u2219 \"n \" dS}"_ustr,
-        getFormula( getRun( getParagraph( 1 ), 1 )));
+    CHECK_FORMULA(
+        u"iiint from {V} to <?> {\"div\" \"F\"}  dV\"=\" llint from {S} to <?> 
{\"F\" \u2219 \"n \" dS}"_ustr,
+        getFormula(getRun(getParagraph(1), 1)));
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testFdo48557)
@@ -1155,6 +1162,12 @@ DECLARE_OOXMLEXPORT_TEST(testBnc837302, "bnc837302.docx")
     CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(xParagraph, 1), 
"RedlineType"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf162070Export)
+{
+    loadAndReload("tdf162070_export.docx");
+    CPPUNIT_ASSERT_EQUAL(u"{P} rsub {\"abs\"} \"~\" {B} rsub {0} \u00B2"_ustr, 
getFormula(getRun(getParagraph(1), 1)));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/rtfexport/data/math-mso2007.rtf 
b/sw/qa/extras/rtfexport/data/math-mso2007.rtf
index bc26831bae5a..dd8c9f607521 100644
--- a/sw/qa/extras/rtfexport/data/math-mso2007.rtf
+++ b/sw/qa/extras/rtfexport/data/math-mso2007.rtf
@@ -186,7 +186,7 @@ Cambria Math;}
 {\mr\mscr0\msty2 n}
 }
 { tlchcs1 f34 \ltrchcs0 \i\lochf34\hichf34\dbchf34\insrsid3104674 
\hichf34\dbchf34\loch34 
-{\mr\mscr0\msty2 -}
+{\mr\mscr0\msty2 \u8722\'3f}
 }
 { tlchcs1 f34 
 \ltrchcs0 \i\lochf34\hichf34\dbchf34\insrsid3104674 
\hichf34\dbchf34\loch34 
@@ -290,7 +290,7 @@ Cambria Math;}
 {\mr\mscr0\msty2 n}
 }
 { tlchcs1 f31507 \ltrchcs0 \i\lochf34\hichf34\dbchf31505\insrsid3104674 
\hichf34\dbchf31505\loch34 
-{\mr\mscr0\msty2 -}
+{\mr\mscr0\msty2 \u8722\'3f}
 }
 { tlchcs1 f31507 \ltrchcs0 
 \i\lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 
@@ -643,7 +643,7 @@ Cambria Math;}
 {\mnum
 { tlchcs1 f34 \ltrchcs0 
 \lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 
-{\mr\mscr0\msty0 -}
+{\mr\mscr0\msty0 \u8722\'3f}
 }
 { tlchcs1 f34 \ltrchcs0 \i\lochf34\hichf34\dbchf31505\insrsid3104674 
\hichf34\dbchf31505\loch34 
 {\mr\mscr0\msty2 b}
@@ -685,7 +685,7 @@ Cambria Math;}
 }
 }
 { tlchcs1 f34 \ltrchcs0 \lochf34\hichf34\dbchf31505\insrsid3104674 
\hichf34\dbchf31505\loch34 
-{\mr\mscr0\msty0 -}
+{\mr\mscr0\msty0 \u8722\'3f}
 }
 { tlchcs1 f34 \ltrchcs0 
 \lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 
@@ -855,7 +855,7 @@ Cambria Math;}
 {\mr\mscr0\msty0   }
 }
 { tlchcs1 f31507 \ltrchcs0 \i\lochf34\hichf34\dbchf31505\insrsid3104674 
\hichf34\dbchf31505\loch34 
-{\mr\mscr0\msty2 \hich34 -\u8734\'38}
+{\mr\mscr0\msty2 \hich34 \u8722\'3f\u8734\'38}
 }
 { tlchcs1 f31507 \ltrchcs0 \i\lochf34\hichf34\dbchf31505\insrsid3104674 
 \hichf34\dbchf31505\loch34 
@@ -1198,7 +1198,7 @@ Cambria Math;}
 {\mr\mscr0\msty2 \'e1}
 }
 { tlchcs1 f34 \ltrchcs0 \i\lochf34\hichf34\dbchf34\insrsid3104674 
\hichf34\dbchf34\loch34 
-{\mr\mscr0\msty2 -}
+{\mr\mscr0\msty2 \u8722\'3f}
 }
 { tlchcs1 f635 
 \ltrchcs0 \i\lochf635\hichf635\dbchf34\insrsid3104674 
\lochf635\dbchf34\hich635 
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx 
b/sw/qa/extras/rtfexport/rtfexport.cxx
index 193d0c6e54fb..6c2b7abea06c 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -192,9 +192,9 @@ CPPUNIT_TEST_FIXTURE(Test, testMathEqarray)
 {
     loadAndReload("math-eqarray.rtf");
     OUString aActual = getFormula(getRun(getParagraph(1), 1));
-    CPPUNIT_ASSERT_EQUAL(
-        OUString("y = left lbrace stack { 0 , x < 0 # 1 , x = 0 # {x} ^ {2} , 
x > 0 } right none"),
-        aActual);
+    CPPUNIT_ASSERT_EQUAL(OUString("y \"=\" left lbrace stack { 0 , x \"<\" 0 # 
1 , x \"=\" 0 # {x} "
+                                  "^ {2} , x \">\" 0 } right none"),
+                         aActual);
 }
 
 DECLARE_RTFEXPORT_TEST(testMathD, "math-d.rtf")
@@ -238,45 +238,49 @@ CPPUNIT_TEST_FIXTURE(Test, testMathMso2007)
 {
     loadAndReload("math-mso2007.rtf");
     OUString aActual = getFormula(getRun(getParagraph(1), 1));
-    OUString aExpected(u"A = \u03C0 {r} ^ {2}"_ustr);
+    OUString aExpected(u"A \"=\" \u03C0 {r} ^ {2}"_ustr);
     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
 
     aActual = getFormula(getRun(getParagraph(2), 1));
-    aExpected = u"{left (x + a right )} ^ {n} = sum from {k = 0} to {n} {left 
(stack { n "
-                u"# k } right ) {x} ^ {k} {a} ^ {n \u2212 k}}"_ustr;
+    aExpected
+        = u"{left (x \"+\" a right )} ^ {n} \"=\" sum from {k \"=\" 0} to {n} 
{left (stack { n "
+          u"# k } right ) {x} ^ {k} {a} ^ {n \u2212 k}}"_ustr;
     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
 
     aActual = getFormula(getRun(getParagraph(3), 1));
-    aExpected = u"{left (1 + x right )} ^ {n} = 1 + {nx} over {1 !} + {n left 
(n \u2212 1 "
-                u"right ) {x} ^ {2}} over {2 !} + \u2026"_ustr;
+    aExpected = u"{left (1 \"+\" x right )} ^ {n} \"=\" 1 \"+\" {nx} over {1 
!} \"+\" {n left (n "
+                u"\u2212 1 "
+                u"right ) {x} ^ {2}} over {2 !} \"+\" \u2026"_ustr;
     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
 
     aActual = getFormula(getRun(getParagraph(4), 1));
-    aExpected = u"f left (x right ) = {a} rsub {0} + sum from {n = 1} to 
{\u221E} {left "
-                u"({a} rsub {n} cos {n\u03C0x} over {L} + {b} rsub {n} sin 
{n\u03C0x} "
-                u"over {L} right )}"_ustr;
+    aExpected
+        = u"f left (x right ) \"=\" {a} rsub {0} \"+\" sum from {n \"=\" 1} to 
{\u221E} {left "
+          u"({a} rsub {n} cos {n\u03C0x} over {L} \"+\" {b} rsub {n} sin 
{n\u03C0x} "
+          u"over {L} right )}"_ustr;
     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
 
     aActual = getFormula(getRun(getParagraph(5), 1));
-    aExpected = "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}";
+    aExpected = "{a} ^ {2} \"+\" {b} ^ {2} \"=\" {c} ^ {2}";
     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
 
     aActual = getFormula(getRun(getParagraph(6), 1));
-    aExpected = u"x = {\u2212 b \u00B1 sqrt {{b} ^ {2} \u2212 4 ac}} over {2 
a}"_ustr;
+    aExpected = u"x \"=\" {\u2212 b \u00B1 sqrt {{b} ^ {2} \u2212 4 ac}} over 
{2 a}"_ustr;
     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
 
     aActual = getFormula(getRun(getParagraph(7), 1));
-    aExpected = u"{e} ^ {x} = 1 + {x} over {1 !} + {{x} ^ {2}} over {2 !} + 
{{x} ^ {3}} "
-                u"over {3 !} + \u2026 , \u2212 \u221E < x < \u221E"_ustr;
+    aExpected
+        = u"{e} ^ {x} \"=\" 1 \"+\" {x} over {1 !} \"+\" {{x} ^ {2}} over {2 
!} \"+\" {{x} ^ {3}} "
+          u"over {3 !} \"+\" \u2026 , \u2212 \u221E \"<\" x \"<\" \u221E"_ustr;
     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
 
     aActual = getFormula(getRun(getParagraph(8), 1));
-    aExpected = u"sin \u03B1 \u00B1 sin \u03B2 = 2 sin {1} over {2} left 
(\u03B1 \u00B1 "
+    aExpected = u"sin \u03B1 \u00B1 sin \u03B2 \"=\" 2 sin {1} over {2} left 
(\u03B1 \u00B1 "
                 u"\u03B2 right ) cos {1} over {2} left (\u03B1 \u2213 \u03B2 
right )"_ustr;
     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
 
     aActual = getFormula(getRun(getParagraph(9), 1));
-    aExpected = u"cos \u03B1 + cos \u03B2 = 2 cos {1} over {2} left (\u03B1 + 
\u03B2 "
+    aExpected = u"cos \u03B1 \"+\" cos \u03B2 \"=\" 2 cos {1} over {2} left 
(\u03B1 \"+\" \u03B2 "
                 u"right ) cos {1} over {2} left (\u03B1 \u2212 \u03B2 right 
)"_ustr;
     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
 }
@@ -286,7 +290,7 @@ CPPUNIT_TEST_FIXTURE(Test, testMathNary)
     loadAndReload("math-nary.rtf");
     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     CPPUNIT_ASSERT_EQUAL(
-        OUString("lllint from {1} to {2} {x + 1} prod from {a} {b} sum to {2} 
{x}"), aActual);
+        OUString("lllint from {1} to {2} {x \"+\" 1} prod from {a} {b} sum to 
{2} {x}"), aActual);
 }
 
 DECLARE_RTFEXPORT_TEST(testMathLimupp, "math-limupp.rtf")
@@ -314,7 +318,7 @@ CPPUNIT_TEST_FIXTURE(Test, testMathRad)
 {
     loadAndReload("math-rad.rtf");
     OUString aActual = getFormula(getRun(getParagraph(1), 1));
-    CPPUNIT_ASSERT_EQUAL(OUString("sqrt {4} nroot {3} {x + 1}"), aActual);
+    CPPUNIT_ASSERT_EQUAL(OUString("sqrt {4} nroot {3} {x \"+\" 1}"), aActual);
 }
 
 DECLARE_RTFEXPORT_TEST(testMathSepchr, "math-sepchr.rtf")
@@ -327,7 +331,7 @@ DECLARE_RTFEXPORT_TEST(testMathSubscripts, 
"math-subscripts.rtf")
 {
     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     CPPUNIT_ASSERT_EQUAL(
-        OUString("{x} ^ {y} + {e} ^ {x} {x} ^ {b} {x} rsub {b} {a} rsub {c} 
rsup {b} "
+        OUString("{x} ^ {y} \"+\" {e} ^ {x} {x} ^ {b} {x} rsub {b} {a} rsub 
{c} rsup {b} "
                  "{x} lsub {2} lsup {1} {{x csup {6} csub {3}} lsub {4} lsup 
{5}} rsub "
                  "{2} rsup {1}"),
         aActual);
@@ -371,7 +375,7 @@ CPPUNIT_TEST_FIXTURE(Test, testMathRuns)
 {
     loadAndReload("math-runs.rtf");
     // was [](){}, i.e. first curly bracket had an incorrect position
-    CPPUNIT_ASSERT_EQUAL(OUString("\{ left [ right ] \( \) \}"),
+    CPPUNIT_ASSERT_EQUAL(OUString("\{ \[ \] \( \) \}"),
                          getFormula(getRun(getParagraph(1), 1)));
 }
 
@@ -522,7 +526,7 @@ DECLARE_RTFEXPORT_TEST(testMnor, "mnor.rtf")
     // \mnor wasn't handled, leading to missing quotes around "divF" and so on.
     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     CPPUNIT_ASSERT_EQUAL(
-        u"iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" 
\u2219 \"n\" dS}"_ustr,
+        u"iiint from {V} to <?> {\"divF\"} dV \"=\" llint from {S} to <?> 
{\"F\" \u2219 \"n\" dS}"_ustr,
         aActual);
 }
 

Reply via email to