summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Jaap <patrick.jaap@tu-dresden.de>2019-09-06 10:50:05 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-09-24 09:01:19 +0200
commit1e9d08d046bfe362e5e2ffeb36e35692fc3b55f5 (patch)
treedae636621a946a24b18fad29e280c863c86b7f11
parentb212f74a9a25bde0ab662777ab2f1fa657314504 (diff)
tdf#127235 break if object is larger than page
We will always have an overlap if the object is larger than the whole page. Look for the next page style: if it is missing or the same as the current, we simply stop. Change-Id: I699d5146d215f17b4775dbcb32811fa5b6ebf60d Reviewed-on: https://gerrit.libreoffice.org/78696 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/79104
-rw-r--r--sw/qa/extras/layout/data/tdf127235.odtbin0 -> 3239 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx9
-rw-r--r--sw/source/core/text/txtfly.cxx21
3 files changed, 28 insertions, 2 deletions
diff --git a/sw/qa/extras/layout/data/tdf127235.odt b/sw/qa/extras/layout/data/tdf127235.odt
new file mode 100644
index 000000000000..5b27c921cf17
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf127235.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index c2c6d2cd5b9d..ec568d69f767 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -67,6 +67,7 @@ public:
void testTdf122878();
void testTdf115094();
void testTdf118719();
+ void testTdf127235();
CPPUNIT_TEST_SUITE(SwLayoutWriter);
CPPUNIT_TEST(testRedlineFootnotes);
@@ -106,6 +107,7 @@ public:
CPPUNIT_TEST(testTdf122878);
CPPUNIT_TEST(testTdf115094);
CPPUNIT_TEST(testTdf118719);
+ CPPUNIT_TEST(testTdf127235);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2728,6 +2730,13 @@ void SwLayoutWriter::testTdf118719()
CPPUNIT_ASSERT_GREATER(nOther, nLast);
}
+void SwLayoutWriter::testTdf127235()
+{
+ SwDoc* pDoc = createDoc("tdf127235.odt");
+ // This resulted in a layout loop.
+ pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index e16cd878ce75..18bec6284a57 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -998,6 +998,24 @@ bool SwTextFly::ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const
{
SwSwapIfSwapped swap(const_cast<SwTextFrame *>(m_pCurrFrame));
+ // Optimization
+ SwRectFnSet aRectFnSet(m_pCurrFrame);
+
+ // tdf#127235 stop if the area is larger than the page
+ if( aRectFnSet.GetHeight(pPage->getFrameArea()) < aRectFnSet.GetHeight(rRect))
+ {
+ // get the doc model description
+ const SwPageDesc* pPageDesc = pPage->GetPageDesc();
+
+ // if there is no next page style or it is the same as the current
+ // => stop trying to place the frame (it would end in an infinite loop)
+ if( pPageDesc &&
+ ( !pPageDesc->GetFollow() || pPageDesc->GetFollow() == pPageDesc) )
+ {
+ return false;
+ }
+ }
+
bool bRet = false;
// #i68520#
const SwAnchoredObjList::size_type nCount( bOn ? GetAnchoredObjList()->size() : 0 );
@@ -1010,10 +1028,9 @@ bool SwTextFly::ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const
SwRect aRect( pAnchoredObj->GetObjRectWithSpaces() );
- // Optimization
- SwRectFnSet aRectFnSet(m_pCurrFrame);
if( aRectFnSet.GetLeft(aRect) > aRectFnSet.GetRight(rRect) )
break;
+
// #i68520#
if ( mpCurrAnchoredObj != pAnchoredObj && aRect.IsOver( rRect ) )
{