diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-27 12:36:25 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-05-13 14:14:27 +0200 |
commit | 68fb9e49a112224c147476c729ae656ec13dd892 (patch) | |
tree | 03e278bfa435dc7346883a08e9ff410c0988155d | |
parent | forcepoint#90 fix crash on layout of specific rtf (diff) | |
download | core-68fb9e49a112224c147476c729ae656ec13dd892.tar.gz core-68fb9e49a112224c147476c729ae656ec13dd892.zip |
forcepoint#93 fix crash on layout of specific rtf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133481
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 5277b953b29845555cba8f867c9c750e8bc510a5)
(cherry picked from commit 97f4ea4b8b44425ed0fe34df650c7531cfa721f5)
Change-Id: Id81729de2efd6f65f1b51bdb437ca21a260eaf6e
-rw-r--r-- | sw/qa/extras/layout/data/forcepoint93-1.rtf | bin | 0 -> 88310 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/data/forcepoint93-2.rtf | bin | 0 -> 5456 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/inc/frame.hxx | 11 | ||||
-rw-r--r-- | sw/source/core/layout/objectformattertxtfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/wsfrm.cxx | 2 |
6 files changed, 17 insertions, 7 deletions
diff --git a/sw/qa/extras/layout/data/forcepoint93-1.rtf b/sw/qa/extras/layout/data/forcepoint93-1.rtf Binary files differnew file mode 100644 index 000000000000..bbe5ecfb78f2 --- /dev/null +++ b/sw/qa/extras/layout/data/forcepoint93-1.rtf diff --git a/sw/qa/extras/layout/data/forcepoint93-2.rtf b/sw/qa/extras/layout/data/forcepoint93-2.rtf Binary files differnew file mode 100644 index 000000000000..bcc5f3dc8855 --- /dev/null +++ b/sw/qa/extras/layout/data/forcepoint93-2.rtf diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index e32fd100f31d..97950bd8d497 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -36,6 +36,7 @@ public: void testUXTSOREL(); void testForcepoint90(); void testForcepoint92(); + void testForcepoint93(); void testTdf118058(); void testTdf117188(); void testTdf119875(); @@ -60,6 +61,7 @@ public: //FIXME this asserts CPPUNIT_TEST(testUXTSOREL); CPPUNIT_TEST(testForcepoint90); CPPUNIT_TEST(testForcepoint92); + CPPUNIT_TEST(testForcepoint93); CPPUNIT_TEST(testTdf118058); CPPUNIT_TEST(testTdf117188); CPPUNIT_TEST(testTdf119875); @@ -276,6 +278,13 @@ void SwLayoutWriter::testForcepoint90() //just care it doesn't crash/assert void SwLayoutWriter::testForcepoint92() { createDoc("forcepoint92.doc"); } +//just care it doesn't crash/assert +void SwLayoutWriter::testForcepoint93() +{ +//fails to load createDoc("forcepoint93-1.rtf"); +//layout loop createDoc("forcepoint93-2.rtf"); +} + #if 0 // no createSwWebDoc //just care it doesn't crash/assert CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint94) diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index 0f1b1dd07e6c..4dadc50df4db 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -421,7 +421,7 @@ protected: bool mbColLocked : 1; // lock Grow/Shrink for column-wise section // or fly frames, will be set in Format bool m_isInDestroy : 1; - bool mbForbidDelete : 1; + int mnForbidDelete; void ColLock() { mbColLocked = true; } void ColUnlock() { mbColLocked = false; } @@ -854,7 +854,7 @@ public: bool IsProtected() const; bool IsColLocked() const { return mbColLocked; } - virtual bool IsDeleteForbidden() const { return mbForbidDelete; } + virtual bool IsDeleteForbidden() const { return mnForbidDelete > 0; } /// this is the only way to delete a SwFrame instance static void DestroyFrame(SwFrame *const pFrame); @@ -897,8 +897,8 @@ public: void RegisterToFormat( SwFormat& rFormat ); void ValidateThisAndAllLowers( const sal_uInt16 nStage ); - void ForbidDelete() { mbForbidDelete = true; } - void AllowDelete() { mbForbidDelete = false; } + void ForbidDelete() { ++mnForbidDelete; } + void AllowDelete() { assert(mnForbidDelete > 0); --mnForbidDelete; } drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const; bool supportsFullDrawingLayerFillAttributeSet() const; @@ -1226,8 +1226,7 @@ public: //it in e.g. SwSectionFrame::MergeNext etc because we will need it //again after the SwFrameDeleteGuard dtor explicit SwFrameDeleteGuard(SwFrame* pFrame) - : m_pForbidFrame((pFrame && !pFrame->IsDeleteForbidden()) ? - pFrame : nullptr) + : m_pForbidFrame(pFrame) { if (m_pForbidFrame) m_pForbidFrame->ForbidDelete(); diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx index f591fa662e76..815fb4324102 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -736,6 +736,8 @@ void SwObjectFormatterTextFrame::FormatAnchorFrameAndItsPrevs( SwTextFrame& _rAn // Thus, check for valid <pFrame>. while ( pFrame && pFrame != pSectFrame ) { + SwFrameDeleteGuard aDeleteFrameGuard(pFrame); + if ( pFrame->IsLayoutFrame() ) lcl_FormatContentOfLayoutFrame( static_cast<SwLayoutFrame*>(pFrame) ); else diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index cdce7870a536..aff410f10414 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -318,7 +318,7 @@ SwFrame::SwFrame( SwModify *pMod, SwFrame* pSib ) mbInfSct ( false ), mbColLocked(false), m_isInDestroy(false), - mbForbidDelete(false) + mnForbidDelete(0) { OSL_ENSURE( pMod, "No frame format given." ); } |