diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-07-19 13:50:21 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-07-19 14:03:50 +0100 |
commit | 3442913accc4e44c3a1ac69a990edee15117948e (patch) | |
tree | e0031b758e3d3982efde0192c9e9741b9b4bf799 /sw/qa | |
parent | 238eba337cedda17a9ed1ce7e91755c66446195a (diff) |
Related: fdo#46757 fix weird word/char count with hidden deleted text
i.e. changes on, but not shown then unseen deleted text counted in word/char
count
Change-Id: I5725063edfbfc1f6545fe1dcea9b224dbfa3a418
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/core/swdoc-test.cxx | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/sw/qa/core/swdoc-test.cxx b/sw/qa/core/swdoc-test.cxx index 8c06e252bdc5..f76cad3d2c2f 100644 --- a/sw/qa/core/swdoc-test.cxx +++ b/sw/qa/core/swdoc-test.cxx @@ -61,6 +61,8 @@ #include "fmtftn.hxx" #include "fmtrfmrk.hxx" #include "fmtfld.hxx" +#include "redline.hxx" +#include "docary.hxx" SO2_DECL_REF(SwDocShell) SO2_IMPL_REF(SwDocShell) @@ -399,7 +401,7 @@ void SwDocTest::testSwScanner() pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len()); CPPUNIT_ASSERT_EQUAL(aDocStat.nWord, static_cast<sal_uLong>(2)); - //turn on red-lining + //turn on red-lining and show changes m_pDoc->SetRedlineMode(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_DELETE|nsRedlineMode_t::REDLINE_SHOW_INSERT); CPPUNIT_ASSERT_MESSAGE("redlining should be on", m_pDoc->IsRedlineOn()); CPPUNIT_ASSERT_MESSAGE("redlines should be visible", IDocumentRedlineAccess::IsShowChanges(m_pDoc->GetRedlineMode())); @@ -414,6 +416,39 @@ void SwDocTest::testSwScanner() pTxtNode->SetWordCountDirty(true); pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len()); //but word-counting the text should only count the non-deleted text CPPUNIT_ASSERT_EQUAL(aDocStat.nWord, static_cast<sal_uLong>(1)); + + pTxtNode->SetWordCountDirty(true); + + //keep red-lining on but hide changes + m_pDoc->SetRedlineMode(nsRedlineMode_t::REDLINE_ON); + CPPUNIT_ASSERT_MESSAGE("redlining should be still on", m_pDoc->IsRedlineOn()); + CPPUNIT_ASSERT_MESSAGE("redlines should be invisible", !IDocumentRedlineAccess::IsShowChanges(m_pDoc->GetRedlineMode())); + + aDocStat.Reset(); + pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len()); //but word-counting the text should only count the non-deleted text + CPPUNIT_ASSERT_EQUAL(aDocStat.nWord, static_cast<sal_uLong>(1)); + + rtl::OUString sLorem = pTxtNode->GetTxt(); + CPPUNIT_ASSERT(sLorem == "Lorem"); + + const SwRedlineTbl& rTbl = m_pDoc->GetRedlineTbl(); + + SwNodes& rNds = m_pDoc->GetNodes(); + CPPUNIT_ASSERT(rTbl.Count() == 1); + + SwNodeIndex* pNodeIdx = rTbl[0]->GetContentIdx(); + CPPUNIT_ASSERT(pNodeIdx); + + pTxtNode = rNds[ pNodeIdx->GetIndex() + 1 ]->GetTxtNode(); //first deleted txtnode + CPPUNIT_ASSERT(pTxtNode); + + rtl::OUString sIpsum = pTxtNode->GetTxt(); + CPPUNIT_ASSERT(sIpsum == " ipsum"); + + 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)); } } |