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

Patrick Jaap (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 18 14:24:33 UTC 2019


 sw/qa/extras/layout/data/tdf127235.odt |binary
 sw/qa/extras/layout/layout.cxx         |    7 +++++++
 sw/source/core/text/txtfly.cxx         |   21 +++++++++++++++++++--
 3 files changed, 26 insertions(+), 2 deletions(-)

New commits:
commit 37b79c872b2637912c5d6972812ee2c9d5b096c7
Author:     Patrick Jaap <patrick.jaap at tu-dresden.de>
AuthorDate: Fri Sep 6 10:50:05 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Sep 18 16:23:14 2019 +0200

    WIP: 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 at collabora.com>

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
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf127235.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index af3cde2db379..59e1e08939e0 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3089,6 +3089,13 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf113014)
     assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/textarray[5]/text", "3.");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf127235)
+{
+    SwDoc* pDoc = createDoc("tdf127235.odt");
+    // This resulted in a layout loop.
+    pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 82b16055e82a..51befd6f2878 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -999,6 +999,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 );
@@ -1011,10 +1029,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 ) )
             {


More information about the Libreoffice-commits mailing list