[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sw/qa xmloff/source

Michael Stahl mstahl at redhat.com
Fri Feb 10 09:44:07 UTC 2017


 sw/qa/extras/odfexport/data/tdf103567.odt  |binary
 sw/qa/extras/odfexport/odfexport.cxx       |   37 +++++++++++++++++++++++++++++
 xmloff/source/text/XMLTextFrameContext.cxx |   29 ++++++++++++++++++++++
 3 files changed, 66 insertions(+)

New commits:
commit 38c82af5368c7dfb134305cb402b1ce9e1a7cc7f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Feb 9 11:12:26 2017 +0100

    tdf#103567 xmloff: ODF import: fix more lossage on Writer frames
    
    There's another context that reads draw:frame, and it has the same
    problem as the one used for Impress shapes.  This causes SVG images
    in Writer to lose contour polygons and image maps.
    
    Fix this the same way as the other context.
    
    (likely regression from 44cfc7cb6533d827fd2d6e586d92c61d7d7f7a70)
    
    Change-Id: I16cf55e68829b4e1b0841f2015d0729be0ce3725
    (cherry picked from commit ae00898f12b9087e1d9b59d9a7820d64b5501775)
    Reviewed-on: https://gerrit.libreoffice.org/34088
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/odfexport/data/tdf103567.odt b/sw/qa/extras/odfexport/data/tdf103567.odt
new file mode 100644
index 0000000..cbd29bd
Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf103567.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 3d805ba..8c82740 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -15,6 +15,7 @@
 #include <com/sun/star/awt/Gradient.hpp>
 #include <com/sun/star/container/XIndexReplace.hpp>
 #include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/PointSequenceSequence.hpp>
 #include <com/sun/star/table/ShadowFormat.hpp>
 #include <com/sun/star/table/XCellRange.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
@@ -107,6 +108,42 @@ DECLARE_ODFEXPORT_TEST(testMathObjectFlatExport, "2_MathType3.docx")
     CPPUNIT_ASSERT_EQUAL(OUString(" size 12{2+2=4} {}"), formula2);
 }
 
+DECLARE_ODFEXPORT_TEST(testTdf103567, "tdf103567.odt")
+{
+    uno::Reference<drawing::XShape> const xShape(getShape(1));
+
+    // contour wrap polygon
+    css::drawing::PointSequenceSequence const pointss(
+        getProperty<css::drawing::PointSequenceSequence>(xShape, "ContourPolyPolygon"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pointss.getLength());
+    // for some reason this property exists with 199 points if it wasn't
+    // imported, that would be a fail
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(5), pointss[0].getLength());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(   0), pointss[0][0].X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][0].Y);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(   0), pointss[0][1].X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1111), pointss[0][1].Y);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][2].X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1111), pointss[0][2].Y);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][3].X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][3].Y);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(   0), pointss[0][4].X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2672), pointss[0][4].Y);
+
+    // image map, one rectangle
+    uno::Reference<container::XIndexContainer> const xImageMap(
+        getProperty<uno::Reference<container::XIndexContainer>>(xShape, "ImageMap"));
+
+    uno::Reference<beans::XPropertySet> const xEntry(xImageMap->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), getProperty<OUString>(xEntry, "URL"));
+    awt::Rectangle const rect(getProperty<awt::Rectangle>(xEntry, "Boundary"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32( 726), rect.X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1718), rect.Y);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1347), rect.Width);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32( 408), rect.Height);
+}
+
+
 DECLARE_ODFEXPORT_TEST(testFramebackgrounds, "framebackgrounds.odt")
 {
    //Counting the Number of Frames and checking with the expected count
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index d0cc7c1..8dd43dd 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -1575,6 +1575,10 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext(
             {
                 if( IsXMLToken( rLocalName, XML_TITLE ) )
                 {
+                    if (getSupportsMultipleContents())
+                    {   // tdf#103567 ensure props are set on surviving shape
+                        m_xImplContext = solveMultipleImages();
+                    }
                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
                                                                         p_nPrefix,
                                                                         rLocalName,
@@ -1582,6 +1586,10 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext(
                 }
                 else if ( IsXMLToken( rLocalName, XML_DESC ) )
                 {
+                    if (getSupportsMultipleContents())
+                    {   // tdf#103567 ensure props are set on surviving shape
+                        m_xImplContext = solveMultipleImages();
+                    }
                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
                                                                         p_nPrefix,
                                                                         rLocalName,
@@ -1594,24 +1602,40 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext(
             Reference < XPropertySet > xPropSet;
             if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) )
             {
+                if (getSupportsMultipleContents())
+                {   // tdf#103567 ensure props are set on surviving shape
+                    m_xImplContext = solveMultipleImages();
+                }
                 if( CreateIfNotThere( xPropSet ) )
                     pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
                                                   xAttrList, xPropSet, false );
             }
             else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) )
             {
+                if (getSupportsMultipleContents())
+                {   // tdf#103567 ensure props are set on surviving shape
+                    m_xImplContext = solveMultipleImages();
+                }
                 if( CreateIfNotThere( xPropSet ) )
                     pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
                                                   xAttrList, xPropSet, true );
             }
             else if( IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
             {
+                if (getSupportsMultipleContents())
+                {   // tdf#103567 ensure props are set on surviving shape
+                    m_xImplContext = solveMultipleImages();
+                }
                 if( CreateIfNotThere( xPropSet ) )
                     pContext = new XMLImageMapContext( GetImport(), p_nPrefix, rLocalName, xPropSet );
             }
         }
         else if( (XML_NAMESPACE_OFFICE == p_nPrefix) && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
         {
+            if (getSupportsMultipleContents())
+            {   // tdf#103567 ensure props are set on surviving shape
+                m_xImplContext = solveMultipleImages();
+            }
             // do we still have the frame object?
             Reference < XPropertySet > xPropSet;
             if( CreateIfNotThere( xPropSet ) )
@@ -1630,6 +1654,11 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext(
     else if( p_nPrefix == XML_NAMESPACE_SVG &&  // #i68101#
                 (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
     {
+        if (getSupportsMultipleContents())
+        {   // tdf#103567 ensure props are set on surviving shape
+            // note: no more draw:image can be added once we get here
+            m_xImplContext = solveMultipleImages();
+        }
         pContext = m_xImplContext->CreateChildContext( p_nPrefix, rLocalName, xAttrList );
     }
     else


More information about the Libreoffice-commits mailing list