[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source

Michael Stahl mstahl at redhat.com
Thu Apr 27 13:32:15 UTC 2017


 sw/qa/extras/uiwriter/uiwriter.cxx |   22 ++++++++++++++++++++++
 sw/source/core/layout/atrfrm.cxx   |    2 +-
 2 files changed, 23 insertions(+), 1 deletion(-)

New commits:
commit daca28debc20f4bddcab8c22e8d3a0ca5a990486
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Apr 27 15:05:49 2017 +0200

    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

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.
commit 99777c5a15df2d92bb8a9ddb6329fc3df1b2b8bf
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Apr 27 15:03:21 2017 +0200

    sw: fix always-true condition in lcl_DelHFFormat ...
    
    ... that prevents headers from being deleted if they have a client.
    
    (regression from d4267231754c1e6b03c7723a6fecc46750e7c780)
    
    Change-Id: I71f52f8806e59c97b81aa14144c700c14c5527b0

diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 7661a0511948..c6521ae769f3 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -120,7 +120,7 @@ static void lcl_DelHFFormat( SwClient *pToRemove, SwFrameFormat *pFormat )
         // It's suboptimal if the format is deleted beforehand.
         SwIterator<SwClient,SwFrameFormat> aIter(*pFormat);
         for(SwClient* pLast = aIter.First(); bDel && pLast; pLast = aIter.Next())
-            if(dynamic_cast<const SwFrame*>( pLast ) ==  nullptr || !SwXHeadFootText::IsXHeadFootText(pLast))
+            if (dynamic_cast<const SwFrame*>(pLast) == nullptr && !SwXHeadFootText::IsXHeadFootText(pLast))
                 bDel = false;
     }
 


More information about the Libreoffice-commits mailing list