1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef _SDR_ATTRIBUTE_SDRALLFILLATTRIBUTESHELPER_HXX
23 #define _SDR_ATTRIBUTE_SDRALLFILLATTRIBUTESHELPER_HXX
24 
25 #include "svx/svxdllapi.h"
26 #include <drawinglayer/attribute/fillgradientattribute.hxx>
27 #include <drawinglayer/attribute/sdrfillattribute.hxx>
28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
29 #include <boost/shared_ptr.hpp>
30 #include <tools/color.hxx>
31 #include <svl/itemset.hxx>
32 
33 //////////////////////////////////////////////////////////////////////////////
34 
35 namespace drawinglayer
36 {
37     namespace attribute
38     {
39         class SVX_DLLPUBLIC SdrAllFillAttributesHelper
40         {
41         private:
42             basegfx::B2DRange                                                   maLastPaintRange;
43             basegfx::B2DRange                                                   maLastDefineRange;
44             boost::shared_ptr< drawinglayer::attribute::SdrFillAttribute >      maFillAttribute;
45             boost::shared_ptr< drawinglayer::attribute::FillGradientAttribute > maFillGradientAttribute;
46             drawinglayer::primitive2d::Primitive2DSequence                      maPrimitives;
47 
48             void createPrimitive2DSequence(
49                 const basegfx::B2DRange& rPaintRange,
50                 const basegfx::B2DRange& rDefineRange);
51 
52         protected:
53         public:
54             SdrAllFillAttributesHelper();
55             SdrAllFillAttributesHelper(const Color& rColor);
56             SdrAllFillAttributesHelper(const SfxItemSet& rSet);
57             ~SdrAllFillAttributesHelper();
58 
59             bool isUsed() const;
hasSdrFillAttribute() const60             bool hasSdrFillAttribute() const { return maFillAttribute.get(); }
hasFillGradientAttribute() const61             bool hasFillGradientAttribute() const { return maFillGradientAttribute.get(); }
62             bool isTransparent() const;
63 
64             const drawinglayer::attribute::SdrFillAttribute& getFillAttribute() const;
65             const drawinglayer::attribute::FillGradientAttribute& getFillGradientAttribute() const;
66             const drawinglayer::primitive2d::Primitive2DSequence& getPrimitive2DSequence(
67                 const basegfx::B2DRange& rPaintRange,
68                 const basegfx::B2DRange& rDefineRange) const;
69 
70             // get average fill color; tries to calculate a 'medium' color
71             // which e.g. may be used as comparison to decide if other
72             // colors are visible
73             basegfx::BColor getAverageColor(const basegfx::BColor& rFallback) const;
74 
75             // return if a repaint of this content needs a complete repaint. This
76             // is e.g. not needed for no fill or color fill (a partial repaint
77             // will do the trick), but necessary for everything that is not top-left
78             // oriented
79             bool needCompleteRepaint() const;
80         };
81     } // end of namespace attribute
82 } // end of namespace drawinglayer
83 
84 //////////////////////////////////////////////////////////////////////////////
85 
86 namespace drawinglayer
87 {
88     namespace attribute
89     {
90         typedef boost::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
91     } // end of namespace attribute
92 } // end of namespace drawinglayer
93 
94 //////////////////////////////////////////////////////////////////////////////
95 
96 #endif // _SDR_ATTRIBUTE_SDRALLFILLATTRIBUTESHELPER_HXX
97 
98 // eof
99