diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-16 11:38:18 +0200 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-16 14:11:23 +0200 |
commit | 73ad72e820ed3de346efa1914432a7f2c6264dde (patch) | |
tree | 9a4bb88d177629f27fb46656ac2b178cb036ca55 | |
parent | be415a0f9a65d44d1042b313141f49c617bedd93 (diff) |
ooxml: Preserve effects on pictures
If a picture contains some 2D (glow, shadow...) or 3D effect
(rotation, extrusion...), we prevent the importer from transforming
it into a XTextContent so the XShape grab bag is not removed and
the effects are preserved using the existing mechanisms. Added a unit
test for this issue, and modified some existing unit tests to match
the new behaviour.
Change-Id: I3b87069ea208604383a592d34d0a4ceb6b0f9fc7
-rw-r--r-- | oox/source/export/shapes.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/picture-effects-preservation.docx | bin | 0 -> 33275 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 53 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 13 |
6 files changed, 78 insertions, 6 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index c9eaa6fa384d..82d2b5e7e793 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -530,6 +530,10 @@ void ShapeExport::WriteGraphicObjectShapePart( Reference< XShape > xShape, const WritePresetShape( "rect" ); // graphic object can come with the frame (bnc#654525) WriteOutline( xShapeProps ); + + WriteShapeEffects( xShapeProps ); + WriteShape3DEffects( xShapeProps ); + pFS->endElementNS( mnXmlNamespace, XML_spPr ); pFS->endElementNS( mnXmlNamespace, XML_pic ); diff --git a/sw/qa/extras/ooxmlexport/data/picture-effects-preservation.docx b/sw/qa/extras/ooxmlexport/data/picture-effects-preservation.docx Binary files differnew file mode 100644 index 000000000000..d26def49f943 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/picture-effects-preservation.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 014c3b9d12a2..67ee861dc48d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1079,8 +1079,10 @@ DECLARE_OOXMLEXPORT_TEST(testFdo67737, "fdo67737.docx") DECLARE_OOXMLEXPORT_TEST(testTransparentShadow, "transparent-shadow.docx") { uno::Reference<drawing::XShape> xPicture = getShape(1); - table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xPicture, "ShadowFormat"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x7f808080), aShadow.Color); + sal_Int32 nShadowColor = getProperty<sal_Int32>(xPicture, "ShadowColor"); + sal_Int16 nShadowTransparence = getProperty<sal_Int16>(xPicture, "ShadowTransparence"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x808080), nShadowColor); + CPPUNIT_ASSERT_EQUAL(sal_Int16(50), nShadowTransparence); } DECLARE_OOXMLEXPORT_TEST(testBnc834035, "bnc834035.odt") diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx index 736546a51e46..21eff8e09ac2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx @@ -1285,6 +1285,59 @@ DECLARE_OOXMLEXPORT_TEST(testShape3DEffectPreservation, "shape-3d-effect-preserv "prstMaterial", "legacyWireframe"); } +DECLARE_OOXMLEXPORT_TEST(testPictureEffectPreservation, "picture-effects-preservation.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + // first picture: glow effect with theme color and transformations, 3d rotation and extrusion + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:glow", + "rad", "228600"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:glow/a:schemeClr", + "val", "accent1"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:glow/a:schemeClr/*", + 2); + + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:scene3d/a:camera", + "prst", "isometricRightUp"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:scene3d/a:lightRig", + "rig", "threePt"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:sp3d", + "extrusionH", "76200"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:sp3d/a:extrusionClr/a:srgbClr", + "val", "92d050"); + + // second picture: shadow and reflection effects + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:outerShdw", + "dir", "8100000"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:outerShdw/a:srgbClr", + "val", "000000"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:outerShdw/a:srgbClr/a:alpha", + "val", "40000"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:reflection", + "dir", "5400000"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:reflection/*", + 0 ); // should not be present + + // third picture: soft edge effect + assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:softEdge", + "rad", "63500"); +} + DECLARE_OOXMLEXPORT_TEST(fdo77719, "fdo77719.docx") { xmlDocPtr pXmlDoc = parseExport("word/document.xml"); diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 3ffe132a90bd..5c08d7a72f70 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -828,9 +828,11 @@ DECLARE_OOXMLIMPORT_TEST(testShadow, "imgshadow.docx") */ uno::Reference<beans::XPropertySet> xPropertySet(getShape(2), uno::UNO_QUERY); - table::ShadowFormat aShadow; - xPropertySet->getPropertyValue("ShadowFormat") >>= aShadow; - CPPUNIT_ASSERT(sal_Int32(aShadow.ShadowWidth) > 0); + bool bShadow = getProperty<bool>(xPropertySet, "Shadow"); + CPPUNIT_ASSERT(bShadow); + + sal_Int32 nShadowXDistance = getProperty<sal_Int32>(xPropertySet, "ShadowXDistance"); + CPPUNIT_ASSERT(nShadowXDistance != 0); } DECLARE_OOXMLIMPORT_TEST(testN782061, "n782061.docx") diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 10c7029acd60..59f27fc5cd6e 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -643,6 +643,17 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) sal_Int32 nRotation = 0; xShapeProps->getPropertyValue("RotateAngle") >>= nRotation; + ::css::beans::PropertyValues aGrabBag; + bool bContainsEffects = false; + xShapeProps->getPropertyValue("InteropGrabBag") >>= aGrabBag; + for( sal_Int32 i = 0; i < aGrabBag.getLength(); ++i ) + { + // if the shape contains effects in the grab bag, we should not transform it + // in a XTextContent so those effects can be preserved + if( aGrabBag[i].Name == "EffectProperties" || aGrabBag[i].Name == "3DEffectProperties" ) + bContainsEffects = true; + } + ::com::sun::star::beans::PropertyValues aMediaProperties( 1 ); aMediaProperties[0].Name = "URL"; aMediaProperties[0].Value <<= sUrl; @@ -661,7 +672,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) xShapeProps->getPropertyValue("AdjustContrast") >>= m_pImpl->nContrast; // fdo#70457: transform XShape into a SwXTextGraphicObject only if there's no rotation - if ( nRotation == 0 ) + if ( nRotation == 0 && !bContainsEffects ) m_xGraphicObject = createGraphicObject( aMediaProperties ); bUseShape = !m_xGraphicObject.is( ); |