summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-11-12 11:37:23 +0100
committerLászló Németh <nemeth@numbertext.org>2022-11-14 09:30:14 +0100
commitc6688def010fcb6854c6d896efe7186ff6c63475 (patch)
tree530d37fa3cbd18fb30b6cba00537951c93ab6c0e /sw/qa
parent099d5d22b38bb0ea91faaed14ecc0edfa010ff11 (diff)
tdf#151993 DOCX import: convert decimal comma only if needed
E.g. convert en_US document with decimal comma, but not de_DE document with decimal comma. Regression from commit 94bf4908a6661101c270ef647e33dde09f16ac08 "tdf#148799 DOCX import: fix invalid formulas with comma". DOCX allows to set decimal symbol independently from the locale of the document, so if the DOCX document uses comma, but its locale ("language") has got a default decimal point in Writer, Writer formulas must contain decimal points instead of commas, otherwise automatic update of the formulas, e.g. moving text cursor in the table, results ** Expression is faulty ** instead of the recalculated value. The only way to get standard Writer formulas is to replace the commas with points in numbers in writerfilter, if document language has a default decimal point in Writer. Note: not only document language, but area setting of LibreOffice installation modifies formula handling. I.e. plain numbers recognized with comma only if area setting is modified to a language, which uses decimal comma (but formulas still need decimal points, if the language of the document is a locale with default decimal point). E.g. an en_US DOCX document with decimal comma, or a de_DE document with decimal comma loaded correctly now, but recognizing cell content with a single number with comma needs to set also the correct area setting. Change-Id: I16dba1e10bf4271a44c435b5b09345d8d698b91d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142611 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/data/tdf151993.docxbin0 -> 11913 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter8.cxx31
2 files changed, 30 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf151993.docx b/sw/qa/extras/uiwriter/data/tdf151993.docx
new file mode 100644
index 000000000000..462feb0a61e4
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf151993.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 83698fa36a18..e6b5d0dad60c 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -1400,7 +1400,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf146573)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148799)
{
- // load a document with table formulas with comma delimiter
+ // load a document with table formulas with comma delimiter,
+ // but with a document language with default point delimiter
createSwDoc("tdf148799.docx");
SwDoc* pDoc = getSwDoc();
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
@@ -1430,6 +1431,34 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148799)
CPPUNIT_ASSERT_EQUAL(OUString("23684.5"), xCellA4->getString());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf151993)
+{
+ // load a document with table formulas with comma delimiter
+ // (with a document language with default comma delimiter)
+ createSwDoc("tdf151993.docx");
+ SwDoc* pDoc = getSwDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+ // check formula update
+
+ // put cursor in the first table row
+ pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1);
+
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
+ uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+ uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getRows()->getCount());
+
+ // This was 0
+ uno::Reference<text::XTextRange> xCellA1(xTextTable->getCellByName("A2"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("30"), xCellA1->getString());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148849)
{
// load a document with a table and an empty paragraph before the table