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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Mon May 31 08:07:52 UTC 2021


 writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx          |   21 ++++++++++
 writerfilter/qa/cppunittests/dmapper/data/textbox-textline.docx |binary
 writerfilter/source/dmapper/GraphicImport.cxx                   |    7 +++
 3 files changed, 28 insertions(+)

New commits:
commit 10843ca47ea495d39f32fa30b83d4da9153ee053
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jan 18 20:51:26 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon May 31 10:07:20 2021 +0200

    tdf#135153 DOCX import: avoid line-of-text relation with to-para anchoring
    
    Regression from commit 8f1a1092d47947847e1d888b0284e8364c663d1f
    (tdf#97371 DOCX import: fix text covered by shape, 2016-01-28), the
    problem was that once the import decides that a shape should have no
    to-char anchoring, it should not leave behind vertical relation types
    which make no sense for to-para anchoring.
    
    text::RelOrientation::TEXT_LINE is specific to to-char anchoring, so
    reset the relation back to the default text::RelOrientation::FRAME.
    
    This means we'll no longer show "from top" on the UI while the doc model
    contains "from bottom": and those have to be in sync, otherwise pressing
    "down" while the shape is selected will actually move it up.
    
    (cherry picked from commit 3303a4c5f21874453e634d84408c50e7a0055a4d)
    
    Conflicts:
            writerfilter/source/dmapper/GraphicImport.cxx
    
    Change-Id: I660a7bb30133ea866cc4ba1620ae15fea243ef8f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116230
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
index 37e462012c66..bc0271fa13a4 100644
--- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
@@ -171,6 +171,27 @@ CPPUNIT_TEST_FIXTURE(Test, testWrapPolyCrop)
     // were wrapping around the image, not only 2 as Word does it.
     CPPUNIT_ASSERT_EQUAL(2368., aPolygon.getB2DPoint(0).getY());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testTextboxTextline)
+{
+    // Load a document with a shape with a textbox.
+    // The shape's vertical relation is <wp:positionV relativeFrom="line">.
+    OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "textbox-textline.docx";
+    getComponent() = loadFromDesktop(aURL);
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+    uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+    sal_Int16 nActual{};
+    CPPUNIT_ASSERT(xShape->getPropertyValue("VertOrientRelation") >>= nActual);
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 0 (text::RelOrientation::FRAME)
+    // - Actual  : 9 (text::RelOrientation::TEXT_LINE)
+    // i.e. the relation had a value which doesn't make sense for to-para anchoring (only for
+    // to-char anchoring).
+    sal_Int16 nExpected = text::RelOrientation::FRAME;
+    CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/qa/cppunittests/dmapper/data/textbox-textline.docx b/writerfilter/qa/cppunittests/dmapper/data/textbox-textline.docx
new file mode 100644
index 000000000000..493604d778e9
Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/textbox-textline.docx differ
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index f8a2482d39ef..ae98dadfc004 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -841,6 +841,13 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
 
                         xShapeProps->setPropertyValue("AnchorType", uno::makeAny(eAnchorType));
 
+                        if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE && bTextBox)
+                        {
+                            // TEXT_LINE to specific to to-char anchoring, we have to-para, so reset
+                            // to default.
+                            m_pImpl->nVertRelation = text::RelOrientation::FRAME;
+                        }
+
                         //only the position orientation is handled in applyPosition()
                         m_pImpl->applyPosition(xShapeProps);
 


More information about the Libreoffice-commits mailing list