diff options
author | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2011-01-11 13:26:59 +0100 |
---|---|---|
committer | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2011-01-11 13:26:59 +0100 |
commit | d4c7fa84b7856918328bee20a5387cb32442bec3 (patch) | |
tree | 1907f51856829aa9f40bdd94f02a89fe2fc9f036 | |
parent | f9a2b2913692fa1d65200f53c90e77b0bd134445 (diff) |
dr78: oox - encapsulate shape property handling in own class ShapePropertyMap
28 files changed, 649 insertions, 582 deletions
diff --git a/oox/inc/oox/drawingml/color.hxx b/oox/inc/oox/drawingml/color.hxx index 51e9501205cf..ae5b82022f59 100644 --- a/oox/inc/oox/drawingml/color.hxx +++ b/oox/inc/oox/drawingml/color.hxx @@ -92,10 +92,10 @@ public: @param nPhClr Actual color for the phClr placeholder color used in theme style lists. */ sal_Int32 getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; - /** Returns true, if the color has a transparence set. */ - bool hasTransparence() const; - /** Returns the transparence of the color (0 = opaque, 100 = full transparent). */ - sal_Int16 getTransparence() const; + /** Returns true, if the color is transparent. */ + bool hasTransparency() const; + /** Returns the transparency of the color (0 = opaque, 100 = full transparent). */ + sal_Int16 getTransparency() const; private: /** Internal helper for getColor(). */ diff --git a/oox/inc/oox/drawingml/drawingmltypes.hxx b/oox/inc/oox/drawingml/drawingmltypes.hxx index 3ceb0e82838a..f0b66de6c273 100644 --- a/oox/inc/oox/drawingml/drawingmltypes.hxx +++ b/oox/inc/oox/drawingml/drawingmltypes.hxx @@ -167,6 +167,7 @@ inline sal_Int32 convertEmuToHmm( sal_Int64 nValue ) // ============================================================================ +/** A structure for a point with 64-bit interger components. */ struct EmuPoint { sal_Int64 X; @@ -178,6 +179,7 @@ struct EmuPoint // ============================================================================ +/** A structure for a size with 64-bit interger components. */ struct EmuSize { sal_Int64 Width; @@ -189,6 +191,7 @@ struct EmuSize // ============================================================================ +/** A structure for a rectangle with 64-bit interger components. */ struct EmuRectangle : public EmuPoint, public EmuSize { inline explicit EmuRectangle() {} diff --git a/oox/inc/oox/drawingml/fillproperties.hxx b/oox/inc/oox/drawingml/fillproperties.hxx index d62651ebdc20..9f0271e418e8 100644 --- a/oox/inc/oox/drawingml/fillproperties.hxx +++ b/oox/inc/oox/drawingml/fillproperties.hxx @@ -36,7 +36,6 @@ namespace oox { class GraphicHelper; - class ModelObjectHelper; class PropertyMap; class PropertySet; } @@ -44,38 +43,7 @@ namespace oox { namespace oox { namespace drawingml { -// ============================================================================ - -enum FillPropertyId -{ - FillStyleId, - FillColorId, - FillTransparenceId, - FillGradientId, - FillBitmapUrlId, - FillBitmapModeId, - FillBitmapSizeXId, - FillBitmapSizeYId, - FillBitmapOffsetXId, - FillBitmapOffsetYId, - FillBitmapRectanglePointId, - FillId_END -}; - -struct FillPropertyIds -{ - const sal_Int32* mpnPropertyIds; - bool mbNamedFillGradient; - bool mbNamedFillBitmap; - - explicit FillPropertyIds( - const sal_Int32* pnPropertyIds, - bool bNamedFillGradient, - bool bNamedFillBitmap ); - - inline bool has( FillPropertyId ePropId ) const { return mpnPropertyIds[ ePropId ] >= 0; } - inline sal_Int32 operator[]( FillPropertyId ePropId ) const { return mpnPropertyIds[ ePropId ]; } -}; +class ShapePropertyMap; // ============================================================================ @@ -147,8 +115,6 @@ struct FillProperties PatternFillProperties maPatternProps; /// Properties for pattern fills. BlipFillProperties maBlipProps; /// Properties for bitmap fills. - static FillPropertyIds DEFAULT_IDS; /// Default fill property identifiers for shape fill. - /** Overwrites all members that are explicitly set in rSourceProps. */ void assignUsed( const FillProperties& rSourceProps ); @@ -158,19 +124,8 @@ struct FillProperties /** Writes the properties to the passed property map. */ void pushToPropMap( - PropertyMap& rPropMap, - ModelObjectHelper& rModelObjHelper, + ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, - const FillPropertyIds& rPropIds = DEFAULT_IDS, - sal_Int32 nShapeRotation = 0, - sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; - - /** Writes the properties to the passed property set. */ - void pushToPropSet( - PropertySet& rPropSet, - ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, - const FillPropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nShapeRotation = 0, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; @@ -189,12 +144,6 @@ struct GraphicProperties PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; - - /** Writes the properties to the passed property set. */ - void pushToPropSet( - PropertySet& rPropSet, - const GraphicHelper& rGraphicHelper, - sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; // ============================================================================ diff --git a/oox/inc/oox/drawingml/lineproperties.hxx b/oox/inc/oox/drawingml/lineproperties.hxx index 0f034a89f65b..2ddb21d2fb93 100644 --- a/oox/inc/oox/drawingml/lineproperties.hxx +++ b/oox/inc/oox/drawingml/lineproperties.hxx @@ -35,40 +35,6 @@ namespace drawingml { // ============================================================================ -enum LinePropertyId -{ - LineStyleId, - LineWidthId, - LineColorId, - LineTransparenceId, - LineDashId, - LineJointId, - LineStartId, - LineStartWidthId, - LineStartCenterId, - LineEndId, - LineEndWidthId, - LineEndCenterId, - LineId_END -}; - -struct LinePropertyIds -{ - const sal_Int32* mpnPropertyIds; - bool mbNamedLineDash; - bool mbNamedLineMarker; - - explicit LinePropertyIds( - const sal_Int32* pnPropertyIds, - bool bNamedLineDash, - bool bNamedLineMarker ); - - inline bool has( LinePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ] >= 0; } - inline sal_Int32 operator[]( LinePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ]; } -}; - -// ============================================================================ - struct LineArrowProperties { OptValue< sal_Int32 > moArrowType; @@ -96,25 +62,13 @@ struct LineProperties OptValue< sal_Int32 > moLineCap; /// Line cap (OOXML token). OptValue< sal_Int32 > moLineJoint; /// Line joint type (OOXML token). - static LinePropertyIds DEFAULT_IDS; /// Default line property identifiers. - /** Overwrites all members that are explicitly set in rSourceProps. */ void assignUsed( const LineProperties& rSourceProps ); /** Writes the properties to the passed property map. */ void pushToPropMap( - PropertyMap& rPropMap, - ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, - const LinePropertyIds& rPropIds = DEFAULT_IDS, - sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; - - /** Writes the properties to the passed property map. */ - void pushToPropSet( - PropertySet& rPropSet, - ModelObjectHelper& rModelObjHelper, + ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, - const LinePropertyIds& rPropIds = DEFAULT_IDS, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; diff --git a/oox/inc/oox/drawingml/shapepropertymap.hxx b/oox/inc/oox/drawingml/shapepropertymap.hxx new file mode 100755 index 000000000000..e012d4b2a9ac --- /dev/null +++ b/oox/inc/oox/drawingml/shapepropertymap.hxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX +#define OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX + +#include "oox/helper/propertymap.hxx" + +namespace oox { class ModelObjectHelper; } + +namespace oox { +namespace drawingml { + +// ============================================================================ + +/** Enumeration for various properties related to drawing shape formatting. + + This is an abstraction for shape formatting properties that have different + names in various implementations, e.g. drawing shapes vs. chart objects. + */ +enum ShapePropertyId +{ + SHAPEPROP_LineStyle, + SHAPEPROP_LineWidth, + SHAPEPROP_LineColor, + SHAPEPROP_LineTransparency, + SHAPEPROP_LineDash, /// Explicit line dash or name of a line dash stored in a global container. + SHAPEPROP_LineJoint, + SHAPEPROP_LineStart, /// Explicit line start marker or name of a line marker stored in a global container. + SHAPEPROP_LineStartWidth, + SHAPEPROP_LineStartCenter, + SHAPEPROP_LineEnd, /// Explicit line end marker or name of a line marker stored in a global container. + SHAPEPROP_LineEndWidth, + SHAPEPROP_LineEndCenter, + SHAPEPROP_FillStyle, + SHAPEPROP_FillColor, + SHAPEPROP_FillTransparency, + SHAPEPROP_FillGradient, /// Explicit fill gradient or name of a fill gradient stored in a global container. + SHAPEPROP_FillBitmapUrl, /// Explicit fill bitmap URL or name of a fill bitmap URL stored in a global container. + SHAPEPROP_FillBitmapMode, + SHAPEPROP_FillBitmapSizeX, + SHAPEPROP_FillBitmapSizeY, + SHAPEPROP_FillBitmapOffsetX, + SHAPEPROP_FillBitmapOffsetY, + SHAPEPROP_FillBitmapRectanglePoint, + SHAPEPROP_END +}; + +// ============================================================================ + +struct ShapePropertyInfo +{ + const sal_Int32* mpnPropertyIds; /// Pointer to array of property identifiers for all SHAPEPROP properties. + bool mbNamedLineMarker; /// True = use named line marker instead of explicit line marker. + bool mbNamedLineDash; /// True = use named line dash instead of explicit line dash. + bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient. + bool mbNamedFillBitmapUrl; /// True = use named fill bitmap URL instead of explicit fill bitmap URL. + + static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods). + + explicit ShapePropertyInfo( + const sal_Int32* pnPropertyIds, + bool bNamedLineMarker, + bool bNamedLineDash, + bool bNamedFillGradient, + bool bNamedFillBitmapUrl ); + + inline bool has( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ] >= 0; } + inline sal_Int32 operator[]( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ]; } +}; + +// ============================================================================ + +class ShapePropertyMap : public PropertyMap +{ +public: + explicit ShapePropertyMap( + ModelObjectHelper& rModelObjHelper, + const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT ); + + /** Returns true, if the specified property is supported. */ + bool supportsProperty( ShapePropertyId ePropId ) const; + + /** Returns true, if named line markers are supported, and the specified + line marker has already been inserted into the marker table. */ + bool hasNamedLineMarkerInTable( const ::rtl::OUString& rMarkerName ) const; + + /** Sets the specified shape property to the passed value. */ + bool setAnyProperty( ShapePropertyId ePropId, const ::com::sun::star::uno::Any& rValue ); + + /** Sets the specified shape property to the passed value. */ + template< typename Type > + inline bool setProperty( ShapePropertyId ePropId, const Type& rValue ) + { return setAnyProperty( ePropId, ::com::sun::star::uno::Any( rValue ) ); } + + using PropertyMap::setAnyProperty; + using PropertyMap::setProperty; + using PropertyMap::operator[]; + +private: + /** Sets an explicit line marker, or creates a named line marker. */ + bool setLineMarker( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + /** Sets an explicit line dash, or creates a named line dash. */ + bool setLineDash( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + /** Sets an explicit fill gradient, or creates a named fill gradient. */ + bool setFillGradient( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + /** Sets an explicit fill bitmap URL, or creates a named fill bitmap URL. */ + bool setFillBitmapUrl( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + + // not implemented, to prevent implicit conversion from enum to int + ::com::sun::star::uno::Any& operator[]( ShapePropertyId ePropId ); + const ::com::sun::star::uno::Any& operator[]( ShapePropertyId ePropId ) const; + +private: + ModelObjectHelper& mrModelObjHelper; + ShapePropertyInfo maShapePropInfo; +}; + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + +#endif diff --git a/oox/inc/oox/helper/modelobjecthelper.hxx b/oox/inc/oox/helper/modelobjecthelper.hxx index a9ef27e8cb98..6c0d97960894 100644 --- a/oox/inc/oox/helper/modelobjecthelper.hxx +++ b/oox/inc/oox/helper/modelobjecthelper.hxx @@ -45,9 +45,9 @@ namespace oox { /** Contains tables for named drawing objects for a document model. Contains tables for named line markers, line dashes, fill gradients, and - fill bitmaps. The class is needed to handle different document models in - the same filter (e.g. embedded charts) which carry their own drawing object - tables. + fill bitmap URLs. The class is needed to handle different document models + in the same filter (e.g. embedded charts) which carry their own drawing + object tables. */ class ModelObjectHelper { @@ -72,18 +72,18 @@ public: an internal constant name with a new unused index appended. */ ::rtl::OUString insertFillGradient( const ::com::sun::star::awt::Gradient& rGradient ); - /** Inserts a new named fill bitmap, returns the bitmap name, based on an - internal constant name with a new unused index appended. */ - ::rtl::OUString insertFillBitmap( const ::rtl::OUString& rGraphicUrl ); + /** Inserts a new named fill bitmap URL, returns the bitmap name, based on + an internal constant name with a new unused index appended. */ + ::rtl::OUString insertFillBitmapUrl( const ::rtl::OUString& rGraphicUrl ); private: ObjectContainer maMarkerContainer; ObjectContainer maDashContainer; ObjectContainer maGradientContainer; - ObjectContainer maBitmapContainer; + ObjectContainer maBitmapUrlContainer; const ::rtl::OUString maDashNameBase; const ::rtl::OUString maGradientNameBase; - const ::rtl::OUString maBitmapNameBase; + const ::rtl::OUString maBitmapUrlNameBase; }; // ============================================================================ diff --git a/oox/inc/oox/helper/propertymap.hxx b/oox/inc/oox/helper/propertymap.hxx index 150f5c3d9364..7480b8153656 100644 --- a/oox/inc/oox/helper/propertymap.hxx +++ b/oox/inc/oox/helper/propertymap.hxx @@ -58,7 +58,6 @@ class PropertyMap : public PropertyMapBase { public: explicit PropertyMap(); - ~PropertyMap(); /** Returns the name of the passed property identifier. */ static const ::rtl::OUString& getPropertyName( sal_Int32 nPropId ); @@ -72,9 +71,18 @@ public: /** Sets the specified property to the passed value. Does nothing, if the identifier is invalid. */ + inline bool setAnyProperty( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ) + { if( nPropId < 0 ) return false; (*this)[ nPropId ] = rValue; return true; } + + /** Sets the specified property to the passed value. Does nothing, if the + identifier is invalid. */ template< typename Type > - inline void setProperty( sal_Int32 nPropId, const Type& rValue ) - { if( nPropId >= 0 ) (*this)[ nPropId ] <<= rValue; } + inline bool setProperty( sal_Int32 nPropId, const Type& rValue ) + { if( nPropId < 0 ) return false; (*this)[ nPropId ] <<= rValue; return true; } + + /** Inserts all properties contained in the passed property map. */ + inline void assignUsed( const PropertyMap& rPropMap ) + { insert( rPropMap.begin(), rPropMap.end() ); } /** Returns a sequence of property values, filled with all contained properties. */ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > @@ -85,7 +93,7 @@ public: ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues ) const; - /** Creates and fills a new instance supporting the XPropertySet interface. */ + /** Creates a property set supporting the XPropertySet interface and inserts all properties. */ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > makePropertySet() const; diff --git a/oox/inc/oox/helper/propertyset.hxx b/oox/inc/oox/helper/propertyset.hxx index 8ddfaff44421..c3952e9f6723 100644 --- a/oox/inc/oox/helper/propertyset.hxx +++ b/oox/inc/oox/helper/propertyset.hxx @@ -84,21 +84,19 @@ public: // Get properties --------------------------------------------------------- /** Gets the specified property from the property set. - @return true, if the any could be filled with the property value. */ - bool getAnyProperty( ::com::sun::star::uno::Any& orValue, sal_Int32 nPropId ) const; + @return the property value, or an empty Any, if the property is missing. */ + ::com::sun::star::uno::Any getAnyProperty( sal_Int32 nPropId ) const; /** Gets the specified property from the property set. @return true, if the passed variable could be filled with the property value. */ template< typename Type > - inline bool getProperty( Type& orValue, sal_Int32 nPropId ) const; - - /** Gets the specified property from the property set. - @return the property value, or an empty Any, if the property is missing. */ - ::com::sun::star::uno::Any getAnyProperty( sal_Int32 nPropId ) const; + inline bool getProperty( Type& orValue, sal_Int32 nPropId ) const + { return getAnyProperty( nPropId ) >>= orValue; } /** Gets the specified boolean property from the property set. @return true = property contains true; false = property contains false or error occured. */ - bool getBoolProperty( sal_Int32 nPropId ) const; + inline bool getBoolProperty( sal_Int32 nPropId ) const + { bool bValue = false; return getProperty( bValue, nPropId ) && bValue; } /** Gets the specified properties from the property set. Tries to use the XMultiPropertySet interface. @param orValues (out-parameter) The related property values. @@ -110,11 +108,12 @@ public: // Set properties --------------------------------------------------------- /** Puts the passed any into the property set. */ - void setAnyProperty( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); + bool setAnyProperty( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); /** Puts the passed value into the property set. */ template< typename Type > - inline void setProperty( sal_Int32 nPropId, const Type& rValue ); + inline bool setProperty( sal_Int32 nPropId, const Type& rValue ) + { return setAnyProperty( nPropId, ::com::sun::star::uno::Any( rValue ) ); } /** Puts the passed properties into the property set. Tries to use the XMultiPropertySet interface. @param rPropNames The property names. MUST be ordered alphabetically. @@ -135,10 +134,10 @@ public: private: /** Gets the specified property from the property set. @return true, if the any could be filled with the property value. */ - bool getAnyProperty( ::com::sun::star::uno::Any& orValue, const ::rtl::OUString& rPropName ) const; + bool implGetPropertyValue( ::com::sun::star::uno::Any& orValue, const ::rtl::OUString& rPropName ) const; /** Puts the passed any into the property set. */ - void setAnyProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rValue ); + bool implSetPropertyValue( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rValue ); private: ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > @@ -147,21 +146,6 @@ private: mxMultiPropSet; /// The optional multi property set interface. }; -// ---------------------------------------------------------------------------- - -template< typename Type > -inline bool PropertySet::getProperty( Type& orValue, sal_Int32 nPropId ) const -{ - ::com::sun::star::uno::Any aAny; - return getAnyProperty( aAny, nPropId ) && (aAny >>= orValue); -} - -template< typename Type > -inline void PropertySet::setProperty( sal_Int32 nPropId, const Type& rValue ) -{ - setAnyProperty( nPropId, ::com::sun::star::uno::Any( rValue ) ); -} - // ============================================================================ } // namespace oox diff --git a/oox/inc/oox/ppt/slidepersist.hxx b/oox/inc/oox/ppt/slidepersist.hxx index bcb0c5803d61..444d12546f12 100644 --- a/oox/inc/oox/ppt/slidepersist.hxx +++ b/oox/inc/oox/ppt/slidepersist.hxx @@ -91,7 +91,7 @@ public: void setBackgroundProperties( const oox::drawingml::FillPropertiesPtr pFillPropertiesPtr ){ mpBackgroundPropertiesPtr = pFillPropertiesPtr; } oox::drawingml::FillPropertiesPtr getBackgroundProperties() const { return mpBackgroundPropertiesPtr; } - oox::drawingml::Color& getBackgroundColorRef() { return maBackgroundColorRef; } + oox::drawingml::Color& getBackgroundColor() { return maBackgroundColor; } sal_Bool isMasterPage() const { return mbMaster; } sal_Bool isNotesPage() const { return mbNotes; } @@ -131,7 +131,7 @@ private: SlidePersistPtr mpMasterPagePtr; oox::drawingml::ShapePtr maShapesPtr; - oox::drawingml::Color maBackgroundColorRef; + oox::drawingml::Color maBackgroundColor; oox::drawingml::FillPropertiesPtr mpBackgroundPropertiesPtr; ::std::list< boost::shared_ptr< TimeNode > > maTimeNodeList; diff --git a/oox/inc/oox/vml/vmlformatting.hxx b/oox/inc/oox/vml/vmlformatting.hxx index 76242fca3418..7bf4135b3f81 100644 --- a/oox/inc/oox/vml/vmlformatting.hxx +++ b/oox/inc/oox/vml/vmlformatting.hxx @@ -30,11 +30,8 @@ #include "oox/helper/helper.hxx" -namespace oox { - class GraphicHelper; - class ModelObjectHelper; - class PropertyMap; -} +namespace oox { class GraphicHelper; } +namespace oox { namespace drawingml { class ShapePropertyMap; } } namespace oox { namespace vml { @@ -149,8 +146,7 @@ struct StrokeModel /** Writes the properties to the passed property map. */ void pushToPropMap( - PropertyMap& rPropMap, - ModelObjectHelper& rModelObjectHelper, + ::oox::drawingml::ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper ) const; }; @@ -176,8 +172,7 @@ struct FillModel /** Writes the properties to the passed property map. */ void pushToPropMap( - PropertyMap& rPropMap, - ModelObjectHelper& rModelObjectHelper, + ::oox::drawingml::ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper ) const; }; diff --git a/oox/inc/oox/xls/drawingmanager.hxx b/oox/inc/oox/xls/drawingmanager.hxx index 0e5610d05d24..91fba91ee271 100755 --- a/oox/inc/oox/xls/drawingmanager.hxx +++ b/oox/inc/oox/xls/drawingmanager.hxx @@ -36,6 +36,8 @@ namespace com { namespace sun { namespace star { namespace drawing { class XShapes; } } } } +namespace oox { namespace drawingml { class ShapePropertyMap; } } + namespace oox { namespace xls { @@ -201,11 +203,11 @@ protected: void readMacroBiff8( BiffInputStream& rStrm ); /** Converts the passed line formatting to the passed property map. */ - void convertLineProperties( PropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows = 0 ) const; + void convertLineProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows = 0 ) const; /** Converts the passed fill formatting to the passed property map. */ - void convertFillProperties( PropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const; + void convertFillProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const; /** Converts the passed frame flags to the passed property map. */ - void convertFrameProperties( PropertyMap& rPropMap, sal_uInt16 nFrameFlags ) const; + void convertFrameProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, sal_uInt16 nFrameFlags ) const; /** Derived classes read the contents of the a BIFF3 OBJ record from the passed stream. */ virtual void implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize ); @@ -340,7 +342,7 @@ protected: void readFrameData( BiffInputStream& rStrm ); /** Converts fill formatting, line formatting, and frame style. */ - void convertRectProperties( PropertyMap& rPropMap ) const; + void convertRectProperties( ::oox::drawingml::ShapePropertyMap& rPropMap ) const; /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */ virtual void implReadObjBiff3( BiffInputStream& rStrm, sal_uInt16 nMacroSize ); diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index d96e2d43dd6f..8fd1a376abd6 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -32,14 +32,15 @@ #include <com/sun/star/util/XNumberFormatTypes.hpp> #include "properties.hxx" #include "tokens.hxx" -#include "oox/helper/modelobjecthelper.hxx" #include "oox/core/xmlfilterbase.hxx" #include "oox/drawingml/fillproperties.hxx" #include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/drawingml/textbody.hxx" #include "oox/drawingml/textparagraph.hxx" #include "oox/drawingml/theme.hxx" #include "oox/drawingml/chart/chartspacemodel.hxx" +#include "oox/helper/modelobjecthelper.hxx" using ::rtl::OStringBuffer; using ::rtl::OUString; @@ -494,19 +495,50 @@ const AutoTextEntry* lclGetAutoTextEntry( const AutoTextEntry* pEntries, sal_Int // ---------------------------------------------------------------------------- -/** Enumerates different sets of property names for chart object formatting. */ -enum PropertyType +/** Property identifiers for common chart objects, to be used in ShapePropertyInfo. */ +static const sal_Int32 spnCommonPropIds[] = +{ + PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDashName, + PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, + PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillGradientName, + PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, + PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint +}; + +/** Property identifiers for linear data series, to be used in ShapePropertyInfo. */ +static const sal_Int32 spnLinearPropIds[] = { - PROPERTYTYPE_COMMON, /// Common objects, no special handling. - PROPERTYTYPE_LINEARSERIES, /// Specific to linear data series. - PROPERTYTYPE_FILLEDSERIES /// Specific to filled data series. + PROP_LineStyle, PROP_LineWidth, PROP_Color, PROP_Transparency, PROP_LineDashName, + PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, + PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, + PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, + PROP_INVALID, PROP_INVALID, PROP_INVALID }; +/** Property identifiers for filled data series, to be used in ShapePropertyInfo. */ +static const sal_Int32 spnFilledPropIds[] = +{ + PROP_BorderStyle, PROP_BorderWidth, PROP_BorderColor, PROP_BorderTransparency, PROP_BorderDashName, + PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, + PROP_FillStyle, PROP_Color, PROP_Transparency, PROP_GradientName, + PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, + PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint +}; + +/** Property info for common chart objects, to be used in ShapePropertyMap. */ +static const ShapePropertyInfo saCommonPropInfo( spnCommonPropIds, false, true, true, true ); +/** Property info for linear data series, to be used in ShapePropertyMap. */ +static const ShapePropertyInfo saLinearPropInfo( spnLinearPropIds, false, true, true, true ); +/** Property info for filled data series, to be used in ShapePropertyMap. */ +static const ShapePropertyInfo saFilledPropInfo( spnFilledPropIds, false, true, true, true ); + +// ---------------------------------------------------------------------------- + /** Contains information about formatting of a specific chart object type. */ struct ObjectTypeFormatEntry { ObjectType meObjType; /// Object type for automatic format. - PropertyType mePropType; /// Property type for property names. + const ShapePropertyInfo* mpPropInfo; /// Property info for the ShapePropertyMap class. const AutoFormatEntry* mpAutoLines; /// Automatic line formatting for all chart styles. const AutoFormatEntry* mpAutoFills; /// Automatic fill formatting for all chart styles. const AutoFormatEntry* mpAutoEffects; /// Automatic effect formatting for all chart styles. @@ -522,37 +554,38 @@ struct ObjectTypeFormatEntry static const ObjectTypeFormatEntry spObjTypeFormatEntries[] = { - // object type property type auto text auto line auto fill auto effect - TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE, PROPERTYTYPE_COMMON, 0, spChartSpaceLines, spChartSpaceFills, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE, PROPERTYTYPE_COMMON, spChartTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND, PROPERTYTYPE_COMMON, spOtherTexts, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D, PROPERTYTYPE_COMMON, 0, 0 /* eq to Ch2 */, spPlotArea2dFills, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA3D, PROPERTYTYPE_COMMON, 0, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_WALL, PROPERTYTYPE_COMMON, 0, 0 /* eq to Ch2 */, spWallFloorFills, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_FLOOR, PROPERTYTYPE_COMMON, 0, spFloorLines, spWallFloorFills, 0 /* eq to Ch2 */ ), - TYPEFORMAT_LINE( OBJECTTYPE_AXIS, PROPERTYTYPE_COMMON, spOtherTexts, spAxisLines ), - TYPEFORMAT_FRAME( OBJECTTYPE_AXISTITLE, PROPERTYTYPE_COMMON, spAxisTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_FRAME( OBJECTTYPE_AXISUNIT, PROPERTYTYPE_COMMON, spAxisTitleTexts, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */ ), - TYPEFORMAT_LINE( OBJECTTYPE_MAJORGRIDLINE, PROPERTYTYPE_COMMON, 0, spMajorGridLines ), - TYPEFORMAT_LINE( OBJECTTYPE_MINORGRIDLINE, PROPERTYTYPE_COMMON, 0, spMinorGridLines ), - TYPEFORMAT_LINE( OBJECTTYPE_LINEARSERIES2D, PROPERTYTYPE_LINEARSERIES, 0, spLinearSeriesLines ), - TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES2D, PROPERTYTYPE_FILLEDSERIES, 0, spFilledSeriesLines, spFilledSeries2dFills, spFilledSeriesEffects ), - TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES3D, PROPERTYTYPE_FILLEDSERIES, 0, spFilledSeriesLines, spFilledSeries3dFills, spFilledSeriesEffects ), - TYPEFORMAT_FRAME( OBJECTTYPE_DATALABEL, PROPERTYTYPE_COMMON, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_LINE( OBJECTTYPE_TRENDLINE, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_FRAME( OBJECTTYPE_TRENDLINELABEL, PROPERTYTYPE_COMMON, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), - TYPEFORMAT_LINE( OBJECTTYPE_ERRORBAR, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_LINE( OBJECTTYPE_SERLINE, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_LINE( OBJECTTYPE_LEADERLINE, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_LINE( OBJECTTYPE_DROPLINE, PROPERTYTYPE_COMMON, 0, spOtherLines ), - TYPEFORMAT_LINE( OBJECTTYPE_HILOLINE, PROPERTYTYPE_LINEARSERIES, 0, spOtherLines ), - TYPEFORMAT_FRAME( OBJECTTYPE_UPBAR, PROPERTYTYPE_COMMON, 0, spUpDownBarLines, spUpBarFills, spUpDownBarEffects ), - TYPEFORMAT_FRAME( OBJECTTYPE_DOWNBAR, PROPERTYTYPE_COMMON, 0, spUpDownBarLines, spDownBarFills, spUpDownBarEffects ), - TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE, PROPERTYTYPE_COMMON, spOtherTexts, spChartSpaceLines ) + // object type property info auto text auto line auto fill auto effect + TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE, &saCommonPropInfo, 0, spChartSpaceLines, spChartSpaceFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE, &saCommonPropInfo, spChartTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND, &saCommonPropInfo, spOtherTexts, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D, &saCommonPropInfo, 0, 0 /* eq to Ch2 */, spPlotArea2dFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA3D, &saCommonPropInfo, 0, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_WALL, &saCommonPropInfo, 0, 0 /* eq to Ch2 */, spWallFloorFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_FLOOR, &saCommonPropInfo, 0, spFloorLines, spWallFloorFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_LINE( OBJECTTYPE_AXIS, &saCommonPropInfo, spOtherTexts, spAxisLines ), + TYPEFORMAT_FRAME( OBJECTTYPE_AXISTITLE, &saCommonPropInfo, spAxisTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_AXISUNIT, &saCommonPropInfo, spAxisTitleTexts, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */, 0 /* eq in Ch2 */ ), + TYPEFORMAT_LINE( OBJECTTYPE_MAJORGRIDLINE, &saCommonPropInfo, 0, spMajorGridLines ), + TYPEFORMAT_LINE( OBJECTTYPE_MINORGRIDLINE, &saCommonPropInfo, 0, spMinorGridLines ), + TYPEFORMAT_LINE( OBJECTTYPE_LINEARSERIES2D, &saLinearPropInfo, 0, spLinearSeriesLines ), + TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES2D, &saFilledPropInfo, 0, spFilledSeriesLines, spFilledSeries2dFills, spFilledSeriesEffects ), + TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES3D, &saFilledPropInfo, 0, spFilledSeriesLines, spFilledSeries3dFills, spFilledSeriesEffects ), + TYPEFORMAT_FRAME( OBJECTTYPE_DATALABEL, &saCommonPropInfo, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_LINE( OBJECTTYPE_TRENDLINE, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_FRAME( OBJECTTYPE_TRENDLINELABEL, &saCommonPropInfo, spOtherTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), + TYPEFORMAT_LINE( OBJECTTYPE_ERRORBAR, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_LINE( OBJECTTYPE_SERLINE, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_LINE( OBJECTTYPE_LEADERLINE, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_LINE( OBJECTTYPE_DROPLINE, &saCommonPropInfo, 0, spOtherLines ), + TYPEFORMAT_LINE( OBJECTTYPE_HILOLINE, &saLinearPropInfo, 0, spOtherLines ), + TYPEFORMAT_FRAME( OBJECTTYPE_UPBAR, &saCommonPropInfo, 0, spUpDownBarLines, spUpBarFills, spUpDownBarEffects ), + TYPEFORMAT_FRAME( OBJECTTYPE_DOWNBAR, &saCommonPropInfo, 0, spUpDownBarLines, spDownBarFills, spUpDownBarEffects ), + TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE, &saCommonPropInfo, spOtherTexts, spChartSpaceLines ) }; #undef TYPEFORMAT_FRAME #undef TYPEFORMAT_LINE + // ---------------------------------------------------------------------------- void lclConvertPictureOptions( FillProperties& orFillProps, const PictureOptionsModel& rPicOptions ) @@ -561,15 +594,6 @@ void lclConvertPictureOptions( FillProperties& orFillProps, const PictureOptions orFillProps.maBlipProps.moBitmapMode = bStacked ? XML_tile : XML_stretch; } -// ---------------------------------------------------------------------------- - -const sal_Int32 spnCommonLineIds[ LineId_END ] = { PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDashName, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID }; -const sal_Int32 spnLinearLineIds[ LineId_END ] = { PROP_LineStyle, PROP_LineWidth, PROP_Color, PROP_Transparency, PROP_LineDashName, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID }; -const sal_Int32 spnFilledLineIds[ LineId_END ] = { PROP_BorderStyle, PROP_BorderWidth, PROP_BorderColor, PROP_BorderTransparency, PROP_BorderDashName, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID }; - -const sal_Int32 spnCommonFillIds[ FillId_END ] = { PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillGradientName, PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint }; -const sal_Int32 spnFilledFillIds[ FillId_END ] = { PROP_FillStyle, PROP_Color, PROP_Transparency, PROP_GradientName, PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint }; - } // namespace // ============================================================================ @@ -611,18 +635,16 @@ class LineFormatter : public DetailFormatterBase public: explicit LineFormatter( ObjectFormatterData& rData, - const AutoFormatEntry* pAutoFormatEntry, - PropertyType ePropType ); + const AutoFormatEntry* pAutoFormatEntry ); /** Converts line formatting to the passed property set. */ void convertFormatting( - PropertySet& rPropSet, + ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx ); private: LinePropertiesPtr mxAutoLine; /// Automatic line properties. - LinePropertyIds& mrLinePropIds; /// Property identifiers for border/line formatting. }; // ---------------------------------------------------------------------------- @@ -632,19 +654,17 @@ class FillFormatter : public DetailFormatterBase public: explicit FillFormatter( ObjectFormatterData& rData, - const AutoFormatEntry* pAutoFormatEntry, - PropertyType ePropType ); + const AutoFormatEntry* pAutoFormatEntry ); /** Converts area formatting to the passed property set. */ void convertFormatting( - PropertySet& rPropSet, + ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx ); private: FillPropertiesPtr mxAutoFill; /// Automatic fill properties. - FillPropertyIds& mrFillPropIds; /// Property identifiers for fill formatting. }; // ---------------------------------------------------------------------------- @@ -654,12 +674,11 @@ class EffectFormatter : public DetailFormatterBase public: explicit EffectFormatter( ObjectFormatterData& rData, - const AutoFormatEntry* pAutoFormatEntry, - PropertyType ePropType ); + const AutoFormatEntry* pAutoFormatEntry ); /** Converts effect formatting to the passed property set. */ void convertFormatting( - PropertySet& rPropSet, + ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx ); }; @@ -736,6 +755,7 @@ private: FillFormatter maFillFormatter; /// Converter for fill formatting. EffectFormatter maEffectFormatter; /// Converter for effect formatting. TextFormatter maTextFormatter; /// Converter for text formatting. + ModelObjectHelper& mrModelObjHelper; /// Helper for named drawing formatting. const ObjectTypeFormatEntry& mrEntry; /// Additional settings. }; @@ -748,11 +768,6 @@ struct ObjectFormatterData const XmlFilterBase& mrFilter; /// Base filter object. ObjectTypeFormatterMap maTypeFormatters; /// Formatters for all types of objects in a chart. ModelObjectHelper maModelObjHelper; /// Helper for named drawing formatting (dashes, gradients, bitmaps). - LinePropertyIds maCommonLineIds; /// Property identifiers for common border formatting. - LinePropertyIds maLinearLineIds; /// Property identifiers for line formatting of linear series. - LinePropertyIds maFilledLineIds; /// Property identifiers for line formatting of filled series. - FillPropertyIds maCommonFillIds; /// Property identifiers for common area fill. - FillPropertyIds maFilledFillIds; /// Property identifiers for area fill of filled series. Reference< XNumberFormats > mxNumFmts; /// Number formats collection of container document. Reference< XNumberFormatTypes > mxNumTypes; /// Number format types collection of container document. Locale maEnUsLocale; /// Locale struct containing en-US. @@ -765,9 +780,6 @@ struct ObjectFormatterData const ChartSpaceModel& rChartSpace ); ObjectTypeFormatter* getTypeFormatter( ObjectType eObjType ); - - LinePropertyIds& getLinePropertyIds( PropertyType ePropType ); - FillPropertyIds& getFillPropertyIds( PropertyType ePropType ); }; // ============================================================================ @@ -864,9 +876,8 @@ sal_Int32 DetailFormatterBase::getSchemeColor( sal_Int32 nColorToken, sal_Int32 // ============================================================================ -LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, PropertyType ePropType ) : - DetailFormatterBase( rData, pAutoFormatEntry ), - mrLinePropIds( rData.getLinePropertyIds( ePropType ) ) +LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) : + DetailFormatterBase( rData, pAutoFormatEntry ) { if( pAutoFormatEntry ) { @@ -881,21 +892,20 @@ LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* } } -void LineFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx ) +void LineFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx ) { LineProperties aLineProps; if( mxAutoLine.get() ) aLineProps.assignUsed( *mxAutoLine ); if( rxShapeProp.is() ) aLineProps.assignUsed( rxShapeProp->getLineProperties() ); - aLineProps.pushToPropSet( rPropSet, mrData.maModelObjHelper, mrData.mrFilter.getGraphicHelper(), mrLinePropIds, getPhColor( nSeriesIdx ) ); + aLineProps.pushToPropMap( rPropMap, mrData.mrFilter.getGraphicHelper(), getPhColor( nSeriesIdx ) ); } // ============================================================================ -FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, PropertyType ePropType ) : - DetailFormatterBase( rData, pAutoFormatEntry ), - mrFillPropIds( rData.getFillPropertyIds( ePropType ) ) +FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) : + DetailFormatterBase( rData, pAutoFormatEntry ) { if( pAutoFormatEntry ) { @@ -907,7 +917,7 @@ FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* } } -void FillFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx ) +void FillFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx ) { FillProperties aFillProps; if( mxAutoFill.get() ) @@ -916,17 +926,17 @@ void FillFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Sh aFillProps.assignUsed( rxShapeProp->getFillProperties() ); if( pPicOptions ) lclConvertPictureOptions( aFillProps, *pPicOptions ); - aFillProps.pushToPropSet( rPropSet, mrData.maModelObjHelper, mrData.mrFilter.getGraphicHelper(), mrFillPropIds, 0, getPhColor( nSeriesIdx ) ); + aFillProps.pushToPropMap( rPropMap, mrData.mrFilter.getGraphicHelper(), 0, getPhColor( nSeriesIdx ) ); } // ============================================================================ -EffectFormatter::EffectFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, PropertyType /*ePropType*/ ) : +EffectFormatter::EffectFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) : DetailFormatterBase( rData, pAutoFormatEntry ) { } -void EffectFormatter::convertFormatting( PropertySet& /*rPropSet*/, const ModelRef< Shape >& /*rxShapeProp*/, sal_Int32 /*nSeriesIdx*/ ) +void EffectFormatter::convertFormatting( ShapePropertyMap& /*rPropMap*/, const ModelRef< Shape >& /*rxShapeProp*/, sal_Int32 /*nSeriesIdx*/ ) { } @@ -984,20 +994,23 @@ void TextFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Te // ============================================================================ ObjectTypeFormatter::ObjectTypeFormatter( ObjectFormatterData& rData, const ObjectTypeFormatEntry& rEntry, const ChartSpaceModel& rChartSpace ) : - maLineFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoLines, rChartSpace.mnStyle ), rEntry.mePropType ), - maFillFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoFills, rChartSpace.mnStyle ), rEntry.mePropType ), - maEffectFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoEffects, rChartSpace.mnStyle ), rEntry.mePropType ), + maLineFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoLines, rChartSpace.mnStyle ) ), + maFillFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoFills, rChartSpace.mnStyle ) ), + maEffectFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoEffects, rChartSpace.mnStyle ) ), maTextFormatter( rData, lclGetAutoTextEntry( rEntry.mpAutoTexts, rChartSpace.mnStyle ), rChartSpace.mxTextProp ), + mrModelObjHelper( rData.maModelObjHelper ), mrEntry( rEntry ) { } void ObjectTypeFormatter::convertFrameFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx ) { - maLineFormatter.convertFormatting( rPropSet, rxShapeProp, nSeriesIdx ); + ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo ); + maLineFormatter.convertFormatting( aPropMap, rxShapeProp, nSeriesIdx ); if( mrEntry.mbIsFrame ) - maFillFormatter.convertFormatting( rPropSet, rxShapeProp, pPicOptions, nSeriesIdx ); - maEffectFormatter.convertFormatting( rPropSet, rxShapeProp, nSeriesIdx ); + maFillFormatter.convertFormatting( aPropMap, rxShapeProp, pPicOptions, nSeriesIdx ); + maEffectFormatter.convertFormatting( aPropMap, rxShapeProp, nSeriesIdx ); + rPropSet.setProperties( aPropMap ); } void ObjectTypeFormatter::convertTextFormatting( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp ) @@ -1018,16 +1031,20 @@ void ObjectTypeFormatter::convertTextFormatting( PropertySet& rPropSet, const Te void ObjectTypeFormatter::convertAutomaticLine( PropertySet& rPropSet, sal_Int32 nSeriesIdx ) { + ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo ); ModelRef< Shape > xShapeProp; - maLineFormatter.convertFormatting( rPropSet, xShapeProp, nSeriesIdx ); - maEffectFormatter.convertFormatting( rPropSet, xShapeProp, nSeriesIdx ); + maLineFormatter.convertFormatting( aPropMap, xShapeProp, nSeriesIdx ); + maEffectFormatter.convertFormatting( aPropMap, xShapeProp, nSeriesIdx ); + rPropSet.setProperties( aPropMap ); } void ObjectTypeFormatter::convertAutomaticFill( PropertySet& rPropSet, sal_Int32 nSeriesIdx ) { + ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo ); ModelRef< Shape > xShapeProp; - maFillFormatter.convertFormatting( rPropSet, xShapeProp, 0, nSeriesIdx ); - maEffectFormatter.convertFormatting( rPropSet, xShapeProp, nSeriesIdx ); + maFillFormatter.convertFormatting( aPropMap, xShapeProp, 0, nSeriesIdx ); + maEffectFormatter.convertFormatting( aPropMap, xShapeProp, nSeriesIdx ); + rPropSet.setProperties( aPropMap ); } // ============================================================================ @@ -1035,11 +1052,6 @@ void ObjectTypeFormatter::convertAutomaticFill( PropertySet& rPropSet, sal_Int32 ObjectFormatterData::ObjectFormatterData( const XmlFilterBase& rFilter, const Reference< XChartDocument >& rxChartDoc, const ChartSpaceModel& rChartSpace ) : mrFilter( rFilter ), maModelObjHelper( Reference< XMultiServiceFactory >( rxChartDoc, UNO_QUERY ) ), - maCommonLineIds( spnCommonLineIds, true, false ), - maLinearLineIds( spnLinearLineIds, true, false ), - maFilledLineIds( spnFilledLineIds, true, false ), - maCommonFillIds( spnCommonFillIds, true, true ), - maFilledFillIds( spnFilledFillIds, true, true ), maEnUsLocale( CREATE_OUSTRING( "en" ), CREATE_OUSTRING( "US" ), OUString() ), mnMaxSeriesIdx( -1 ) { @@ -1065,28 +1077,6 @@ ObjectTypeFormatter* ObjectFormatterData::getTypeFormatter( ObjectType eObjType return maTypeFormatters.get( eObjType ).get(); } -LinePropertyIds& ObjectFormatterData::getLinePropertyIds( PropertyType ePropType ) -{ - switch( ePropType ) - { - case PROPERTYTYPE_COMMON: return maCommonLineIds; - case PROPERTYTYPE_LINEARSERIES: return maLinearLineIds; - case PROPERTYTYPE_FILLEDSERIES: return maFilledLineIds; - } - return maCommonLineIds; -} - -FillPropertyIds& ObjectFormatterData::getFillPropertyIds( PropertyType ePropType ) -{ - switch( ePropType ) - { - case PROPERTYTYPE_COMMON: return maCommonFillIds; - case PROPERTYTYPE_LINEARSERIES: return maCommonFillIds; - case PROPERTYTYPE_FILLEDSERIES: return maFilledFillIds; - } - return maCommonFillIds; -} - // ============================================================================ ObjectFormatter::ObjectFormatter( const XmlFilterBase& rFilter, const Reference< XChartDocument >& rxChartDoc, const ChartSpaceModel& rChartSpace ) : @@ -1165,7 +1155,7 @@ void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFo sal_Int32 nPropId = bPercentFormat ? PROP_PercentageNumberFormat : PROP_NumberFormat; if( rNumberFormat.mbSourceLinked || (rNumberFormat.maFormatCode.getLength() == 0) ) { - rPropSet.setProperty( nPropId, Any() ); + rPropSet.setAnyProperty( nPropId, Any() ); } else try { diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index 8653d787517d..ad626b670fae 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -512,12 +512,12 @@ sal_Int32 Color::getColor( const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr return mnC1; } -bool Color::hasTransparence() const +bool Color::hasTransparency() const { return mnAlpha < MAX_PERCENT; } -sal_Int16 Color::getTransparence() const +sal_Int16 Color::getTransparency() const { return static_cast< sal_Int16 >( (MAX_PERCENT - mnAlpha) / PER_PERCENT ); } diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 08d001f09a62..4285286c623d 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -39,10 +39,8 @@ #include "properties.hxx" #include "tokens.hxx" #include "oox/helper/graphichelper.hxx" -#include "oox/helper/modelobjecthelper.hxx" -#include "oox/helper/propertymap.hxx" -#include "oox/helper/propertyset.hxx" #include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/shapepropertymap.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::drawing; @@ -62,21 +60,6 @@ namespace drawingml { namespace { -static const sal_Int32 spnDefaultFillIds[ FillId_END ] = -{ - PROP_FillStyle, - PROP_FillColor, - PROP_FillTransparence, - PROP_FillGradient, - PROP_FillBitmapURL, - PROP_FillBitmapMode, - PROP_FillBitmapSizeX, - PROP_FillBitmapSizeY, - PROP_FillBitmapPositionOffsetX, - PROP_FillBitmapPositionOffsetY, - PROP_FillBitmapRectanglePoint -}; - BitmapMode lclGetBitmapMode( sal_Int32 nToken ) { switch( nToken ) @@ -130,16 +113,6 @@ const awt::Size lclGetOriginalSize( const GraphicHelper& rGraphicHelper, const R // ============================================================================ -FillPropertyIds::FillPropertyIds( const sal_Int32* pnPropertyIds, bool bNamedFillGradient, bool bNamedFillBitmap ) : - mpnPropertyIds( pnPropertyIds ), - mbNamedFillGradient( bNamedFillGradient ), - mbNamedFillBitmap( bNamedFillBitmap ) -{ - OSL_ENSURE( mpnPropertyIds != 0, "FillPropertyIds::FillPropertyIds - missing property identifiers" ); -} - -// ============================================================================ - void GradientFillProperties::assignUsed( const GradientFillProperties& rSourceProps ) { if( !rSourceProps.maGradientStops.empty() ) @@ -186,8 +159,6 @@ void BlipFillProperties::assignUsed( const BlipFillProperties& rSourceProps ) // ============================================================================ -FillPropertyIds FillProperties::DEFAULT_IDS( spnDefaultFillIds, false, false ); - void FillProperties::assignUsed( const FillProperties& rSourceProps ) { moFillType.assignIfUsed( rSourceProps.moFillType ); @@ -216,9 +187,8 @@ Color FillProperties::getBestSolidColor() const return aSolidColor; } -void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds, - sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const +void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const { if( moFillType.has() ) { @@ -232,16 +202,16 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM case XML_solidFill: if( maFillColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ FillColorId ], maFillColor.getColor( rGraphicHelper, nPhClr ) ); - if( maFillColor.hasTransparence() ) - rPropMap.setProperty( rPropIds[ FillTransparenceId ], maFillColor.getTransparence() ); + rPropMap.setProperty( SHAPEPROP_FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) ); + if( maFillColor.hasTransparency() ) + rPropMap.setProperty( SHAPEPROP_FillTransparency, maFillColor.getTransparency() ); eFillStyle = FillStyle_SOLID; } break; case XML_gradFill: // do not create gradient struct if property is not supported... - if( rPropIds.has( FillGradientId ) ) + if( rPropMap.supportsProperty( SHAPEPROP_FillGradient ) ) { awt::Gradient aGradient; aGradient.Angle = 900; @@ -291,62 +261,35 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM aGradient.Angle = static_cast< sal_Int16 >( (4500 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 ); // push gradient or named gradient to property map - if( rPropIds.mbNamedFillGradient ) - { - OUString aGradientName = rModelObjHelper.insertFillGradient( aGradient ); - if( aGradientName.getLength() > 0 ) - { - rPropMap.setProperty( rPropIds[ FillGradientId ], aGradientName ); - eFillStyle = FillStyle_GRADIENT; - } - } - else - { - rPropMap.setProperty( rPropIds[ FillGradientId ], aGradient ); + if( rPropMap.setProperty( SHAPEPROP_FillGradient, aGradient ) ) eFillStyle = FillStyle_GRADIENT; - } } break; case XML_blipFill: // do not start complex graphic transformation if property is not supported... - if( maBlipProps.mxGraphic.is() && rPropIds.has( FillBitmapUrlId ) ) + if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( SHAPEPROP_FillBitmapUrl ) ) { // TODO: "rotate with shape" is not possible with our current core OUString aGraphicUrl = rGraphicHelper.createGraphicObject( maBlipProps.mxGraphic ); - if( aGraphicUrl.getLength() > 0 ) - { - // push bitmap or named bitmap to property map - if( rPropIds.mbNamedFillBitmap ) - { - OUString aBitmapName = rModelObjHelper.insertFillBitmap( aGraphicUrl ); - if( aBitmapName.getLength() > 0 ) - { - rPropMap.setProperty( rPropIds[ FillBitmapUrlId ], aBitmapName ); - eFillStyle = FillStyle_BITMAP; - } - } - else - { - rPropMap.setProperty( rPropIds[ FillBitmapUrlId ], aGraphicUrl ); - eFillStyle = FillStyle_BITMAP; - } - } + // push bitmap or named bitmap to property map + if( (aGraphicUrl.getLength() > 0) && rPropMap.setProperty( SHAPEPROP_FillBitmapUrl, aGraphicUrl ) ) + eFillStyle = FillStyle_BITMAP; // set other bitmap properties, if bitmap has been inserted into the map if( eFillStyle == FillStyle_BITMAP ) { // bitmap mode (single, repeat, stretch) BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.get( XML_TOKEN_INVALID ) ); - rPropMap.setProperty( rPropIds[ FillBitmapModeId ], eBitmapMode ); + rPropMap.setProperty( SHAPEPROP_FillBitmapMode, eBitmapMode ); // additional settings for repeated bitmap if( eBitmapMode == BitmapMode_REPEAT ) { // anchor position inside bitmap RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) ); - rPropMap.setProperty( rPropIds[ FillBitmapRectanglePointId ], eRectPoint ); + rPropMap.setProperty( SHAPEPROP_FillBitmapRectanglePoint, eRectPoint ); awt::Size aOriginalSize = lclGetOriginalSize( rGraphicHelper, maBlipProps.mxGraphic ); if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) ) @@ -354,16 +297,16 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM // size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm double fScaleX = maBlipProps.moTileScaleX.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT ); sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1, SAL_MAX_INT32 ); - rPropMap.setProperty( rPropIds[ FillBitmapSizeXId ], nFillBmpSizeX ); + rPropMap.setProperty( SHAPEPROP_FillBitmapSizeX, nFillBmpSizeX ); double fScaleY = maBlipProps.moTileScaleY.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT ); sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 ); - rPropMap.setProperty( rPropIds[ FillBitmapSizeYId ], nFillBmpSizeY ); + rPropMap.setProperty( SHAPEPROP_FillBitmapSizeY, nFillBmpSizeY ); // offset of the first bitmap tile (given as EMUs), convert to percent sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetX.get( 0 ) / 3.6 / aOriginalSize.Width, 0, 100 ); - rPropMap.setProperty( rPropIds[ FillBitmapOffsetXId ], nTileOffsetX ); + rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetX, nTileOffsetX ); sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 ); - rPropMap.setProperty( rPropIds[ FillBitmapOffsetYId ], nTileOffsetY ); + rPropMap.setProperty( SHAPEPROP_FillBitmapOffsetY, nTileOffsetY ); } } } @@ -376,9 +319,9 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM Color aColor = getBestSolidColor(); if( aColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ FillColorId ], aColor.getColor( rGraphicHelper, nPhClr ) ); - if( aColor.hasTransparence() ) - rPropMap.setProperty( rPropIds[ FillTransparenceId ], aColor.getTransparence() ); + rPropMap.setProperty( SHAPEPROP_FillColor, aColor.getColor( rGraphicHelper, nPhClr ) ); + if( aColor.hasTransparency() ) + rPropMap.setProperty( SHAPEPROP_FillTransparency, aColor.getTransparency() ); eFillStyle = FillStyle_SOLID; } } @@ -391,19 +334,10 @@ void FillProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM } // set final fill style property - rPropMap.setProperty( rPropIds[ FillStyleId ], eFillStyle ); + rPropMap.setProperty( SHAPEPROP_FillStyle, eFillStyle ); } } -void FillProperties::pushToPropSet( PropertySet& rPropSet, ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, const FillPropertyIds& rPropIds, - sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const -{ - PropertyMap aPropMap; - pushToPropMap( aPropMap, rModelObjHelper, rGraphicHelper, rPropIds, nShapeRotation, nPhClr ); - rPropSet.setProperties( aPropMap ); -} - // ============================================================================ void GraphicProperties::assignUsed( const GraphicProperties& rSourceProps ) @@ -421,9 +355,9 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe { sal_Int32 nFromColor = maBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr ); sal_Int32 nToColor = maBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr ); - if ( (nFromColor != nToColor) || maBlipProps.maColorChangeTo.hasTransparence() ) try + if ( (nFromColor != nToColor) || maBlipProps.maColorChangeTo.hasTransparency() ) try { - sal_Int16 nToTransparence = maBlipProps.maColorChangeTo.getTransparence(); + sal_Int16 nToTransparence = maBlipProps.maColorChangeTo.getTransparency(); sal_Int8 nToAlpha = static_cast< sal_Int8 >( (100 - nToTransparence) / 39.062 ); // ?!? correct ?!? Reference< XGraphicTransformer > xTransformer( maBlipProps.mxGraphic, UNO_QUERY_THROW ); xGraphic = xTransformer->colorChange( maBlipProps.mxGraphic, nFromColor, 9, nToColor, nToAlpha ); @@ -476,13 +410,6 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe rPropMap[ PROP_AdjustContrast ] <<= nContrast; } -void GraphicProperties::pushToPropSet( PropertySet& rPropSet, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const -{ - PropertyMap aPropMap; - pushToPropMap( aPropMap, rGraphicHelper, nPhClr ); - rPropSet.setProperties( aPropMap ); -} - // ============================================================================ } // namespace drawingml diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index a0836612fafb..c24166e4a8c0 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -28,6 +28,7 @@ #include "oox/drawingml/lineproperties.hxx" #include <vector> #include <rtl/ustrbuf.hxx> +#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/drawing/FlagSequence.hpp> #include <com/sun/star/drawing/LineDash.hpp> @@ -38,12 +39,11 @@ #include "properties.hxx" #include "tokens.hxx" #include "oox/helper/graphichelper.hxx" -#include "oox/helper/modelobjecthelper.hxx" -#include "oox/helper/propertymap.hxx" -#include "oox/helper/propertyset.hxx" #include "oox/core/namespaces.hxx" #include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/shapepropertymap.hxx" +using namespace ::com::sun::star::beans; using namespace ::com::sun::star::drawing; using ::rtl::OUString; @@ -60,24 +60,6 @@ namespace drawingml { namespace { -static const sal_Int32 spnDefaultLineIds[ LineId_END ] = -{ - PROP_LineStyle, - PROP_LineWidth, - PROP_LineColor, - PROP_LineTransparence, - PROP_LineDash, - PROP_LineJoint, - PROP_LineStartName, - PROP_LineStartWidth, - PROP_LineStartCenter, - PROP_LineEndName, - PROP_LineEndWidth, - PROP_LineEndCenter -}; - -// ---------------------------------------------------------------------------- - void lclSetDashData( LineDash& orLineDash, sal_Int16 nDots, sal_Int32 nDotLen, sal_Int16 nDashes, sal_Int32 nDashLen, sal_Int32 nDistance ) { @@ -196,15 +178,16 @@ sal_Int32 lclGetArrowSize( sal_Int32 nToken ) // ---------------------------------------------------------------------------- -void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& rArrowProps, - ModelObjectHelper& rModelObjHelper, const LinePropertyIds& rPropIds, sal_Int32 nLineWidth, bool bLineEnd ) +void lclPushMarkerProperties( ShapePropertyMap& rPropMap, + const LineArrowProperties& rArrowProps, sal_Int32 nLineWidth, bool bLineEnd ) { - PolyPolygonBezierCoords aMarker; - OUString aMarkerName; - sal_Int32 nMarkerWidth = 0; - bool bMarkerCenter = false; + /* Store the marker polygon and the marker name in a single value, to be + able to pass both to the ShapePropertyMap::setProperty() function. */ + NamedValue aNamedMarker; OUStringBuffer aBuffer; + sal_Int32 nMarkerWidth = 0; + bool bMarkerCenter = false; sal_Int32 nArrowType = rArrowProps.moArrowType.get( XML_none ); switch( nArrowType ) { @@ -234,7 +217,7 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& sal_Int32 nNameIndex = nWidth * 3 + nLength + 1; aBuffer.append( sal_Unicode( ' ' ) ).append( nNameIndex ); - aMarkerName = aBuffer.makeStringAndClear(); + OUString aMarkerName = aBuffer.makeStringAndClear(); bool bIsArrow = nArrowType == XML_arrow; double fArrowLength = 1.0; @@ -255,8 +238,11 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& sal_Int32 nBaseLineWidth = ::std::max< sal_Int32 >( nLineWidth, 70 ); nMarkerWidth = static_cast< sal_Int32 >( fArrowWidth * nBaseLineWidth ); - // test if the arrow already exists, do not create it again in this case - if( !rPropIds.mbNamedLineMarker || !rModelObjHelper.hasLineMarker( aMarkerName ) ) + /* Test if the marker already exists in the marker table, do not + create it again in this case. If markers are inserted explicitly + instead by their name, the polygon will be created always. + TODO: this can be optimized by using a map. */ + if( !rPropMap.hasNamedLineMarkerInTable( aMarkerName ) ) { // pass X and Y as percentage to OOX_ARROW_POINT #define OOX_ARROW_POINT( x, y ) Point( static_cast< sal_Int32 >( fArrowWidth * x ), static_cast< sal_Int32 >( fArrowLength * y ) ) @@ -311,46 +297,44 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& } #undef OOX_ARROW_POINT - OSL_ENSURE( !aPoints.empty(), "ApiLineMarkerProperties::ApiLineMarkerProperties - missing arrow coordinates" ); + OSL_ENSURE( !aPoints.empty(), "lclPushMarkerProperties - missing arrow coordinates" ); if( !aPoints.empty() ) { - aMarker.Coordinates.realloc( 1 ); - aMarker.Coordinates[ 0 ] = ContainerHelper::vectorToSequence( aPoints ); + PolyPolygonBezierCoords aMarkerCoords; + aMarkerCoords.Coordinates.realloc( 1 ); + aMarkerCoords.Coordinates[ 0 ] = ContainerHelper::vectorToSequence( aPoints ); ::std::vector< PolygonFlags > aFlags( aPoints.size(), PolygonFlags_NORMAL ); - aMarker.Flags.realloc( 1 ); - aMarker.Flags[ 0 ] = ContainerHelper::vectorToSequence( aFlags ); + aMarkerCoords.Flags.realloc( 1 ); + aMarkerCoords.Flags[ 0 ] = ContainerHelper::vectorToSequence( aFlags ); - if( rPropIds.mbNamedLineMarker && !rModelObjHelper.insertLineMarker( aMarkerName, aMarker ) ) - aMarkerName = OUString(); - } - else - { - aMarkerName = OUString(); + aNamedMarker.Name = aMarkerName; + aNamedMarker.Value <<= aMarkerCoords; } } + else + { + /* Named marker object exists already in the marker table, pass + its name only. This will set the name as property value, but + does not create a new object in the marker table. */ + aNamedMarker.Name = aMarkerName; + } } - // push the properties (filled aMarkerName indicates valid marker) - if( aMarkerName.getLength() > 0 ) + // push the properties (filled aNamedMarker.Name indicates valid marker) + if( aNamedMarker.Name.getLength() > 0 ) { if( bLineEnd ) { - if( rPropIds.mbNamedLineMarker ) - rPropMap.setProperty( rPropIds[ LineEndId ], aMarkerName ); - else - rPropMap.setProperty( rPropIds[ LineEndId ], aMarker ); - rPropMap.setProperty( rPropIds[ LineEndWidthId ], nMarkerWidth ); - rPropMap.setProperty( rPropIds[ LineEndCenterId ], bMarkerCenter ); + rPropMap.setProperty( SHAPEPROP_LineEnd, aNamedMarker ); + rPropMap.setProperty( SHAPEPROP_LineEndWidth, nMarkerWidth ); + rPropMap.setProperty( SHAPEPROP_LineEndCenter, bMarkerCenter ); } else { - if( rPropIds.mbNamedLineMarker ) - rPropMap.setProperty( rPropIds[ LineStartId ], aMarkerName ); - else - rPropMap.setProperty( rPropIds[ LineStartId ], aMarker ); - rPropMap.setProperty( rPropIds[ LineStartWidthId ], nMarkerWidth ); - rPropMap.setProperty( rPropIds[ LineStartCenterId ], bMarkerCenter ); + rPropMap.setProperty( SHAPEPROP_LineStart, aNamedMarker ); + rPropMap.setProperty( SHAPEPROP_LineStartWidth, nMarkerWidth ); + rPropMap.setProperty( SHAPEPROP_LineStartCenter, bMarkerCenter ); } } } @@ -359,16 +343,6 @@ void lclPushMarkerProperties( PropertyMap& rPropMap, const LineArrowProperties& // ============================================================================ -LinePropertyIds::LinePropertyIds( const sal_Int32* pnPropertyIds, bool bNamedLineDash, bool bNamedLineMarker ) : - mpnPropertyIds( pnPropertyIds ), - mbNamedLineDash( bNamedLineDash ), - mbNamedLineMarker( bNamedLineMarker ) -{ - OSL_ENSURE( mpnPropertyIds != 0, "LinePropertyIds::LinePropertyIds - missing property identifiers" ); -} - -// ============================================================================ - void LineArrowProperties::assignUsed( const LineArrowProperties& rSourceProps ) { moArrowType.assignIfUsed( rSourceProps.moArrowType ); @@ -378,8 +352,6 @@ void LineArrowProperties::assignUsed( const LineArrowProperties& rSourceProps ) // ============================================================================ -LinePropertyIds LineProperties::DEFAULT_IDS( spnDefaultLineIds, false, true ); - void LineProperties::assignUsed( const LineProperties& rSourceProps ) { maStartArrow.assignUsed( rSourceProps.maStartArrow ); @@ -394,8 +366,8 @@ void LineProperties::assignUsed( const LineProperties& rSourceProps ) moLineJoint.assignIfUsed( rSourceProps.moLineJoint ); } -void LineProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const +void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const { // line fill type must exist, otherwise ignore other properties if( maLineFill.moFillType.has() ) @@ -424,55 +396,35 @@ void LineProperties::pushToPropMap( PropertyMap& rPropMap, ModelObjectHelper& rM aLineDash.DashLen *= nBaseLineWidth; aLineDash.Distance *= nBaseLineWidth; - if( rPropIds.mbNamedLineDash ) - { - OUString aDashName = rModelObjHelper.insertLineDash( aLineDash ); - if( aDashName.getLength() > 0 ) - { - rPropMap.setProperty( rPropIds[ LineDashId ], aDashName ); - eLineStyle = LineStyle_DASH; - } - } - else - { - rPropMap.setProperty( rPropIds[ LineDashId ], aLineDash ); + if( rPropMap.setProperty( SHAPEPROP_LineDash, aLineDash ) ) eLineStyle = LineStyle_DASH; - } } // set final line style property - rPropMap.setProperty( rPropIds[ LineStyleId ], eLineStyle ); + rPropMap.setProperty( SHAPEPROP_LineStyle, eLineStyle ); // line joint type if( moLineJoint.has() ) - rPropMap.setProperty( rPropIds[ LineJointId ], lclGetLineJoint( moLineJoint.get() ) ); + rPropMap.setProperty( SHAPEPROP_LineJoint, lclGetLineJoint( moLineJoint.get() ) ); // line width in 1/100mm - rPropMap.setProperty( rPropIds[ LineWidthId ], nLineWidth ); + rPropMap.setProperty( SHAPEPROP_LineWidth, nLineWidth ); // line color and transparence Color aLineColor = maLineFill.getBestSolidColor(); if( aLineColor.isUsed() ) { - rPropMap.setProperty( rPropIds[ LineColorId ], aLineColor.getColor( rGraphicHelper, nPhClr ) ); - if( aLineColor.hasTransparence() ) - rPropMap.setProperty( rPropIds[ LineTransparenceId ], aLineColor.getTransparence() ); + rPropMap.setProperty( SHAPEPROP_LineColor, aLineColor.getColor( rGraphicHelper, nPhClr ) ); + if( aLineColor.hasTransparency() ) + rPropMap.setProperty( SHAPEPROP_LineTransparency, aLineColor.getTransparency() ); } // line markers - lclPushMarkerProperties( rPropMap, maStartArrow, rModelObjHelper, rPropIds, nLineWidth, false ); - lclPushMarkerProperties( rPropMap, maEndArrow, rModelObjHelper, rPropIds, nLineWidth, true ); + lclPushMarkerProperties( rPropMap, maStartArrow, nLineWidth, false ); + lclPushMarkerProperties( rPropMap, maEndArrow, nLineWidth, true ); } } -void LineProperties::pushToPropSet( PropertySet& rPropSet, ModelObjectHelper& rModelObjHelper, - const GraphicHelper& rGraphicHelper, const LinePropertyIds& rPropIds, sal_Int32 nPhClr ) const -{ - PropertyMap aPropMap; - pushToPropMap( aPropMap, rModelObjHelper, rGraphicHelper, rPropIds, nPhClr ); - rPropSet.setProperties( aPropMap ); -} - // ============================================================================ } // namespace drawingml diff --git a/oox/source/drawingml/makefile.mk b/oox/source/drawingml/makefile.mk index e2d4ea6b8f3d..0546fb4c233d 100644 --- a/oox/source/drawingml/makefile.mk +++ b/oox/source/drawingml/makefile.mk @@ -62,6 +62,7 @@ SLOFILES = \ $(SLO)$/shapecontext.obj\ $(SLO)$/shapegroupcontext.obj\ $(SLO)$/shapepropertiescontext.obj\ + $(SLO)$/shapepropertymap.obj\ $(SLO)$/shapestylecontext.obj\ $(SLO)$/spdefcontext.obj\ $(SLO)$/textbody.obj\ diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 4d15886a641a..af44469a6ced 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -30,6 +30,7 @@ #include "oox/drawingml/theme.hxx" #include "oox/drawingml/fillproperties.hxx" #include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/drawingml/textbody.hxx" #include "oox/drawingml/table/tableproperties.hxx" #include "oox/core/namespaces.hxx" @@ -397,7 +398,6 @@ Reference< XShape > Shape::createAndInsert( } } - ModelObjectHelper& rModelObjectHelper = rFilterBase.getModelObjectHelper(); const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper(); LineProperties aLineProperties; @@ -432,33 +432,23 @@ Reference< XShape > Shape::createAndInsert( aLineProperties.assignUsed( getLineProperties() ); aFillProperties.assignUsed( getFillProperties() ); - PropertyMap aShapeProperties; - PropertyMap::const_iterator aShapePropIter; + ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() ); if( mxCreateCallback.get() ) - { - for ( aShapePropIter = mxCreateCallback->getShapeProperties().begin(); - aShapePropIter != mxCreateCallback->getShapeProperties().end(); aShapePropIter++ ) - aShapeProperties[ (*aShapePropIter).first ] = (*aShapePropIter).second; - } + aShapeProps.assignUsed( mxCreateCallback->getShapeProperties() ); // add properties from textbody to shape properties if( mpTextBody.get() ) - { - for ( aShapePropIter = mpTextBody->getTextProperties().maPropertyMap.begin(); - aShapePropIter != mpTextBody->getTextProperties().maPropertyMap.end(); aShapePropIter++ ) - aShapeProperties[ (*aShapePropIter).first ] = (*aShapePropIter).second; - } + aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap ); - aShapeProperties.insert( getShapeProperties().begin(), getShapeProperties().end() ); // applying properties - PropertySet aPropSet( xSet ); + aShapeProps.assignUsed( getShapeProperties() ); if ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.GraphicObjectShape" ) ) - mpGraphicPropertiesPtr->pushToPropSet( aPropSet, rGraphicHelper ); + mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper ); if ( mpTablePropertiesPtr.get() && ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.TableShape" ) ) ) mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle ); - aFillProperties.pushToPropSet( aPropSet, rModelObjectHelper, rGraphicHelper, FillProperties::DEFAULT_IDS, mnRotation, nFillPhClr ); - aLineProperties.pushToPropSet( aPropSet, rModelObjectHelper, rGraphicHelper, LineProperties::DEFAULT_IDS, nLinePhClr ); + aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr ); + aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr ); // applying autogrowheight property before setting shape size, because // the shape size might be changed if currently autogrowheight is true @@ -466,12 +456,12 @@ Reference< XShape > Shape::createAndInsert( Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() ); const OUString& rPropName = PropertyMap::getPropertyName( PROP_TextAutoGrowHeight ); if( xSetInfo.is() && xSetInfo->hasPropertyByName( rPropName ) ) - if( /*const Any* pAutoGrowHeight =*/ aShapeProperties.getProperty( PROP_TextAutoGrowHeight ) ) + if( aShapeProps.hasProperty( PROP_TextAutoGrowHeight ) ) xSet->setPropertyValue( rPropName, Any( false ) ); // do not set properties at a group shape (this causes assertions from svx) if( aServiceName != OUString::createFromAscii( "com.sun.star.drawing.GroupShape" ) ) - aPropSet.setProperties( aShapeProperties ); + PropertySet( xSet ).setProperties( aShapeProps ); if( bIsCustomShape ) { diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx new file mode 100755 index 000000000000..9d2397cf5f7e --- /dev/null +++ b/oox/source/drawingml/shapepropertymap.cxx @@ -0,0 +1,195 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/drawingml/shapepropertymap.hxx" + +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/drawing/LineDash.hpp> +#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> +#include "oox/helper/modelobjecthelper.hxx" +#include "properties.hxx" + +namespace oox { +namespace drawingml { + +// ============================================================================ + +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::uno; + +using ::rtl::OUString; + +// ============================================================================ + +namespace { + +static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END ] = +{ + PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDash, PROP_LineJoint, + PROP_LineStartName, PROP_LineStartWidth, PROP_LineStartCenter, PROP_LineEndName, PROP_LineEndWidth, PROP_LineEndCenter, + PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillGradient, + PROP_FillBitmapURL, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, + PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint +}; + +} // namespace + +ShapePropertyInfo ShapePropertyInfo::DEFAULT( spnDefaultShapeIds, true, false, false, false ); + +ShapePropertyInfo::ShapePropertyInfo( const sal_Int32* pnPropertyIds, + bool bNamedLineMarker, bool bNamedLineDash, bool bNamedFillGradient, bool bNamedFillBitmapUrl ) : + mpnPropertyIds( pnPropertyIds ), + mbNamedLineMarker( bNamedLineMarker ), + mbNamedLineDash( bNamedLineDash ), + mbNamedFillGradient( bNamedFillGradient ), + mbNamedFillBitmapUrl( bNamedFillBitmapUrl ) +{ + OSL_ENSURE( mpnPropertyIds != 0, "ShapePropertyInfo::ShapePropertyInfo - missing property identifiers" ); +} + +// ============================================================================ + +ShapePropertyMap::ShapePropertyMap( ModelObjectHelper& rModelObjHelper, const ShapePropertyInfo& rShapePropInfo ) : + mrModelObjHelper( rModelObjHelper ), + maShapePropInfo( rShapePropInfo ) +{ +} + +bool ShapePropertyMap::supportsProperty( ShapePropertyId ePropId ) const +{ + return maShapePropInfo.has( ePropId ); +} + +bool ShapePropertyMap::hasNamedLineMarkerInTable( const OUString& rMarkerName ) const +{ + return maShapePropInfo.mbNamedLineMarker && mrModelObjHelper.hasLineMarker( rMarkerName ); +} + +bool ShapePropertyMap::setAnyProperty( ShapePropertyId ePropId, const Any& rValue ) +{ + // get current property identifier for the specified property + sal_Int32 nPropId = maShapePropInfo[ ePropId ]; + if( nPropId < 0 ) return false; + + // special handling for properties supporting named objects in tables + switch( ePropId ) + { + case SHAPEPROP_LineStart: + case SHAPEPROP_LineEnd: + return setLineMarker( nPropId, rValue ); + + case SHAPEPROP_LineDash: + return setLineDash( nPropId, rValue ); + + case SHAPEPROP_FillGradient: + return setFillGradient( nPropId, rValue ); + + case SHAPEPROP_FillBitmapUrl: + return setFillBitmapUrl( nPropId, rValue ); + + default:; // suppress compiler warnings + } + + // set plain property value + operator[]( nPropId ) = rValue; + return true; +} + +// private -------------------------------------------------------------------- + +bool ShapePropertyMap::setLineMarker( sal_Int32 nPropId, const Any& rValue ) +{ + NamedValue aNamedMarker; + if( (rValue >>= aNamedMarker) && (aNamedMarker.Name.getLength() > 0) ) + { + // push line marker explicitly + if( !maShapePropInfo.mbNamedLineMarker ) + return setAnyProperty( nPropId, aNamedMarker.Value ); + + // create named line marker (if coordinates have been passed) and push its name + bool bInserted = !aNamedMarker.Value.has< PolyPolygonBezierCoords >() || + mrModelObjHelper.insertLineMarker( aNamedMarker.Name, aNamedMarker.Value.get< PolyPolygonBezierCoords >() ); + return bInserted && setProperty( nPropId, aNamedMarker.Name ); + } + return false; +} + +bool ShapePropertyMap::setLineDash( sal_Int32 nPropId, const Any& rValue ) +{ + // push line dash explicitly + if( !maShapePropInfo.mbNamedLineDash ) + return setAnyProperty( nPropId, rValue ); + + // create named line dash and push its name + if( rValue.has< LineDash >() ) + { + OUString aDashName = mrModelObjHelper.insertLineDash( rValue.get< LineDash >() ); + return (aDashName.getLength() > 0) && setProperty( nPropId, aDashName ); + } + + return false; +} + +bool ShapePropertyMap::setFillGradient( sal_Int32 nPropId, const Any& rValue ) +{ + // push gradient explicitly + if( !maShapePropInfo.mbNamedFillGradient ) + return setAnyProperty( nPropId, rValue ); + + // create named gradient and push its name + if( rValue.has< Gradient >() ) + { + OUString aGradientName = mrModelObjHelper.insertFillGradient( rValue.get< Gradient >() ); + return (aGradientName.getLength() > 0) && setProperty( nPropId, aGradientName ); + } + + return false; +} + +bool ShapePropertyMap::setFillBitmapUrl( sal_Int32 nPropId, const Any& rValue ) +{ + // push bitmap URL explicitly + if( !maShapePropInfo.mbNamedFillBitmapUrl ) + return setAnyProperty( nPropId, rValue ); + + // create named bitmap URL and push its name + if( rValue.has< OUString >() ) + { + OUString aBitmapUrlName = mrModelObjHelper.insertFillBitmapUrl( rValue.get< OUString >() ); + return (aBitmapUrlName.getLength() > 0) && setProperty( nPropId, aBitmapUrlName ); + } + + return false; +} + +// ============================================================================ + +} // namespace drawingml +} // namespace oox diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index ee3ac495f4d6..d31627e61148 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -27,12 +27,13 @@ #include "oox/drawingml/table/tablecell.hxx" #include "oox/drawingml/table/tableproperties.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/drawingml/textbody.hxx" #include "oox/core/namespaces.hxx" #include "oox/core/xmlfilterbase.hxx" +#include "oox/helper/propertyset.hxx" #include "properties.hxx" #include "tokens.hxx" -#include "oox/helper/propertyset.hxx" #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/table/XTable.hpp> @@ -358,9 +359,10 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottomLeftToTopRight, PROP_DiagonalBLTR ); aFillProperties.assignUsed( maFillProperties ); - PropertySet aPropSet( xPropSet ); + ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() ); // TODO: phClr? - aFillProperties.pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), rFilterBase.getGraphicHelper() ); + aFillProperties.pushToPropMap( aPropMap, rFilterBase.getGraphicHelper() ); + PropertySet( xPropSet ).setProperties( aPropMap ); } } } } diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx index 6528fea5634d..21dbe9c3a2eb 100644 --- a/oox/source/helper/modelobjecthelper.cxx +++ b/oox/source/helper/modelobjecthelper.cxx @@ -45,13 +45,13 @@ namespace oox { // ============================================================================ ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& rxModelFactory ) : - maMarkerContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ), - maDashContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ), - maGradientContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ), - maBitmapContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ), - maDashNameBase( CREATE_OUSTRING( "msLineDash " ) ), - maGradientNameBase( CREATE_OUSTRING( "msFillGradient " ) ), - maBitmapNameBase( CREATE_OUSTRING( "msFillBitmap " ) ) + maMarkerContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ), + maDashContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ), + maGradientContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ), + maBitmapUrlContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ), + maDashNameBase( CREATE_OUSTRING( "msLineDash " ) ), + maGradientNameBase( CREATE_OUSTRING( "msFillGradient " ) ), + maBitmapUrlNameBase( CREATE_OUSTRING( "msFillBitmap " ) ) { } @@ -78,10 +78,10 @@ OUString ModelObjectHelper::insertFillGradient( const Gradient& rGradient ) return maGradientContainer.insertObject( maGradientNameBase, Any( rGradient ), true ); } -OUString ModelObjectHelper::insertFillBitmap( const OUString& rGraphicUrl ) +OUString ModelObjectHelper::insertFillBitmapUrl( const OUString& rGraphicUrl ) { if( rGraphicUrl.getLength() > 0 ) - return maBitmapContainer.insertObject( maBitmapNameBase, Any( rGraphicUrl ), true ); + return maBitmapUrlContainer.insertObject( maBitmapUrlNameBase, Any( rGraphicUrl ), true ); return OUString(); } diff --git a/oox/source/helper/propertymap.cxx b/oox/source/helper/propertymap.cxx index 31072fe449e5..155b2015dffa 100644 --- a/oox/source/helper/propertymap.cxx +++ b/oox/source/helper/propertymap.cxx @@ -186,10 +186,6 @@ PropertyMap::PropertyMap() : { } -PropertyMap::~PropertyMap() -{ -} - /*static*/ const OUString& PropertyMap::getPropertyName( sal_Int32 nPropId ) { OSL_ENSURE( (0 <= nPropId) && (nPropId < PROP_COUNT), "PropertyMap::getPropertyName - invalid property identifier" ); diff --git a/oox/source/helper/propertyset.cxx b/oox/source/helper/propertyset.cxx index e7071ba402a2..a46c189f9a2b 100644 --- a/oox/source/helper/propertyset.cxx +++ b/oox/source/helper/propertyset.cxx @@ -52,22 +52,10 @@ void PropertySet::set( const Reference< XPropertySet >& rxPropSet ) // Get properties ------------------------------------------------------------- -bool PropertySet::getAnyProperty( Any& orValue, sal_Int32 nPropId ) const -{ - return getAnyProperty( orValue, PropertyMap::getPropertyName( nPropId ) ); -} - Any PropertySet::getAnyProperty( sal_Int32 nPropId ) const { Any aValue; - return getAnyProperty( aValue, nPropId ) ? aValue : Any(); -} - -bool PropertySet::getBoolProperty( sal_Int32 nPropId ) const -{ - Any aAny; - bool bValue = false; - return getAnyProperty( aAny, nPropId ) && (aAny >>= bValue) && bValue; + return implGetPropertyValue( aValue, PropertyMap::getPropertyName( nPropId ) ) ? aValue : Any(); } void PropertySet::getProperties( Sequence< Any >& orValues, const Sequence< OUString >& rPropNames ) const @@ -90,15 +78,15 @@ void PropertySet::getProperties( Sequence< Any >& orValues, const Sequence< OUSt orValues.realloc( nLen ); Any* pValue = orValues.getArray(); for( ; pPropName != pPropNameEnd; ++pPropName, ++pValue ) - getAnyProperty( *pValue, *pPropName ); + implGetPropertyValue( *pValue, *pPropName ); } } // Set properties ------------------------------------------------------------- -void PropertySet::setAnyProperty( sal_Int32 nPropId, const Any& rValue ) +bool PropertySet::setAnyProperty( sal_Int32 nPropId, const Any& rValue ) { - setAnyProperty( PropertyMap::getPropertyName( nPropId ), rValue ); + return implSetPropertyValue( PropertyMap::getPropertyName( nPropId ), rValue ); } void PropertySet::setProperties( const Sequence< OUString >& rPropNames, const Sequence< Any >& rValues ) @@ -122,7 +110,7 @@ void PropertySet::setProperties( const Sequence< OUString >& rPropNames, const S const OUString* pPropNameEnd = pPropName + rPropNames.getLength(); const Any* pValue = rValues.getConstArray(); for( ; pPropName != pPropNameEnd; ++pPropName, ++pValue ) - setAnyProperty( *pPropName, *pValue ); + implSetPropertyValue( *pPropName, *pValue ); } } @@ -139,37 +127,34 @@ void PropertySet::setProperties( const PropertyMap& rPropertyMap ) // private -------------------------------------------------------------------- -bool PropertySet::getAnyProperty( Any& orValue, const OUString& rPropName ) const +bool PropertySet::implGetPropertyValue( Any& orValue, const OUString& rPropName ) const { - bool bHasValue = false; - try + if( mxPropSet.is() ) try { - if( mxPropSet.is() ) - { - orValue = mxPropSet->getPropertyValue( rPropName ); - bHasValue = true; - } + orValue = mxPropSet->getPropertyValue( rPropName ); + return true; } catch( Exception& ) { - OSL_ENSURE( false, OStringBuffer( "PropertySet::getAnyProperty - cannot get property \"" ). + OSL_ENSURE( false, OStringBuffer( "PropertySet::implGetPropertyValue - cannot get property \"" ). append( OUStringToOString( rPropName, RTL_TEXTENCODING_ASCII_US ) ).append( '"' ).getStr() ); } - return bHasValue; + return false; } -void PropertySet::setAnyProperty( const OUString& rPropName, const Any& rValue ) +bool PropertySet::implSetPropertyValue( const OUString& rPropName, const Any& rValue ) { - try + if( mxPropSet.is() ) try { - if( mxPropSet.is() ) - mxPropSet->setPropertyValue( rPropName, rValue ); + mxPropSet->setPropertyValue( rPropName, rValue ); + return true; } catch( Exception& ) { - OSL_ENSURE( false, OStringBuffer( "PropertySet::setAnyProperty - cannot set property \"" ). + OSL_ENSURE( false, OStringBuffer( "PropertySet::implSetPropertyValue - cannot set property \"" ). append( OUStringToOString( rPropName, RTL_TEXTENCODING_ASCII_US ) ).append( '"' ).getStr() ); } + return false; } #if OSL_DEBUG_LEVEL > 0 diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx index 7e77f5a54938..7db7cba4c68c 100644 --- a/oox/source/ppt/slidefragmenthandler.cxx +++ b/oox/source/ppt/slidefragmenthandler.cxx @@ -150,7 +150,7 @@ Reference< XFastContextHandler > SlideFragmentHandler::createFastChildContext( s { FillPropertiesPtr pFillPropertiesPtr( new FillProperties( *mpSlidePersistPtr->getTheme()->getFillStyle( xAttribs->getOptionalValue( XML_idx ).toInt32() ) ) ); - xRet.set( new ColorContext( *this, mpSlidePersistPtr->getBackgroundColorRef() ) ); + xRet.set( new ColorContext( *this, mpSlidePersistPtr->getBackgroundColor() ) ); mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); } break; diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index 8555ba371b77..f6f6eb8f42c7 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -25,14 +25,16 @@ * ************************************************************************/ -#include "oox/helper/propertyset.hxx" #include "oox/ppt/timenode.hxx" #include "oox/ppt/pptshape.hxx" #include "oox/ppt/slidepersist.hxx" #include "oox/drawingml/fillproperties.hxx" +#include "oox/drawingml/shapepropertymap.hxx" +#include "oox/helper/propertyset.hxx" #include "oox/vml/vmldrawing.hxx" #include "oox/core/namespaces.hxx" #include "oox/core/xmlfilterbase.hxx" +#include "properties.hxx" #include "tokens.hxx" #include <com/sun/star/style/XStyle.hpp> @@ -171,24 +173,12 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase ) { if ( mpBackgroundPropertiesPtr ) { - try - { - sal_Int32 nPhClr = API_RGB_TRANSPARENT; - if ( maBackgroundColorRef.isUsed() ) - nPhClr = maBackgroundColorRef.getColor( rFilterBase.getGraphicHelper() ); + sal_Int32 nPhClr = maBackgroundColor.isUsed() ? + maBackgroundColor.getColor( rFilterBase.getGraphicHelper() ) : API_RGB_TRANSPARENT; - PropertyMap aPropMap; - static const rtl::OUString sBackground( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ); - uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xPropertySet( aPropMap.makePropertySet() ); - PropertySet aPropSet( xPropertySet ); - mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), - rFilterBase.getGraphicHelper(), oox::drawingml::FillProperties::DEFAULT_IDS, 0, nPhClr ); - xPagePropSet->setPropertyValue( sBackground, Any( xPropertySet ) ); - } - catch( Exception ) - { - } + ::oox::drawingml::ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() ); + mpBackgroundPropertiesPtr->pushToPropMap( aPropMap, rFilterBase.getGraphicHelper(), 0, nPhClr ); + PropertySet( mxPage ).setProperty( PROP_Background, aPropMap.makePropertySet() ); } } diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 2850d422e234..d1b7cb8c3bf2 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -16,6 +16,7 @@ AutoShowInfo Autocomplete BackGraphicLocation BackGraphicURL +Background BackgroundColor BasicLibraries BlackDay diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index 9ee8a4ec3215..1e846457f9a5 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -43,6 +43,7 @@ using ::oox::drawingml::Color; using ::oox::drawingml::FillProperties; using ::oox::drawingml::LineArrowProperties; using ::oox::drawingml::LineProperties; +using ::oox::drawingml::ShapePropertyMap; namespace oox { namespace vml { @@ -430,8 +431,7 @@ void StrokeModel::assignUsed( const StrokeModel& rSource ) moJoinStyle.assignIfUsed( rSource.moJoinStyle ); } -void StrokeModel::pushToPropMap( PropertyMap& rPropMap, - ModelObjectHelper& rModelObjectHelper, const GraphicHelper& rGraphicHelper ) const +void StrokeModel::pushToPropMap( ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper ) const { /* Convert VML line formatting to DrawingML line formatting and let the DrawingML code do the hard work. */ @@ -454,7 +454,7 @@ void StrokeModel::pushToPropMap( PropertyMap& rPropMap, aLineProps.maLineFill.moFillType = XML_noFill; } - aLineProps.pushToPropMap( rPropMap, rModelObjectHelper, rGraphicHelper ); + aLineProps.pushToPropMap( rPropMap, rGraphicHelper ); } // ============================================================================ @@ -475,8 +475,7 @@ void FillModel::assignUsed( const FillModel& rSource ) moRotate.assignIfUsed( rSource.moRotate ); } -void FillModel::pushToPropMap( PropertyMap& rPropMap, - ModelObjectHelper& rModelObjectHelper, const GraphicHelper& rGraphicHelper ) const +void FillModel::pushToPropMap( ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper ) const { /* Convert VML fill formatting to DrawingML fill formatting and let the DrawingML code do the hard work. */ @@ -594,7 +593,7 @@ void FillModel::pushToPropMap( PropertyMap& rPropMap, aFillProps.moFillType = XML_noFill; } - aFillProps.pushToPropMap( rPropMap, rModelObjectHelper, rGraphicHelper ); + aFillProps.pushToPropMap( rPropMap, rGraphicHelper ); } // ============================================================================ diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index d557a7f50354..52b2217b290d 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -36,8 +36,8 @@ #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include "properties.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/helper/graphichelper.hxx" -#include "oox/helper/propertymap.hxx" #include "oox/helper/propertyset.hxx" #include "oox/core/xmlfilterbase.hxx" #include "oox/ole/axcontrol.hxx" @@ -313,15 +313,11 @@ Rectangle ShapeBase::calcShapeRectangle( const ShapeParentAnchor* pParentAnchor void ShapeBase::convertShapeProperties( const Reference< XShape >& rxShape ) const { - ModelObjectHelper& rModelObjectHelper = mrDrawing.getFilter().getModelObjectHelper(); + ::oox::drawingml::ShapePropertyMap aPropMap( mrDrawing.getFilter().getModelObjectHelper() ); const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper(); - - PropertyMap aPropMap; - maTypeModel.maStrokeModel.pushToPropMap( aPropMap, rModelObjectHelper, rGraphicHelper ); - maTypeModel.maFillModel.pushToPropMap( aPropMap, rModelObjectHelper, rGraphicHelper ); - - PropertySet aPropSet( rxShape ); - aPropSet.setProperties( aPropMap ); + maTypeModel.maStrokeModel.pushToPropMap( aPropMap, rGraphicHelper ); + maTypeModel.maFillModel.pushToPropMap( aPropMap, rGraphicHelper ); + PropertySet( rxShape ).setProperties( aPropMap ); } // ============================================================================ diff --git a/oox/source/xls/drawingmanager.cxx b/oox/source/xls/drawingmanager.cxx index e1607e99e6c6..dbc6ae19b703 100755 --- a/oox/source/xls/drawingmanager.cxx +++ b/oox/source/xls/drawingmanager.cxx @@ -33,9 +33,9 @@ #include <com/sun/star/drawing/PolygonKind.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include "oox/core/filterbase.hxx" +#include "oox/drawingml/fillproperties.hxx" #include "oox/drawingml/lineproperties.hxx" -#include "oox/helper/propertymap.hxx" -#include "oox/helper/propertyset.hxx" +#include "oox/drawingml/shapepropertymap.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/unitconverter.hxx" #include "properties.hxx" @@ -594,7 +594,7 @@ void BiffDrawingObjectBase::readMacroBiff8( BiffInputStream& rStrm ) } } -void BiffDrawingObjectBase::convertLineProperties( PropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows ) const +void BiffDrawingObjectBase::convertLineProperties( ShapePropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows ) const { if( rLineModel.mbAuto ) { @@ -705,10 +705,10 @@ void BiffDrawingObjectBase::convertLineProperties( PropertyMap& rPropMap, const } } - aLineProps.pushToPropMap( rPropMap, getBaseFilter().getModelObjectHelper(), getBaseFilter().getGraphicHelper() ); + aLineProps.pushToPropMap( rPropMap, getBaseFilter().getGraphicHelper() ); } -void BiffDrawingObjectBase::convertFillProperties( PropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const +void BiffDrawingObjectBase::convertFillProperties( ShapePropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const { if( rFillModel.mbAuto ) { @@ -791,10 +791,10 @@ void BiffDrawingObjectBase::convertFillProperties( PropertyMap& rPropMap, const #endif } - aFillProps.pushToPropMap( rPropMap, getBaseFilter().getModelObjectHelper(), getBaseFilter().getGraphicHelper() ); + aFillProps.pushToPropMap( rPropMap, getBaseFilter().getGraphicHelper() ); } -void BiffDrawingObjectBase::convertFrameProperties( PropertyMap& /*rPropMap*/, sal_uInt16 /*nFrameFlags*/ ) const +void BiffDrawingObjectBase::convertFrameProperties( ShapePropertyMap& /*rPropMap*/, sal_uInt16 /*nFrameFlags*/ ) const { } @@ -1044,7 +1044,7 @@ void BiffLineObject::implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameL Reference< XShape > BiffLineObject::implConvertAndInsert( BiffDrawingBase& rDrawing, const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const { - PropertyMap aPropMap; + ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); convertLineProperties( aPropMap, maLineModel, mnArrows ); // create the line polygon @@ -1087,7 +1087,7 @@ void BiffRectObject::readFrameData( BiffInputStream& rStrm ) rStrm >> maFillModel >> maLineModel >> mnFrameFlags; } -void BiffRectObject::convertRectProperties( PropertyMap& rPropMap ) const +void BiffRectObject::convertRectProperties( ShapePropertyMap& rPropMap ) const { convertLineProperties( rPropMap, maLineModel ); convertFillProperties( rPropMap, maFillModel ); @@ -1116,7 +1116,7 @@ void BiffRectObject::implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameL Reference< XShape > BiffRectObject::implConvertAndInsert( BiffDrawingBase& rDrawing, const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const { - PropertyMap aPropMap; + ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); convertRectProperties( aPropMap ); Reference< XShape > xShape = rDrawing.createAndInsertXShape( CREATE_OUSTRING( "com.sun.star.drawing.RectangleShape" ), rxShapes, rShapeRect ); @@ -1134,7 +1134,7 @@ BiffOvalObject::BiffOvalObject( const WorksheetHelper& rHelper ) : Reference< XShape > BiffOvalObject::implConvertAndInsert( BiffDrawingBase& rDrawing, const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const { - PropertyMap aPropMap; + ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); convertRectProperties( aPropMap ); Reference< XShape > xShape = rDrawing.createAndInsertXShape( CREATE_OUSTRING( "com.sun.star.drawing.EllipseShape" ), rxShapes, rShapeRect ); @@ -1176,7 +1176,7 @@ void BiffArcObject::implReadObjBiff5( BiffInputStream& rStrm, sal_uInt16 nNameLe Reference< XShape > BiffArcObject::implConvertAndInsert( BiffDrawingBase& rDrawing, const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const { - PropertyMap aPropMap; + ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); convertLineProperties( aPropMap, maLineModel ); convertFillProperties( aPropMap, maFillModel ); @@ -1257,7 +1257,7 @@ Reference< XShape > BiffPolygonObject::implConvertAndInsert( BiffDrawingBase& rD Reference< XShape > xShape; if( maCoords.size() >= 2 ) { - PropertyMap aPropMap; + ShapePropertyMap aPropMap( getBaseFilter().getModelObjectHelper() ); convertRectProperties( aPropMap ); // create the polygon |