summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-01-23 18:05:26 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-01-23 22:22:56 +0100
commit195eae4852012eed6da72c0a9f55094a09aa2867 (patch)
treea843ed390fe1dc4994c405126226ccd8f49a1696 /sw
parent2a0aba855b09b45297091098bfa9e1d1bcdb055c (diff)
sw DoNotCaptureDrawObjsOnPage: don't capture wrap-through Writer images, either
This compat flag was originally added in commit 7961b14c4f9f00696b241e5ad9bf9ba18041fe22 (INTEGRATION: CWS swdrawobjpos203 (1.12.54); FILE MERGED, 2006-03-22) for compatibility with OOo 1.x. Later commit af313fc149f80adb0f1680ca20e19745ccb7fede (tdf#105143 DOCX import: enable DoNotCaptureDrawObjsOnPage layout compat option, 2017-01-06) also turned it on for DOCX documents. One overlooked difference was that the compat flag disables "capturing" of draw objects only, but not wrap-through Writer images. The DOCX case wants the same for wrap-through Writer images as well, since Word does no capturing in either case. Fix the problem by disabling capturing for wrap-through Writer images as well; if this turns out to be too problematic, we can have a dedicated compat flag just for OOo 1.x documents, but that comes at some cost as well. (Need to write the new compat flag to each & every new ODT.) TextBoxes are handled separately (see testTDF91260 in CppunitTest_sw_ooxmlexport8), so leave their handling unchanged. Change-Id: I74f434ed7518d7784c7cba085deb6ff8baf1770a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87289 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/layout/data/writer-image-no-capture.docxbin0 -> 14531 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx15
-rw-r--r--sw/source/core/objectpositioning/anchoredobjectposition.cxx6
3 files changed, 19 insertions, 2 deletions
diff --git a/sw/qa/extras/layout/data/writer-image-no-capture.docx b/sw/qa/extras/layout/data/writer-image-no-capture.docx
new file mode 100644
index 000000000000..ebb1f669f4a7
--- /dev/null
+++ b/sw/qa/extras/layout/data/writer-image-no-capture.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index f1ed1785532e..862f4a30eb41 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3608,6 +3608,21 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf121658)
assertXPath(pXmlDoc, "//Special[@nType='PortionType::Hyphen']", 2);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testWriterImageNoCapture)
+{
+ createDoc("writer-image-no-capture.docx");
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+ CPPUNIT_ASSERT(pXmlDoc);
+ sal_Int32 nPageLeft = getXPath(pXmlDoc, "//page/infos/bounds", "left").toInt32();
+ sal_Int32 nImageLeft = getXPath(pXmlDoc, "//fly/infos/bounds", "left").toInt32();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected less than: 284
+ // - Actual : 284
+ // i.e. the image position was modified to be inside the page frame ("captured"), even if Word
+ // does not do that.
+ CPPUNIT_ASSERT_LESS(nPageLeft, nImageLeft);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index 6a9e02a499bf..48a0e27c881c 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -117,10 +117,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
+ // - it's a drawing object or it's a non-textbox wrap-though fly frame
// - it doesn't follow the text flow
{
- mbDoNotCaptureAnchoredObj = !mbIsObjFly && !mbFollowTextFlow &&
+ bool bTextBox = SwTextBoxHelper::isTextBox(mpFrameFormat, RES_FLYFRMFMT);
+ bool bWrapThrough = mpFrameFormat->GetSurround().GetSurround() == css::text::WrapTextMode_THROUGH;
+ mbDoNotCaptureAnchoredObj = (!mbIsObjFly || (!bTextBox && bWrapThrough)) && !mbFollowTextFlow &&
mpFrameFormat->getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE);
}
}