sw/qa/core/text/data/clearing-break-header.fodt |   31 ++++++++++++++++++++++++
 sw/qa/core/text/text.cxx                        |   16 ++++++++++++
 sw/source/core/text/txtfly.cxx                  |    7 +++++
 3 files changed, 54 insertions(+)

New commits:
commit 61888e49d6eee55197ca1c27b4b023f9b2108d48
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Apr 5 16:15:15 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Apr 5 17:52:24 2022 +0200

    tdf#148366 sw clearing breaks: fix handling of anchored objs from 
header/footer
    
    Regression from commit f86d1482bef285f90079b5130e410646db96cf58 (sw
    clearing breaks: add DOCX import, 2022-03-08), the trouble was that we
    considered an anchored object from the header for text wrapping, while
    this anchored object was in the background in Word.
    
    Change-Id: I806cc91ce1eb390c02cbff2defa4cb47fde86853
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132578
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/core/text/data/clearing-break-header.fodt 
b/sw/qa/core/text/data/clearing-break-header.fodt
new file mode 100644
index 000000000000..2bdbcd3c7567
--- /dev/null
+++ b/sw/qa/core/text/data/clearing-break-header.fodt
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+  <office:automatic-styles>
+    <style:style style:name="gr1" style:family="graphic">
+      <style:graphic-properties fo:margin-left="0.318cm" 
fo:margin-right="0.318cm" fo:margin-top="0cm" fo:margin-bottom="0cm" 
style:run-through="background" style:wrap="run-through" 
style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" 
style:vertical-rel="page" style:horizontal-pos="from-left" 
style:horizontal-rel="page" draw:wrap-influence-on-position="once-concurrent" 
loext:allow-overlap="true" style:flow-with-text="false"/>
+    </style:style>
+    <style:style style:name="gr2" style:family="graphic">
+      <style:graphic-properties draw:stroke="none" svg:stroke-width="0cm" 
draw:fill="none" draw:textarea-horizontal-align="center" 
draw:textarea-vertical-align="bottom" draw:auto-grow-height="false" 
style:run-through="background"/>
+    </style:style>
+    <style:page-layout style:name="pm1">
+      <style:page-layout-properties fo:page-width="21.001cm" 
fo:page-height="29.7cm" fo:margin-top="1.251cm" fo:margin-bottom="2.54cm" 
fo:margin-left="2.501cm" fo:margin-right="2.501cm">
+      </style:page-layout-properties>
+      <style:header-style>
+        <style:header-footer-properties fo:min-height="1.289cm" 
fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-bottom="1.189cm" 
style:dynamic-spacing="true"/>
+      </style:header-style>
+    </style:page-layout>
+  </office:automatic-styles>
+  <office:master-styles>
+    <style:master-page style:name="Standard" style:page-layout-name="pm1">
+      <style:header>
+        <text:p><draw:g text:anchor-type="char" draw:z-index="1" 
draw:style-name="gr1"><draw:rect draw:style-name="gr2" svg:width="8.347cm" 
svg:height="8.908cm" svg:x="11.871cm" 
svg:y="21.243cm"><text:p/></draw:rect></draw:g></text:p>
+        <text:p/>
+      </style:header>
+    </style:master-page>
+  </office:master-styles>
+  <office:body>
+    <office:text>
+      <text:p><text:line-break loext:clear="all"/></text:p>
+    </office:text>
+  </office:body>
+</office:document>
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index ec04039d8e15..8ad0d230bebc 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -366,6 +366,22 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testClearingLineBreakLeft)
     assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout[1]", "height", "2837");
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testClearingLineBreakHeader)
+{
+    // Given a document with a shape in the header and a clearing break in the 
body text:
+    createSwDoc(DATA_DIRECTORY, "clearing-break-header.fodt");
+
+    // When laying out that document:
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+    // Then make sure that the shape from the header is ignored while 
calculating the line height:
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 276
+    // - Actual  : 15398
+    // i.e. the shape was in the background, but we failed to ignore it for 
the break portion.
+    assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout[1]", "height", "276");
+}
+
 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 1b9c3b55308a..88f0687de8c1 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -1012,6 +1012,13 @@ SwTwips SwTextFly::GetMaxBottom(const SwBreakPortion& 
rPortion, const SwTextForm
     for (size_t i = 0; i < nCount; ++i)
     {
         const SwAnchoredObject* pAnchoredObj = (*mpAnchoredObjList)[i];
+
+        if (pAnchoredObj->GetAnchorFrame()->FindFooterOrHeader())
+        {
+            // Anchored in the header or footer, ignore it for clearing break 
purposes.
+            continue;
+        }
+
         SwRect aRect(pAnchoredObj->GetObjRectWithSpaces());
         if (rPortion.GetClear() == SwLineBreakClear::LEFT)
         {

Reply via email to