diff options
author | martinb214 <bakosmartin@gmail.com> | 2017-12-06 20:58:45 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-12-23 02:57:55 +0100 |
commit | 7f42b0f96a2798ae99aa65b84b0db3b2af2b282b (patch) | |
tree | c4df9708b0c871636c16d9f877ca3c450c3f80a9 | |
parent | a692cdf779dc998f58ebf9e9f84f22edf7dbe421 (diff) |
tdf#111790: Shadow imported from a PPTX file is not overriden
by the settings while saving back to PPTX
Change-Id: I958f1987d0123bcf89ef37b13807f407781f3c15
Reviewed-on: https://gerrit.libreoffice.org/45989
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r-- | oox/source/export/drawingml.cxx | 83 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 6 |
2 files changed, 74 insertions, 15 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 17fc99acbc7f..f0f9bee96125 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -3181,18 +3181,36 @@ void DrawingML::WriteShapeEffect( const OUString& sName, const Sequence< Propert } } +sal_Int32 lcl_CalculateDist(const double dX, const double dY) +{ + return static_cast< sal_Int32 >(sqrt(dX*dX + dY*dY) * 360); +} + +sal_Int32 lcl_CalculateDir(const double dX, const double dY) +{ + return (static_cast< sal_Int32 >(atan2(dY,dX) * 180 * 60000 / M_PI) + 21600000) % 21600000; +} + void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) { if( !GetProperty( rXPropSet, "InteropGrabBag" ) ) return; - Sequence< PropertyValue > aGrabBag, aEffects; + Sequence< PropertyValue > aGrabBag, aEffects, aOuterShdwProps; mAny >>= aGrabBag; for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i ) { if( aGrabBag[i].Name == "EffectProperties" ) { aGrabBag[i].Value >>= aEffects; + for( sal_Int32 j=0; j < aEffects.getLength(); ++j ) + { + if( aEffects[j].Name == "outerShdw" ) + { + aEffects[j].Value >>= aOuterShdwProps; + break; + } + } break; } } @@ -3210,9 +3228,9 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) rXPropSet->getPropertyValue( "ShadowYDistance" ) >>= dY; aShadowAttribsGrabBag[0].Name = "dist"; - aShadowAttribsGrabBag[0].Value <<= static_cast< sal_Int32 >(sqrt(dX*dX + dY*dY) * 360); + aShadowAttribsGrabBag[0].Value <<= lcl_CalculateDist(dX, dY); aShadowAttribsGrabBag[1].Name = "dir"; - aShadowAttribsGrabBag[1].Value <<= (static_cast< sal_Int32 >(atan2(dY,dX) * 180 * 60000 / M_PI) + 21600000) % 21600000; + aShadowAttribsGrabBag[1].Value <<= lcl_CalculateDir(dX, dY);; aShadowGrabBag[0].Name = "Attribs"; aShadowGrabBag[0].Value <<= aShadowAttribsGrabBag; @@ -3225,19 +3243,60 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) WriteShapeEffect( "outerShdw", aShadowGrabBag ); mpFS->endElementNS(XML_a, XML_effectLst); } - return; } + else + { + for( sal_Int32 i=0; i < aOuterShdwProps.getLength(); ++i ) + { + if( aOuterShdwProps[i].Name == "Attribs" ) + { + Sequence< PropertyValue > aAttribsProps; + aOuterShdwProps[i].Value >>= aAttribsProps; - mpFS->startElementNS(XML_a, XML_effectLst, FSEND); + double dX = +0.0, dY = +0.0; + rXPropSet->getPropertyValue( "ShadowXDistance" ) >>= dX; + rXPropSet->getPropertyValue( "ShadowYDistance" ) >>= dY; - for( sal_Int32 i=0; i < aEffects.getLength(); ++i ) - { - Sequence< PropertyValue > aEffectProps; - aEffects[i].Value >>= aEffectProps; - WriteShapeEffect( aEffects[i].Name, aEffectProps ); - } + for( sal_Int32 j=0; j < aAttribsProps.getLength(); ++j ) + { + if( aAttribsProps[j].Name == "dist" ) + { + aAttribsProps[j].Value <<= lcl_CalculateDist(dX, dY); + } + else if( aAttribsProps[j].Name == "dir" ) + { + aAttribsProps[j].Value <<= lcl_CalculateDir(dX, dY); + } + } - mpFS->endElementNS(XML_a, XML_effectLst); + aOuterShdwProps[i].Value <<= aAttribsProps; + } + else if( aOuterShdwProps[i].Name == "RgbClr" ) + { + aOuterShdwProps[i].Value = rXPropSet->getPropertyValue( "ShadowColor" ); + } + else if( aOuterShdwProps[i].Name == "RgbClrTransparency" ) + { + aOuterShdwProps[i].Value = rXPropSet->getPropertyValue( "ShadowTransparence" ); + } + } + + mpFS->startElementNS(XML_a, XML_effectLst, FSEND); + for( sal_Int32 i=0; i < aEffects.getLength(); ++i ) + { + if( aEffects[i].Name == "outerShdw" ) + { + WriteShapeEffect( aEffects[i].Name, aOuterShdwProps ); + } + else + { + Sequence< PropertyValue > aEffectProps; + aEffects[i].Value >>= aEffectProps; + WriteShapeEffect( aEffects[i].Name, aEffectProps ); + } + } + mpFS->endElementNS(XML_a, XML_effectLst); + } } void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet ) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 4240f7530f7c..3e8a6e0fe333 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -170,7 +170,7 @@ DECLARE_OOXMLEXPORT_TEST(testShapeEffectPreservation, "shape-effect-preservation "dir", "2700000"); assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw", - "dist", "38100"); + "dist", "37674"); assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw", "rotWithShape", "0"); @@ -193,7 +193,7 @@ DECLARE_OOXMLEXPORT_TEST(testShapeEffectPreservation, "shape-effect-preservation "dir", "2700000"); assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw", - "dist", "203200"); + "dist", "203137"); assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw", "rotWithShape", "0"); @@ -440,7 +440,7 @@ DECLARE_OOXMLEXPORT_TEST(testPictureEffectPreservation, "picture-effects-preserv // 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"); + "dir", "8076614"); 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"); |