[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jan 23 21:23:29 UTC 2020
sw/qa/extras/layout/data/writer-image-no-capture.docx |binary
sw/qa/extras/layout/layout.cxx | 15 ++++++++++++
sw/source/core/objectpositioning/anchoredobjectposition.cxx | 6 +++-
3 files changed, 19 insertions(+), 2 deletions(-)
New commits:
commit 195eae4852012eed6da72c0a9f55094a09aa2867
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jan 23 18:05:26 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jan 23 22:22:56 2020 +0100
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 at collabora.com>
Tested-by: Jenkins
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
Binary files /dev/null and b/sw/qa/extras/layout/data/writer-image-no-capture.docx 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);
}
}
More information about the Libreoffice-commits
mailing list