From 361bad18d8ab8df1fe852d60d97ca8ce976d1de4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 20 Dec 2013 10:23:56 +0100 Subject: oox: import textframe shadow from drawingml CppunitTest_sw_ooxmlexport's testTextFrameBorders is a reproducer for this problem. Change-Id: I5e164c6c151caca62e5b4464e7ed3708f59ada82 --- oox/source/drawingml/shape.cxx | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'oox') diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index a28b1b4c1b1e..1406567184f3 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -642,6 +643,56 @@ Reference< XShape > Shape::createAndInsert( } aShapeProps.erase(PROP_LineColor); } + + // TextFrames have ShadowFormat, not individual shadow properties. + boost::optional oShadowDistance; + if (aShapeProps.hasProperty(PROP_ShadowXDistance)) + { + oShadowDistance = aShapeProps[PROP_ShadowXDistance].get(); + aShapeProps.erase(PROP_ShadowXDistance); + } + if (aShapeProps.hasProperty(PROP_ShadowYDistance)) + { + // There is a single 'dist' attribute, so no need to count the avg of x and y. + aShapeProps.erase(PROP_ShadowYDistance); + } + boost::optional oShadowColor; + if (aShapeProps.hasProperty(PROP_ShadowColor)) + { + oShadowColor = aShapeProps[PROP_ShadowColor].get(); + aShapeProps.erase(PROP_ShadowColor); + } + if (aShapeProps.hasProperty(PROP_Shadow)) + aShapeProps.erase(PROP_Shadow); + + if (oShadowDistance || oShadowColor || aEffectProperties.maShadow.moShadowDir.has()) + { + css::table::ShadowFormat aFormat; + if (oShadowColor) + aFormat.Color = *oShadowColor; + if (aEffectProperties.maShadow.moShadowDir.has()) + { + css::table::ShadowLocation nLocation = css::table::ShadowLocation_NONE; + switch (aEffectProperties.maShadow.moShadowDir.get()) + { + case 13500000: + nLocation = css::table::ShadowLocation_TOP_LEFT; + break; + case 18900000: + nLocation = css::table::ShadowLocation_TOP_RIGHT; + break; + case 8100000: + nLocation = css::table::ShadowLocation_BOTTOM_LEFT; + break; + case 2700000: + nLocation = css::table::ShadowLocation_BOTTOM_RIGHT; + break; + } + aFormat.Location = nLocation; + } + aFormat.ShadowWidth = *oShadowDistance; + aShapeProps.setProperty(PROP_ShadowFormat, uno::makeAny(aFormat)); + } } PropertySet( xSet ).setProperties( aShapeProps ); -- cgit