1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <oox/helper/propertymap.hxx>
24 #include <oox/core/xmlfilterbase.hxx>
25 #include <oox/drawingml/color.hxx>
26 #include <oox/drawingml/drawingmltypes.hxx>
28 #include <com/sun/star/frame/XModel.hpp>
29 #include <com/sun/star/drawing/XDrawPage.hpp>
31 #include <basegfx/matrix/b2dhommatrix.hxx>
34 #include <oox/dllapi.h>
36 namespace oox
{ namespace vml
{
40 namespace oox
{ namespace drawingml
{
42 class CustomShapeProperties
;
43 typedef std::shared_ptr
< CustomShapeProperties
> CustomShapePropertiesPtr
;
45 typedef ::std::map
< OUString
, ShapePtr
> ShapeIdMap
;
50 sal_Int32 mnThemedIdx
;
51 ShapeStyleRef() : mnThemedIdx(0) {}
54 typedef ::std::map
< sal_Int32
, ShapeStyleRef
> ShapeStyleRefMap
;
56 /** Additional information for a chart embedded in a drawing shape. */
59 OUString maFragmentPath
; ///< Path to related XML stream, e.g. for charts.
60 bool mbEmbedShapes
; ///< True = load chart shapes into chart, false = load into parent drawpage.
62 explicit ChartShapeInfo( bool bEmbedShapes
) : mbEmbedShapes( bEmbedShapes
) {}
65 /// Attributes for a linked textbox.
70 LinkedTxbxAttr(): id(0),seq(0){};
74 class OOX_DLLPUBLIC Shape
75 : public std::enable_shared_from_this
< Shape
>
79 explicit Shape( const sal_Char
* pServiceType
= 0, bool bDefaultHeight
= true );
80 explicit Shape( const ShapePtr
& pSourceShape
);
83 OUString
& getServiceName(){ return msServiceName
; }
84 void setServiceName( const sal_Char
* pServiceName
);
86 PropertyMap
& getShapeProperties(){ return maShapeProperties
; }
88 LineProperties
& getLineProperties() { return *mpLinePropertiesPtr
; }
89 const LineProperties
& getLineProperties() const { return *mpLinePropertiesPtr
; }
91 FillProperties
& getFillProperties() { return *mpFillPropertiesPtr
; }
92 const FillProperties
& getFillProperties() const { return *mpFillPropertiesPtr
; }
94 GraphicProperties
& getGraphicProperties() { return *mpGraphicPropertiesPtr
; }
95 const GraphicProperties
& getGraphicProperties() const { return *mpGraphicPropertiesPtr
; }
97 CustomShapePropertiesPtr
getCustomShapeProperties(){ return mpCustomShapePropertiesPtr
; }
99 Shape3DProperties
& get3DProperties() { return *mp3DPropertiesPtr
; }
100 const Shape3DProperties
& get3DProperties() const { return *mp3DPropertiesPtr
; }
102 table::TablePropertiesPtr
getTableProperties();
104 EffectProperties
& getEffectProperties() { return *mpEffectPropertiesPtr
; }
106 void setChildPosition( com::sun::star::awt::Point nPosition
){ maChPosition
= nPosition
; }
107 void setChildSize( com::sun::star::awt::Size aSize
){ maChSize
= aSize
; }
109 void setPosition( com::sun::star::awt::Point nPosition
){ maPosition
= nPosition
; }
110 const com::sun::star::awt::Point
& getPosition() const { return maPosition
; }
112 void setSize( com::sun::star::awt::Size aSize
){ maSize
= aSize
; }
113 const com::sun::star::awt::Size
& getSize() const { return maSize
; }
115 void setRotation( sal_Int32 nRotation
) { mnRotation
= nRotation
; }
116 void setFlip( bool bFlipH
, bool bFlipV
) { mbFlipH
= bFlipH
; mbFlipV
= bFlipV
; }
117 void addChild( const ShapePtr
& rChildPtr
) { maChildren
.push_back( rChildPtr
); }
118 std::vector
< ShapePtr
>& getChildren() { return maChildren
; }
120 void setName( const OUString
& rName
) { msName
= rName
; }
121 OUString
getName( ) { return msName
; }
122 void setId( const OUString
& rId
) { msId
= rId
; }
123 OUString
getId() { return msId
; }
124 void setHidden( bool bHidden
) { mbHidden
= bHidden
; }
125 bool getHidden() const { return mbHidden
; };
126 void setHiddenMasterShape( bool bHiddenMasterShape
) { mbHiddenMasterShape
= bHiddenMasterShape
; }
127 void setSubType( sal_Int32 nSubType
) { mnSubType
= nSubType
; }
128 sal_Int32
getSubType() const { return mnSubType
; }
129 void setSubTypeIndex( sal_Int32 nSubTypeIndex
) { moSubTypeIndex
= nSubTypeIndex
; }
130 const OptValue
< sal_Int32
>& getSubTypeIndex() const { return moSubTypeIndex
; }
132 // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
133 void setDefaults(bool bHeight
);
135 ::oox::vml::OleObjectInfo
& setOleObjectType();
136 ChartShapeInfo
& setChartType( bool bEmbedShapes
);
137 void setDiagramType();
140 void setTextBody(const TextBodyPtr
& pTextBody
);
141 TextBodyPtr
getTextBody() { return mpTextBody
;}
142 void setMasterTextListStyle( const TextListStylePtr
& pMasterTextListStyle
);
143 TextListStylePtr
getMasterTextListStyle() const { return mpMasterTextListStyle
; }
145 ShapeStyleRefMap
& getShapeStyleRefs() { return maShapeStyleRefs
; }
146 const ShapeStyleRefMap
& getShapeStyleRefs() const { return maShapeStyleRefs
; }
147 const ShapeStyleRef
* getShapeStyleRef( sal_Int32 nRefType
) const;
149 // addShape is creating and inserting the corresponding XShape.
151 ::oox::core::XmlFilterBase
& rFilterBase
,
153 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& rxShapes
,
154 const basegfx::B2DHomMatrix
& aTransformation
,
155 FillProperties
& rShapeOrParentShapeFillProps
,
156 const ::com::sun::star::awt::Rectangle
* pShapeRect
= 0,
157 ShapeIdMap
* pShapeMap
= 0 );
159 void dropChildren() { maChildren
.clear(); }
162 ::oox::core::XmlFilterBase
& rFilterBase
,
164 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& rxShapes
,
165 basegfx::B2DHomMatrix
& aTransformation
,
166 const ::com::sun::star::awt::Rectangle
* pShapeRect
= 0,
167 ShapeIdMap
* pShapeMap
= 0 );
169 void setXShape( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& rXShape
)
170 { mxShape
= rXShape
; };
171 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> &
172 getXShape() const { return mxShape
; }
174 virtual void applyShapeReference( const Shape
& rReferencedShape
, bool bUseText
= true );
175 const ::std::vector
<OUString
>&
176 getExtDrawings() { return maExtDrawings
; }
177 void addExtDrawingRelId( const OUString
&rRelId
) { maExtDrawings
.push_back( rRelId
); }
178 // Set font color only for extdrawings.
179 void setFontRefColorForNodes(const Color
& rColor
) { maFontRefColorForNodes
= rColor
; }
180 const Color
& getFontRefColorForNodes() const { return maFontRefColorForNodes
; }
181 void setLockedCanvas(bool bLockedCanvas
);
182 bool getLockedCanvas() { return mbLockedCanvas
;}
183 void setWps(bool bWps
);
184 bool getWps() { return mbWps
;}
185 void setTextBox(bool bTextBox
);
186 const com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
> &
187 getDiagramDoms() { return maDiagramDoms
; }
188 void setDiagramDoms(const com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& rDiagramDoms
) { maDiagramDoms
= rDiagramDoms
; }
189 com::sun::star::uno::Sequence
< com::sun::star::uno::Sequence
< com::sun::star::uno::Any
> >resolveRelationshipsOfTypeFromOfficeDoc(
190 core::XmlFilterBase
& rFilter
, const OUString
& sFragment
, const OUString
& sType
);
191 void setLinkedTxbxAttributes(const LinkedTxbxAttr
& rhs
){ maLinkedTxbxAttr
= rhs
; };
192 void setTxbxHasLinkedTxtBox( const bool rhs
){ mbHasLinkedTxbx
= rhs
; };
193 const LinkedTxbxAttr
& getLinkedTxbxAttributes() { return maLinkedTxbxAttr
; };
194 bool isLinkedTxbx() { return mbHasLinkedTxbx
; };
198 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
200 ::oox::core::XmlFilterBase
& rFilterBase
,
201 const OUString
& rServiceName
,
203 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& rxShapes
,
204 const ::com::sun::star::awt::Rectangle
* pShapeRect
,
206 bool bDoNotInsertEmptyTextBody
,
207 basegfx::B2DHomMatrix
& aTransformation
,
208 FillProperties
& rShapeOrParentShapeFillProps
212 ::oox::core::XmlFilterBase
& rFilterBase
,
215 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& rxShapes
,
216 const ::com::sun::star::awt::Rectangle
& rClientRect
,
217 ShapeIdMap
* pShapeMap
,
218 const basegfx::B2DHomMatrix
& aTransformation
);
220 void keepDiagramCompatibilityInfo( ::oox::core::XmlFilterBase
& rFilterBase
);
222 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
223 renderDiagramToGraphic( ::oox::core::XmlFilterBase
& rFilterBase
);
225 OUString
finalizeServiceName(
226 ::oox::core::XmlFilterBase
& rFilter
,
227 const OUString
& rServiceName
,
228 const ::com::sun::star::awt::Rectangle
& rShapeRect
);
230 virtual void finalizeXShape(
231 ::oox::core::XmlFilterBase
& rFilter
,
232 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& rxShapes
);
234 void putPropertyToGrabBag(
235 const OUString
& sPropertyName
, const ::com::sun::star::uno::Any
& aPropertyValue
);
236 void putPropertyToGrabBag(
237 const ::com::sun::star::beans::PropertyValue
& pProperty
);
238 void putPropertiesToGrabBag(
239 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aProperties
);
241 std::vector
< ShapePtr
> maChildren
; // only used for group shapes
242 com::sun::star::awt::Size maChSize
; // only used for group shapes
243 com::sun::star::awt::Point maChPosition
; // only used for group shapes
246 TextBodyPtr mpTextBody
;
247 LinePropertiesPtr mpLinePropertiesPtr
;
248 LinePropertiesPtr mpShapeRefLinePropPtr
;
249 FillPropertiesPtr mpFillPropertiesPtr
;
250 FillPropertiesPtr mpShapeRefFillPropPtr
;
251 GraphicPropertiesPtr mpGraphicPropertiesPtr
;
252 CustomShapePropertiesPtr mpCustomShapePropertiesPtr
;
253 table::TablePropertiesPtr mpTablePropertiesPtr
;
254 Shape3DPropertiesPtr mp3DPropertiesPtr
;
255 EffectPropertiesPtr mpEffectPropertiesPtr
;
256 EffectPropertiesPtr mpShapeRefEffectPropPtr
;
257 PropertyMap maShapeProperties
;
258 PropertyMap maDefaultShapeProperties
;
259 TextListStylePtr mpMasterTextListStyle
;
260 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> mxShape
;
262 OUString msServiceName
;
265 sal_Int32 mnSubType
; // if this type is not zero, then the shape is a placeholder
266 OptValue
< sal_Int32
> moSubTypeIndex
;
268 ShapeStyleRefMap maShapeStyleRefs
;
270 com::sun::star::awt::Size maSize
;
271 com::sun::star::awt::Point maPosition
;
272 ::std::vector
<OUString
> maExtDrawings
;
273 Color maFontRefColorForNodes
;
278 FRAMETYPE_GENERIC
, ///< Generic shape, no special type.
279 FRAMETYPE_OLEOBJECT
, ///< OLE object embedded in a shape.
280 FRAMETYPE_CHART
, ///< Chart embedded in a shape.
281 FRAMETYPE_DIAGRAM
, ///< Complex diagram drawing shape.
282 FRAMETYPE_TABLE
///< A table embedded in a shape.
285 typedef std::shared_ptr
< ::oox::vml::OleObjectInfo
> OleObjectInfoRef
;
286 typedef std::shared_ptr
< ChartShapeInfo
> ChartShapeInfoRef
;
288 FrameType meFrameType
; ///< Type for graphic frame shapes.
289 OleObjectInfoRef mxOleObjectInfo
; ///< Additional data for OLE objects.
290 ChartShapeInfoRef mxChartShapeInfo
; ///< Additional data for chart shapes.
292 sal_Int32 mnRotation
;
296 bool mbHiddenMasterShape
; // master shapes can be hidden in layout slides
297 // we need separate flag because we don't want
298 // to propagate it when applying reference shape
299 bool mbLockedCanvas
; ///< Is this shape part of a locked canvas?
300 bool mbWps
; ///< Is this a wps shape?
301 bool mbTextBox
; ///< This shape has a textbox.
302 LinkedTxbxAttr maLinkedTxbxAttr
;
303 bool mbHasLinkedTxbx
; // this text box has linked text box ?
305 com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
> maDiagramDoms
;
310 #endif // INCLUDED_OOX_DRAWINGML_SHAPE_HXX
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */