diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-12-21 17:55:02 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-12-22 17:02:08 +0100 |
commit | fad7b155ea8de886685c0fff99d959c02caf2356 (patch) | |
tree | d607d5211fb51eadd9618b645a838bf52ab44f30 /sw/qa | |
parent | a9b042dd4554764eb5cef336c35d615d009806d6 (diff) |
sw: fix layout loop due to a keep-with-next vs 100% image height conflict
The document in question has a landscape page, the last paragraph has an
image where the width is 100% and the height is set to keep the ratio
(which 1:1). This means that SwFlyFreeFrame::CheckClip() will scale the
image down, so the image fits the page (and give up that 100% width was
requested).
The next problem is that this image has a wrap type set to none, so not
only the total height of the page is taken, but also no content is
allowed on the left/right side, effectively taking the entire body
frame. Combine this with a previous paragraph, which is a heading, so
keep-with-next is set for it. Layout loops because keep-with-next and
take-the-entire-page are conflicting requirements and we used to have no
explicit code to relax one of them when both are present:
SwFlowFrame::MoveBwd: frame is 4, old upper is 10, new upper is 2
SwFlowFrame::MoveFwd: frame is 4, old upper is 2, new upper is 10
SwFlowFrame::MoveBwd: frame is 4, old upper is 10, new upper is 2
SwFlowFrame::MoveFwd: frame is 4, old upper is 2, new upper is 10
SwFlowFrame::MoveBwd: loop control, frame is 4, old upper is 10, new upper would be 2, but not moving there
Fix the problem by giving up keep-with-next to stop the loop, mostly
because we have to give up one of the requirements and Word resolves the
conflict this way.
(cherry picked from commit 160db4bf0fc391b2ded635d0bd998d5352541742)
Conflicts:
sw/qa/core/layout/layout.cxx
Change-Id: I7da1ebcff9302cd144887f63efb94e0b2b2be8fd
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/core/layout/data/keepwithnext-fullheight.fodt | 42 | ||||
-rw-r--r-- | sw/qa/core/layout/layout.cxx | 18 |
2 files changed, 60 insertions, 0 deletions
diff --git a/sw/qa/core/layout/data/keepwithnext-fullheight.fodt b/sw/qa/core/layout/data/keepwithnext-fullheight.fodt new file mode 100644 index 000000000000..b33dd80e719e --- /dev/null +++ b/sw/qa/core/layout/data/keepwithnext-fullheight.fodt @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:mimetype="application/vnd.oasis.opendocument.text" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"> + <office:styles> + <style:style style:name="OLE" style:family="graphic"> + <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" style:wrap="none" style:horizontal-pos="center" style:horizontal-rel="paragraph" style:flow-with-text="false"/> + </style:style> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:master-page-name="Landscape"/> + <style:style style:name="fr1" style:family="graphic" style:parent-style-name="OLE"> + <style:graphic-properties style:vertical-pos="top" style:vertical-rel="paragraph" draw:ole-draw-aspect="1"/> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="82.652cm" fo:page-height="57.683cm" style:num-format="1" style:print-orientation="landscape" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm"/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Landscape" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:p text:style-name="P1">Landscape page</text:p> + <text:h>Heading</text:h> + <text:p><draw:frame draw:style-name="fr1" draw:name="Image1" text:anchor-type="paragraph" svg:width="58.644cm" style:rel-width="100%" svg:height="57.683cm" style:rel-height="scale" draw:z-index="0"><draw:image draw:mime-type="image/png"><office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz + UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA + AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 + AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ + BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 + cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn + /878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF + QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo + YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo + 2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A + cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA + AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A + hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 + 5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA + AABJRU5ErkJggg== + </office:binary-data></draw:image></draw:frame></text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index ccf2b5cd513a..4cc7390d63f9 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -146,6 +146,24 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testContinuousEndnotesMoveBackwards) assertXPath(pLayout, "/root/page[2]/ftncont", 1); } +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testKeepwithnextFullheight) +{ + // The document has a heading (keep with next) and a full-page image in the next paragraph, i.e. + // conflicting requirements. + // Without the accompanying fix in place, this test would have failed with a layout loop in + // SwEditShell::CalcLayout(). + load(DATA_DIRECTORY, "keepwithnext-fullheight.fodt"); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + // Make sure the document has 2 pages. + assertXPath(pXmlDoc, "//page", 2); + // Heading stays on page 1 to avoid a layout loop. + assertXPathContent(pXmlDoc, "//page[1]/body/txt[2]", "Heading"); + // Image stays on page 2. + assertXPath(pXmlDoc, "//page[2]/body/txt/anchored/fly", 1); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |