[Libreoffice-commits] core.git: oox/source sw/qa writerfilter/source

Jacobo Aragunde Pérez jaragunde at igalia.com
Thu Nov 14 03:46:47 PST 2013


 oox/source/vml/vmlshape.cxx                   |    3 +++
 sw/qa/extras/ooxmlimport/data/fdo70457.docx   |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx      |   14 ++++++++++++++
 writerfilter/source/dmapper/GraphicImport.cxx |    7 ++++++-
 4 files changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 5c7ede91afaf334cd6faa099ae3f7c1d6cc929c8
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Tue Oct 29 19:10:40 2013 +0100

    fdo#70457: Preserve rotation of embedded bitmaps from docx
    
    When importing bitmaps coming from VML code, we were mistakenly ignoring
    rotation information: we have just added it to the existing XShape object.
    
    In the case of bitmaps expressed in DrawingML, the code was transforming
    them into SwXTextGraphicObjects which don't have rotation information.
    We are now preventing that transformation when rotation value differs from
    zero, leaving the XShape object that was built in the first pass through
    the document.
    
    Added a unit test.
    
    Conflicts:
    	sw/qa/extras/ooxmlimport/ooxmlimport.cxx
    Reviewed on:
    	https://gerrit.libreoffice.org/6484
    
    Change-Id: I40100f8919894e48c005f8ed445bb5cad4f58d8b

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 5346b7d..7b8c9eb 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -695,6 +695,9 @@ Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >
             aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y);
             aPropSet.setProperty(PROP_Opaque, sal_False);
         }
+        // fdo#70457: preserve rotation information
+        if ( !maTypeModel.maRotation.isEmpty() )
+            lcl_SetRotation( aPropSet, maTypeModel.maRotation.toInt32() );
 
         lcl_SetAnchorType(aPropSet, maTypeModel);
     }
diff --git a/sw/qa/extras/ooxmlimport/data/fdo70457.docx b/sw/qa/extras/ooxmlimport/data/fdo70457.docx
new file mode 100644
index 0000000..b9cabb1
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/fdo70457.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 91f49c0..dad6d7d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1512,6 +1512,20 @@ DECLARE_OOXMLIMPORT_TEST(testWpsOnly, "wps-only.docx")
     CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eValue);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testFdo70457, "fdo70457.docx")
+{
+    // The document contains a rotated bitmap
+    // It must be imported as a XShape object with the proper rotation value
+
+    // Check: there is one shape in the doc
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
+
+    // Check: the angle of the shape is 45º
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(4500), getProperty<sal_Int32>(getShape(1), "RotateAngle"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index ff3409c..7e1a42e 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -908,6 +908,9 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
                         OUString sUrl;
                         xShapeProps->getPropertyValue("GraphicURL") >>= sUrl;
 
+                        sal_Int32 nRotation;
+                        xShapeProps->getPropertyValue("RotateAngle") >>= nRotation;
+
                         ::com::sun::star::beans::PropertyValues aMediaProperties( 1 );
                         aMediaProperties[0].Name = "URL";
                         aMediaProperties[0].Value <<= sUrl;
@@ -921,7 +924,9 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
                             xShapeProps->getPropertyValue("ShadowTransparence") >>= m_pImpl->nShadowTransparence;
                         }
 
-                        m_xGraphicObject = createGraphicObject( aMediaProperties );
+                        // fdo#70457: transform XShape into a SwXTextGraphicObject only if there's no rotation
+                        if ( nRotation == 0 )
+                            m_xGraphicObject = createGraphicObject( aMediaProperties );
 
                         bUseShape = !m_xGraphicObject.is( );
 


More information about the Libreoffice-commits mailing list