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 : #ifndef _SDR_ATTRIBUTE_SDRALLFILLATTRIBUTESHELPER_HXX
20 : #define _SDR_ATTRIBUTE_SDRALLFILLATTRIBUTESHELPER_HXX
21 :
22 : #include "svx/svxdllapi.h"
23 : #include <drawinglayer/attribute/fillgradientattribute.hxx>
24 : #include <drawinglayer/attribute/sdrfillattribute.hxx>
25 : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 : #include <boost/shared_ptr.hpp>
27 : #include <tools/color.hxx>
28 : #include <svl/itemset.hxx>
29 :
30 : //////////////////////////////////////////////////////////////////////////////
31 :
32 : namespace drawinglayer
33 : {
34 : namespace attribute
35 : {
36 : class SVX_DLLPUBLIC SdrAllFillAttributesHelper
37 : {
38 : private:
39 : basegfx::B2DRange maLastPaintRange;
40 : basegfx::B2DRange maLastDefineRange;
41 : boost::shared_ptr< drawinglayer::attribute::SdrFillAttribute > maFillAttribute;
42 : boost::shared_ptr< drawinglayer::attribute::FillGradientAttribute > maFillGradientAttribute;
43 : drawinglayer::primitive2d::Primitive2DSequence maPrimitives;
44 :
45 : void createPrimitive2DSequence(
46 : const basegfx::B2DRange& rPaintRange,
47 : const basegfx::B2DRange& rDefineRange);
48 :
49 : protected:
50 : public:
51 : SdrAllFillAttributesHelper(const Color& rColor);
52 : SdrAllFillAttributesHelper(const SfxItemSet& rSet);
53 : ~SdrAllFillAttributesHelper();
54 :
55 : bool isUsed() const;
56 20214 : bool hasSdrFillAttribute() const { return maFillAttribute.get(); }
57 3015 : bool hasFillGradientAttribute() const { return maFillGradientAttribute.get(); }
58 : bool isTransparent() const;
59 :
60 : const drawinglayer::attribute::SdrFillAttribute& getFillAttribute() const;
61 : const drawinglayer::attribute::FillGradientAttribute& getFillGradientAttribute() const;
62 : const drawinglayer::primitive2d::Primitive2DSequence& getPrimitive2DSequence(
63 : const basegfx::B2DRange& rPaintRange,
64 : const basegfx::B2DRange& rDefineRange) const;
65 :
66 : // get average fill color; tries to calculate a 'medium' color
67 : // which e.g. may be used as comparison to decide if other
68 : // colors are visible
69 : basegfx::BColor getAverageColor(const basegfx::BColor& rFallback) const;
70 :
71 : // return if a repaint of this content needs a complete repaint. This
72 : // is e.g. not needed for no fill or color fill (a partial repaint
73 : // will do the trick), but necessary for everything that is not top-left
74 : // oriented
75 : bool needCompleteRepaint() const;
76 : };
77 : } // end of namespace attribute
78 : } // end of namespace drawinglayer
79 :
80 : //////////////////////////////////////////////////////////////////////////////
81 :
82 : namespace drawinglayer
83 : {
84 : namespace attribute
85 : {
86 : typedef boost::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
87 : } // end of namespace attribute
88 : } // end of namespace drawinglayer
89 :
90 : //////////////////////////////////////////////////////////////////////////////
91 :
92 : #endif // _SDR_ATTRIBUTE_SDRALLFILLATTRIBUTESHELPER_HXX
93 :
94 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|