[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sw/qa writerfilter/source

Bakos Attila (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 20 17:00:07 UTC 2019


 sw/qa/extras/ooxmlexport/data/tdf87569_drawingml.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf87569_vml.docx       |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx            |   20 ++++++++++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx          |   15 +++++++++++++
 writerfilter/source/dmapper/GraphicImport.cxx         |    9 ++++++++
 5 files changed, 44 insertions(+)

New commits:
commit b83d394a16a9a93b314f20ea8fb2ccbb99d9d07f
Author:     Bakos Attila <bakos.attilakaroly at nisz.hu>
AuthorDate: Sat Dec 14 12:36:13 2019 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Dec 20 17:59:14 2019 +0100

    tdf#87569 tdf#109411 DOCX import: fix shape anchor in tables
    
    Import "relative from page" horizontal setting of
    VML and DrawingML shapes as "relative from column"
    in tables, just as MSO handles it.
    
    Change-Id: If71f2e52bbba324a98651e701feaeb99acfefc48
    Reviewed-on: https://gerrit.libreoffice.org/85141
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Reviewed-on: https://gerrit.libreoffice.org/85572

diff --git a/sw/qa/extras/ooxmlexport/data/tdf87569_drawingml.docx b/sw/qa/extras/ooxmlexport/data/tdf87569_drawingml.docx
new file mode 100644
index 000000000000..7f00a46e2cc6
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf87569_drawingml.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf87569_vml.docx b/sw/qa/extras/ooxmlexport/data/tdf87569_vml.docx
new file mode 100644
index 000000000000..0223ad71d4e2
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf87569_vml.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 1c4d89028fbd..2271aa413dd6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -15,6 +15,7 @@
 #include <editsh.hxx>
 #include <frmatr.hxx>
 #include <com/sun/star/text/TableColumnSeparator.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
 
 class Test : public SwModelTestBase
 {
@@ -31,6 +32,25 @@ protected:
     }
 };
 
+DECLARE_OOXMLEXPORT_TEST(testTdf87569v, "tdf87569_vml.docx")
+{
+    //the original tdf87569 sample has vml shapes...
+    uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), uno::UNO_QUERY);
+    sal_Int16 nValue;
+    xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("tdf87569_vml: The Shape is not in the table!",
+                                 text::RelOrientation::FRAME, nValue);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf87569d, "tdf87569_drawingml.docx")
+{
+    //if the original tdf87569 sample is upgraded it will have drawingml shapes...
+    uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), uno::UNO_QUERY);
+    sal_Int16 nValue;
+    xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("tdf87569_drawingml: The Shape is not in the table!",
+                                 text::RelOrientation::FRAME, nValue);
+}
 
 DECLARE_OOXMLEXPORT_TEST(testTdf120315, "tdf120315.docx")
 {
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 16d42193ac6a..5417b6a05e0b 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3035,6 +3035,21 @@ void DomainMapper::lcl_startShape(uno::Reference<drawing::XShape> const& xShape)
         m_pImpl->PushPendingShape(xShape);
 
     m_pImpl->SetIsFirstParagraphInShape(true);
+
+    //tdf#87569: Fix table layout with correcting anchoring
+    //If anchored object is in table, Word calculates its position from cell border
+    //instead of page (what is set in the sample document)
+    if (m_pImpl->m_nTableDepth > 0) //if we had a table
+    {
+        uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY);
+        sal_Int16 nCurrentHorOriRel; //A temp variable for storaging the current setting
+        xShapePropSet->getPropertyValue("HoriOrientRelation") >>= nCurrentHorOriRel;
+        //and the correction:
+        if (nCurrentHorOriRel == text::RelOrientation::PAGE_FRAME)
+            xShapePropSet->setPropertyValue("HoriOrientRelation",
+                                            uno::makeAny(text::RelOrientation::FRAME));
+    }
+
 }
 
 void DomainMapper::lcl_endShape( )
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 33275d9f0d55..da2b9ce04ef4 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -860,6 +860,15 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
                             if (nRotation)
                                 xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(nRotation));
                         }
+
+                        //tdf#109411 If anchored object is in table, Word calculates its position from cell border
+                        //instead of page (what is set in the sample document)
+                        if (m_pImpl->rDomainMapper.IsInTable() &&
+                            m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME && IsGraphic())
+                        {
+                            m_pImpl->nHoriRelation = text::RelOrientation::FRAME;
+                        }
+
                         m_pImpl->applyRelativePosition(xShapeProps, /*bRelativeOnly=*/true);
 
                         xShapeProps->setPropertyValue("SurroundContour", uno::makeAny(m_pImpl->bContour));


More information about the Libreoffice-commits mailing list