[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 24 10:31:46 UTC 2020


 sw/qa/extras/layout/data/writer-image-no-capture.docx       |binary
 sw/qa/extras/layout/layout.cxx                              |   17 ++++++++++++
 sw/source/core/objectpositioning/anchoredobjectposition.cxx |    6 ++--
 3 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit 77dc17ee6b718e311250a190d4f5d529a2e9e5e4
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jan 23 18:05:26 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jan 24 11:31:17 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.
    
    (cherry picked from commit 195eae4852012eed6da72c0a9f55094a09aa2867)
    
    Conflicts:
            sw/qa/extras/layout/layout.cxx
    
    Change-Id: I74f434ed7518d7784c7cba085deb6ff8baf1770a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87327
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

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 0070fd86dd15..d0e45b7e066b 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -80,6 +80,7 @@ public:
     void testTdf123651();
     void testBtlrCell();
     void testImageComment();
+    void testWriterImageNoCapture();
 
     CPPUNIT_TEST_SUITE(SwLayoutWriter);
     CPPUNIT_TEST(testRedlineFootnotes);
@@ -123,6 +124,7 @@ public:
     CPPUNIT_TEST(testTdf123651);
     CPPUNIT_TEST(testBtlrCell);
     CPPUNIT_TEST(testImageComment);
+    CPPUNIT_TEST(testWriterImageNoCapture);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2958,6 +2960,21 @@ void SwLayoutWriter::testImageComment()
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5), aPosition.nContent.GetIndex());
 }
 
+void 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_TEST_SUITE_REGISTRATION(SwLayoutWriter);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index 00fa9abfc13b..f5274c051008 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -118,10 +118,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