summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-09-24 10:06:49 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-09-24 10:56:28 +0200
commitacfb28d572201396bbe60e3824ccab28567d6a74 (patch)
treef9396b98f243a0c5d007273176a78710eb783445
parent9ec2c77046901fdacca77753052b54c81e6bc82c (diff)
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@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/qa/extras/layout/data/tdf124600.docxbin0 -> 16899 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx13
-rw-r--r--sw/source/core/text/itrform2.cxx8
3 files changed, 21 insertions, 0 deletions
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
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf124600.docx
Binary files 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;