summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorIrgaliev Amin <irgaliev01@mail.ru>2023-12-25 20:13:34 +0400
committerXisco Fauli <xiscofauli@libreoffice.org>2024-06-18 14:06:35 +0200
commit57946f4262b5d548d3429723faf380eaba5ce9f8 (patch)
tree9ccf93af13742a8c77fe9db42360895311b93422 /sw
parentf3958668003a8aae1ce0ff0473b2b3e75d285739 (diff)
tdf#158023 Add \ before parentheses if they are in the <t> tag.
MSO allows you to write unpair opening or closing parentheses in the t tag. The patch adds a backslash before parentheses, which allows you to correctly recognize and correctly save such formulas when exporting. Also add a test to check whether the parentheses are wrapped correctly. Change-Id: Ib1a941858f0843742b56b8089f3c14983ba1222c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158794 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins (cherry picked from commit 8148dd6ed3c61eaf5f9fe3a060ecda9d11611f39) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169103 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf158023_export.docxbin0 -> 10504 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport2.cxx9
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf158023_import.docxbin0 -> 10329 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport2.cxx20
-rw-r--r--sw/qa/extras/rtfexport/data/tdf158023.rtf8
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx10
6 files changed, 45 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf158023_export.docx b/sw/qa/extras/ooxmlexport/data/tdf158023_export.docx
new file mode 100644
index 000000000000..289619a7e4b6
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf158023_export.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index 6e27f9a6a1ab..e18c1eebca5e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -261,7 +261,14 @@ CPPUNIT_TEST_FIXTURE(Test, testCommentsNested)
CPPUNIT_TEST_FIXTURE(Test, testMathEscape)
{
loadAndReload("math-escape.docx");
- CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1)));
+ CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] \\( \\) \\}"), getFormula(getRun(getParagraph(1), 1)));
+}
+
+// Saving left and right for parentheses when importing not from the m:t tag (docx)
+CPPUNIT_TEST_FIXTURE(Test, testTdf158023Export)
+{
+ loadAndReload("tdf158023_export.docx");
+ CPPUNIT_ASSERT_EQUAL(OUString("left [ right ] left ( right ) left lbrace right rbrace"), getFormula(getRun(getParagraph(1), 1)));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo51034)
diff --git a/sw/qa/extras/ooxmlimport/data/tdf158023_import.docx b/sw/qa/extras/ooxmlimport/data/tdf158023_import.docx
new file mode 100644
index 000000000000..1095499e2ebf
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf158023_import.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 0c29484d765e..642c05b14aa8 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -697,6 +697,26 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf119200)
CPPUNIT_ASSERT_EQUAL(u" size 12{ func \u2287 } {}"_ustr, getFormula(getRun(xPara, 7)));
}
+// Checking a formula where the closing brackets
+// come first, and then the opening ones
+CPPUNIT_TEST_FIXTURE(Test, testTdf158023Import)
+{
+ auto verify = [this]() {
+ auto xPara = getParagraph(1);
+ CPPUNIT_ASSERT_EQUAL(u"\\) sqrt {\\)2\\(} \\("_ustr, getFormula(getRun(xPara, 1)));
+ };
+ auto verifyReload = [this]() {
+ auto xPara = getParagraph(1);
+ CPPUNIT_ASSERT_EQUAL(u"\\) sqrt {\\) 2 \\(} \\("_ustr, getFormula(getRun(xPara, 1)));
+ };
+
+ createSwDoc("tdf158023_import.docx");
+ verify();
+
+ saveAndReload("Office Open XML Text");
+ verifyReload();
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf115094)
{
createSwDoc("tdf115094.docx");
diff --git a/sw/qa/extras/rtfexport/data/tdf158023.rtf b/sw/qa/extras/rtfexport/data/tdf158023.rtf
new file mode 100644
index 000000000000..cdcddc4532fc
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf158023.rtf
@@ -0,0 +1,8 @@
+{\rtf1
+{\mmath {\*\moMath
+{\md {\mdPr {\mbegChr [}{\mendChr ]}}{\me {\mr a}}}
+{\md {\mdPr {\mbegChr (}{\mendChr )}}{\me {\mr b}}}
+{\md {\mdPr {\mbegChr \{}{\mendChr \}}}{\me {\mr c}}}
+}}
+\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index bbb09090500e..193d0c6e54fb 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -371,7 +371,15 @@ 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 ] left ( right ) \\}"),
+ CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] \\( \\) \\}"),
+ getFormula(getRun(getParagraph(1), 1)));
+}
+
+// Saving left and right for parentheses when importing not from the m:t tag (rtf)
+CPPUNIT_TEST_FIXTURE(Test, testTdf158023_rtf)
+{
+ loadAndReload("tdf158023.rtf");
+ CPPUNIT_ASSERT_EQUAL(OUString("left [a right ] left (b right ) left lbrace c right rbrace"),
getFormula(getRun(getParagraph(1), 1)));
}