summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/core/objectpositioning/data/do-not-capture-draw-objs-on-page-draw-wrap-none.docxbin0 -> 21260 bytes
-rw-r--r--sw/qa/core/objectpositioning/objectpositioning.cxx31
-rw-r--r--sw/source/core/objectpositioning/anchoredobjectposition.cxx4
3 files changed, 33 insertions, 2 deletions
diff --git a/sw/qa/core/objectpositioning/data/do-not-capture-draw-objs-on-page-draw-wrap-none.docx b/sw/qa/core/objectpositioning/data/do-not-capture-draw-objs-on-page-draw-wrap-none.docx
new file mode 100644
index 000000000000..8eea3a7e0df2
--- /dev/null
+++ b/sw/qa/core/objectpositioning/data/do-not-capture-draw-objs-on-page-draw-wrap-none.docx
Binary files differ
diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx b/sw/qa/core/objectpositioning/objectpositioning.cxx
index ba2e225e7d07..e8d9f0d445cc 100644
--- a/sw/qa/core/objectpositioning/objectpositioning.cxx
+++ b/sw/qa/core/objectpositioning/objectpositioning.cxx
@@ -475,6 +475,37 @@ CPPUNIT_TEST_FIXTURE(Test, testDoNotMirrorRtlDrawObjsLayout)
// i.e. the graphic was on the left margin, not on the right margin.
CPPUNIT_ASSERT_GREATER(nBodyRight, aAnchoredCenter.getX());
}
+
+CPPUNIT_TEST_FIXTURE(Test, testDoNotCaptureDrawObjsOnPageDrawWrapNone)
+{
+ // Given a document with a draw object on page 2, wrap type is set to none (not through):
+ createSwDoc("do-not-capture-draw-objs-on-page-draw-wrap-none.docx");
+
+ // When laying out that document:
+ calcLayout();
+
+ // Then make sure the draw object is captured on page 2:
+ SwDoc* pDoc = getSwDoc();
+ SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+ CPPUNIT_ASSERT(pPage1);
+ auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+ CPPUNIT_ASSERT(pPage2);
+ CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+ const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rPage2Objs.size());
+ SwAnchoredObject* pDrawObj = rPage2Objs[0];
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(RES_DRAWFRMFMT),
+ pDrawObj->GetFrameFormat()->Which());
+ SwTwips nDrawObjTop = pDrawObj->GetObjRect().Top();
+ SwTwips nPage2Top = pPage2->getFrameArea().Top();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected greater than: 17383
+ // - Actual : 13518
+ // i.e. the draw object was way above the page 2 rectangle, instead of inside it (apart from
+ // some <1px difference).
+ CPPUNIT_ASSERT_GREATER(nPage2Top - MINFLY, nDrawObjTop);
+}
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index 4af3af542b27..9d61d9cd3054 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -119,12 +119,12 @@ void SwAnchoredObjectPosition::GetInfoAboutObj()
// determine, if anchored object has not to be captured on the page.
// the following conditions must be hold to *not* capture it:
// - corresponding document compatibility flag is set
- // - it's a drawing object or it's a non-textbox wrap-though fly frame
+ // - it's a drawing object or it's a non-textbox fly frame with wrap-though
// - it doesn't follow the text flow
{
bool bTextBox = SwTextBoxHelper::isTextBox(mpFrameFormat, RES_FLYFRMFMT);
bool bWrapThrough = mpFrameFormat->GetSurround().GetSurround() == css::text::WrapTextMode_THROUGH;
- mbDoNotCaptureAnchoredObj = (!mbIsObjFly || (!bTextBox && bWrapThrough)) && !mbFollowTextFlow &&
+ mbDoNotCaptureAnchoredObj = ((!mbIsObjFly || !bTextBox) && bWrapThrough) && !mbFollowTextFlow &&
mpFrameFormat->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE);
}
}