diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2013-10-29 19:10:40 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-14 12:46:21 +0100 |
commit | 5c7ede91afaf334cd6faa099ae3f7c1d6cc929c8 (patch) | |
tree | f9ea43b037b41eefb701dd41bfd82b3b395fb79e | |
parent | 8e0aec74cadcc7ad0fe38d52f542c6a6643308ae (diff) |
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
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 3 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/fdo70457.docx | bin | 0 -> 20296 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 14 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 7 |
4 files changed, 23 insertions, 1 deletions
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 5346b7db4c98..7b8c9eb66195 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 Binary files differnew file mode 100644 index 000000000000..b9cabb11902c --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/fdo70457.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 91f49c0ecddf..dad6d7d32841 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 ff3409c80145..7e1a42ecdf6f 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( ); |