Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / slideshow / source / inc / shapeattributelayer.hxx
blob88405f8eea2acca2e055d71ebc22209005f41c72
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_SHAPEATTRIBUTELAYER_HXX
21 #define INCLUDED_SLIDESHOW_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 "state.hxx"
33 #include "rgbcolor.hxx"
35 #include <stack>
36 #include <boost/shared_ptr.hpp>
39 namespace slideshow
41 namespace internal
43 class ShapeAttributeLayer;
45 typedef ::boost::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr;
47 /** Encapsulates all modifiable attributes of a shape.
49 This class holds all modifiable attributes of a shape, and
50 at the same time provides means to layer attributes on top
51 of each other..
53 And yes, there's a reason why we even pass bools and ints
54 by const reference. Namely, that makes the set* methods
55 differ only in the value type, which greatly reduces
56 template variability (e.g. in AnimationFactory).
58 class ShapeAttributeLayer
60 public:
61 /** Create a ShapeAttributeLayer instance, with all
62 attributes set to default.
64 Furthermore, this constructor gets a pointer to a
65 child layer, which is used as the fallback (or the
66 base value) for all attributes
68 @param rChildLayer
69 Layer below this one
71 @attention
72 This method is only supposed to be called from Shape objects
74 explicit ShapeAttributeLayer( const ShapeAttributeLayerSharedPtr& rChildLayer );
76 // Children management methods
77 //------------------------------------------------------------------
79 /** Revoke the given layer.
81 This method revokes the given layer from this object
82 or one of the children. That is, if this object does
83 have children, and the given layer is no direct child,
84 it is recursively passed to the children for removal.
86 @return true, if removal was successful.
88 @attention
89 This method is only supposed to be called from Shape objects
91 bool revokeChildLayer( const ShapeAttributeLayerSharedPtr& rChildLayer );
93 /** Query the child layer of this object.
95 @attention
96 This method is only supposed to be called from Shape objects
98 ShapeAttributeLayerSharedPtr getChildLayer() const;
100 /** Set the additive mode for possible child attributes
102 This method sets the additive mode for child
103 attributes. That is the way underlying attribute
104 layers are combined with this one (i.e. to overrule
105 lower layers, or how to combine the values). The
106 default is
107 ::com::sun::star::animations::AnimationAdditiveMode::BASE,
108 which means, take the value of the underlying layers,
109 or from the model shape itself.
111 @param nMode
112 Must be one of
113 ::com::sun::star::animations::AnimationAdditiveMode.
115 void setAdditiveMode( sal_Int16 nMode );
117 // Attribute methods
118 //------------------------------------------------------------------
120 /** Query whether the width attribute is valid.
122 bool isWidthValid() const;
123 /** Query the current width of the shape
125 double getWidth() const;
126 /** Set the new width of the shape
128 @param rNewWidth
129 A negative width mirrors the shape.
131 void setWidth( const double& rNewWidth );
133 /** Query whether the height attribute is valid.
135 bool isHeightValid() const;
136 /** Query the current height of the shape
138 double getHeight() const;
139 /** Set the new height of the shape
141 @param rNewHeight
142 A negative height mirrors the shape.
144 void setHeight( const double& rNewHeight );
146 /** Set the new size of the shape
148 @param rNewSize
149 A negative size mirrors the shape.
151 void setSize( const ::basegfx::B2DSize& rNewSize );
153 /** Query whether the x position attribute is valid
155 bool isPosXValid() const;
156 /** Query the current x position of the shape.
158 The current x position of the shape is always relative
159 to the <em>center</em> of the shape (in contrast to
160 the Shape::getBounds() and Shape::getUpdateArea()
161 methods).
163 double getPosX() const;
164 /** Set the new x position of the shape
166 The current x position of the shape is always relative
167 to the <em>center</em> of the shape (in contrast to
168 the Shape::getBounds() and Shape::getUpdateArea()
169 methods).
171 void setPosX( const double& rNewX );
173 /** Query whether the y position attribute is valid
175 bool isPosYValid() const;
176 /** Query the current y position of the shape
178 The current y position of the shape is always relative
179 to the <em>center</em> of the shape (in contrast to
180 the Shape::getBounds() and Shape::getUpdateArea()
181 methods).
183 double getPosY() const;
184 /** Set the new y position of the shape
186 The current y position of the shape is always relative
187 to the <em>center</em> of the shape (in contrast to
188 the Shape::getBounds() and Shape::getUpdateArea()
189 methods).
191 void setPosY( const double& rNewY );
193 /** Set the new position of the shape
195 The current 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 setPosition( const ::basegfx::B2DPoint& rNewPos );
202 /** Query whether the rotation angle attribute is valid
204 bool isRotationAngleValid() const;
205 /** Query the current rotation angle of the shape
207 @return the rotation angle in degrees.
209 double getRotationAngle() const;
210 /** Set the new rotation angle of the shape
212 @param rNewAngle
213 New rotation angle in degrees.
215 void setRotationAngle( const double& rNewAngle );
217 /** Query whether the shear x angle attribute is valid
219 bool isShearXAngleValid() const;
220 /** Query the current shear angle at the x axis of the shape
222 @return the shear angle in degrees.
224 double getShearXAngle() const;
225 /** Set the new shear angle at the x axis of the shape
227 @param rNewAngle
228 New shear angle in radians.
230 void setShearXAngle( const double& rNewAngle );
232 /** Query whether the shear y angle attribute is valid
234 bool isShearYAngleValid() const;
235 /** Query the current shear angle at the y axis of the shape
237 @return the shear angle in degrees.
239 double getShearYAngle() const;
240 /** Set the new shear angle at the y axis of the shape
242 @param rNewAngle
243 New shear angle in radians.
245 void setShearYAngle( const double& rNewAngle );
247 /** Query whether the alpha attribute is valid
249 bool isAlphaValid() const;
250 /** Query the current alpha value of the shape
252 double getAlpha() const;
253 /** Set the new alpha value of the shape
255 @param rNewValue
256 New alpha value, must be in the [0,1] range
258 void setAlpha( const double& rNewValue );
260 /** Query whether the clip attribute is valid
262 bool isClipValid() const;
263 /** Query the current clip polygon of the shape
265 ::basegfx::B2DPolyPolygon getClip() const;
266 /** Set the new clip polygon of the shape
268 @param rNewClip
269 New clip polygon, is interpreted in shape view coordinates, but
270 relative to the shape (i.e. the origin of the shape coincides
271 with the origin of the clip polygon).
273 void setClip( const ::basegfx::B2DPolyPolygon& rNewClip );
275 /** Query whether the dim color attribute is valid
277 The dim color globally 'dims' the shape towards that
278 color
280 bool isDimColorValid() const;
281 /** Get the dim color for the whole shape.
283 RGBColor getDimColor() const;
284 /** Set the dim color globally for the whole shape.
286 void setDimColor( const RGBColor& nNewColor );
288 /** Query whether the fill color attribute is valid
290 bool isFillColorValid() const;
291 /** Get the fill color for the whole shape.
293 If there's no unique fill color, the color from the
294 first filled polygon is returned.
296 RGBColor getFillColor() const;
297 /** Set the fill color globally for the whole shape.
299 void setFillColor( const RGBColor& nNewColor );
301 /** Query whether the line color attribute is valid
303 bool isLineColorValid() const;
304 /** Get the line color for the whole shape.
306 If there's no unique line color, the color from the
307 first line is returned.
309 RGBColor getLineColor() const;
310 /** Set the line color globally for the whole shape.
312 void setLineColor( const RGBColor& nNewColor );
314 /** Query whether the fill mode attribute is valid
316 bool isFillStyleValid() const;
317 /** Get the current fill mode for polygon fillings.
319 @returns the current style
321 sal_Int16 getFillStyle() const;
322 /** Changes polygon fillings.
324 void setFillStyle( const sal_Int16& rStyle );
326 /** Query whether the line mode attribute is valid
328 bool isLineStyleValid() const;
329 /** Get the current line mode for line drawing.
331 @returns the current line style
333 sal_Int16 getLineStyle() const;
334 /** Set line style for the whole shape
336 void setLineStyle( const sal_Int16& rStyle );
338 /** Query whether the visibility state attribute is valid
340 bool isVisibilityValid() const;
341 /** Get the current shape visibility.
343 @returns true for visible, false for invisible.
345 bool getVisibility() const;
346 /** Set the shape visibility
348 void setVisibility( const bool& bVisible );
350 /** Query whether the char color attribute is valid
352 bool isCharColorValid() const;
353 /** Get the text color for the whole shape.
355 If there's no unique text color, the color from the
356 first text drawn is returned.
358 RGBColor getCharColor() const;
359 /** Set the text color globally for the whole shape.
361 void setCharColor( const RGBColor& nNewColor );
363 /** Query whether the char rotation angle attribute is valid
365 bool isCharRotationAngleValid() const;
366 /** Query the current text rotation angle of the shape
368 @return the text rotation angle in degrees.
370 double getCharRotationAngle() const;
371 /** Set the new text rotation angle of the shape
373 @param rNewAngle
374 New text rotation angle in degrees.
376 void setCharRotationAngle( const double& rNewAngle );
378 /** Query whether the char weight attribute is valid
380 bool isCharWeightValid() const;
381 /** Get the current char weight value for the whole shape.
383 @returns the value for the char weight. The value must
384 be out of the ::com::sun::star::awt::FontWeight
385 constant group.
387 double getCharWeight() const;
388 /** Set the char weight globally for the whole shape.
390 The value must be out of the
391 ::com::sun::star::awt::FontWeight constant group.
393 void setCharWeight( const double& rStyle );
395 /** Query whether the underline mode attribute is valid
397 bool isUnderlineModeValid() const;
398 /** Get the current text underline status for the whole shape.
400 If there is no unique underline status, false is returned.
402 @returns true for underlined text, false for normal.
404 sal_Int16 getUnderlineMode() const;
405 /** Set the underline status globally for the whole shape
407 void setUnderlineMode( const sal_Int16& bUnderline );
409 /** Query whether the font family attribute is valid
411 bool isFontFamilyValid() const;
412 /** Get the current text font family for the whole shape.
414 If there is no unique font family, the font family of
415 the first text of the shape is returned.
417 ::rtl::OUString getFontFamily() const;
418 /** Set the text font family name globally for the whole shape
420 void setFontFamily( const ::rtl::OUString& rName );
422 /** Query whether the italic mode attribute is valid
424 bool isCharPostureValid() const;
425 /** Get the current text italic style for the whole shape.
427 @returns the italic style. The value returned is one
428 of the ::com::sun::star::awt::FontSlant enums
430 sal_Int16 getCharPosture() const;
431 /** Set the italic style globally for the whole shape.
433 The value must be one of the
434 ::com::sun::star::awt::FontSlant enums.
436 void setCharPosture( const sal_Int16& rStyle );
438 /** Query whether the char scaling attribute is valid
440 bool isCharScaleValid() const;
441 /** Query the current char scaling attribute globally for
442 the shape.
444 The char scaling changes the scale of the whole shape
445 text (uniformely, i.e. both in x and in y direction).
447 double getCharScale() const;
448 /** Set the new char scale globally for the shape
450 @param rNewScale
451 New char scale
453 void setCharScale( const double& rNewScale );
455 // State change query methods
456 // ==========================
458 State::StateId getTransformationState() const;
459 State::StateId getClipState() const;
460 State::StateId getAlphaState() const;
461 State::StateId getPositionState() const;
462 State::StateId getContentState() const;
463 State::StateId getVisibilityState() const;
465 private:
466 // default copy/assignment operator is okay
467 // ShapeAttributeLayer(const ShapeAttributeLayer&);
468 // ShapeAttributeLayer& operator=( const ShapeAttributeLayer& );
470 bool haveChild() const { return mpChild; }
471 void updateStateIds();
473 template< typename T > T calcValue( const T& rCurrValue,
474 bool bThisInstanceValid,
475 bool (ShapeAttributeLayer::*pIsValid)() const,
476 T (ShapeAttributeLayer::*pGetValue)() const ) const;
478 ShapeAttributeLayerSharedPtr mpChild; // may be NULL
480 ::basegfx::B2DSize maSize;
481 ::basegfx::B2DPoint maPosition;
482 ::basegfx::B2DPolyPolygon maClip;
484 ::rtl::OUString maFontFamily;
486 double mnRotationAngle;
487 double mnShearXAngle;
488 double mnShearYAngle;
489 double mnAlpha;
490 double mnCharRotationAngle;
491 double mnCharScale;
492 double mnCharWeight;
494 ::com::sun::star::drawing::FillStyle meFillStyle;
495 ::com::sun::star::drawing::LineStyle meLineStyle;
496 ::com::sun::star::awt::FontSlant meCharPosture;
497 sal_Int16 mnUnderlineMode;
499 RGBColor maDimColor;
500 RGBColor maFillColor;
501 RGBColor maLineColor;
502 RGBColor maCharColor;
504 State::StateId mnTransformationState;
505 State::StateId mnClipState;
506 State::StateId mnAlphaState;
507 State::StateId mnPositionState;
508 State::StateId mnContentState;
509 State::StateId mnVisibilityState;
511 sal_Int16 mnAdditiveMode;
513 bool mbVisibility : 1;
515 bool mbWidthValid : 1;
516 bool mbHeightValid : 1;
517 bool mbPosXValid : 1;
518 bool mbPosYValid : 1;
519 bool mbClipValid : 1;
521 bool mbFontFamilyValid : 1;
523 bool mbRotationAngleValid : 1;
524 bool mbShearXAngleValid : 1;
525 bool mbShearYAngleValid : 1;
527 bool mbAlphaValid : 1;
529 bool mbCharRotationAngleValid: 1;
530 bool mbCharScaleValid : 1;
532 bool mbDimColorValid : 1;
533 bool mbFillColorValid : 1;
534 bool mbLineColorValid : 1;
535 bool mbCharColorValid : 1;
537 bool mbFillStyleValid : 1;
538 bool mbLineStyleValid : 1;
539 bool mbCharWeightValid : 1;
540 bool mbUnderlineModeValid : 1;
541 bool mbCharPostureValid : 1;
542 bool mbVisibilityValid : 1;
548 #endif /* INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYER_HXX */
550 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */