fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / slideshow / source / inc / shapeattributelayer.hxx
blobf2bed3498fba8a4c7bf30c60bd71762452821cfd
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_SLIDESHOW_SOURCE_INC_SHAPEATTRIBUTELAYER_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_INC_SHAPEATTRIBUTELAYER_HXX
23 #include <com/sun/star/drawing/FillStyle.hpp>
24 #include <com/sun/star/drawing/LineStyle.hpp>
25 #include <com/sun/star/awt/FontSlant.hpp>
27 #include <basegfx/vector/b2dsize.hxx>
28 #include <basegfx/point/b2dpoint.hxx>
29 #include <basegfx/range/b2drectangle.hxx>
30 #include <basegfx/polygon/b2dpolypolygon.hxx>
32 #include "rgbcolor.hxx"
34 #include <stack>
35 #include <boost/shared_ptr.hpp>
38 namespace slideshow
40 namespace internal
43 /** This interface represents a stateful object.
45 The state ID returned by the getStateId() method
46 abstractly encodes the object's state. When this ID
47 changes, clients can assume that the object's state has
48 changed.
50 class State
52 public:
53 virtual ~State() {}
55 /// Abstract, numerically encoded state ID
56 typedef ::std::size_t StateId;
58 /** This method returns a numerical state identifier.
60 The state ID returned by this method abstractly
61 encodes the object's state. When this ID changes,
62 clients can assume that the object's state has
63 changed.
65 @return an abstract, numerical state ID.
70 typedef ::boost::shared_ptr< State > StateSharedPtr;
72 class ShapeAttributeLayer;
74 typedef ::boost::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr;
76 /** Encapsulates all modifiable attributes of a shape.
78 This class holds all modifiable attributes of a shape, and
79 at the same time provides means to layer attributes on top
80 of each other..
82 And yes, there's a reason why we even pass bools and ints
83 by const reference. Namely, that makes the set* methods
84 differ only in the value type, which greatly reduces
85 template variability (e.g. in AnimationFactory).
87 class ShapeAttributeLayer
89 public:
90 /** Create a ShapeAttributeLayer instance, with all
91 attributes set to default.
93 Furthermore, this constructor gets a pointer to a
94 child layer, which is used as the fallback (or the
95 base value) for all attributes
97 @param rChildLayer
98 Layer below this one
100 @attention
101 This method is only supposed to be called from Shape objects
103 explicit ShapeAttributeLayer( const ShapeAttributeLayerSharedPtr& rChildLayer );
105 // Children management methods
108 /** Revoke the given layer.
110 This method revokes the given layer from this object
111 or one of the children. That is, if this object does
112 have children, and the given layer is no direct child,
113 it is recursively passed to the children for removal.
115 @return true, if removal was successful.
117 @attention
118 This method is only supposed to be called from Shape objects
120 bool revokeChildLayer( const ShapeAttributeLayerSharedPtr& rChildLayer );
122 /** Query the child layer of this object.
124 @attention
125 This method is only supposed to be called from Shape objects
127 ShapeAttributeLayerSharedPtr getChildLayer() const;
129 /** Set the additive mode for possible child attributes
131 This method sets the additive mode for child
132 attributes. That is the way underlying attribute
133 layers are combined with this one (i.e. to overrule
134 lower layers, or how to combine the values). The
135 default is
136 ::com::sun::star::animations::AnimationAdditiveMode::BASE,
137 which means, take the value of the underlying layers,
138 or from the model shape itself.
140 @param nMode
141 Must be one of
142 ::com::sun::star::animations::AnimationAdditiveMode.
144 void setAdditiveMode( sal_Int16 nMode );
146 // Attribute methods
149 /** Query whether the width attribute is valid.
151 bool isWidthValid() const;
152 /** Query the current width of the shape
154 double getWidth() const;
155 /** Set the new width of the shape
157 @param rNewWidth
158 A negative width mirrors the shape.
160 void setWidth( const double& rNewWidth );
162 /** Query whether the height attribute is valid.
164 bool isHeightValid() const;
165 /** Query the current height of the shape
167 double getHeight() const;
168 /** Set the new height of the shape
170 @param rNewHeight
171 A negative height mirrors the shape.
173 void setHeight( const double& rNewHeight );
175 /** Set the new size of the shape
177 @param rNewSize
178 A negative size mirrors the shape.
180 void setSize( const ::basegfx::B2DSize& rNewSize );
182 /** Query whether the x position attribute is valid
184 bool isPosXValid() const;
185 /** Query the current x position of the shape.
187 The current x position of the shape is always relative
188 to the <em>center</em> of the shape (in contrast to
189 the Shape::getBounds() and Shape::getUpdateArea()
190 methods).
192 double getPosX() const;
193 /** Set the new x position of the shape
195 The current x position of the shape is always relative
196 to the <em>center</em> of the shape (in contrast to
197 the Shape::getBounds() and Shape::getUpdateArea()
198 methods).
200 void setPosX( const double& rNewX );
202 /** Query whether the y position attribute is valid
204 bool isPosYValid() const;
205 /** Query the current y position of the shape
207 The current y position of the shape is always relative
208 to the <em>center</em> of the shape (in contrast to
209 the Shape::getBounds() and Shape::getUpdateArea()
210 methods).
212 double getPosY() const;
213 /** Set the new y position of the shape
215 The current y position of the shape is always relative
216 to the <em>center</em> of the shape (in contrast to
217 the Shape::getBounds() and Shape::getUpdateArea()
218 methods).
220 void setPosY( const double& rNewY );
222 /** Set the new position of the shape
224 The current position of the shape is always relative
225 to the <em>center</em> of the shape (in contrast to
226 the Shape::getBounds() and Shape::getUpdateArea()
227 methods).
229 void setPosition( const ::basegfx::B2DPoint& rNewPos );
231 /** Query whether the rotation angle attribute is valid
233 bool isRotationAngleValid() const;
234 /** Query the current rotation angle of the shape
236 @return the rotation angle in degrees.
238 double getRotationAngle() const;
239 /** Set the new rotation angle of the shape
241 @param rNewAngle
242 New rotation angle in degrees.
244 void setRotationAngle( const double& rNewAngle );
246 /** Query whether the shear x angle attribute is valid
248 bool isShearXAngleValid() const;
249 /** Query the current shear angle at the x axis of the shape
251 @return the shear angle in degrees.
253 double getShearXAngle() const;
254 /** Set the new shear angle at the x axis of the shape
256 @param rNewAngle
257 New shear angle in radians.
259 void setShearXAngle( const double& rNewAngle );
261 /** Query whether the shear y angle attribute is valid
263 bool isShearYAngleValid() const;
264 /** Query the current shear angle at the y axis of the shape
266 @return the shear angle in degrees.
268 double getShearYAngle() const;
269 /** Set the new shear angle at the y axis of the shape
271 @param rNewAngle
272 New shear angle in radians.
274 void setShearYAngle( const double& rNewAngle );
276 /** Query whether the alpha attribute is valid
278 bool isAlphaValid() const;
279 /** Query the current alpha value of the shape
281 double getAlpha() const;
282 /** Set the new alpha value of the shape
284 @param rNewValue
285 New alpha value, must be in the [0,1] range
287 void setAlpha( const double& rNewValue );
289 /** Query whether the clip attribute is valid
291 bool isClipValid() const;
292 /** Query the current clip polygon of the shape
294 ::basegfx::B2DPolyPolygon getClip() const;
295 /** Set the new clip polygon of the shape
297 @param rNewClip
298 New clip polygon, is interpreted in shape view coordinates, but
299 relative to the shape (i.e. the origin of the shape coincides
300 with the origin of the clip polygon).
302 void setClip( const ::basegfx::B2DPolyPolygon& rNewClip );
304 /** Query whether the dim color attribute is valid
306 The dim color globally 'dims' the shape towards that
307 color
309 bool isDimColorValid() const;
310 /** Get the dim color for the whole shape.
312 RGBColor getDimColor() const;
313 /** Set the dim color globally for the whole shape.
315 void setDimColor( const RGBColor& nNewColor );
317 /** Query whether the fill color attribute is valid
319 bool isFillColorValid() const;
320 /** Get the fill color for the whole shape.
322 If there's no unique fill color, the color from the
323 first filled polygon is returned.
325 RGBColor getFillColor() const;
326 /** Set the fill color globally for the whole shape.
328 void setFillColor( const RGBColor& nNewColor );
330 /** Query whether the line color attribute is valid
332 bool isLineColorValid() const;
333 /** Get the line color for the whole shape.
335 If there's no unique line color, the color from the
336 first line is returned.
338 RGBColor getLineColor() const;
339 /** Set the line color globally for the whole shape.
341 void setLineColor( const RGBColor& nNewColor );
343 /** Query whether the fill mode attribute is valid
345 bool isFillStyleValid() const;
346 /** Get the current fill mode for polygon fillings.
348 @returns the current style
350 sal_Int16 getFillStyle() const;
351 /** Changes polygon fillings.
353 void setFillStyle( const sal_Int16& rStyle );
355 /** Query whether the line mode attribute is valid
357 bool isLineStyleValid() const;
358 /** Get the current line mode for line drawing.
360 @returns the current line style
362 sal_Int16 getLineStyle() const;
363 /** Set line style for the whole shape
365 void setLineStyle( const sal_Int16& rStyle );
367 /** Query whether the visibility state attribute is valid
369 bool isVisibilityValid() const;
370 /** Get the current shape visibility.
372 @returns true for visible, false for invisible.
374 bool getVisibility() const;
375 /** Set the shape visibility
377 void setVisibility( const bool& bVisible );
379 /** Query whether the char color attribute is valid
381 bool isCharColorValid() const;
382 /** Get the text color for the whole shape.
384 If there's no unique text color, the color from the
385 first text drawn is returned.
387 RGBColor getCharColor() const;
388 /** Set the text color globally for the whole shape.
390 void setCharColor( const RGBColor& nNewColor );
392 /** Query whether the char rotation angle attribute is valid
394 bool isCharRotationAngleValid() const;
395 /** Query the current text rotation angle of the shape
397 @return the text rotation angle in degrees.
399 double getCharRotationAngle() const;
400 /** Set the new text rotation angle of the shape
402 @param rNewAngle
403 New text rotation angle in degrees.
405 void setCharRotationAngle( const double& rNewAngle );
407 /** Query whether the char weight attribute is valid
409 bool isCharWeightValid() const;
410 /** Get the current char weight value for the whole shape.
412 @returns the value for the char weight. The value must
413 be out of the ::com::sun::star::awt::FontWeight
414 constant group.
416 double getCharWeight() const;
417 /** Set the char weight globally for the whole shape.
419 The value must be out of the
420 ::com::sun::star::awt::FontWeight constant group.
422 void setCharWeight( const double& rStyle );
424 /** Query whether the underline mode attribute is valid
426 bool isUnderlineModeValid() const;
427 /** Get the current text underline status for the whole shape.
429 If there is no unique underline status, false is returned.
431 @returns true for underlined text, false for normal.
433 sal_Int16 getUnderlineMode() const;
434 /** Set the underline status globally for the whole shape
436 void setUnderlineMode( const sal_Int16& bUnderline );
438 /** Query whether the font family attribute is valid
440 bool isFontFamilyValid() const;
441 /** Get the current text font family for the whole shape.
443 If there is no unique font family, the font family of
444 the first text of the shape is returned.
446 OUString getFontFamily() const;
447 /** Set the text font family name globally for the whole shape
449 void setFontFamily( const OUString& rName );
451 /** Query whether the italic mode attribute is valid
453 bool isCharPostureValid() const;
454 /** Get the current text italic style for the whole shape.
456 @returns the italic style. The value returned is one
457 of the ::com::sun::star::awt::FontSlant enums
459 sal_Int16 getCharPosture() const;
460 /** Set the italic style globally for the whole shape.
462 The value must be one of the
463 ::com::sun::star::awt::FontSlant enums.
465 void setCharPosture( const sal_Int16& rStyle );
467 /** Query whether the char scaling attribute is valid
469 bool isCharScaleValid() const;
470 /** Query the current char scaling attribute globally for
471 the shape.
473 The char scaling changes the scale of the whole shape
474 text (uniformely, i.e. both in x and in y direction).
476 double getCharScale() const;
477 /** Set the new char scale globally for the shape
479 @param rNewScale
480 New char scale
482 void setCharScale( const double& rNewScale );
484 // State change query methods
487 State::StateId getTransformationState() const;
488 State::StateId getClipState() const;
489 State::StateId getAlphaState() const;
490 State::StateId getPositionState() const;
491 State::StateId getContentState() const;
492 State::StateId getVisibilityState() const;
494 private:
495 // default copy/assignment operator is okay
496 // ShapeAttributeLayer(const ShapeAttributeLayer&);
497 // ShapeAttributeLayer& operator=( const ShapeAttributeLayer& );
499 bool haveChild() const { return static_cast< bool >(mpChild); }
500 void updateStateIds();
502 template< typename T > T calcValue( const T& rCurrValue,
503 bool bThisInstanceValid,
504 bool (ShapeAttributeLayer::*pIsValid)() const,
505 T (ShapeAttributeLayer::*pGetValue)() const ) const;
507 ShapeAttributeLayerSharedPtr mpChild; // may be NULL
509 ::basegfx::B2DSize maSize;
510 ::basegfx::B2DPoint maPosition;
511 ::basegfx::B2DPolyPolygon maClip;
513 OUString maFontFamily;
515 double mnRotationAngle;
516 double mnShearXAngle;
517 double mnShearYAngle;
518 double mnAlpha;
519 double mnCharRotationAngle;
520 double mnCharScale;
521 double mnCharWeight;
523 ::com::sun::star::drawing::FillStyle meFillStyle;
524 ::com::sun::star::drawing::LineStyle meLineStyle;
525 ::com::sun::star::awt::FontSlant meCharPosture;
526 sal_Int16 mnUnderlineMode;
528 RGBColor maDimColor;
529 RGBColor maFillColor;
530 RGBColor maLineColor;
531 RGBColor maCharColor;
533 State::StateId mnTransformationState;
534 State::StateId mnClipState;
535 State::StateId mnAlphaState;
536 State::StateId mnPositionState;
537 State::StateId mnContentState;
538 State::StateId mnVisibilityState;
540 sal_Int16 mnAdditiveMode;
542 bool mbVisibility : 1;
544 bool mbWidthValid : 1;
545 bool mbHeightValid : 1;
546 bool mbPosXValid : 1;
547 bool mbPosYValid : 1;
548 bool mbClipValid : 1;
550 bool mbFontFamilyValid : 1;
552 bool mbRotationAngleValid : 1;
553 bool mbShearXAngleValid : 1;
554 bool mbShearYAngleValid : 1;
556 bool mbAlphaValid : 1;
558 bool mbCharRotationAngleValid: 1;
559 bool mbCharScaleValid : 1;
561 bool mbDimColorValid : 1;
562 bool mbFillColorValid : 1;
563 bool mbLineColorValid : 1;
564 bool mbCharColorValid : 1;
566 bool mbFillStyleValid : 1;
567 bool mbLineStyleValid : 1;
568 bool mbCharWeightValid : 1;
569 bool mbUnderlineModeValid : 1;
570 bool mbCharPostureValid : 1;
571 bool mbVisibilityValid : 1;
577 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SHAPEATTRIBUTELAYER_HXX
579 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */