sw/qa/extras/uiwriter/data/tdf157132.odt |binary
 sw/qa/extras/uiwriter/uiwriter8.cxx      |   42 +++++++++++++++++++++++++++++++
 sw/source/core/table/swtable.cxx         |    2 +
 3 files changed, 44 insertions(+)

New commits:
commit 0bd6d55a35688d92c411d3ba647c3fcf8de263b5
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Oct 25 18:07:18 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Oct 26 15:48:59 2023 +0200

    tdf#157132: restore behaviour for TBL_RELBOXNAME
    
    Regression from 8a3dc12a13a3b9e99dbd5000ca6a1d541cf472f7
    "8a3dc12a13a3b9e99dbd5000ca6a1d541cf472f7"
    TBL_RELBOXNAME was no longer calling ToRelBoxNm
    
    Change-Id: I296d84ab955b4415bf9173ccf72b4d51e55152f8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158454
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 43419accf5aa27a9bd2f2a97cbf969fb30871277)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158437
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/qa/extras/uiwriter/data/tdf157132.odt 
b/sw/qa/extras/uiwriter/data/tdf157132.odt
new file mode 100644
index 000000000000..ddb9522bf835
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf157132.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 43ef6d9ccc2d..a669192fdc25 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -1480,6 +1480,48 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf146573)
     CPPUNIT_ASSERT_EQUAL(OUString("204"), xCellA4->getString());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157132)
+{
+    createSwDoc("tdf157132.odt");
+
+    SwDoc* pDoc = getSwDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    // Go to cell A2
+    pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1);
+
+    // Select A2 and A3 and copy
+    pWrtShell->Down(/*bSelect=*/true, /*nCount=*/1);
+
+    dispatchCommand(mxComponent, ".uno:Copy", {});
+
+    // Go to A4 and paste
+    pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1);
+
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+
+    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);
+
+    uno::Reference<text::XTextRange> xCellA2(xTextTable->getCellByName("A2"), 
uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("2"), xCellA2->getString());
+    uno::Reference<text::XTextRange> xCellA3(xTextTable->getCellByName("A3"), 
uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("3"), xCellA3->getString());
+    uno::Reference<text::XTextRange> xCellA4(xTextTable->getCellByName("A4"), 
uno::UNO_QUERY);
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 6
+    // - Actual  : 2
+    CPPUNIT_ASSERT_EQUAL(OUString("6"), xCellA4->getString());
+    uno::Reference<text::XTextRange> xCellA5(xTextTable->getCellByName("A5"), 
uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("7"), xCellA5->getString());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf147938)
 {
     createSwDoc("tdf147938.fodt");
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index e5a2ccba936f..ff06bf510195 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1722,6 +1722,8 @@ void SwTable::UpdateFields(TableFormulaUpdateFlags eFlags)
         {
             if(eFlags == TBL_BOXPTR)
                 pBoxFormula->TryBoxNmToPtr();
+            else if(eFlags == TBL_RELBOXNAME)
+                pBoxFormula->ToRelBoxNm(this);
             else
                 pBoxFormula->ChangeState();
         }

Reply via email to