LCOV - code coverage report
Current view: top level - libreoffice/slideshow/source/inc - shapeattributelayer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 2 0.0 %
Date: 2012-12-27 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYER_HXX
      21             : #define INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYER_HXX
      22             : 
      23             : #include <com/sun/star/drawing/FillStyle.hpp>
      24             : #include <com/sun/star/drawing/LineStyle.hpp>
      25             : #include <com/sun/star/awt/FontSlant.hpp>
      26             : 
      27             : #include <basegfx/vector/b2dsize.hxx>
      28             : #include <basegfx/point/b2dpoint.hxx>
      29             : #include <basegfx/range/b2drectangle.hxx>
      30             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      31             : 
      32             : #include "state.hxx"
      33             : #include "rgbcolor.hxx"
      34             : 
      35             : #include <stack>
      36             : #include <boost/shared_ptr.hpp>
      37             : 
      38             : 
      39             : namespace slideshow
      40             : {
      41             :     namespace internal
      42             :     {
      43             :         class ShapeAttributeLayer;
      44             : 
      45             :         typedef ::boost::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr;
      46             : 
      47             :         /** Encapsulates all modifiable attributes of a shape.
      48             : 
      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..
      52             : 
      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).
      57             :          */
      58           0 :         class ShapeAttributeLayer
      59             :         {
      60             :         public:
      61             :             /** Create a ShapeAttributeLayer instance, with all
      62             :                 attributes set to default.
      63             : 
      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
      67             : 
      68             :                 @param rChildLayer
      69             :                 Layer below this one
      70             : 
      71             :                 @attention
      72             :                 This method is only supposed to be called from Shape objects
      73             :              */
      74             :             explicit ShapeAttributeLayer( const ShapeAttributeLayerSharedPtr& rChildLayer );
      75             : 
      76             :             // Children management methods
      77             :             //------------------------------------------------------------------
      78             : 
      79             :             /** Revoke the given layer.
      80             : 
      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.
      85             : 
      86             :                 @return true, if removal was successful.
      87             : 
      88             :                 @attention
      89             :                 This method is only supposed to be called from Shape objects
      90             :              */
      91             :             bool revokeChildLayer( const ShapeAttributeLayerSharedPtr& rChildLayer );
      92             : 
      93             :             /** Query the child layer of this object.
      94             : 
      95             :                 @attention
      96             :                 This method is only supposed to be called from Shape objects
      97             :              */
      98             :             ShapeAttributeLayerSharedPtr getChildLayer() const;
      99             : 
     100             :             /** Set the additive mode for possible child attributes
     101             : 
     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.
     110             : 
     111             :                 @param nMode
     112             :                 Must be one of
     113             :                 ::com::sun::star::animations::AnimationAdditiveMode.
     114             :              */
     115             :             void setAdditiveMode( sal_Int16 nMode );
     116             : 
     117             :             // Attribute methods
     118             :             //------------------------------------------------------------------
     119             : 
     120             :             /** Query whether the width attribute is valid.
     121             :              */
     122             :             bool isWidthValid() const;
     123             :             /** Query the current width of the shape
     124             :              */
     125             :             double getWidth() const;
     126             :             /** Set the new width of the shape
     127             : 
     128             :                 @param rNewWidth
     129             :                 A negative width mirrors the shape.
     130             :              */
     131             :             void setWidth( const double& rNewWidth );
     132             : 
     133             :             /** Query whether the height attribute is valid.
     134             :              */
     135             :             bool isHeightValid() const;
     136             :             /** Query the current height of the shape
     137             :              */
     138             :             double getHeight() const;
     139             :             /** Set the new height of the shape
     140             : 
     141             :                 @param rNewHeight
     142             :                 A negative height mirrors the shape.
     143             :              */
     144             :             void setHeight( const double& rNewHeight );
     145             : 
     146             :             /** Set the new size of the shape
     147             : 
     148             :                 @param rNewSize
     149             :                 A negative size mirrors the shape.
     150             :              */
     151             :             void setSize( const ::basegfx::B2DSize& rNewSize );
     152             : 
     153             :             /** Query whether the x position attribute is valid
     154             :              */
     155             :             bool isPosXValid() const;
     156             :             /** Query the current x position of the shape.
     157             : 
     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).
     162             :              */
     163             :             double getPosX() const;
     164             :             /** Set the new x position of the shape
     165             : 
     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).
     170             :              */
     171             :             void setPosX( const double& rNewX );
     172             : 
     173             :             /** Query whether the y position attribute is valid
     174             :              */
     175             :             bool isPosYValid() const;
     176             :             /** Query the current y position of the shape
     177             : 
     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).
     182             :              */
     183             :             double getPosY() const;
     184             :             /** Set the new y position of the shape
     185             : 
     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).
     190             :              */
     191             :             void setPosY( const double& rNewY );
     192             : 
     193             :             /** Set the new position of the shape
     194             : 
     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).
     199             :              */
     200             :             void setPosition( const ::basegfx::B2DPoint& rNewPos );
     201             : 
     202             :             /** Query whether the rotation angle attribute is valid
     203             :              */
     204             :             bool isRotationAngleValid() const;
     205             :             /** Query the current rotation angle of the shape
     206             : 
     207             :                 @return the rotation angle in degrees.
     208             :              */
     209             :             double getRotationAngle() const;
     210             :             /** Set the new rotation angle of the shape
     211             : 
     212             :                 @param rNewAngle
     213             :                 New rotation angle in degrees.
     214             :              */
     215             :             void setRotationAngle( const double& rNewAngle );
     216             : 
     217             :             /** Query whether the shear x angle attribute is valid
     218             :              */
     219             :             bool isShearXAngleValid() const;
     220             :             /** Query the current shear angle at the x axis of the shape
     221             : 
     222             :                 @return the shear angle in degrees.
     223             :              */
     224             :             double getShearXAngle() const;
     225             :             /** Set the new shear angle at the x axis of the shape
     226             : 
     227             :                 @param rNewAngle
     228             :                 New shear angle in radians.
     229             :              */
     230             :             void setShearXAngle( const double& rNewAngle );
     231             : 
     232             :             /** Query whether the shear y angle attribute is valid
     233             :              */
     234             :             bool isShearYAngleValid() const;
     235             :             /** Query the current shear angle at the y axis of the shape
     236             : 
     237             :                 @return the shear angle in degrees.
     238             :              */
     239             :             double getShearYAngle() const;
     240             :             /** Set the new shear angle at the y axis of the shape
     241             : 
     242             :                 @param rNewAngle
     243             :                 New shear angle in radians.
     244             :              */
     245             :             void setShearYAngle( const double& rNewAngle );
     246             : 
     247             :             /** Query whether the alpha attribute is valid
     248             :              */
     249             :             bool isAlphaValid() const;
     250             :             /** Query the current alpha value of the shape
     251             :              */
     252             :             double getAlpha() const;
     253             :             /** Set the new alpha value of the shape
     254             : 
     255             :                 @param rNewValue
     256             :                 New alpha value, must be in the [0,1] range
     257             :              */
     258             :             void setAlpha( const double& rNewValue );
     259             : 
     260             :             /** Query whether the clip attribute is valid
     261             :              */
     262             :             bool isClipValid() const;
     263             :             /** Query the current clip polygon of the shape
     264             :              */
     265             :             ::basegfx::B2DPolyPolygon getClip() const;
     266             :             /** Set the new clip polygon of the shape
     267             : 
     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).
     272             :              */
     273             :             void setClip( const ::basegfx::B2DPolyPolygon& rNewClip );
     274             : 
     275             :             /** Query whether the dim color attribute is valid
     276             : 
     277             :                 The dim color globally 'dims' the shape towards that
     278             :                 color
     279             :              */
     280             :             bool isDimColorValid() const;
     281             :             /** Get the dim color for the whole shape.
     282             :              */
     283             :             RGBColor getDimColor() const;
     284             :             /** Set the dim color globally for the whole shape.
     285             :              */
     286             :             void setDimColor( const RGBColor& nNewColor );
     287             : 
     288             :             /** Query whether the fill color attribute is valid
     289             :              */
     290             :             bool isFillColorValid() const;
     291             :             /** Get the fill color for the whole shape.
     292             : 
     293             :                 If there's no unique fill color, the color from the
     294             :                 first filled polygon is returned.
     295             :              */
     296             :             RGBColor getFillColor() const;
     297             :             /** Set the fill color globally for the whole shape.
     298             :              */
     299             :             void setFillColor( const RGBColor& nNewColor );
     300             : 
     301             :             /** Query whether the line color attribute is valid
     302             :              */
     303             :             bool isLineColorValid() const;
     304             :             /** Get the line color for the whole shape.
     305             : 
     306             :                 If there's no unique line color, the color from the
     307             :                 first line is returned.
     308             :              */
     309             :             RGBColor  getLineColor() const;
     310             :             /** Set the line color globally for the whole shape.
     311             :              */
     312             :             void setLineColor( const RGBColor& nNewColor );
     313             : 
     314             :             /** Query whether the fill mode attribute is valid
     315             :              */
     316             :             bool isFillStyleValid() const;
     317             :             /** Get the current fill mode for polygon fillings.
     318             : 
     319             :                 @returns the current style
     320             :              */
     321             :             sal_Int16 getFillStyle() const;
     322             :             /** Changes polygon fillings.
     323             :              */
     324             :             void setFillStyle( const sal_Int16& rStyle );
     325             : 
     326             :             /** Query whether the line mode attribute is valid
     327             :              */
     328             :             bool isLineStyleValid() const;
     329             :             /** Get the current line mode for line drawing.
     330             : 
     331             :                 @returns the current line style
     332             :              */
     333             :             sal_Int16 getLineStyle() const;
     334             :             /** Set line style for the whole shape
     335             :              */
     336             :             void setLineStyle( const sal_Int16& rStyle );
     337             : 
     338             :             /** Query whether the visibility state attribute is valid
     339             :              */
     340             :             bool isVisibilityValid() const;
     341             :             /** Get the current shape visibility.
     342             : 
     343             :                 @returns true for visible, false for invisible.
     344             :              */
     345             :             bool getVisibility() const;
     346             :             /** Set the shape visibility
     347             :              */
     348             :             void setVisibility( const bool& bVisible );
     349             : 
     350             :             /** Query whether the char color attribute is valid
     351             :              */
     352             :             bool isCharColorValid() const;
     353             :             /** Get the text color for the whole shape.
     354             : 
     355             :                 If there's no unique text color, the color from the
     356             :                 first text drawn is returned.
     357             :              */
     358             :             RGBColor getCharColor() const;
     359             :             /** Set the text color globally for the whole shape.
     360             :              */
     361             :             void setCharColor( const RGBColor& nNewColor );
     362             : 
     363             :             /** Query whether the char rotation angle attribute is valid
     364             :              */
     365             :             bool isCharRotationAngleValid() const;
     366             :             /** Query the current text rotation angle of the shape
     367             : 
     368             :                 @return the text rotation angle in degrees.
     369             :              */
     370             :             double getCharRotationAngle() const;
     371             :             /** Set the new text rotation angle of the shape
     372             : 
     373             :                 @param rNewAngle
     374             :                 New text rotation angle in degrees.
     375             :              */
     376             :             void setCharRotationAngle( const double& rNewAngle );
     377             : 
     378             :             /** Query whether the char weight attribute is valid
     379             :              */
     380             :             bool isCharWeightValid() const;
     381             :             /** Get the current char weight value for the whole shape.
     382             : 
     383             :                 @returns the value for the char weight. The value must
     384             :                 be out of the ::com::sun::star::awt::FontWeight
     385             :                 constant group.
     386             :              */
     387             :             double getCharWeight() const;
     388             :             /** Set the char weight globally for the whole shape.
     389             : 
     390             :                 The value must be out of the
     391             :                 ::com::sun::star::awt::FontWeight constant group.
     392             :              */
     393             :             void setCharWeight( const double& rStyle );
     394             : 
     395             :             /** Query whether the underline mode attribute is valid
     396             :              */
     397             :             bool isUnderlineModeValid() const;
     398             :             /** Get the current text underline status for the whole shape.
     399             : 
     400             :                 If there is no unique underline status, false is returned.
     401             : 
     402             :                 @returns true for underlined text, false for normal.
     403             :              */
     404             :             sal_Int16 getUnderlineMode() const;
     405             :             /** Set the underline status globally for the whole shape
     406             :              */
     407             :             void setUnderlineMode( const sal_Int16& bUnderline );
     408             : 
     409             :             /** Query whether the font family attribute is valid
     410             :              */
     411             :             bool isFontFamilyValid() const;
     412             :             /** Get the current text font family for the whole shape.
     413             : 
     414             :                 If there is no unique font family, the font family of
     415             :                 the first text of the shape is returned.
     416             :              */
     417             :             ::rtl::OUString getFontFamily() const;
     418             :             /** Set the text font family name globally for the whole shape
     419             :              */
     420             :             void setFontFamily( const ::rtl::OUString& rName );
     421             : 
     422             :             /** Query whether the italic mode attribute is valid
     423             :              */
     424             :             bool isCharPostureValid() const;
     425             :             /** Get the current text italic style for the whole shape.
     426             : 
     427             :                 @returns the italic style. The value returned is one
     428             :                 of the ::com::sun::star::awt::FontSlant enums
     429             :              */
     430             :             sal_Int16 getCharPosture() const;
     431             :             /** Set the italic style globally for the whole shape.
     432             : 
     433             :                 The value must be one of the
     434             :                 ::com::sun::star::awt::FontSlant enums.
     435             :             */
     436             :             void setCharPosture( const sal_Int16& rStyle );
     437             : 
     438             :             /** Query whether the char scaling attribute is valid
     439             :              */
     440             :             bool isCharScaleValid() const;
     441             :             /** Query the current char scaling attribute globally for
     442             :                 the shape.
     443             : 
     444             :                 The char scaling changes the scale of the whole shape
     445             :                 text (uniformely, i.e. both in x and in y direction).
     446             :              */
     447             :             double getCharScale() const;
     448             :             /** Set the new char scale globally for the shape
     449             : 
     450             :                 @param rNewScale
     451             :                 New char scale
     452             :              */
     453             :             void setCharScale( const double& rNewScale );
     454             : 
     455             :             // State change query methods
     456             :             // ==========================
     457             : 
     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;
     464             : 
     465             :         private:
     466             :             // default copy/assignment operator is okay
     467             :             // ShapeAttributeLayer(const ShapeAttributeLayer&);
     468             :             // ShapeAttributeLayer& operator=( const ShapeAttributeLayer& );
     469             : 
     470           0 :             bool haveChild() const { return mpChild; }
     471             :             void updateStateIds();
     472             : 
     473             :             template< typename T > T calcValue( const T&                   rCurrValue,
     474             :                                                 bool                           bThisInstanceValid,
     475             :                                                 bool (ShapeAttributeLayer::*pIsValid)() const,
     476             :                                                 T   (ShapeAttributeLayer::*pGetValue)() const ) const;
     477             : 
     478             :             ShapeAttributeLayerSharedPtr                mpChild; // may be NULL
     479             : 
     480             :             ::basegfx::B2DSize                          maSize;
     481             :             ::basegfx::B2DPoint                         maPosition;
     482             :             ::basegfx::B2DPolyPolygon                   maClip;
     483             : 
     484             :             ::rtl::OUString                             maFontFamily;
     485             : 
     486             :             double                                      mnRotationAngle;
     487             :             double                                      mnShearXAngle;
     488             :             double                                      mnShearYAngle;
     489             :             double                                      mnAlpha;
     490             :             double                                      mnCharRotationAngle;
     491             :             double                                      mnCharScale;
     492             :             double                                      mnCharWeight;
     493             : 
     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;
     498             : 
     499             :             RGBColor                                    maDimColor;
     500             :             RGBColor                                    maFillColor;
     501             :             RGBColor                                    maLineColor;
     502             :             RGBColor                                    maCharColor;
     503             : 
     504             :             State::StateId                              mnTransformationState;
     505             :             State::StateId                              mnClipState;
     506             :             State::StateId                              mnAlphaState;
     507             :             State::StateId                              mnPositionState;
     508             :             State::StateId                              mnContentState;
     509             :             State::StateId                              mnVisibilityState;
     510             : 
     511             :             sal_Int16                                   mnAdditiveMode;
     512             : 
     513             :             bool                                        mbVisibility            : 1;
     514             : 
     515             :             bool                                        mbWidthValid            : 1;
     516             :             bool                                        mbHeightValid           : 1;
     517             :             bool                                        mbPosXValid             : 1;
     518             :             bool                                        mbPosYValid             : 1;
     519             :             bool                                        mbClipValid             : 1;
     520             : 
     521             :             bool                                        mbFontFamilyValid       : 1;
     522             : 
     523             :             bool                                        mbRotationAngleValid    : 1;
     524             :             bool                                        mbShearXAngleValid      : 1;
     525             :             bool                                        mbShearYAngleValid      : 1;
     526             : 
     527             :             bool                                        mbAlphaValid            : 1;
     528             : 
     529             :             bool                                        mbCharRotationAngleValid: 1;
     530             :             bool                                        mbCharScaleValid        : 1;
     531             : 
     532             :             bool                                        mbDimColorValid         : 1;
     533             :             bool                                        mbFillColorValid        : 1;
     534             :             bool                                        mbLineColorValid        : 1;
     535             :             bool                                        mbCharColorValid        : 1;
     536             : 
     537             :             bool                                        mbFillStyleValid        : 1;
     538             :             bool                                        mbLineStyleValid        : 1;
     539             :             bool                                        mbCharWeightValid       : 1;
     540             :             bool                                        mbUnderlineModeValid    : 1;
     541             :             bool                                        mbCharPostureValid      : 1;
     542             :             bool                                        mbVisibilityValid       : 1;
     543             :         };
     544             : 
     545             :     }
     546             : }
     547             : 
     548             : #endif /* INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYER_HXX */
     549             : 
     550             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10