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 0c008ab081aa5bbf53f8562e95e547deae5afc2e 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 08:48:23 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> 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 8e4869c5d694..7cef16f032bf 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 3d53ef518903..d50c493079a2 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -1727,6 +1727,8 @@ void SwTable::UpdateFields(TableFormulaUpdateFlags eFlags) { if(eFlags == TBL_BOXPTR) pBoxFormula->TryBoxNmToPtr(); + else if(eFlags == TBL_RELBOXNAME) + pBoxFormula->ToRelBoxNm(this); else pBoxFormula->ChangeState(); }