summaryrefslogtreecommitdiff
path: root/sw/qa/core
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-11-03 09:49:37 +0000
committerMichael Stahl <mstahl@redhat.com>2014-11-04 16:24:46 +0000
commit5ae6072774ab544fdfdfebf2364e97ca2fa2326a (patch)
treeb13af642bff1c08a99cb4fb1ce7610a30f981796 /sw/qa/core
parent026d048e896683a0630ee08879f2f2e5bff89284 (diff)
Resolves: fdo#68347 fix word count with recorded changes
also see fdo#46757 a) We need to ignore redline-deleted text, but count redline-added text b) each block of text is denoted by its end position in the model and where that maps to in the view so a hidden portion should record its end point not its starting point, and a non-hidden deleted portion should always record its end point c) when mapping a model position to the view we take the offset of the model pos arg from the block end and use that to offset the mapped block-end view pos to get the final view pos. But for hidden portions that won't make a whole lot of sense, and end up offsetting into prior portions, so map all positions within a hidden portion to the same block-end view pos add regression tests for these cases (cherry picked from commit fa430e6b4e6f5d096bdf59db26e5d7393ca2297b) Conflicts: sw/qa/core/uwriter.cxx Change-Id: I45c76bba47fd430bc3bccb5f919502660d415d9e Reviewed-on: https://gerrit.libreoffice.org/12219 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw/qa/core')
-rw-r--r--sw/qa/core/uwriter.cxx34
1 files changed, 26 insertions, 8 deletions
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index bd6e000e9d02..1297c65b1257 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -321,7 +321,7 @@ void SwDocTest::testModelToViewHelper()
}
{
- ModelToViewHelper aModelToViewHelper(*pTxtNode, HIDEREDLINED);
+ ModelToViewHelper aModelToViewHelper(*pTxtNode, HIDEDELETIONS);
OUString sViewText = aModelToViewHelper.getViewText();
CPPUNIT_ASSERT_EQUAL(
OUString("AAAABB " + OUString(CH_TXTATR_BREAKWORD) + " CCCCC " + OUString(CH_TXTATR_BREAKWORD) + " DDDDD"),
@@ -349,14 +349,14 @@ void SwDocTest::testModelToViewHelper()
}
{
- ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | HIDEREDLINED | EXPANDFOOTNOTE);
+ ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | HIDEDELETIONS | EXPANDFOOTNOTE);
OUString sViewText = aModelToViewHelper.getViewText();
CPPUNIT_ASSERT_EQUAL(
OUString("AAAABB foo CCCCC foo DDDDD"), sViewText);
}
{
ModelToViewHelper aModelToViewHelper(*pTxtNode,
- EXPANDFIELDS | HIDEREDLINED | EXPANDFOOTNOTE | REPLACEMODE);
+ EXPANDFIELDS | HIDEDELETIONS | EXPANDFOOTNOTE | REPLACEMODE);
OUString sViewText = aModelToViewHelper.getViewText();
CPPUNIT_ASSERT_EQUAL(
OUString("AAAABB " + OUString(CHAR_ZWSP) + " CCCCC " + OUString(CHAR_ZWSP) + " DDDDD"),
@@ -372,7 +372,7 @@ void SwDocTest::testModelToViewHelper()
}
{
- ModelToViewHelper aModelToViewHelper(*pTxtNode, HIDEINVISIBLE | HIDEREDLINED);
+ ModelToViewHelper aModelToViewHelper(*pTxtNode, HIDEINVISIBLE | HIDEDELETIONS);
OUString sViewText = aModelToViewHelper.getViewText();
OUStringBuffer aBuffer;
aBuffer.append("AAAACCCCC ");
@@ -382,13 +382,13 @@ void SwDocTest::testModelToViewHelper()
}
{
- ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | HIDEINVISIBLE | HIDEREDLINED | EXPANDFOOTNOTE);
+ ModelToViewHelper aModelToViewHelper(*pTxtNode, EXPANDFIELDS | HIDEINVISIBLE | HIDEDELETIONS | EXPANDFOOTNOTE);
OUString sViewText = aModelToViewHelper.getViewText();
CPPUNIT_ASSERT_EQUAL(OUString("AAAACCCCC foo DDDDD"), sViewText);
}
{
ModelToViewHelper aModelToViewHelper(*pTxtNode,
- EXPANDFIELDS | HIDEINVISIBLE | HIDEREDLINED | EXPANDFOOTNOTE | REPLACEMODE);
+ EXPANDFIELDS | HIDEINVISIBLE | HIDEDELETIONS | EXPANDFOOTNOTE | REPLACEMODE);
OUString sViewText = aModelToViewHelper.getViewText();
CPPUNIT_ASSERT_EQUAL(sViewText,
OUString("AAAACCCCC " + OUString(CHAR_ZWSP) + " DDDDD"));
@@ -669,8 +669,26 @@ void SwDocTest::testSwScanner()
aDocStat.Reset();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len()); //word-counting the text should only count the non-deleted text, and this whole chunk should be ignored
- CPPUNIT_ASSERT_EQUAL(aDocStat.nWord, static_cast<sal_uLong>(0));
- CPPUNIT_ASSERT_EQUAL(aDocStat.nChar, static_cast<sal_uLong>(0));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(0), aDocStat.nWord);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(0), aDocStat.nChar);
+
+ // https://bugs.libreoffice.org/show_bug.cgi?id=68347 we do want to count
+ // redline *added* text though
+ m_pDoc->SetRedlineMode(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_DELETE|nsRedlineMode_t::REDLINE_SHOW_INSERT);
+ aPaM.DeleteMark();
+ aPaM.GetPoint()->nContent.Assign(aPaM.GetCntntNode(), 0);
+ m_pDoc->InsertString(aPaM, "redline-new-text ");
+ aDocStat.Reset();
+ pTxtNode = aPaM.GetNode()->GetTxtNode();
+ pTxtNode->SetWordCountDirty(true);
+ pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(2), aDocStat.nWord);
+ //redline-new-text Lorem ipsum
+ //+++++++++++++++++ ------
+ //select start of original text and part of deleted text
+ aDocStat.Reset();
+ pTxtNode->CountWords(aDocStat, 17, 25);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(5), aDocStat.nChar);
}
//See https://bugs.libreoffice.org/show_bug.cgi?id=38983