summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-11-23 17:06:51 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2023-11-23 18:21:20 +0100
commit32ce5fe4ed19a79b6f15a5d4d1892e6cc8d778d9 (patch)
tree43533c361e99c0efaecb3d09c4342fef355ceb90
parent17e362e56f9e15d0214c441e632c91d22e58519d (diff)
tdf#158336: Only Change current table
For that, use the same logic as TryBoxNmToPtr Regression from 0c008ab081aa5bbf53f8562e95e547deae5afc2e "tdf#157132: restore behaviour for TBL_RELBOXNAME" Change-Id: I8f93ad3a9686001fd6bd7226400925e43b81ec23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159865 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/inc/cellatr.hxx1
-rw-r--r--sw/qa/extras/uiwriter/data/tdf157132.odtbin11289 -> 12449 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter8.cxx17
-rw-r--r--sw/source/core/attr/cellatr.cxx12
-rw-r--r--sw/source/core/table/swtable.cxx2
5 files changed, 30 insertions, 2 deletions
diff --git a/sw/inc/cellatr.hxx b/sw/inc/cellatr.hxx
index 2c00b5321190..54ddf2caa5ba 100644
--- a/sw/inc/cellatr.hxx
+++ b/sw/inc/cellatr.hxx
@@ -75,6 +75,7 @@ public:
{ return const_cast<SwTableBoxFormula*>(this)->GetTableBox(); }
void TryBoxNmToPtr();
+ void TryRelBoxNm();
void ToSplitMergeBoxNmWithHistory(SwTableFormulaUpdate& rUpdate, SwHistory* pHistory);
void ChangeState()
{
diff --git a/sw/qa/extras/uiwriter/data/tdf157132.odt b/sw/qa/extras/uiwriter/data/tdf157132.odt
index ddb9522bf835..3cfbec4d756b 100644
--- a/sw/qa/extras/uiwriter/data/tdf157132.odt
+++ b/sw/qa/extras/uiwriter/data/tdf157132.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 41be9a196dfb..0fbb8e9fae81 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -1517,7 +1517,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157132)
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
@@ -1533,6 +1533,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157132)
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());
+
+ xTextTable.set(xTables->getByIndex(1), uno::UNO_QUERY);
+
+ xCellA2.set(xTextTable->getCellByName("A2"), uno::UNO_QUERY);
+
+ // tdf#158336: Without the fix in place, this test would have failed with
+ // - Expected: 2
+ // - Actual : ** Expression is faulty **
+ CPPUNIT_ASSERT_EQUAL(OUString("2"), xCellA2->getString());
+ xCellA3.set(xTextTable->getCellByName("A3"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("3"), xCellA3->getString());
+ xCellA4.set(xTextTable->getCellByName("A4"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("6"), xCellA4->getString());
+ xCellA5.set(xTextTable->getCellByName("A5"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("7"), xCellA5->getString());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf147938)
diff --git a/sw/source/core/attr/cellatr.cxx b/sw/source/core/attr/cellatr.cxx
index 9023cca2f793..19e7b2f39d53 100644
--- a/sw/source/core/attr/cellatr.cxx
+++ b/sw/source/core/attr/cellatr.cxx
@@ -104,6 +104,18 @@ void SwTableBoxFormula::TryBoxNmToPtr()
BoxNmToPtr(&pTableNd->GetTable());
}
}
+
+void SwTableBoxFormula::TryRelBoxNm()
+{
+ const SwNode* pNd = GetNodeOfFormula();
+ if (!pNd || &pNd->GetNodes() != &pNd->GetDoc().GetNodes())
+ return;
+ if(const SwTableNode* pTableNd = pNd->FindTableNode())
+ {
+ ToRelBoxNm(&pTableNd->GetTable());
+ }
+}
+
void SwTableBoxFormula::ToSplitMergeBoxNmWithHistory(SwTableFormulaUpdate& rUpdate, SwHistory* pHistory)
{
if(!pHistory)
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 8b8f449c7df9..cfa9f52a206c 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1728,7 +1728,7 @@ void SwTable::UpdateFields(TableFormulaUpdateFlags eFlags)
if(eFlags == TBL_BOXPTR)
pBoxFormula->TryBoxNmToPtr();
else if(eFlags == TBL_RELBOXNAME)
- pBoxFormula->ToRelBoxNm(this);
+ pBoxFormula->TryRelBoxNm();
else
pBoxFormula->ChangeState();
}