update credits
[LibreOffice.git] / include / oox / drawingml / shape.hxx
blob94c8342ef46562d3a0ee3dadb5606f206b81fa67
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef OOX_DRAWINGML_SHAPE_HXX
21 #define OOX_DRAWINGML_SHAPE_HXX
23 #include "oox/helper/propertymap.hxx"
24 #include "oox/drawingml/drawingmltypes.hxx"
25 #include "oox/drawingml/customshapeproperties.hxx"
26 #include "oox/drawingml/textliststyle.hxx"
27 #include "oox/drawingml/shape3dproperties.hxx"
29 #include <com/sun/star/frame/XModel.hpp>
30 #include <com/sun/star/drawing/XDrawPage.hpp>
31 #include <boost/shared_ptr.hpp>
32 #include <boost/enable_shared_from_this.hpp>
33 #include <basegfx/matrix/b2dhommatrix.hxx>
34 #include <vector>
35 #include <map>
36 #include "oox/dllapi.h"
38 namespace oox { namespace vml {
39 struct OleObjectInfo;
40 } }
42 namespace oox { namespace drawingml {
44 class CustomShapeProperties;
45 typedef boost::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
47 typedef ::std::map< OUString, ShapePtr > ShapeIdMap;
49 struct ShapeStyleRef
51 Color maPhClr;
52 sal_Int32 mnThemedIdx;
55 typedef ::std::map< sal_Int32, ShapeStyleRef > ShapeStyleRefMap;
57 // ============================================================================
59 /** Additional information for a chart embedded in a drawing shape. */
60 struct ChartShapeInfo
62 OUString maFragmentPath; ///< Path to related XML stream, e.g. for charts.
63 bool mbEmbedShapes; ///< True = load chart shapes into chart, false = load into parent drawpage.
65 inline explicit ChartShapeInfo( bool bEmbedShapes ) : mbEmbedShapes( bEmbedShapes ) {}
68 // ============================================================================
70 class OOX_DLLPUBLIC Shape
71 : public boost::enable_shared_from_this< Shape >
73 public:
75 explicit Shape( const sal_Char* pServiceType = 0 );
76 explicit Shape( const ShapePtr& pSourceShape );
77 virtual ~Shape();
79 OUString& getServiceName(){ return msServiceName; }
80 void setServiceName( const sal_Char* pServiceName );
82 PropertyMap& getShapeProperties(){ return maShapeProperties; }
84 inline LineProperties& getLineProperties() { return *mpLinePropertiesPtr; }
85 inline const LineProperties& getLineProperties() const { return *mpLinePropertiesPtr; }
87 inline FillProperties& getFillProperties() { return *mpFillPropertiesPtr; }
88 inline const FillProperties& getFillProperties() const { return *mpFillPropertiesPtr; }
90 inline GraphicProperties& getGraphicProperties() { return *mpGraphicPropertiesPtr; }
91 inline const GraphicProperties& getGraphicProperties() const { return *mpGraphicPropertiesPtr; }
93 CustomShapePropertiesPtr getCustomShapeProperties(){ return mpCustomShapePropertiesPtr; }
95 Shape3DProperties& get3DProperties() { return *mp3DPropertiesPtr; }
96 const Shape3DProperties& get3DProperties() const { return *mp3DPropertiesPtr; }
98 table::TablePropertiesPtr getTableProperties();
100 inline EffectProperties& getEffectProperties() { return *mpEffectPropertiesPtr; }
102 void setChildPosition( com::sun::star::awt::Point nPosition ){ maChPosition = nPosition; }
103 void setChildSize( com::sun::star::awt::Size aSize ){ maChSize = aSize; }
104 void moveAllToPosition( const com::sun::star::awt::Point &rPoint );
106 void setPosition( com::sun::star::awt::Point nPosition ){ maPosition = nPosition; }
107 const com::sun::star::awt::Point& getPosition() const { return maPosition; }
109 void setSize( com::sun::star::awt::Size aSize ){ maSize = aSize; }
110 const com::sun::star::awt::Size& getSize() const { return maSize; }
112 void setRotation( sal_Int32 nRotation ) { mnRotation = nRotation; }
113 void setFlip( sal_Bool bFlipH, sal_Bool bFlipV ) { mbFlipH = bFlipH; mbFlipV = bFlipV; }
114 void addChild( const ShapePtr pChildPtr ) { maChildren.push_back( pChildPtr ); }
115 std::vector< ShapePtr >& getChildren() { return maChildren; }
117 void setName( const OUString& rName ) { msName = rName; }
118 OUString getName( ) { return msName; }
119 void setId( const OUString& rId ) { msId = rId; }
120 OUString getId() { return msId; }
121 void setHidden( sal_Bool bHidden ) { mbHidden = bHidden; }
122 sal_Bool getHidden() const { return mbHidden; };
123 void setHiddenMasterShape( sal_Bool bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; }
124 void setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; }
125 sal_Int32 getSubType() const { return mnSubType; }
126 void setSubTypeIndex( sal_Int32 nSubTypeIndex ) { moSubTypeIndex = nSubTypeIndex; }
127 const OptValue< sal_Int32 >& getSubTypeIndex() const { return moSubTypeIndex; }
129 // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
130 void setDefaults();
132 ::oox::vml::OleObjectInfo& setOleObjectType();
133 ChartShapeInfo& setChartType( bool bEmbedShapes );
134 void setDiagramType();
135 void setTableType();
137 void setTextBody(const TextBodyPtr & pTextBody);
138 TextBodyPtr getTextBody();
139 void setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle );
140 TextListStylePtr getMasterTextListStyle() const { return mpMasterTextListStyle; }
142 inline ShapeStyleRefMap& getShapeStyleRefs() { return maShapeStyleRefs; }
143 inline const ShapeStyleRefMap& getShapeStyleRefs() const { return maShapeStyleRefs; }
144 const ShapeStyleRef* getShapeStyleRef( sal_Int32 nRefType ) const;
146 // addShape is creating and inserting the corresponding XShape.
147 void addShape(
148 ::oox::core::XmlFilterBase& rFilterBase,
149 const Theme* pTheme,
150 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
151 basegfx::B2DHomMatrix& aTransformation,
152 FillProperties& rShapeOrParentShapeFillProps,
153 const ::com::sun::star::awt::Rectangle* pShapeRect = 0,
154 ShapeIdMap* pShapeMap = 0 );
156 void dropChildren() { maChildren.clear(); }
158 void addChildren(
159 ::oox::core::XmlFilterBase& rFilterBase,
160 const Theme* pTheme,
161 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
162 basegfx::B2DHomMatrix& aTransformation,
163 const ::com::sun::star::awt::Rectangle* pShapeRect = 0,
164 ShapeIdMap* pShapeMap = 0 );
166 void setXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rXShape )
167 { mxShape = rXShape; };
168 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > &
169 getXShape() const { return mxShape; }
171 virtual void applyShapeReference( const Shape& rReferencedShape, bool bUseText = true );
172 const ::std::vector<OUString>&
173 getExtDrawings() { return maExtDrawings; }
174 void addExtDrawingRelId( const OUString &rRelId ) { maExtDrawings.push_back( rRelId ); }
175 void setLockedCanvas(bool bLockedCanvas);
176 bool getLockedCanvas();
178 protected:
180 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
181 createAndInsert(
182 ::oox::core::XmlFilterBase& rFilterBase,
183 const OUString& rServiceName,
184 const Theme* pTheme,
185 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
186 const ::com::sun::star::awt::Rectangle* pShapeRect,
187 sal_Bool bClearText,
188 sal_Bool bDoNotInsertEmptyTextBody,
189 basegfx::B2DHomMatrix& aTransformation,
190 FillProperties& rShapeOrParentShapeFillProps
193 void addChildren(
194 ::oox::core::XmlFilterBase& rFilterBase,
195 Shape& rMaster,
196 const Theme* pTheme,
197 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
198 const ::com::sun::star::awt::Rectangle& rClientRect,
199 ShapeIdMap* pShapeMap,
200 basegfx::B2DHomMatrix& aTransformation );
202 virtual OUString finalizeServiceName(
203 ::oox::core::XmlFilterBase& rFilter,
204 const OUString& rServiceName,
205 const ::com::sun::star::awt::Rectangle& rShapeRect );
207 virtual void finalizeXShape(
208 ::oox::core::XmlFilterBase& rFilter,
209 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes );
211 std::vector< ShapePtr > maChildren; // only used for group shapes
212 com::sun::star::awt::Size maChSize; // only used for group shapes
213 com::sun::star::awt::Point maChPosition; // only used for group shapes
214 com::sun::star::awt::Size maAbsoluteSize; // only used for group shapes
215 com::sun::star::awt::Point maAbsolutePosition; // only used for group shapes
216 sal_Bool mbIsChild;
218 TextBodyPtr mpTextBody;
219 LinePropertiesPtr mpLinePropertiesPtr;
220 FillPropertiesPtr mpFillPropertiesPtr;
221 GraphicPropertiesPtr mpGraphicPropertiesPtr;
222 CustomShapePropertiesPtr mpCustomShapePropertiesPtr;
223 table::TablePropertiesPtr mpTablePropertiesPtr;
224 Shape3DPropertiesPtr mp3DPropertiesPtr;
225 EffectPropertiesPtr mpEffectPropertiesPtr;
226 PropertyMap maShapeProperties;
227 PropertyMap maDefaultShapeProperties;
228 TextListStylePtr mpMasterTextListStyle;
229 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape;
231 OUString msServiceName;
232 OUString msName;
233 OUString msId;
234 sal_Int32 mnSubType; // if this type is not zero, then the shape is a placeholder
235 OptValue< sal_Int32 > moSubTypeIndex;
237 ShapeStyleRefMap maShapeStyleRefs;
239 com::sun::star::awt::Size maSize;
240 com::sun::star::awt::Point maPosition;
241 ::std::vector<OUString> maExtDrawings;
243 private:
244 enum FrameType
246 FRAMETYPE_GENERIC, ///< Generic shape, no special type.
247 FRAMETYPE_OLEOBJECT, ///< OLE object embedded in a shape.
248 FRAMETYPE_CHART, ///< Chart embedded in a shape.
249 FRAMETYPE_DIAGRAM, ///< Complex diagram drawing shape.
250 FRAMETYPE_TABLE ///< A table embedded in a shape.
253 typedef ::boost::shared_ptr< ::oox::vml::OleObjectInfo > OleObjectInfoRef;
254 typedef ::boost::shared_ptr< ChartShapeInfo > ChartShapeInfoRef;
256 FrameType meFrameType; ///< Type for graphic frame shapes.
257 OleObjectInfoRef mxOleObjectInfo; ///< Additional data for OLE objects.
258 ChartShapeInfoRef mxChartShapeInfo; ///< Additional data for chart shapes.
260 sal_Int32 mnRotation;
261 sal_Bool mbFlipH;
262 sal_Bool mbFlipV;
263 sal_Bool mbHidden;
264 sal_Bool mbHiddenMasterShape; // master shapes can be hidden in layout slides
265 // we need separate flag because we don't want
266 // to propagate it when applying reference shape
267 bool mbLockedCanvas; ///< Is this shape part of a locked canvas?
270 // ============================================================================
274 #endif // OOX_DRAWINGML_SHAPE_HXX
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */