sw/qa/core/txtnode/data/tdf157287.odt |binary
 sw/qa/core/txtnode/txtnode.cxx        |   27 +++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

New commits:
commit bae0736bf0ec54828766c3d903e2a27458643395
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Oct 23 16:30:07 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Oct 23 21:22:13 2023 +0200

    tdf#157287: sw_core_txtnode: Add unittest
    
    Change-Id: I4c14cbe8610dc6426b910f4ef5d96ccc6e7a4604
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158359
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/core/txtnode/data/tdf157287.odt 
b/sw/qa/core/txtnode/data/tdf157287.odt
new file mode 100644
index 000000000000..3ff6c4c6b9a6
Binary files /dev/null and b/sw/qa/core/txtnode/data/tdf157287.odt differ
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index 5e5f79969781..c5d7d8fc740e 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -12,6 +12,7 @@
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <comphelper/lok.hxx>
 #include <comphelper/propertyvalue.hxx>
+#include <com/sun/star/text/XTextTable.hpp>
 #include <sfx2/viewsh.hxx>
 #include <vcl/gdimtf.hxx>
 #include <vcl/scheduler.hxx>
@@ -432,6 +433,32 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, 
testContentControlCopy)
     CPPUNIT_ASSERT_EQUAL(SwContentControlType::CHECKBOX, 
rFormat2.GetContentControl()->GetType());
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTdf157287)
+{
+    createSwDoc("tdf157287.odt");
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+    auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
+    uno::Reference<text::XTextField> xField(xFields->nextElement(), 
uno::UNO_QUERY);
+
+    CPPUNIT_ASSERT_EQUAL(OUString("30"), xField->getPresentation(false));
+
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xIndexAccess(xTextTablesSupplier->getTextTables(),
+                                                         uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTextTable(xIndexAccess->getByIndex(0), 
uno::UNO_QUERY);
+
+    uno::Reference<text::XTextRange> xCellA1(xTextTable->getCellByName("B1"), 
uno::UNO_QUERY);
+    xCellA1->setString("100");
+
+    dispatchCommand(mxComponent, ".uno:UpdateFields", {});
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 120
+    // - Actual  :
+    CPPUNIT_ASSERT_EQUAL(OUString("120"), xField->getPresentation(false));
+}
+
 CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testFlySplitFootnote)
 {
     // Given a document with a split fly (to host a table):

Reply via email to