summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorEilidh McAdam <eilidh@lanedo.com>2012-09-26 12:22:17 +0100
committerNoel Power <noel.power@suse.com>2012-09-26 19:32:15 +0000
commitf0efecfb69b336e064e7c8dd2597655eff07944f (patch)
tree1b8902ba6d3e063dd6d3b78c0ddc45810f1e6bec /oox/source
parent0cd97e8c33c49a6c44d26ba309493dbfec00eb8d (diff)
Import shadow effect properties for shapes in docx.
Change-Id: I0cfd6b45be268d688b7389c79c5e9ad7f48eb12d Reviewed-on: https://gerrit.libreoffice.org/702 Reviewed-by: Noel Power <noel.power@suse.com> Tested-by: Noel Power <noel.power@suse.com>
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/drawingml/effectproperties.cxx59
-rw-r--r--oox/source/drawingml/effectpropertiescontext.cxx56
-rw-r--r--oox/source/drawingml/shape.cxx9
-rw-r--r--oox/source/drawingml/shapepropertiescontext.cxx2
-rw-r--r--oox/source/token/properties.txt5
5 files changed, 131 insertions, 0 deletions
diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx
new file mode 100644
index 000000000000..799169bf0f54
--- /dev/null
+++ b/oox/source/drawingml/effectproperties.cxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-baosic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "oox/drawingml/effectproperties.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/drawingml/shapepropertymap.hxx"
+#include "oox/helper/graphichelper.hxx"
+#include "oox/token/tokens.hxx"
+
+#include <basegfx/numeric/ftools.hxx>
+
+namespace oox {
+namespace drawingml {
+
+// ============================================================================
+
+void EffectShadowProperties::assignUsed(const EffectShadowProperties& rSourceProps)
+{
+ moShadowDist.assignIfUsed( rSourceProps.moShadowDist );
+ moShadowDir.assignIfUsed( rSourceProps.moShadowDir );
+ moShadowColor.assignIfUsed( rSourceProps.moShadowColor );
+}
+
+void EffectProperties::assignUsed( const EffectProperties& rSourceProps )
+{
+ maShadow.assignUsed(rSourceProps.maShadow);
+}
+
+void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
+ const GraphicHelper& rGraphicHelper ) const
+{
+ if (maShadow.moShadowDist.has())
+ {
+ // Negative X or Y dist indicates left or up, respectively
+ double nAngle = (maShadow.moShadowDir.get(0) / PER_DEGREE) * F_PI180;
+ sal_Int32 nDist = convertEmuToHmm(maShadow.moShadowDist.get(0));
+ sal_Int32 nXDist = cos(nAngle) * nDist;
+ sal_Int32 nYDist = sin(nAngle) * nDist;
+
+ rPropMap.setProperty( PROP_Shadow, sal_True );
+ rPropMap.setProperty( PROP_ShadowXDistance, nXDist);
+ rPropMap.setProperty( PROP_ShadowYDistance, nYDist);
+ rPropMap.setProperty( PROP_ShadowColor, maShadow.moShadowColor.getColor(rGraphicHelper, -1 ) );
+ rPropMap.setProperty( PROP_ShadowTransparence, maShadow.moShadowColor.getTransparency());
+ }
+}
+
+// ============================================================================
+
+} // namespace drawingml
+} // namespace oox
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/effectpropertiescontext.cxx b/oox/source/drawingml/effectpropertiescontext.cxx
new file mode 100644
index 000000000000..700f225de5b7
--- /dev/null
+++ b/oox/source/drawingml/effectpropertiescontext.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "oox/drawingml/effectpropertiescontext.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
+#include "oox/drawingml/effectproperties.hxx"
+#include "oox/helper/attributelist.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+// CT_EffectProperties
+
+namespace oox { namespace drawingml {
+// ---------------------------------------------------------------------
+
+EffectPropertiesContext::EffectPropertiesContext( ContextHandler& rParent,
+ EffectProperties& rEffectProperties ) throw()
+: ContextHandler( rParent )
+, mrEffectProperties( rEffectProperties )
+{
+}
+
+EffectPropertiesContext::~EffectPropertiesContext()
+{
+}
+
+Reference< XFastContextHandler > EffectPropertiesContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ AttributeList aAttribs( xAttribs );
+ switch( nElement )
+ {
+ case A_TOKEN( outerShdw ):
+ {
+ mrEffectProperties.maShadow.moShadowDist = aAttribs.getInteger( XML_dist, 0 );
+ mrEffectProperties.maShadow.moShadowDir = aAttribs.getInteger( XML_dir, 0 );
+ return new ColorContext( *this, mrEffectProperties.maShadow.moShadowColor );
+ }
+ break;
+ }
+
+ return 0;
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 6d2ff4c72518..a9f006287d52 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -22,6 +22,7 @@
#include "oox/drawingml/theme.hxx"
#include "oox/drawingml/fillproperties.hxx"
#include "oox/drawingml/lineproperties.hxx"
+#include "oox/drawingml/effectproperties.hxx"
#include "oox/drawingml/shapepropertymap.hxx"
#include "oox/drawingml/textbody.hxx"
#include "oox/drawingml/table/tableproperties.hxx"
@@ -73,6 +74,7 @@ Shape::Shape( const sal_Char* pServiceName )
, mpFillPropertiesPtr( new FillProperties )
, mpGraphicPropertiesPtr( new GraphicProperties )
, mpCustomShapePropertiesPtr( new CustomShapeProperties )
+, mpEffectPropertiesPtr( new EffectProperties )
, mpMasterTextListStyle( new TextListStyle )
, mnSubType( 0 )
, meFrameType( FRAMETYPE_GENERIC )
@@ -97,6 +99,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
, mpCustomShapePropertiesPtr( pSourceShape->mpCustomShapePropertiesPtr )
, mpTablePropertiesPtr( pSourceShape->mpTablePropertiesPtr )
, mp3DPropertiesPtr( pSourceShape->mp3DPropertiesPtr )
+, mpEffectPropertiesPtr (pSourceShape->mpEffectPropertiesPtr)
, maShapeProperties( pSourceShape->maShapeProperties )
, mpMasterTextListStyle( pSourceShape->mpMasterTextListStyle )
, mxShape()
@@ -234,6 +237,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
mpFillPropertiesPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) );
mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) );
mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : NULL );
+ mpEffectPropertiesPtr = EffectPropertiesPtr( new EffectProperties( *rReferencedShape.mpEffectPropertiesPtr.get() ) );
mpMasterTextListStyle = TextListStylePtr( new TextListStyle( *rReferencedShape.mpMasterTextListStyle.get() ) );
maShapeStyleRefs = rReferencedShape.maShapeStyleRefs;
maSize = rReferencedShape.maSize;
@@ -486,6 +490,7 @@ Reference< XShape > Shape::createAndInsert(
FillProperties aFillProperties;
aFillProperties.moFillType = XML_noFill;
sal_Int32 nFillPhClr = -1;
+ EffectProperties aEffectProperties;
if( pTheme )
{
@@ -511,6 +516,7 @@ Reference< XShape > Shape::createAndInsert(
aLineProperties.assignUsed( getLineProperties() );
aFillProperties.assignUsed( getFillProperties() );
+ aEffectProperties.assignUsed ( getEffectProperties() );
ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() );
@@ -530,6 +536,7 @@ Reference< XShape > Shape::createAndInsert(
mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr );
aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
+ aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper );
// applying autogrowheight property before setting shape size, because
// the shape size might be changed if currently autogrowheight is true
@@ -542,7 +549,9 @@ Reference< XShape > Shape::createAndInsert(
// do not set properties at a group shape (this causes assertions from svx)
if( aServiceName != "com.sun.star.drawing.GroupShape" )
+ {
PropertySet( xSet ).setProperties( aShapeProps );
+ }
if( bIsCustomShape )
{
diff --git a/oox/source/drawingml/shapepropertiescontext.cxx b/oox/source/drawingml/shapepropertiescontext.cxx
index 437b177883f1..24416c7bdbb7 100644
--- a/oox/source/drawingml/shapepropertiescontext.cxx
+++ b/oox/source/drawingml/shapepropertiescontext.cxx
@@ -30,6 +30,7 @@
#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
#include "oox/drawingml/transform2dcontext.hxx"
#include "oox/drawingml/customshapegeometry.hxx"
+#include "oox/drawingml/effectpropertiescontext.hxx"
using rtl::OUString;
using namespace oox::core;
@@ -102,6 +103,7 @@ Reference< XFastContextHandler > ShapePropertiesContext::createFastChildContext(
// todo not supported by core
case A_TOKEN( effectLst ): // CT_EffectList
case A_TOKEN( effectDag ): // CT_EffectContainer
+ xRet.set( new EffectPropertiesContext( *this, mrShape.getEffectProperties() ) );
break;
// todo
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 59673370a52e..3fed5300c428 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -406,6 +406,11 @@ ScrollWidth
Segments
SelectedItems
SelectedPage
+Shadow
+ShadowColor
+ShadowTransparence
+ShadowXDistance
+ShadowYDistance
Show
ShowBorder
ShowCharts