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 | 90 ++++++++++++-------- sw/qa/extras/rtfexport/data/math-mso2007.rtf | 12 +- sw/qa/extras/rtfexport/rtfexport.cxx | 54 ++++++------ sw/qa/uitest/data/tdf157569.docx |binary sw/qa/uitest/writer_tests6/tdf157569.py | 2 9 files changed, 146 insertions(+), 73 deletions(-)
New commits: commit 19df53668c2078015e7135aaca261093f5c4dc0a Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Tue Nov 12 12:50:10 2024 +0530 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Feb 27 10:45:28 2025 +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 Note: So in MSO if you use operator with spaces on either size it will be treated as literal and when you use them without space in either side it will be operator. This same thing goes for all operators. In libre office you will be able to see visual difference in operator and literal one is slightly bold than other. 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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177797 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.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 5f851d9c39b2..dec486e6025b 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 ea4e8e9a2d44..5c18d9e32e5e 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[] = { + static 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 22a4e2169254..f5d9efc4f516 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -271,7 +271,7 @@ CPPUNIT_TEST_FIXTURE(Test, testCommentsNested) CPPUNIT_TEST_FIXTURE(Test, testMathEscape) { loadAndReload("math-escape.docx"); - CPPUNIT_ASSERT_EQUAL(u"\{ left [ right ] \( \) \}"_ustr, getFormula(getRun(getParagraph(1), 1))); + CPPUNIT_ASSERT_EQUAL(u"\{ \[ \] \( \) \}"_ustr, getFormula(getRun(getParagraph(1), 1))); } // Saving left and right for parentheses when importing not from the m:t tag (docx) @@ -320,12 +320,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") @@ -336,38 +337,55 @@ 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( u"{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (stack {n # k} right ) {x} ^ {k} {a} ^ {n-k}}"_ustr, - 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( u"{a} ^ {2} + {b} ^ {2} = {c} ^ {2}"_ustr, 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( - 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 (x\"+\"a right )} ^ {n} \"=\" sum from {k\"=\"0} to {n} {left (stack {n # k} right ) {x} ^ {k} {a} ^ {n\"-\"k}}"_ustr, + getFormula(getRun(getParagraph(2), 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 ))); + 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( -// "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"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(u"{a} ^ {2} \"+\" {b} ^ {2} \"=\" {c} ^ {2}"_ustr, + 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"{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"{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( u"lllint from {1} to {2} {x + 1}"_ustr, getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA(u"lllint from {1} to {2} {x \"+\" 1}"_ustr, + getFormula(getRun(getParagraph(1), 1))); CHECK_FORMULA( u"prod from {a} {b}"_ustr, getFormula( getRun( getParagraph( 1 ), 2 ))); CHECK_FORMULA( u"sum to {2} {x}"_ustr, getFormula( getRun( getParagraph( 1 ), 3 ))); } @@ -391,12 +409,12 @@ DECLARE_OOXMLEXPORT_TEST(testMathPlaceholders, "math-placeholders.docx") DECLARE_OOXMLEXPORT_TEST(testMathRad, "math-rad.docx") { CHECK_FORMULA( u"sqrt {4}"_ustr, getFormula( getRun( getParagraph( 1 ), 1 ))); - CHECK_FORMULA( u"nroot {3} {x + 1}"_ustr, getFormula( getRun( getParagraph( 1 ), 2 ))); + CHECK_FORMULA(u"nroot {3} {x \"+\" 1}"_ustr, getFormula(getRun(getParagraph(1), 2))); } DECLARE_OOXMLEXPORT_TEST(testMathSubscripts, "math-subscripts.docx") { - CHECK_FORMULA( u"{x} ^ {y} + {e} ^ {x}"_ustr, getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA(u"{x} ^ {y} \"+\" {e} ^ {x}"_ustr, getFormula(getRun(getParagraph(1), 1))); CHECK_FORMULA( u"{x} ^ {b}"_ustr, getFormula( getRun( getParagraph( 1 ), 2 ))); CHECK_FORMULA( u"{x} rsub {b}"_ustr, getFormula( getRun( getParagraph( 1 ), 3 ))); CHECK_FORMULA( u"{a} rsub {c} rsup {b}"_ustr, getFormula( getRun( getParagraph( 1 ), 4 ))); @@ -640,8 +658,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) @@ -1147,6 +1166,13 @@ DECLARE_OOXMLEXPORT_TEST(testBnc837302, "bnc837302.docx") CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(xParagraph, 1), u"RedlineType"_ustr)); } +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} } { tlchcs1 f34 \ltrchcs0 \i\lochf34\hichf34\dbchf34\insrsid3104674 \hichf34\dbchf34\loch34 -{\mr\mscr0\msty2 -} +{\mr\mscr0\msty2 \u8722\'3f} } { tlchcs1 f34 \ltrchcs0 \i\lochf34\hichf34\dbchf34\insrsid3104674 \hichf34\dbchf34\loch34 @@ -290,7 +290,7 @@ Cambria Math;} {\mr\mscr0\msty2 n} } { tlchcs1 f31507 \ltrchcs0 \i\lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 -{\mr\mscr0\msty2 -} +{\mr\mscr0\msty2 \u8722\'3f} } { tlchcs1 f31507 \ltrchcs0 \i\lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 @@ -643,7 +643,7 @@ Cambria Math;} {\mnum { tlchcs1 f34 \ltrchcs0 \lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 -{\mr\mscr0\msty0 -} +{\mr\mscr0\msty0 \u8722\'3f} } { tlchcs1 f34 \ltrchcs0 \i\lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 {\mr\mscr0\msty2 b} @@ -685,7 +685,7 @@ Cambria Math;} } } { tlchcs1 f34 \ltrchcs0 \lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 -{\mr\mscr0\msty0 -} +{\mr\mscr0\msty0 \u8722\'3f} } { tlchcs1 f34 \ltrchcs0 \lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 @@ -855,7 +855,7 @@ Cambria Math;} {\mr\mscr0\msty0 } } { tlchcs1 f31507 \ltrchcs0 \i\lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 -{\mr\mscr0\msty2 \hich34 -\u8734\'38} +{\mr\mscr0\msty2 \hich34 \u8722\'3f\u8734\'38} } { tlchcs1 f31507 \ltrchcs0 \i\lochf34\hichf34\dbchf31505\insrsid3104674 \hichf34\dbchf31505\loch34 @@ -1198,7 +1198,7 @@ Cambria Math;} {\mr\mscr0\msty2 \'e1} } { tlchcs1 f34 \ltrchcs0 \i\lochf34\hichf34\dbchf34\insrsid3104674 \hichf34\dbchf34\loch34 -{\mr\mscr0\msty2 -} +{\mr\mscr0\msty2 \u8722\'3f} } { tlchcs1 f635 \ltrchcs0 \i\lochf635\hichf635\dbchf34\insrsid3104674 \lochf635\dbchf34\hich635 diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index fb7c05a0e8a1..156ba778ff99 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -224,7 +224,7 @@ CPPUNIT_TEST_FIXTURE(Test, testMathEqarray) loadAndReload("math-eqarray.rtf"); OUString aActual = getFormula(getRun(getParagraph(1), 1)); CPPUNIT_ASSERT_EQUAL( - u"y = left lbrace stack { 0 , x < 0 # 1 , x = 0 # {x} ^ {2} , x > 0 } right none"_ustr, + u"y \"=\" left lbrace stack { 0 , x \"<\" 0 # 1 , x \"=\" 0 # {x} ^ {2} , x \">\" 0 } right none"_ustr, aActual); } @@ -287,45 +287,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); } @@ -334,8 +338,8 @@ CPPUNIT_TEST_FIXTURE(Test, testMathNary) { loadAndReload("math-nary.rtf"); OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL(u"lllint from {1} to {2} {x + 1} prod from {a} {b} sum to {2} {x}"_ustr, - aActual); + CPPUNIT_ASSERT_EQUAL( + u"lllint from {1} to {2} {x \"+\" 1} prod from {a} {b} sum to {2} {x}"_ustr, aActual); } CPPUNIT_TEST_FIXTURE(Test, testMathLimupp) @@ -381,7 +385,7 @@ CPPUNIT_TEST_FIXTURE(Test, testMathRad) { loadAndReload("math-rad.rtf"); OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL(u"sqrt {4} nroot {3} {x + 1}"_ustr, aActual); + CPPUNIT_ASSERT_EQUAL(u"sqrt {4} nroot {3} {x \"+\" 1}"_ustr, aActual); } CPPUNIT_TEST_FIXTURE(Test, testMathSepchr) @@ -400,10 +404,11 @@ CPPUNIT_TEST_FIXTURE(Test, testMathSubscripts) { auto verify = [this]() { OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL(u"{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}"_ustr, - aActual); + CPPUNIT_ASSERT_EQUAL( + u"{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}"_ustr, + aActual); }; createSwDoc("math-subscripts.rtf"); verify(); @@ -463,8 +468,7 @@ CPPUNIT_TEST_FIXTURE(Test, testMathRuns) { loadAndReload("math-runs.rtf"); // was [](){}, i.e. first curly bracket had an incorrect position - CPPUNIT_ASSERT_EQUAL(u"\{ left [ right ] \( \) \}"_ustr, - getFormula(getRun(getParagraph(1), 1))); + CPPUNIT_ASSERT_EQUAL(u"\{ \[ \] \( \) \}"_ustr, getFormula(getRun(getParagraph(1), 1))); } // Saving left and right for parentheses when importing not from the m:t tag (rtf) @@ -629,7 +633,7 @@ CPPUNIT_TEST_FIXTURE(Test, testMnor) // \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); }; createSwDoc("mnor.rtf"); diff --git a/sw/qa/uitest/data/tdf157569.docx b/sw/qa/uitest/data/tdf157569.docx index 2143a831a0dd..a10c05e07652 100644 Binary files a/sw/qa/uitest/data/tdf157569.docx and b/sw/qa/uitest/data/tdf157569.docx differ diff --git a/sw/qa/uitest/writer_tests6/tdf157569.py b/sw/qa/uitest/writer_tests6/tdf157569.py index 9177047cec51..79816d4e7d68 100644 --- a/sw/qa/uitest/writer_tests6/tdf157569.py +++ b/sw/qa/uitest/writer_tests6/tdf157569.py @@ -26,7 +26,7 @@ class tdf157569(UITestCase): if platform.system() == "Windows": self.assertEqual(2155, nWidth) # no idea why it's different on Windows else: - self.assertEqual(2118, nWidth) + self.assertEqual(2120, nWidth) xDoc = self.xUITest.getTopFocusWindow() xEditWin = xDoc.getChild("writer_edit")