update credits
[LibreOffice.git] / include / oox / vml / vmlshape.hxx
blob0312ec1a17c9bbe312308f031720461880a964ad
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_VML_VMLSHAPE_HXX
21 #define OOX_VML_VMLSHAPE_HXX
23 #include <memory>
24 #include <vector>
25 #include <com/sun/star/awt/Point.hpp>
26 #include "oox/vml/vmlformatting.hxx"
27 #include "oox/vml/vmltextbox.hxx"
28 #include "oox/dllapi.h"
30 namespace com { namespace sun { namespace star {
31 namespace awt { struct Rectangle; }
32 namespace drawing { class XShape; }
33 namespace drawing { class XShapes; }
34 } } }
36 namespace oox {
37 namespace vml {
39 class Drawing;
40 struct ShapeParentAnchor;
41 class ShapeContainer;
43 // ============================================================================
45 const sal_Int32 VML_CLIENTDATA_UNCHECKED = 0;
46 const sal_Int32 VML_CLIENTDATA_CHECKED = 1;
47 const sal_Int32 VML_CLIENTDATA_MIXED = 2;
49 const sal_Int32 VML_CLIENTDATA_TEXT = 0;
50 const sal_Int32 VML_CLIENTDATA_INTEGER = 1;
51 const sal_Int32 VML_CLIENTDATA_NUMBER = 2;
52 const sal_Int32 VML_CLIENTDATA_REFERENCE = 3;
53 const sal_Int32 VML_CLIENTDATA_FORMULA = 4;
55 // ============================================================================
57 /** The shape model structure contains all properties shared by all types of shapes. */
58 struct OOX_DLLPUBLIC ShapeTypeModel
60 OUString maShapeId; ///< Unique identifier of the shape.
61 OUString maShapeName; ///< Name of the shape, if present.
62 OptValue< sal_Int32 > moShapeType; ///< Builtin shape type identifier.
64 OptValue< Int32Pair > moCoordPos; ///< Top-left position of coordinate system for children scaling.
65 OptValue< Int32Pair > moCoordSize; ///< Size of coordinate system for children scaling.
66 OUString maPosition; ///< Position type of the shape.
67 OUString maLeft; ///< X position of the shape bounding box (number with unit).
68 OUString maTop; ///< Y position of the shape bounding box (number with unit).
69 OUString maWidth; ///< Width of the shape bounding box (number with unit).
70 OUString maHeight; ///< Height of the shape bounding box (number with unit).
71 OUString maMarginLeft; ///< X position of the shape bounding box to shape anchor (number with unit).
72 OUString maMarginTop; ///< Y position of the shape bounding box to shape anchor (number with unit).
73 OUString maPositionHorizontalRelative; ///< The X position is relative to this.
74 OUString maPositionVerticalRelative; ///< The Y position is relative to this.
75 OUString maPositionHorizontal; ///< The X position orientation (default: absolute).
76 OUString maPositionVertical; ///< The Y position orientation.
77 OUString maWidthPercent; ///< The width in percents of the WidthRelative
78 OUString maHeightPercent; ///< The height in percents of the HeightRelative
79 OUString maWidthRelative; ///< To what the width is relative
80 OUString maHeightRelative; ///< To what the height is relative
81 OUString maRotation; ///< Rotation of the shape, in degrees.
82 OUString maFlip; ///< Flip type of the shape (can be "x" or "y").
83 sal_Bool mbAutoHeight; ///< If true, the height value is a minimum value (mostly used for textboxes)
84 sal_Bool mbVisible; ///< Visible or Hidden
85 OUString maWrapStyle; ///< Wrapping mode for text.
86 OUString maArcsize; ///< round rectangles arc size
88 StrokeModel maStrokeModel; ///< Border line formatting.
89 FillModel maFillModel; ///< Shape fill formatting.
90 ShadowModel maShadowModel; ///< Shape shadow formatting.
91 TextpathModel maTextpathModel; ///< Shape textpath formatting.
93 OptValue< OUString > moGraphicPath; ///< Path to a graphic for this shape.
94 OptValue< OUString > moGraphicTitle; ///< Title of the graphic.
95 OptValue< OUString > moWrapAnchorX; ///< The base object from which our horizontal positioning should be calculated.
96 OptValue< OUString > moWrapAnchorY; ///< The base object from which our vertical positioning should be calculated.
97 OptValue< ::rtl::OUString > moWrapType; ///< How to wrap the text around the object
98 OptValue< ::rtl::OUString > moWrapSide; ///< On which side to wrap the text around the object
99 OUString maVTextAnchor; ///< How the text inside the shape is anchored vertically.
101 explicit ShapeTypeModel();
103 void assignUsed( const ShapeTypeModel& rSource );
106 // ----------------------------------------------------------------------------
108 /** A shape template contains all formatting properties of shapes and can serve
109 as templates for several shapes in a drawing. */
110 class ShapeType
112 public:
113 explicit ShapeType( Drawing& rDrawing );
114 virtual ~ShapeType();
116 /** Returns read/write access to the shape template model structure. */
117 inline ShapeTypeModel& getTypeModel() { return maTypeModel; }
118 /** Returns read access to the shape template model structure. */
119 inline const ShapeTypeModel& getTypeModel() const { return maTypeModel; }
121 /** Returns the shape identifier (which is unique through the containing drawing). */
122 inline const OUString& getShapeId() const { return maTypeModel.maShapeId; }
123 /** Returns the application defined shape type. */
124 sal_Int32 getShapeType() const;
125 /** Returns the fragment path to the embedded graphic used by this shape. */
126 OUString getGraphicPath() const;
128 const Drawing& getDrawing() const { return mrDrawing; }
130 protected:
131 /** Returns the coordinate system of this shape. */
132 ::com::sun::star::awt::Rectangle getCoordSystem() const;
133 /** Returns the absolute shape rectangle according to the passed anchor. */
134 ::com::sun::star::awt::Rectangle getRectangle( const ShapeParentAnchor* pParentAnchor ) const;
135 /** Returns the absolute shape rectangle. */
136 virtual ::com::sun::star::awt::Rectangle getAbsRectangle() const;
137 /** Returns the rectangle relative to the parent coordinate system. */
138 virtual ::com::sun::star::awt::Rectangle getRelRectangle() const;
140 protected:
141 Drawing& mrDrawing; ///< The VML drawing page that contains this shape.
142 ShapeTypeModel maTypeModel; ///< The model structure containing shape type data.
145 // ============================================================================
147 /** Excel specific shape client data (such as cell anchor). */
148 struct ClientData
150 OUString maAnchor; ///< Cell anchor as comma-separated string.
151 OUString maFmlaMacro; ///< Link to macro associated to the control.
152 OUString maFmlaPict; ///< Target cell range of picture links.
153 OUString maFmlaLink; ///< Link to value cell associated to the control.
154 OUString maFmlaRange; ///< Link to cell range used as data source for the control.
155 OUString maFmlaGroup; ///< Link to value cell associated to a group of option buttons.
156 sal_Int32 mnObjType; ///< Type of the shape.
157 sal_Int32 mnTextHAlign; ///< Horizontal text alignment.
158 sal_Int32 mnTextVAlign; ///< Vertical text alignment.
159 sal_Int32 mnCol; ///< Column index for spreadsheet cell note.
160 sal_Int32 mnRow; ///< Row index for spreadsheet cell note.
161 sal_Int32 mnChecked; ///< State for checkboxes and option buttons.
162 sal_Int32 mnDropStyle; ///< Drop down box style (read-only or editable).
163 sal_Int32 mnDropLines; ///< Number of lines in drop down box.
164 sal_Int32 mnVal; ///< Current value of spin buttons and scroll bars.
165 sal_Int32 mnMin; ///< Minimum value of spin buttons and scroll bars.
166 sal_Int32 mnMax; ///< Maximum value of spin buttons and scroll bars.
167 sal_Int32 mnInc; ///< Small increment of spin buttons and scroll bars.
168 sal_Int32 mnPage; ///< Large increment of spin buttons and scroll bars.
169 sal_Int32 mnSelType; ///< Listbox selection type.
170 sal_Int32 mnVTEdit; ///< Data type of the textbox.
171 bool mbPrintObject; ///< True = print the object.
172 bool mbVisible; ///< True = cell note is visible.
173 bool mbDde; ///< True = object is linked through DDE.
174 bool mbNo3D; ///< True = flat style, false = 3D style.
175 bool mbNo3D2; ///< True = flat style, false = 3D style (listboxes and dropdowns).
176 bool mbMultiLine; ///< True = textbox allows line breaks.
177 bool mbVScroll; ///< True = textbox has a vertical scrollbar.
178 bool mbSecretEdit; ///< True = textbox is a password edit field.
180 explicit ClientData();
183 // ----------------------------------------------------------------------------
185 struct ShapeModel
187 typedef ::std::vector< ::com::sun::star::awt::Point > PointVector;
188 SAL_WNODEPRECATED_DECLARATIONS_PUSH
189 typedef ::std::auto_ptr< TextBox > TextBoxPtr;
190 typedef ::std::auto_ptr< ClientData > ClientDataPtr;
191 SAL_WNODEPRECATED_DECLARATIONS_POP
193 OUString maType; ///< Shape template with default properties.
194 PointVector maPoints; ///< Points for the polyline shape.
195 TextBoxPtr mxTextBox; ///< Text contents and properties.
196 ClientDataPtr mxClientData; ///< Excel specific client data.
197 OUString maLegacyDiagramPath;///< Legacy Diagram Fragment Path
198 OUString maFrom; ///< Start point for line shape.
199 OUString maTo; ///< End point for line shape.
200 OUString maControl1; ///< Bezier control point 1
201 OUString maControl2; ///< Bezier control point 2
202 OUString maVmlPath; ///< VML path for this shape
204 explicit ShapeModel();
205 ~ShapeModel();
207 /** Creates and returns a new shape textbox structure. */
208 TextBox& createTextBox(ShapeTypeModel& rModel);
209 /** Creates and returns a new shape client data structure. */
210 ClientData& createClientData();
213 // ----------------------------------------------------------------------------
215 /** A shape object that is part of a drawing. May inherit properties from a
216 shape template. */
217 class OOX_DLLPUBLIC ShapeBase : public ShapeType
219 public:
220 /** Returns read/write access to the shape model structure. */
221 inline ShapeModel& getShapeModel() { return maShapeModel; }
222 /** Returns read access to the shape model structure. */
223 inline const ShapeModel& getShapeModel() const { return maShapeModel; }
225 /** Returns read access to the shape textbox. */
226 inline const TextBox* getTextBox() const { return maShapeModel.mxTextBox.get(); }
227 /** Returns read access to the shape client data structure. */
228 inline const ClientData* getClientData() const { return maShapeModel.mxClientData.get(); }
230 /** Final processing after import of the drawing fragment. */
231 virtual void finalizeFragmentImport();
233 /** Returns the real shape name if existing, or a generated shape name. */
234 OUString getShapeName() const;
236 /** Returns the shape template with the passed identifier from the child shapes. */
237 virtual const ShapeType* getChildTypeById( const OUString& rShapeId ) const;
238 /** Returns the shape with the passed identifier from the child shapes. */
239 virtual const ShapeBase* getChildById( const OUString& rShapeId ) const;
241 /** Creates the corresponding XShape and inserts it into the passed container. */
242 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
243 convertAndInsert(
244 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
245 const ShapeParentAnchor* pParentAnchor = 0 ) const;
247 /** Converts position and formatting into the passed existing XShape. */
248 void convertFormatting(
249 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
250 const ShapeParentAnchor* pParentAnchor = 0 ) const;
252 protected:
253 explicit ShapeBase( Drawing& rDrawing );
255 /** Derived classes create the corresponding XShape and insert it into the passed container. */
256 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
257 implConvertAndInsert(
258 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
259 const ::com::sun::star::awt::Rectangle& rShapeRect ) const = 0;
261 /** Calculates the final shape rectangle according to the passed anchor,
262 if present, otherwise according to the own anchor settings. */
263 ::com::sun::star::awt::Rectangle calcShapeRectangle(
264 const ShapeParentAnchor* pParentAnchor ) const;
266 /** Converts common shape properties such as formatting attributes. */
267 void convertShapeProperties(
268 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape ) const;
270 protected:
271 ShapeModel maShapeModel; ///< The model structure containing shape data.
274 // ============================================================================
276 /** A simple shape object based on a specific UNO shape service. */
277 class SimpleShape : public ShapeBase
279 public:
280 explicit SimpleShape( Drawing& rDrawing, const OUString& rService );
282 void setService( OUString aService ) { maService = aService; }
284 protected:
285 /** Creates the corresponding XShape and inserts it into the passed container. */
286 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
287 implConvertAndInsert(
288 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
289 const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
290 /** Used by both RectangleShape and ComplexShape. */
291 com::sun::star::uno::Reference<com::sun::star::drawing::XShape>createPictureObject(
292 const com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rxShapes,
293 const com::sun::star::awt::Rectangle& rShapeRect, OUString& rGraphicPath ) const;
295 private:
296 OUString maService; ///< Name of the UNO shape service.
299 // ============================================================================
301 /** A rectangular shape object. */
302 class RectangleShape : public SimpleShape
304 public:
305 explicit RectangleShape( Drawing& rDrawing );
306 protected:
307 /** Creates the corresponding XShape and inserts it into the passed container. */
308 virtual com::sun::star::uno::Reference<com::sun::star::drawing::XShape>
309 implConvertAndInsert(
310 const com::sun::star::uno::Reference<com::sun::star::drawing::XShapes>& rxShapes,
311 const com::sun::star::awt::Rectangle& rShapeRect) const;
314 // ============================================================================
316 /** An oval shape object. */
317 class EllipseShape : public SimpleShape
319 public:
320 explicit EllipseShape( Drawing& rDrawing );
323 // ============================================================================
325 /** A polygon shape object. */
326 class PolyLineShape : public SimpleShape
328 public:
329 explicit PolyLineShape( Drawing& rDrawing );
331 protected:
332 /** Creates the corresponding XShape and inserts it into the passed container. */
333 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
334 implConvertAndInsert(
335 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
336 const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
339 /** A Line shape object. */
340 class LineShape : public SimpleShape
342 public:
343 explicit LineShape( Drawing& rDrawing );
345 protected:
346 /** Returns the absolute shape rectangle. */
347 virtual ::com::sun::star::awt::Rectangle getAbsRectangle() const SAL_OVERRIDE;
348 /** Returns the rectangle relative to the parent coordinate system. */
349 virtual ::com::sun::star::awt::Rectangle getRelRectangle() const SAL_OVERRIDE;
352 /** Bezier shape object that supports to, from, control1 and control2
353 attribute or path attribute specification */
354 class BezierShape : public SimpleShape
356 public:
357 explicit BezierShape( Drawing& rDrawing );
359 protected:
360 /** Creates the corresponding XShape and inserts it into the passed container. */
361 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
362 implConvertAndInsert(
363 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
364 const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
367 // ============================================================================
369 /** A shape object with custom geometry. */
370 class CustomShape : public SimpleShape
372 public:
373 explicit CustomShape( Drawing& rDrawing );
375 protected:
376 /** Creates the corresponding XShape and inserts it into the passed container. */
377 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
378 implConvertAndInsert(
379 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
380 const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
383 // ============================================================================
385 /** A complex shape object. This can be a picture shape, a custom shape, an OLE
386 object, or an ActiveX form control. */
387 class ComplexShape : public CustomShape
389 public:
390 explicit ComplexShape( Drawing& rDrawing );
392 protected:
393 /** Creates the corresponding XShape and inserts it into the passed container. */
394 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
395 implConvertAndInsert(
396 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
397 const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
400 // ============================================================================
402 /** A group shape that extends the basic shape by a container of child shapes. */
403 class GroupShape : public ShapeBase
405 public:
406 explicit GroupShape( Drawing& rDrawing );
407 virtual ~GroupShape();
409 /** Returns read/write access to the container of child shapes and templates. */
410 inline ShapeContainer& getChildren() { return *mxChildren; }
411 /** Returns read access to the container of child shapes and templates. */
412 inline const ShapeContainer& getChildren() const { return *mxChildren; }
414 /** Final processing after import of the drawing fragment. */
415 virtual void finalizeFragmentImport();
417 /** Returns the shape template with the passed identifier from the child shapes. */
418 virtual const ShapeType* getChildTypeById( const OUString& rShapeId ) const;
419 /** Returns the shape with the passed identifier from the child shapes. */
420 virtual const ShapeBase* getChildById( const OUString& rShapeId ) const;
422 protected:
423 /** Creates the corresponding XShape and inserts it into the passed container. */
424 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
425 implConvertAndInsert(
426 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
427 const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
429 private:
430 SAL_WNODEPRECATED_DECLARATIONS_PUSH
431 typedef ::std::auto_ptr< ShapeContainer > ShapeContainerPtr;
432 SAL_WNODEPRECATED_DECLARATIONS_POP
433 ShapeContainerPtr mxChildren; ///< Shapes and templates that are part of this group.
436 // ============================================================================
438 } // namespace vml
439 } // namespace oox
441 #endif
443 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */