summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-09-14 17:38:32 +0200
committerAndras Timar <andras.timar@collabora.com>2018-09-21 09:41:26 +0200
commitc1d717425027ee5770b69e1826ebb75d1d9a3013 (patch)
tree0d7a897088e43b00804e1c141386dd4f0a41698e /sw
parent772c80f7581eb6902c972ce87028a5f5e7f8c4f9 (diff)
tdf#119875 sw: fix invalid pos of frame after 0-sized section with laycache
The interesting part of the layout of page 2 is: - frame #40 is a section frame with a text frame which is in a list ("A") - frame #48 is a section frame after that, with the same top=19213 Given that frame #40 has height > 0, they overlap when the page is rendered. What happens is: - frame #40 grows - there are other section frames between #40 and #48 in-between, but they don't have an SwSection - these frames are skipped - then the position of #48 is invalidated So the next time we calculate the position of #48, we look the last skipped (previous) section frame (which still has top=19213, since its position was not invalidated above), and since its height is 0, we conclude that our current top=19213 is valid after all. This is like this since commit 84a3db80b4fd66c6854b3135b5f69b61fd828e62 (initial import, 2000-09-18), so leave the code there that invalidates not only the next frame, but all the way down to the first non-SwSection-less-SwSectionFrame. But instead of just invalidating the last frame, invalidate the in-between SwSection-less-SwSectionFrames as well. In practice this did not cause a problem in case the document has no layout cache. If it does, then the frames are created on pages hinted by the cache, then later moved to their final place. In practice this bug was visible only in this later case. (I.e. such a layout cache can be only created if the machine that saved the document last time does not have the fonts needed by the document installed; and then the document is opened on an other machine which has those fonts.) (cherry picked from commit b5937112d4035fb9ffb472e1bf36567d9c78c820) Conflicts: sw/qa/extras/layout/layout.cxx Reviewed-on: https://gerrit.libreoffice.org/60658 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de> (cherry picked from commit e850b5a1283485273b91135df15cae7faaac3861) Change-Id: I02ae9f63d0b4b5e9d014df53ed2cf21a04b15090
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/layout/data/tdf119875.odtbin0 -> 7314 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx15
-rw-r--r--sw/source/core/layout/sectfrm.cxx28
3 files changed, 39 insertions, 4 deletions
diff --git a/sw/qa/extras/layout/data/tdf119875.odt b/sw/qa/extras/layout/data/tdf119875.odt
new file mode 100644
index 000000000000..6f579546e312
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf119875.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 8c9740b7e2ae..5dee5c580402 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -23,6 +23,7 @@ public:
void testTdf117923();
void testTdf118058();
void testTdf117188();
+ void testTdf119875();
CPPUNIT_TEST_SUITE(SwLayoutWriter);
CPPUNIT_TEST(testTdf116830);
@@ -31,6 +32,7 @@ public:
CPPUNIT_TEST(testTdf117923);
CPPUNIT_TEST(testTdf118058);
CPPUNIT_TEST(testTdf117188);
+ CPPUNIT_TEST(testTdf119875);
CPPUNIT_TEST_SUITE_END();
private:
@@ -156,6 +158,19 @@ void SwLayoutWriter::testTdf117188()
assertXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds", "height", sHeight);
}
+void SwLayoutWriter::testTdf119875()
+{
+ createDoc("tdf119875.odt");
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+ sal_Int32 nFirstTop
+ = getXPath(pXmlDoc, "/root/page[2]/body/section[1]/infos/bounds", "top").toInt32();
+ sal_Int32 nSecondTop
+ = getXPath(pXmlDoc, "/root/page[2]/body/section[2]/infos/bounds", "top").toInt32();
+ // The first section had the same top value as the second one, so they
+ // overlapped.
+ CPPUNIT_ASSERT_LESS(nSecondTop, nFirstTop);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index 3790c92a199d..f456da19b54d 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -44,6 +44,21 @@
#include <flyfrms.hxx>
#include <sortedobjs.hxx>
+namespace
+{
+/**
+ * Performs the correct type of position invalidation depending on if we're in
+ * CalcContent().
+ */
+void InvalidateFramePos(SwFrame* pFrame, bool bInCalcContent)
+{
+ if (bInCalcContent)
+ pFrame->InvalidatePos_();
+ else
+ pFrame->InvalidatePos();
+}
+}
+
SwSectionFrame::SwSectionFrame( SwSection &rSect, SwFrame* pSib )
: SwLayoutFrame( rSect.GetFormat(), pSib )
, SwFlowFrame( static_cast<SwFrame&>(*this) )
@@ -2121,15 +2136,20 @@ SwTwips SwSectionFrame::Grow_( SwTwips nDist, bool bTst )
}
if( GetNext() )
{
+ // Own height changed, need to invalidate the position of
+ // next frames.
SwFrame *pFrame = GetNext();
while( pFrame && pFrame->IsSctFrame() && !static_cast<SwSectionFrame*>(pFrame)->GetSection() )
+ {
+ // Invalidate all in-between frames, otherwise position
+ // calculation (which only looks back to one relative
+ // frame) will have an incorrect result.
+ InvalidateFramePos(pFrame, bInCalcContent);
pFrame = pFrame->GetNext();
+ }
if( pFrame )
{
- if( bInCalcContent )
- pFrame->InvalidatePos_();
- else
- pFrame->InvalidatePos();
+ InvalidateFramePos(pFrame, bInCalcContent);
}
}
// #i28701# - Due to the new object positioning