summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-04-28 19:48:52 +0200
committerLászló Németh <nemeth@numbertext.org>2022-05-02 22:57:06 +0200
commit978e22f8cfb3db573bed3fd4b14a515cf090f7e5 (patch)
treef507f148ddb566fdfa0e0c51ad95676d4338f9ea /sw
parent64106353c98e8cb0c99c9e4ff509348edf8ed911 (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')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx40
-rw-r--r--sw/source/core/fields/cellfml.cxx5
-rw-r--r--sw/source/core/table/swtable.cxx3
3 files changed, 41 insertions, 7 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();
diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx
index 12bfec75a4ff..339a0337b561 100644
--- a/sw/source/core/fields/cellfml.cxx
+++ b/sw/source/core/fields/cellfml.cxx
@@ -152,9 +152,8 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
OUString sText = pTextNd->GetText();
// use text of the tracked changes
- if ( sText != pTextNd->GetRedlineText() &&
- sText.getLength() > 0 &&
- sText[0] != CH_TXTATR_BREAKWORD && sText[0] != CH_TXTATR_INWORD )
+ if ( sText.getLength() > 0 &&
+ sText[0] != CH_TXTATR_BREAKWORD && sText[0] != CH_TXTATR_INWORD )
{
sText = pTextNd->GetRedlineText();
}
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 7b9f6b030970..da2c2f4a9ae8 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2717,7 +2717,8 @@ SwNodeOffset SwTableBox::IsValidNumTextNd( bool bCheckAttr ) const
continue;
}
}
- else if( RES_TXTATR_ANNOTATION == pAttr->Which() )
+ else if( RES_TXTATR_ANNOTATION == pAttr->Which() ||
+ RES_TXTATR_FTN == pAttr->Which() )
{
continue;
}