Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / oox / drawingml / shape.hxx
blobc98bf4e3f25422be3d97046c2b83d7cefe5acdd5
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 INCLUDED_OOX_DRAWINGML_SHAPE_HXX
21 #define INCLUDED_OOX_DRAWINGML_SHAPE_HXX
23 #include <map>
24 #include <memory>
25 #include <vector>
27 #include <com/sun/star/awt/Point.hpp>
28 #include <com/sun/star/awt/Size.hpp>
29 #include <com/sun/star/beans/PropertyValue.hpp>
30 #include <com/sun/star/uno/Reference.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <oox/dllapi.h>
33 #include <oox/drawingml/color.hxx>
34 #include <oox/drawingml/drawingmltypes.hxx>
35 #include <oox/helper/helper.hxx>
36 #include <oox/helper/propertymap.hxx>
37 #include <rtl/ustring.hxx>
38 #include <sal/types.h>
40 namespace basegfx { class B2DHomMatrix; }
42 namespace com { namespace sun { namespace star {
43 namespace awt { struct Rectangle; }
44 namespace drawing { class XShape; }
45 namespace drawing { class XShapes; }
46 namespace uno { class Any; }
47 } } }
49 namespace oox { namespace core {
50 class XmlFilterBase;
51 } }
53 namespace oox { namespace vml {
54 struct OleObjectInfo;
55 } }
57 namespace oox { namespace drawingml {
59 class Theme;
60 struct EffectProperties;
61 struct FillProperties;
62 struct GraphicProperties;
63 struct LineProperties;
64 struct Shape3DProperties;
66 class CustomShapeProperties;
67 typedef std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
69 typedef ::std::map< OUString, ShapePtr > ShapeIdMap;
71 struct ShapeStyleRef
73 Color maPhClr;
74 sal_Int32 mnThemedIdx;
75 ShapeStyleRef() : mnThemedIdx(0) {}
78 typedef ::std::map< sal_Int32, ShapeStyleRef > ShapeStyleRefMap;
80 /** Additional information for a chart embedded in a drawing shape. */
81 struct ChartShapeInfo
83 OUString maFragmentPath; ///< Path to related XML stream, e.g. for charts.
84 bool mbEmbedShapes; ///< True = load chart shapes into chart, false = load into parent drawpage.
86 explicit ChartShapeInfo( bool bEmbedShapes ) : mbEmbedShapes( bEmbedShapes ) {}
89 /// Attributes for a linked textbox.
90 struct LinkedTxbxAttr
92 sal_Int32 id;
93 sal_Int32 seq;
94 LinkedTxbxAttr(): id(0),seq(0){};
97 class OOX_DLLPUBLIC Shape
98 : public std::enable_shared_from_this< Shape >
100 public:
102 explicit Shape( const sal_Char* pServiceType = nullptr, bool bDefaultHeight = true );
103 explicit Shape( const ShapePtr& pSourceShape );
104 virtual ~Shape();
106 OUString& getServiceName(){ return msServiceName; }
107 void setServiceName( const sal_Char* pServiceName );
109 PropertyMap& getShapeProperties(){ return maShapeProperties; }
111 LineProperties& getLineProperties() { return *mpLinePropertiesPtr; }
112 const LineProperties& getLineProperties() const { return *mpLinePropertiesPtr; }
114 FillProperties& getFillProperties() { return *mpFillPropertiesPtr; }
115 const FillProperties& getFillProperties() const { return *mpFillPropertiesPtr; }
117 GraphicProperties& getGraphicProperties() { return *mpGraphicPropertiesPtr; }
118 const GraphicProperties& getGraphicProperties() const { return *mpGraphicPropertiesPtr; }
120 CustomShapePropertiesPtr& getCustomShapeProperties(){ return mpCustomShapePropertiesPtr; }
122 Shape3DProperties& get3DProperties() { return *mp3DPropertiesPtr; }
123 const Shape3DProperties& get3DProperties() const { return *mp3DPropertiesPtr; }
125 table::TablePropertiesPtr const & getTableProperties();
127 EffectProperties& getEffectProperties() const { return *mpEffectPropertiesPtr; }
129 void setChildPosition( css::awt::Point nPosition ){ maChPosition = nPosition; }
130 void setChildSize( css::awt::Size aSize ){ maChSize = aSize; }
132 void setPosition( css::awt::Point nPosition ){ maPosition = nPosition; }
133 const css::awt::Point& getPosition() const { return maPosition; }
135 void setSize( css::awt::Size aSize ){ maSize = aSize; }
136 const css::awt::Size& getSize() const { return maSize; }
138 void setRotation( sal_Int32 nRotation ) { mnRotation = nRotation; }
139 void setFlip( bool bFlipH, bool bFlipV ) { mbFlipH = bFlipH; mbFlipV = bFlipV; }
140 void applyParentTextFlipV(bool bTextFlipV) { mbInheritedTextFlipV = bTextFlipV; }
141 void addChild( const ShapePtr& rChildPtr ) { maChildren.push_back( rChildPtr ); }
142 std::vector< ShapePtr >& getChildren() { return maChildren; }
144 void setName( const OUString& rName ) { msName = rName; }
145 const OUString& getName( ) { return msName; }
146 void setId( const OUString& rId ) { msId = rId; }
147 const OUString& getId() { return msId; }
148 void setHidden( bool bHidden ) { mbHidden = bHidden; }
149 void setHiddenMasterShape( bool bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; }
150 void setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; }
151 sal_Int32 getSubType() const { return mnSubType; }
152 void setSubTypeIndex( sal_Int32 nSubTypeIndex ) { moSubTypeIndex = nSubTypeIndex; }
153 const OptValue< sal_Int32 >& getSubTypeIndex() const { return moSubTypeIndex; }
155 // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
156 void setDefaults(bool bHeight);
158 ::oox::vml::OleObjectInfo& setOleObjectType();
159 ChartShapeInfo& setChartType( bool bEmbedShapes );
160 void setDiagramType();
161 void setTableType();
163 void setTextBody(const TextBodyPtr & pTextBody);
164 const TextBodyPtr& getTextBody() { return mpTextBody;}
165 void setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle );
166 const TextListStylePtr& getMasterTextListStyle() const { return mpMasterTextListStyle; }
168 ShapeStyleRefMap& getShapeStyleRefs() { return maShapeStyleRefs; }
169 const ShapeStyleRefMap& getShapeStyleRefs() const { return maShapeStyleRefs; }
170 const ShapeStyleRef* getShapeStyleRef( sal_Int32 nRefType ) const;
172 // addShape is creating and inserting the corresponding XShape.
173 void addShape(
174 ::oox::core::XmlFilterBase& rFilterBase,
175 const Theme* pTheme,
176 const css::uno::Reference< css::drawing::XShapes >& rxShapes,
177 const basegfx::B2DHomMatrix& aTransformation,
178 FillProperties& rShapeOrParentShapeFillProps,
179 ShapeIdMap* pShapeMap = nullptr );
181 void addChildren(
182 ::oox::core::XmlFilterBase& rFilterBase,
183 const Theme* pTheme,
184 const css::uno::Reference< css::drawing::XShapes >& rxShapes,
185 basegfx::B2DHomMatrix& aTransformation );
187 void setXShape( const css::uno::Reference< css::drawing::XShape >& rXShape )
188 { mxShape = rXShape; };
189 const css::uno::Reference< css::drawing::XShape > &
190 getXShape() const { return mxShape; }
192 void applyShapeReference( const Shape& rReferencedShape, bool bUseText = true );
193 const ::std::vector<OUString>&
194 getExtDrawings() { return maExtDrawings; }
195 void addExtDrawingRelId( const OUString &rRelId ) { maExtDrawings.push_back( rRelId ); }
196 // Set font color only for extdrawings.
197 void setFontRefColorForNodes(const Color& rColor) { maFontRefColorForNodes = rColor; }
198 const Color& getFontRefColorForNodes() const { return maFontRefColorForNodes; }
199 void setLockedCanvas(bool bLockedCanvas);
200 bool getLockedCanvas() { return mbLockedCanvas;}
201 void setWps(bool bWps);
202 bool getWps() { return mbWps;}
203 void setTextBox(bool bTextBox);
204 const css::uno::Sequence<css::beans::PropertyValue> &
205 getDiagramDoms() { return maDiagramDoms; }
206 void setDiagramDoms(const css::uno::Sequence<css::beans::PropertyValue>& rDiagramDoms) { maDiagramDoms = rDiagramDoms; }
207 css::uno::Sequence< css::uno::Sequence< css::uno::Any > >resolveRelationshipsOfTypeFromOfficeDoc(
208 core::XmlFilterBase& rFilter, const OUString& sFragment, const OUString& sType );
209 void setLinkedTxbxAttributes(const LinkedTxbxAttr& rhs){ maLinkedTxbxAttr = rhs; };
210 void setTxbxHasLinkedTxtBox( const bool rhs){ mbHasLinkedTxbx = rhs; };
211 const LinkedTxbxAttr& getLinkedTxbxAttributes() { return maLinkedTxbxAttr; };
212 bool isLinkedTxbx() { return mbHasLinkedTxbx; };
214 protected:
216 css::uno::Reference< css::drawing::XShape > const &
217 createAndInsert(
218 ::oox::core::XmlFilterBase& rFilterBase,
219 const OUString& rServiceName,
220 const Theme* pTheme,
221 const css::uno::Reference< css::drawing::XShapes >& rxShapes,
222 bool bClearText,
223 bool bDoNotInsertEmptyTextBody,
224 basegfx::B2DHomMatrix& aTransformation,
225 FillProperties& rShapeOrParentShapeFillProps
228 void addChildren(
229 ::oox::core::XmlFilterBase& rFilterBase,
230 Shape& rMaster,
231 const Theme* pTheme,
232 const css::uno::Reference< css::drawing::XShapes >& rxShapes,
233 ShapeIdMap* pShapeMap,
234 const basegfx::B2DHomMatrix& aTransformation );
236 void keepDiagramCompatibilityInfo( ::oox::core::XmlFilterBase& rFilterBase );
238 css::uno::Reference< css::drawing::XShape >
239 renderDiagramToGraphic( ::oox::core::XmlFilterBase& rFilterBase );
241 OUString finalizeServiceName(
242 ::oox::core::XmlFilterBase& rFilter,
243 const OUString& rServiceName,
244 const css::awt::Rectangle& rShapeRect );
246 virtual void finalizeXShape(
247 ::oox::core::XmlFilterBase& rFilter,
248 const css::uno::Reference< css::drawing::XShapes >& rxShapes );
250 void putPropertyToGrabBag(
251 const OUString& sPropertyName, const css::uno::Any& aPropertyValue );
252 void putPropertyToGrabBag(
253 const css::beans::PropertyValue& pProperty );
254 void putPropertiesToGrabBag(
255 const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
257 FillProperties getActualFillProperties(const Theme* pTheme, const FillProperties* pParentShapeFillProps) const;
258 LineProperties getActualLineProperties(const Theme* pTheme) const;
259 EffectProperties getActualEffectProperties(const Theme* pTheme) const;
261 std::vector< ShapePtr > maChildren; // only used for group shapes
262 css::awt::Size maChSize; // only used for group shapes
263 css::awt::Point maChPosition; // only used for group shapes
265 TextBodyPtr mpTextBody;
266 LinePropertiesPtr mpLinePropertiesPtr;
267 LinePropertiesPtr mpShapeRefLinePropPtr;
268 FillPropertiesPtr mpFillPropertiesPtr;
269 FillPropertiesPtr mpShapeRefFillPropPtr;
270 GraphicPropertiesPtr mpGraphicPropertiesPtr;
271 CustomShapePropertiesPtr mpCustomShapePropertiesPtr;
272 table::TablePropertiesPtr mpTablePropertiesPtr;
273 Shape3DPropertiesPtr mp3DPropertiesPtr;
274 EffectPropertiesPtr mpEffectPropertiesPtr;
275 EffectPropertiesPtr mpShapeRefEffectPropPtr;
276 PropertyMap maShapeProperties;
277 PropertyMap maDefaultShapeProperties;
278 TextListStylePtr mpMasterTextListStyle;
279 css::uno::Reference< css::drawing::XShape > mxShape;
281 OUString msServiceName;
282 OUString msName;
283 OUString msId;
284 sal_Int32 mnSubType; // if this type is not zero, then the shape is a placeholder
285 OptValue< sal_Int32 > moSubTypeIndex;
287 ShapeStyleRefMap maShapeStyleRefs;
289 css::awt::Size maSize;
290 css::awt::Point maPosition;
291 ::std::vector<OUString> maExtDrawings;
292 Color maFontRefColorForNodes;
294 private:
295 enum FrameType
297 FRAMETYPE_GENERIC, ///< Generic shape, no special type.
298 FRAMETYPE_OLEOBJECT, ///< OLE object embedded in a shape.
299 FRAMETYPE_CHART, ///< Chart embedded in a shape.
300 FRAMETYPE_DIAGRAM, ///< Complex diagram drawing shape.
301 FRAMETYPE_TABLE ///< A table embedded in a shape.
304 typedef std::shared_ptr< ::oox::vml::OleObjectInfo > OleObjectInfoRef;
305 typedef std::shared_ptr< ChartShapeInfo > ChartShapeInfoRef;
307 FrameType meFrameType; ///< Type for graphic frame shapes.
308 OleObjectInfoRef mxOleObjectInfo; ///< Additional data for OLE objects.
309 ChartShapeInfoRef mxChartShapeInfo; ///< Additional data for chart shapes.
311 sal_Int32 mnRotation;
312 bool mbFlipH;
313 bool mbFlipV;
314 bool mbInheritedTextFlipV; // Used by group shapes only
315 bool mbHidden;
316 bool mbHiddenMasterShape; // master shapes can be hidden in layout slides
317 // we need separate flag because we don't want
318 // to propagate it when applying reference shape
319 bool mbLockedCanvas; ///< Is this shape part of a locked canvas?
320 bool mbWps; ///< Is this a wps shape?
321 bool mbTextBox; ///< This shape has a textbox.
322 LinkedTxbxAttr maLinkedTxbxAttr;
323 bool mbHasLinkedTxbx; // this text box has linked text box ?
325 css::uno::Sequence<css::beans::PropertyValue> maDiagramDoms;
330 #endif // INCLUDED_OOX_DRAWINGML_SHAPE_HXX
332 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */