diff options
-rw-r--r-- | sw/inc/cellatr.hxx | 1 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf157132.odt | bin | 11289 -> 12449 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter8.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/attr/cellatr.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/table/swtable.cxx | 2 |
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 Binary files differindex ddb9522bf835..3cfbec4d756b 100644 --- a/sw/qa/extras/uiwriter/data/tdf157132.odt +++ b/sw/qa/extras/uiwriter/data/tdf157132.odt 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(); } |