summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-04-27 15:05:49 +0200
committerMichael Stahl <mstahl@redhat.com>2017-04-27 15:28:11 +0200
commitdaca28debc20f4bddcab8c22e8d3a0ca5a990486 (patch)
treedf3a4e696716e661dcd3f9c808bfaee67c768331 /sw
parent99777c5a15df2d92bb8a9ddb6329fc3df1b2b8bf (diff)
sw: add test that SwXTextCursor is disposed if header is deleted
This test failed for 2 reasons: 1) since somewhere between LO 5.0 and 5.1, the PaMCorrAbs sent a SwMsgPoolItem but SwUnoCursorPointer checked for a LegacyModifyHint (fixed in commit a029a479429d334875b73e2fc4e34b314a1ad369) 2) the SwXHeadFootText being registered at the header format prevented its deletion (fixed in preceding commit) Change-Id: I1d36bc2b9ca222b1b68fda94ded65451a677214a
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index ef688fbd70ed..9cf0fad97ff3 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -143,6 +143,7 @@ public:
void testBookmarkUndo();
void testFdo85876();
void testFdo87448();
+ void testTextCursorInvalidation();
void testTdf68183();
void testCp1000115();
void testTdf63214();
@@ -269,6 +270,7 @@ public:
CPPUNIT_TEST(testBookmarkUndo);
CPPUNIT_TEST(testFdo85876);
CPPUNIT_TEST(testFdo87448);
+ CPPUNIT_TEST(testTextCursorInvalidation);
CPPUNIT_TEST(testTdf68183);
CPPUNIT_TEST(testCp1000115);
CPPUNIT_TEST(testTdf63214);
@@ -1261,6 +1263,26 @@ void SwUiWriterTest::testFdo87448()
CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), abs(nFirstEnd - nSecondEnd) < 10);
}
+void SwUiWriterTest::testTextCursorInvalidation()
+{
+ createDoc();
+ SwDoc* pDoc = createDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xPageStyle.is());
+ xPageStyle->setPropertyValue("HeaderIsOn", uno::makeAny(true));
+ uno::Reference<text::XText> xHeader(getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderText"));
+ CPPUNIT_ASSERT(xHeader.is());
+ // create cursor inside the header text
+ uno::Reference<text::XTextCursor> xCursor(xHeader->createTextCursor());
+ // can't go right in empty header
+ CPPUNIT_ASSERT(!xCursor->goRight(1, false));
+// this does not actually delete the header: xPageStyle->setPropertyValue("HeaderIsOn", uno::makeAny(false));
+ pWrtShell->ChangeHeaderOrFooter("Default Style", true, false, false);
+ // must be disposed after deleting header
+ CPPUNIT_ASSERT_THROW(xCursor->goRight(1, false), uno::RuntimeException);
+}
+
void SwUiWriterTest::testTdf68183()
{
// First disable RSID and check if indeed no such attribute is inserted.