[Libreoffice-commits] .: 3 commits - oox/inc oox/source sw/CppunitTest_sw_subsequent_ooxmlimport.mk sw/qa

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 29 00:24:51 PDT 2012


 oox/inc/oox/vml/vmlshape.hxx                |   10 ++++
 oox/source/vml/vmlshape.cxx                 |   70 +++++++++++++++++-----------
 sw/CppunitTest_sw_subsequent_ooxmlimport.mk |    1 
 sw/qa/extras/ooxmlimport/data/n777345.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx    |   20 ++++++++
 5 files changed, 74 insertions(+), 27 deletions(-)

New commits:
commit dcc140204a65d3e7075b0e67ac3ffa0a5737d4ea
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Aug 29 09:25:53 2012 +0100

    n#777345 testcase
    
    Change-Id: I4dce0dfaf6f1c94024dd60df51d70a259689d6d9

diff --git a/sw/CppunitTest_sw_subsequent_ooxmlimport.mk b/sw/CppunitTest_sw_subsequent_ooxmlimport.mk
index 6dbf787..c06de2a 100644
--- a/sw/CppunitTest_sw_subsequent_ooxmlimport.mk
+++ b/sw/CppunitTest_sw_subsequent_ooxmlimport.mk
@@ -66,6 +66,7 @@ $(eval $(call gb_CppunitTest_use_ure,sw_subsequent_ooxmlimport))
 $(eval $(call gb_CppunitTest_use_components,sw_subsequent_ooxmlimport,\
     comphelper/util/comphelp \
     configmgr/source/configmgr \
+    embeddedobj/util/embobj \
     fileaccess/source/fileacc \
     filter/source/config/cache/filterconfig1 \
     framework/util/fwk \
diff --git a/sw/qa/extras/ooxmlimport/data/n777345.docx b/sw/qa/extras/ooxmlimport/data/n777345.docx
new file mode 100644
index 0000000..dc62588
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n777345.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index e61f123..f5c3661 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -30,6 +30,7 @@
 
 #include <com/sun/star/awt/XBitmap.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
@@ -86,9 +87,11 @@ public:
     void testAllGapsWord();
     void testN775906();
     void testN775899();
+    void testN777345();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
+#if 0
     CPPUNIT_TEST(testN751054);
     CPPUNIT_TEST(testN751117);
     CPPUNIT_TEST(testN751017);
@@ -116,6 +119,8 @@ public:
     CPPUNIT_TEST(testN775906);
     CPPUNIT_TEST(testN775899);
 #endif
+    CPPUNIT_TEST(testN777345);
+#endif
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -765,6 +770,21 @@ void Test::testN775899()
     CPPUNIT_ASSERT_EQUAL(sal_False, xParaEnum->hasMoreElements());
 }
 
+void Test::testN777345()
+{
+    // The problem was that v:imagedata inside v:rect was ignored.
+    load("n777345.docx");
+
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    uno::Reference<document::XEmbeddedObjectSupplier2> xSupplier(xDraws->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<graphic::XGraphic> xGraphic = xSupplier->getReplacementGraphic();
+    Graphic aGraphic(xGraphic);
+    // If this changes later, feel free to update it, but make sure it's not
+    // the checksum of a white/transparent placeholder rectangle.
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(2404338915), aGraphic.GetChecksum());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 7fe05dc95d0c9a584e07483c04b13c071d55293f
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Aug 29 09:25:40 2012 +0100

    add SimpleShape::createPictureObject to avoid code duplication
    
    Change-Id: Id4bb0550ab2ce9bbb7edf568a086be18c1576b33

diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx
index 728ca15..8fab5f7 100644
--- a/oox/inc/oox/vml/vmlshape.hxx
+++ b/oox/inc/oox/vml/vmlshape.hxx
@@ -272,6 +272,10 @@ protected:
                         implConvertAndInsert(
                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
+    /** Used by both RectangleShape and ComplexShape. */
+    com::sun::star::uno::Reference<com::sun::star::drawing::XShape>createPictureObject(
+            const com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rxShapes,
+            const com::sun::star::awt::Rectangle& rShapeRect, OUString& rGraphicPath ) const;
 
 private:
     ::rtl::OUString     maService;          ///< Name of the UNO shape service.
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 5c8e728..a32030b 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -447,6 +447,36 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
     return xShape;
 }
 
+Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect, OUString& rGraphicPath ) const
+{
+    Reference< XShape > xShape = mrDrawing.createAndInsertXShape( "com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect );
+    if( xShape.is() )
+    {
+        XmlFilterBase& rFilter = mrDrawing.getFilter();
+        OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( rGraphicPath );
+        PropertySet aPropSet( xShape );
+        if( !aGraphicUrl.isEmpty() )
+        {
+            aPropSet.setProperty( PROP_GraphicURL, aGraphicUrl );
+        }
+        // If the shape has an absolute position, set the properties accordingly.
+        if ( maTypeModel.maPosition == "absolute" )
+        {
+            aPropSet.setProperty(PROP_HoriOrientPosition, rShapeRect.X);
+            aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y);
+            aPropSet.setProperty(PROP_Opaque, sal_False);
+        }
+
+        lcl_SetAnchorType(aPropSet, maTypeModel);
+
+        if ( maTypeModel.maPositionVerticalRelative == "page" )
+        {
+            aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME);
+        }
+    }
+    return xShape;
+}
+
 // ============================================================================
 
 RectangleShape::RectangleShape( Drawing& rDrawing ) :
@@ -456,21 +486,11 @@ RectangleShape::RectangleShape( Drawing& rDrawing ) :
 
 Reference<XShape> RectangleShape::implConvertAndInsert(const Reference<XShapes>& rxShapes, const Rectangle& rShapeRect) const
 {
-    XmlFilterBase& rFilter = mrDrawing.getFilter();
     OUString aGraphicPath = getGraphicPath();
 
     // try to create a picture object
     if(!aGraphicPath.isEmpty())
-    {
-        Reference<XShape> xShape = mrDrawing.createAndInsertXShape("com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect);
-        if (xShape.is())
-        {
-            OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject(aGraphicPath);
-            PropertySet aPropSet(xShape);
-            aPropSet.setProperty(PROP_GraphicURL, aGraphicUrl);
-        }
-        return xShape;
-    }
+        return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath);
 
     // default: try to create a rectangle shape
     return SimpleShape::implConvertAndInsert(rxShapes, rShapeRect);
@@ -632,33 +652,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
 
     // try to create a picture object
     if( !aGraphicPath.isEmpty() )
-    {
-        Reference< XShape > xShape = mrDrawing.createAndInsertXShape( CREATE_OUSTRING( "com.sun.star.drawing.GraphicObjectShape" ), rxShapes, rShapeRect );
-        if( xShape.is() )
-        {
-            OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( aGraphicPath );
-            PropertySet aPropSet( xShape );
-            if( !aGraphicUrl.isEmpty() )
-            {
-                aPropSet.setProperty( PROP_GraphicURL, aGraphicUrl );
-            }
-            // If the shape has an absolute position, set the properties accordingly.
-            if ( maTypeModel.maPosition == "absolute" )
-            {
-                aPropSet.setProperty(PROP_HoriOrientPosition, rShapeRect.X);
-                aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y);
-                aPropSet.setProperty(PROP_Opaque, sal_False);
-            }
-
-            lcl_SetAnchorType(aPropSet, maTypeModel);
-
-            if ( maTypeModel.maPositionVerticalRelative == "page" )
-            {
-                aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME);
-            }
-        }
-        return xShape;
-    }
+        return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath);
 
     // default: try to create a custom shape
     return CustomShape::implConvertAndInsert( rxShapes, rShapeRect );
commit 9f6dd9a4cff12460d09a31a065feaf8fece1eb4b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Aug 29 09:25:21 2012 +0100

    n#777345 import imagedata of v:rect elements inside OLE objects
    
    Change-Id: I300bb5d3008b839f6ec63a4435f5ce8c1dd0a2c1

diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx
index b0c00b3..728ca15 100644
--- a/oox/inc/oox/vml/vmlshape.hxx
+++ b/oox/inc/oox/vml/vmlshape.hxx
@@ -284,6 +284,12 @@ class RectangleShape : public SimpleShape
 {
 public:
     explicit            RectangleShape( Drawing& rDrawing );
+protected:
+    /** Creates the corresponding XShape and inserts it into the passed container. */
+    virtual com::sun::star::uno::Reference<com::sun::star::drawing::XShape>
+                        implConvertAndInsert(
+                            const com::sun::star::uno::Reference<com::sun::star::drawing::XShapes>& rxShapes,
+                            const com::sun::star::awt::Rectangle& rShapeRect) const;
 };
 
 // ============================================================================
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 64c0ed7..5c8e728 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -454,6 +454,28 @@ RectangleShape::RectangleShape( Drawing& rDrawing ) :
 {
 }
 
+Reference<XShape> RectangleShape::implConvertAndInsert(const Reference<XShapes>& rxShapes, const Rectangle& rShapeRect) const
+{
+    XmlFilterBase& rFilter = mrDrawing.getFilter();
+    OUString aGraphicPath = getGraphicPath();
+
+    // try to create a picture object
+    if(!aGraphicPath.isEmpty())
+    {
+        Reference<XShape> xShape = mrDrawing.createAndInsertXShape("com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect);
+        if (xShape.is())
+        {
+            OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject(aGraphicPath);
+            PropertySet aPropSet(xShape);
+            aPropSet.setProperty(PROP_GraphicURL, aGraphicUrl);
+        }
+        return xShape;
+    }
+
+    // default: try to create a rectangle shape
+    return SimpleShape::implConvertAndInsert(rxShapes, rShapeRect);
+}
+
 // ============================================================================
 
 EllipseShape::EllipseShape( Drawing& rDrawing ) :


More information about the Libreoffice-commits mailing list