summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-06-02 18:16:15 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2020-06-04 18:50:41 +0200
commitad8df544bb72022eb677beb45231d2ac31ff5cf6 (patch)
tree237e176e24211a16949dbfcef1aca106dbace066
parent903c3b365ec8d6db5efdcff90b59204f465a8e56 (diff)
crashtesting: fix abi11870-2.odt assert in SwBookmarkPortion::Unchain()
This m_pPrevious pointer is a bad idea, should just use FindPrevPortion() to find it, which shouldn't take that long to iterate all the portions in the current line. (regression from 4ce8120f1e53f7b81e653b01d141643013bc69ab) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91622 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit f68749054f36f070310e70e2dbf0a11c496539c0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95415 Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit deee67c566811189ee66d5766d0c9fc644a0120b) Change-Id: Ibb5f2bb28d959958547ed27c51e5084cc746d642
-rw-r--r--sw/qa/extras/layout/data/abi11870-2.odtbin0 -> 117386 bytes
-rwxr-xr-xsw/qa/extras/layout/layout.cxx8
-rwxr-xr-xsw/source/core/text/itrform2.cxx2
-rw-r--r--sw/source/core/text/pormulti.cxx8
-rw-r--r--sw/source/core/text/porrst.cxx9
-rw-r--r--sw/source/core/text/porrst.hxx7
6 files changed, 17 insertions, 17 deletions
diff --git a/sw/qa/extras/layout/data/abi11870-2.odt b/sw/qa/extras/layout/data/abi11870-2.odt
new file mode 100644
index 000000000000..b02bb85646aa
--- /dev/null
+++ b/sw/qa/extras/layout/data/abi11870-2.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index bdbcc12c9487..cb2e3e705ad7 100755
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -36,6 +36,7 @@ public:
void testTdf117188();
void testTdf119875();
void testTdf116989();
+ void testAbi11870();
void testStableAtPageAnchoredFlyPosition();
CPPUNIT_TEST_SUITE(SwLayoutWriter);
@@ -54,6 +55,7 @@ public:
CPPUNIT_TEST(testTdf117188);
CPPUNIT_TEST(testTdf119875);
CPPUNIT_TEST(testTdf116989);
+ CPPUNIT_TEST(testAbi11870);
CPPUNIT_TEST(testStableAtPageAnchoredFlyPosition);
CPPUNIT_TEST_SUITE_END();
@@ -310,6 +312,12 @@ void SwLayoutWriter::testTdf116989()
}
}
+void SwLayoutWriter::testAbi11870()
+{
+ //just care it doesn't assert
+ createDoc("abi11870-2.odt");
+}
+
static SwRect lcl_getVisibleFlyObjRect(SwWrtShell* pWrtShell)
{
SwRootFrame* pRoot = pWrtShell->GetLayout();
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index e838b8c08289..e21c06c8fd23 100755
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -1187,7 +1187,7 @@ SwLinePortion *SwTextFormatter::WhichFirstPortion(SwTextFormatInfo &rInf)
assert(bookmark & SwScriptInfo::MarkKind::Point);
mark = '|';
}
- pPor = new SwBookmarkPortion(rInf.GetLast(), mark);
+ pPor = new SwBookmarkPortion(mark);
}
}
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index 5ff1fceb5a92..0239c0d67744 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -2035,7 +2035,13 @@ bool SwTextFormatter::BuildMultiPortion( SwTextFormatInfo &rInf,
if (rInf.GetLast()->GetWhichPor() == POR_BOOKMARK)
{
auto const pBookmark(static_cast<SwBookmarkPortion*>(rInf.GetLast()));
- rInf.SetLast(pBookmark->Unchain());
+ auto *const pPrevious = pBookmark->FindPrevPortion(rInf.GetRoot());
+ assert(!pPrevious || pPrevious->GetPortion() == pBookmark);
+ if (pPrevious)
+ {
+ pPrevious->SetPortion(nullptr);
+ }
+ rInf.SetLast(pPrevious);
assert(m_pCurr->GetPortion() == nullptr);
m_pCurr->SetPortion(pBookmark);
}
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index 067ae9d477f0..654ddec99fea 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -632,13 +632,4 @@ sal_uInt16 SwControlCharPortion::GetViewWidth( const SwTextSizeInfo& rInf ) cons
return mnViewWidth;
}
-SwLinePortion * SwBookmarkPortion::Unchain()
-{
- assert(!m_pPrevious || m_pPrevious->GetPortion() == this);
- m_pPrevious->SetPortion(nullptr);
- auto const pTmp(m_pPrevious);
- m_pPrevious = nullptr;
- return pTmp;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/porrst.hxx b/sw/source/core/text/porrst.hxx
index 6b930d4f0262..3dd55acf3f0d 100644
--- a/sw/source/core/text/porrst.hxx
+++ b/sw/source/core/text/porrst.hxx
@@ -147,13 +147,9 @@ public:
/// SwControlCharPortion these do not have a character in the text.
class SwBookmarkPortion : public SwControlCharPortion
{
-private:
- SwLinePortion * m_pPrevious;
-
public:
- explicit SwBookmarkPortion(SwLinePortion *const pPrevious, sal_Unicode const cChar)
+ explicit SwBookmarkPortion(sal_Unicode const cChar)
: SwControlCharPortion(cChar)
- , m_pPrevious(pPrevious)
{
SetWhichPor(POR_BOOKMARK);
SetLen(TextFrameIndex(0));
@@ -162,7 +158,6 @@ public:
virtual bool DoPaint(SwTextPaintInfo const& rInf,
OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const override;
virtual SwLinePortion * Compress() override { return this; }
- SwLinePortion * Unchain();
};
#endif