[Libreoffice-commits] .: sw/qa
Caolán McNamara
caolan at kemper.freedesktop.org
Fri Jun 15 13:44:17 PDT 2012
sw/qa/core/swdoc-test.cxx | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
New commits:
commit 03a59c7096cde0ced1a88069647c3ec60f86f9d6
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jun 15 21:42:31 2012 +0100
Regression test for fdo#46757
Change-Id: I41a11bda977cbd5b4b2352776f06fba0e0457a43
diff --git a/sw/qa/core/swdoc-test.cxx b/sw/qa/core/swdoc-test.cxx
index a3f795a..f8c1317 100644
--- a/sw/qa/core/swdoc-test.cxx
+++ b/sw/qa/core/swdoc-test.cxx
@@ -335,6 +335,34 @@ void SwDocTest::testSwScanner()
pTxtNode->CountWords(aDocStat, 0, SAL_N_ELEMENTS(aShouldBeFive));
CPPUNIT_ASSERT_MESSAGE("Should be 5", aDocStat.nWord == 5);
}
+
+ //See https://bugs.freedesktop.org/show_bug.cgi?id=46757
+ {
+ SwDocStat aDocStat;
+
+ const char aString[] = "Lorem ipsum";
+ m_pDoc->AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->InsertString(aPaM, rtl::OUString(aString));
+ pTxtNode = aPaM.GetNode()->GetTxtNode();
+ pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
+ CPPUNIT_ASSERT_EQUAL(aDocStat.nWord, static_cast<sal_uLong>(2));
+
+ //turn on red-lining
+ 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()));
+
+ //delete everything except the first word
+ aPaM.SetMark(); //set start of selection to current pos
+ aPaM.GetPoint()->nContent.Assign(aPaM.GetCntntNode(), 5); //set end of selection to fifth char of current node
+ m_pDoc->DeleteAndJoin(aPaM); //redline-aware deletion api
+ CPPUNIT_ASSERT_MESSAGE("real underlying text should be the same", pTxtNode->GetTxt().EqualsAscii(aString));
+
+ aDocStat.Reset();
+ 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));
+ }
}
//See https://bugs.freedesktop.org/show_bug.cgi?id=40599
More information about the Libreoffice-commits
mailing list