diff options
author | László Németh <nemeth@numbertext.org> | 2022-04-28 19:48:52 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-05-02 22:57:06 +0200 |
commit | 978e22f8cfb3db573bed3fd4b14a515cf090f7e5 (patch) | |
tree | f507f148ddb566fdfa0e0c51ad95676d4338f9ea /sw/qa | |
parent | 64106353c98e8cb0c99c9e4ff509348edf8ed911 (diff) |
tdf#146573 sw: recalculate cells with footnotes
Commit 915d3eebc1dc4f18d7a1992db801ee8313ee46c0
"tdf#39828 sw: fix table formula calculation at track changes"
allowed to use footnotes in value cells unintentionally.
The only problem was that modifying cells with footnotes didn't
trigger formula recalculation in text tables, according to the
incomplete SwTableBox::IsValidNumTextNd(). Instead of
asking formula recalculation pressing F9, now IsValidNumTextNd
was extended to skip footnotes, similar to the already
skipped comments.
Also clean-up to testTdf39828 (remove copy-paste code), and
clean-up to commit 915d3eebc1dc4f18d7a1992db801ee8313ee46c0
"tdf#39828 sw: fix table formula calculation at track changes"
to avoid of unnecessary calls of GetRedlineText(), which
is an expensive call, especially when there are a lot of redlines
with overlapping (see commit d467cd0dd9e9cf3b018859a592e2638527bc7add
"tdf#135683 speedup DocumentRedlineManager::GetRedlinePos").
Change-Id: I00243ef0985805414723e26fe26d6e9c04ce86cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133579
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 91b16d045868..341237f75aaa 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -3490,9 +3490,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf87199) CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf39828) { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf39828.fodt"); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - - pWrtShell->GotoNextTOXBase(); // show changes pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::ShowDelete @@ -3521,6 +3518,43 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf39828) CPPUNIT_ASSERT_EQUAL(OUString("8"), xCellA4->getString()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146573) +{ + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf39828.fodt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + // remove redlines, add a footnote, and change the value + // of the cell with the footnote + dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {}); + Scheduler::ProcessEventsToIdle(); + pWrtShell->Right(CRSR_SKIP_CELLS, /*bSelect=*/false, /*nCount=*/1, /*bBasicCall=*/false); + dispatchCommand(mxComponent, ".uno:InsertFootnote", {}); + dispatchCommand(mxComponent, ".uno:PageUp", {}); // leave footnote + pWrtShell->Left(CRSR_SKIP_CELLS, /*bSelect=*/false, /*nCount=*/1, /*bBasicCall=*/false); + pWrtShell->Left(CRSR_SKIP_CELLS, /*bSelect=*/true, /*nCount=*/1, /*bBasicCall=*/false); + pWrtShell->Insert("100"); + + // trigger recalculation by leaving the cell + pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1); + + 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); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTextTable->getRows()->getCount()); + + uno::Reference<text::XTextRange> xCellA1(xTextTable->getCellByName("A1"), uno::UNO_QUERY); + // value "100" and footnote index "1" + CPPUNIT_ASSERT_EQUAL(OUString("1001"), xCellA1->getString()); + uno::Reference<text::XTextRange> xCellA3(xTextTable->getCellByName("A3"), uno::UNO_QUERY); + // This was 4 (missing recalculation) + CPPUNIT_ASSERT_EQUAL(OUString("102"), xCellA3->getString()); + uno::Reference<text::XTextRange> xCellA4(xTextTable->getCellByName("A4"), uno::UNO_QUERY); + // This was 8 (missing recalculation) + CPPUNIT_ASSERT_EQUAL(OUString("204"), xCellA4->getString()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132603) { createSwDoc(); |