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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 24 08:57:29 UTC 2019


 sw/qa/extras/layout/data/tdf124600.docx |binary
 sw/qa/extras/layout/layout.cxx          |   13 +++++++++++++
 sw/source/core/text/itrform2.cxx        |    8 ++++++++
 3 files changed, 21 insertions(+)

New commits:
commit acfb28d572201396bbe60e3824ccab28567d6a74
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Sep 24 10:06:49 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Sep 24 10:56:28 2019 +0200

    tdf#124600 sw AddVerticalFrameOffsets: fix bad wrap of half-intersecting frame
    
    Commit d07fc485d46f431405a3f6a002f951a08c559677 (tdf#116486 Consider
    upper margin in paragraph positioning with flys, 2018-04-10) already
    improved the interaction between paragraph upper margin and fly frames
    in Word compat mode, this improves the situation further.
    
    The problem is that in case the paragraph with an upper margin
    intersects with a fly frame, then it makes sense to take the area of the
    upper margin into account (i.e. intersect the fly frame rect with the
    frame area, not with the smaller print area), but in case the
    intersection covers only the margin area and none of the print area,
    then the intersection is ignored by Word, so we should do the same in
    compat mode. [ The "intersection bottom is above the para print area
    top" condition can be true only in compat mode. ]
    
    In other words, the mentioned commit fixed the position of a line of
    text below a fly frame, this one makes sure that a long line is not
    wrapped into 2 lines (referred to "text is covered" in the bugreport) in
    Writer, to match Word's behavior.
    
    Change-Id: I4581021c3dd570fbc8a89002394a43ef18f11a67
    Reviewed-on: https://gerrit.libreoffice.org/79431
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/layout/data/tdf124600.docx b/sw/qa/extras/layout/data/tdf124600.docx
new file mode 100644
index 000000000000..fc732b5e73bf
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf124600.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 2110eed1e31c..ccbfd0b944a3 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3154,6 +3154,19 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testShapeAllowOverlap)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124600)
+{
+    createDoc("tdf124600.docx");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 1
+    // - Actual  : 2
+    // i.e. the last line in the body text had 2 lines, while it should have 1, as Word does (as the
+    // fly frame does not intersect with the print area of the paragraph.)
+    assertXPath(pXmlDoc, "/root/page/body/txt[2]/LineBreak", 1);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 9c59c5353fea..f03d93087732 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -2312,6 +2312,14 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
     if ( m_pFrame->IsVertical() )
         m_pFrame->SwitchVerticalToHorizontal( aInter );
 
+    if (!aInter.IsEmpty() && aInter.Bottom() < nTop)
+    {
+        // Intersects with the frame area (with upper margin), but not with the print area (without
+        // upper margin). Don't reserve space for the fly portion in this case, text is allowed to
+        // folow there.
+        aInter.Height(0);
+    }
+
     if( !aInter.IsOver( aLine ) )
         return;
 


More information about the Libreoffice-commits mailing list