summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-11-09 13:35:11 +0100
committerLászló Németh <nemeth@numbertext.org>2022-11-09 16:34:48 +0100
commit94bf4908a6661101c270ef647e33dde09f16ac08 (patch)
tree64e7f67b7e732ec126ed2a8a3e1aed8723d94049 /sw
parentaa8a8b36b73304431bacd7ed0f8803de8dfffe3e (diff)
tdf#148799 DOCX import: fix invalid formulas with comma
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. Note: only formula cells support comma localization, but not formula fields yet, so the recalculated values show decimal point instead of decimal comma. Follow-up to commit 1abf4e6d07ca0ac31bc54f812df84efc82d2af1b "DOCX import: don't throw away cached value of SwHiddenTextField ...", see also tdf#136106. Change-Id: Id5e6dc2b87afc4e8fda0d5c4347ba7942a8989b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142488 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/data/tdf148799.docxbin0 -> 21690 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter8.cxx31
2 files changed, 31 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf148799.docx b/sw/qa/extras/uiwriter/data/tdf148799.docx
new file mode 100644
index 000000000000..280fa18c15b5
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf148799.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx
index dbb1d4fda678..674747b6c0d7 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -1382,6 +1382,37 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf146573)
CPPUNIT_ASSERT_EQUAL(OUString("204"), xCellA4->getString());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148799)
+{
+ // load a document with table formulas with comman delimiter
+ SwDoc* pDoc = createSwDoc("tdf148799.docx");
+ 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(5), xTextTable->getRows()->getCount());
+
+ // These were "** Expression is faulty **"
+
+ uno::Reference<text::XTextRange> xCellA1(xTextTable->getCellByName("D3"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("2.3"), xCellA1->getString());
+ uno::Reference<text::XTextRange> xCellA3(xTextTable->getCellByName("D4"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("2345"), xCellA3->getString());
+ uno::Reference<text::XTextRange> xCellA4(xTextTable->getCellByName("D5"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("23684.5"), xCellA4->getString());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148849)
{
// load a document with a table and an empty paragraph before the table