diff options
-rw-r--r-- | sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt | bin | 0 -> 14133 bytes | |||
-rw-r--r-- | sw/qa/core/objectpositioning/objectpositioning.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/inc/frame.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/findfrm.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx | 5 |
5 files changed, 40 insertions, 1 deletions
diff --git a/sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt b/sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt Binary files differnew file mode 100644 index 000000000000..b10f0b7188fa --- /dev/null +++ b/sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx b/sw/qa/core/objectpositioning/objectpositioning.cxx index 4958b8b6deb4..611ce1294c22 100644 --- a/sw/qa/core/objectpositioning/objectpositioning.cxx +++ b/sw/qa/core/objectpositioning/objectpositioning.cxx @@ -313,6 +313,30 @@ CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testFloatingTableOverlapNever) CPPUNIT_ASSERT_GREATER(pFlyFrame1->getFrameArea().Bottom(), pFlyFrame2->getFrameArea().Top()); } +CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testFloatingTableVertOrientTop) +{ + // Given a document with a vert-orient=from-top anchored floating table: + createSwDoc("floattable-vert-orient-top.odt"); + + // When laying out that document: + calcLayout(); + + // Then make sure we correctly split the table to two pages: + // Without the accompanying fix in place, this test would have produced a layout loop. + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage1); + CPPUNIT_ASSERT(pPage1->GetSortedObjs()); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage1Objs.size()); + auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage2); + CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage2Objs.size()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index d405da36515b..d57654f6a9e7 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -874,6 +874,8 @@ public: inline bool IsTextFrame() const; SwTextFrame* DynCastTextFrame(); const SwTextFrame* DynCastTextFrame() const; + SwPageFrame* DynCastPageFrame(); + const SwPageFrame* DynCastPageFrame() const; inline bool IsNoTextFrame() const; // Frames where its PrtArea depends on their neighbors and that are // positioned in the content flow diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx index 1a98f6cf6747..5331baacd93e 100644 --- a/sw/source/core/layout/findfrm.cxx +++ b/sw/source/core/layout/findfrm.cxx @@ -1944,4 +1944,14 @@ const SwTextFrame* SwFrame::DynCastTextFrame() const return IsTextFrame() ? static_cast<const SwTextFrame*>(this) : nullptr; } +SwPageFrame* SwFrame::DynCastPageFrame() +{ + return IsPageFrame() ? static_cast<SwPageFrame*>(this) : nullptr; +} + +const SwPageFrame* SwFrame::DynCastPageFrame() const +{ + return IsPageFrame() ? static_cast<const SwPageFrame*>(this) : nullptr; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx index 33168ceba432..561c16fd8115 100644 --- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx @@ -422,7 +422,10 @@ void SwToContentAnchoredObjectPosition::CalcPosition() // the frame, the object is oriented at. // #i28701# - correction: adjust relative position, // only if the floating screen object has to follow the text flow. - if ( DoesObjFollowsTextFlow() && pOrientFrame != &rAnchorTextFrame ) + // Also don't do this for split flys: pOrientFrame already points to the follow anchor, + // so pOrientFrame is not the anchor text frame anymore, and that would lead to an + // additional, unwanted increase of nRelPosY. + if (DoesObjFollowsTextFlow() && pOrientFrame != &rAnchorTextFrame && !bFollowSplitFly) { // #i11860# - use new method <GetTopForObjPos> // to get top of frame for object positioning. |