cid#1607171 Data race condition
[LibreOffice.git] / include / svx / sdr / attribute / sdrallfillattributeshelper.hxx
blobc9bb786a80911944dca2ea1ec79e5cb5a28f31df
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 .
19 #ifndef INCLUDED_SVX_SDR_ATTRIBUTE_SDRALLFILLATTRIBUTESHELPER_HXX
20 #define INCLUDED_SVX_SDR_ATTRIBUTE_SDRALLFILLATTRIBUTESHELPER_HXX
22 #include <svx/svxdllapi.h>
23 #include <drawinglayer/attribute/fillgradientattribute.hxx>
24 #include <drawinglayer/attribute/sdrfillattribute.hxx>
25 #include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
26 #include <svl/itemset.hxx>
27 #include <optional>
29 //////////////////////////////////////////////////////////////////////////////
31 class Color;
33 namespace drawinglayer::attribute
35 class SVXCORE_DLLPUBLIC SdrAllFillAttributesHelper
37 private:
38 basegfx::B2DRange maLastPaintRange;
39 basegfx::B2DRange maLastDefineRange;
40 std::optional<drawinglayer::attribute::SdrFillAttribute> maFillAttribute;
41 std::optional<drawinglayer::attribute::FillGradientAttribute> maFillGradientAttribute;
42 drawinglayer::primitive2d::Primitive2DContainer maPrimitives;
44 void createPrimitive2DSequence(
45 const basegfx::B2DRange& rPaintRange,
46 const basegfx::B2DRange& rDefineRange);
48 public:
49 SdrAllFillAttributesHelper(const Color& rColor);
50 SdrAllFillAttributesHelper(const SfxItemSet& rSet);
51 ~SdrAllFillAttributesHelper();
53 bool isUsed() const;
54 bool hasSdrFillAttribute() const { return bool(maFillAttribute); }
55 bool isTransparent() const;
57 const drawinglayer::attribute::SdrFillAttribute& getFillAttribute() const;
58 const drawinglayer::attribute::FillGradientAttribute& getFillGradientAttribute() const;
59 const drawinglayer::primitive2d::Primitive2DContainer& getPrimitive2DSequence(
60 const basegfx::B2DRange& rPaintRange,
61 const basegfx::B2DRange& rDefineRange) const;
63 // get average fill color; tries to calculate a 'medium' color
64 // which e.g. may be used as comparison to decide if other
65 // colors are visible
66 basegfx::BColor getAverageColor(const basegfx::BColor& rFallback) const;
68 // return if a repaint of this content needs a complete repaint. This
69 // is e.g. not needed for no fill or color fill (a partial repaint
70 // will do the trick), but necessary for everything that is not top-left
71 // oriented
72 bool needCompleteRepaint() const;
75 } // end of namespace drawinglayer::attribute
77 //////////////////////////////////////////////////////////////////////////////
79 namespace drawinglayer::attribute
81 typedef std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
82 } // end of namespace drawinglayer::attribute
84 //////////////////////////////////////////////////////////////////////////////
86 #endif
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */