summaryrefslogtreecommitdiff
path: root/sw/qa/core/text/text.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-06-15 08:24:23 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-06-15 09:28:56 +0200
commit737d90b7b7cb03bb6128b74a32906b0391868830 (patch)
tree7917fbac6e3f43db354aee0442dd212d3accc75b /sw/qa/core/text/text.cxx
parent977878814a3573627026e31edb8a51c8f30c8a0c (diff)
sw floattable: fix handling of upper margin of anchor for fly intersect
The bugdoc has 2 paragraphs and a shape between them. Word has a small amount of space between the shape and the 2nd paragraph, Writer has a large amount of space between the shape and the 2nd paragraph. It seems what happens is that Writer puts both the text node's own upper spacing and the previous text node's lower spacing into the upper spacing of the text frame, so the check added in commit d07fc485d46f431405a3f6a002f951a08c559677 (tdf#116486 Consider upper margin in paragraph positioning with flys, 2018-04-10) is not entirely correct, as it deal with both upper and lower margins, but its intention was just the upper margins. Fix the problem by (indirectly) using GetUpperSpaceAmountConsideredForPrevFrame(), which allows doing the intersection for the original text node upper spacing but not for the text node lower spacing. This keeps the original bugdoc working, but fixes the unexpected vertical space for the new bugdoc. This is part of the effort so that the original bnc#816603 bugdoc's DOCX version moves an overlapping floating table from page 4 back to page 3, like Word does. testTdf122878 is modified to just make sure no overlap happens, manual testing of the bugdoc shows that our layout still matches Word. Change-Id: I4622fb77dc8a52493766e50688ec92065eac65bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153101 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/core/text/text.cxx')
-rw-r--r--sw/qa/core/text/text.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 6d71cadcf9ea..dff758985c37 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -1371,6 +1371,36 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf139863)
assertXPath(pXmlDoc, "//body/txt[2]/SwParaPortion/SwLineLayout/child::*", 1);
}
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testParaUpperMarginFlyIntersect)
+{
+ // Given a document with 2 paragraphs, the paragraphs have both upper and lower spacing of 567
+ // twips:
+ createSwDoc("para-upper-margin-fly-intersect.docx");
+
+ // When laying out that document:
+ calcLayout();
+
+ // Then make sure that we shift down the text in the second paragraph only based on the 2nd para
+ // upper margin, not based on the 1st para lower margin:
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ int nFlyCount
+ = getXPathContent(pXmlDoc,
+ "count(//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Fly'])")
+ .toInt32();
+ int nHeight = 0;
+ for (int i = 1; i <= nFlyCount; ++i)
+ {
+ OString xPath = "(//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Fly'])["
+ + OString::number(i) + "]";
+ nHeight += getXPath(pXmlDoc, xPath, "height").toInt32();
+ }
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 521 (~500)
+ // - Actual : 857 (~1000)
+ // I.e. both upper and lower margin was taken into account.
+ CPPUNIT_ASSERT_EQUAL(521, nHeight);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */