1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX 25 #define OOX_DRAWINGML_SHAPEPROPERTYMAP_HXX 26 27 #include "oox/helper/propertymap.hxx" 28 29 namespace oox { class ModelObjectHelper; } 30 31 namespace oox { 32 namespace drawingml { 33 34 // ============================================================================ 35 36 /** Enumeration for various properties related to drawing shape formatting. 37 38 This is an abstraction for shape formatting properties that have different 39 names in various implementations, e.g. drawing shapes vs. chart objects. 40 */ 41 enum ShapePropertyId 42 { 43 SHAPEPROP_LineStyle, 44 SHAPEPROP_LineWidth, 45 SHAPEPROP_LineColor, 46 SHAPEPROP_LineTransparency, 47 SHAPEPROP_LineDash, /// Explicit line dash or name of a line dash stored in a global container. 48 SHAPEPROP_LineJoint, 49 SHAPEPROP_LineStart, /// Explicit line start marker or name of a line marker stored in a global container. 50 SHAPEPROP_LineStartWidth, 51 SHAPEPROP_LineStartCenter, 52 SHAPEPROP_LineEnd, /// Explicit line end marker or name of a line marker stored in a global container. 53 SHAPEPROP_LineEndWidth, 54 SHAPEPROP_LineEndCenter, 55 SHAPEPROP_FillStyle, 56 SHAPEPROP_FillColor, 57 SHAPEPROP_FillTransparency, 58 SHAPEPROP_FillGradient, /// Explicit fill gradient or name of a fill gradient stored in a global container. 59 SHAPEPROP_FillBitmapUrl, /// Explicit fill bitmap URL or name of a fill bitmap URL stored in a global container. 60 SHAPEPROP_FillBitmapMode, 61 SHAPEPROP_FillBitmapSizeX, 62 SHAPEPROP_FillBitmapSizeY, 63 SHAPEPROP_FillBitmapOffsetX, 64 SHAPEPROP_FillBitmapOffsetY, 65 SHAPEPROP_FillBitmapRectanglePoint, 66 SHAPEPROP_END 67 }; 68 69 // ============================================================================ 70 71 struct ShapePropertyInfo 72 { 73 const sal_Int32* mpnPropertyIds; /// Pointer to array of property identifiers for all SHAPEPROP properties. 74 bool mbNamedLineMarker; /// True = use named line marker instead of explicit line marker. 75 bool mbNamedLineDash; /// True = use named line dash instead of explicit line dash. 76 bool mbNamedFillGradient; /// True = use named fill gradient instead of explicit fill gradient. 77 bool mbNamedFillBitmapUrl; /// True = use named fill bitmap URL instead of explicit fill bitmap URL. 78 79 static ShapePropertyInfo DEFAULT; /// Default property info (used as default parameter of other methods). 80 81 explicit ShapePropertyInfo( 82 const sal_Int32* pnPropertyIds, 83 bool bNamedLineMarker, 84 bool bNamedLineDash, 85 bool bNamedFillGradient, 86 bool bNamedFillBitmapUrl ); 87 hasoox::drawingml::ShapePropertyInfo88 inline bool has( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ] >= 0; } operator []oox::drawingml::ShapePropertyInfo89 inline sal_Int32 operator[]( ShapePropertyId ePropId ) const { return mpnPropertyIds[ ePropId ]; } 90 }; 91 92 // ============================================================================ 93 94 class ShapePropertyMap : public PropertyMap 95 { 96 public: 97 explicit ShapePropertyMap( 98 ModelObjectHelper& rModelObjHelper, 99 const ShapePropertyInfo& rShapePropInfo = ShapePropertyInfo::DEFAULT ); 100 101 /** Returns true, if the specified property is supported. */ 102 bool supportsProperty( ShapePropertyId ePropId ) const; 103 104 /** Returns true, if named line markers are supported, and the specified 105 line marker has already been inserted into the marker table. */ 106 bool hasNamedLineMarkerInTable( const ::rtl::OUString& rMarkerName ) const; 107 108 /** Sets the specified shape property to the passed value. */ 109 bool setAnyProperty( ShapePropertyId ePropId, const ::com::sun::star::uno::Any& rValue ); 110 111 /** Sets the specified shape property to the passed value. */ 112 template< typename Type > setProperty(ShapePropertyId ePropId,const Type & rValue)113 inline bool setProperty( ShapePropertyId ePropId, const Type& rValue ) 114 { return setAnyProperty( ePropId, ::com::sun::star::uno::Any( rValue ) ); } 115 116 using PropertyMap::setAnyProperty; 117 using PropertyMap::setProperty; 118 using PropertyMap::operator[]; 119 120 private: 121 /** Sets an explicit line marker, or creates a named line marker. */ 122 bool setLineMarker( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); 123 /** Sets an explicit line dash, or creates a named line dash. */ 124 bool setLineDash( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); 125 /** Sets an explicit fill gradient, or creates a named fill gradient. */ 126 bool setFillGradient( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); 127 /** Sets an explicit fill bitmap URL, or creates a named fill bitmap URL. */ 128 bool setFillBitmapUrl( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); 129 130 // not implemented, to prevent implicit conversion from enum to int 131 ::com::sun::star::uno::Any& operator[]( ShapePropertyId ePropId ); 132 const ::com::sun::star::uno::Any& operator[]( ShapePropertyId ePropId ) const; 133 134 private: 135 ModelObjectHelper& mrModelObjHelper; 136 ShapePropertyInfo maShapePropInfo; 137 }; 138 139 // ============================================================================ 140 141 } // namespace drawingml 142 } // namespace oox 143 144 #endif 145