1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <drawinglayer/drawinglayerdllapi.h>
23 #include <o3tl/cow_wrapper.hxx>
24 #include <com/sun/star/awt/GradientStyle.hpp>
33 namespace drawinglayer::attribute
35 class ImpFillGradientAttribute
;
37 class DRAWINGLAYER_DLLPUBLIC FillGradientAttribute
40 typedef o3tl::cow_wrapper
<ImpFillGradientAttribute
> ImplType
;
43 ImplType mpFillGradientAttribute
;
46 /* MCGR: Adaptions for MultiColorGradients
48 Direct Start/EndCOlor is no longer required, instead the
49 full color gradient is handed over as ColorStops vector.
50 To add the former Start/EndColor in a compatible way, just
51 prepare an instance of basegfx::BColorStops with the
52 StartColor at 0.0 and the EndColor at 1.0.
54 A rigid correction/input data will be done by the constructor,
55 including to sort the ColorStops by offset and removing invalid
56 entries (see sortAndCorrect)
58 To access e.g. the StartColor, use getColorStops().front(), and
59 getColorStops().back(), accordingly, for EndColor. The existence
60 of at least one entry is guaranteed, so no need to check before
61 accessing using of front()/back() calls. If only one color entry
62 exists, start == end color is assumed, so not really a gradient
63 but (existing) fallbacks to filled polygon can trigger.
65 /// constructors/assignmentoperator/destructor
66 FillGradientAttribute(css::awt::GradientStyle eStyle
, double fBorder
, double fOffsetX
,
67 double fOffsetY
, double fAngle
, const basegfx::BColorStops
& rColorStops
,
68 sal_uInt16 nSteps
= 0);
69 FillGradientAttribute();
70 FillGradientAttribute(const FillGradientAttribute
&);
71 FillGradientAttribute(FillGradientAttribute
&&);
72 FillGradientAttribute
& operator=(const FillGradientAttribute
&);
73 FillGradientAttribute
& operator=(FillGradientAttribute
&&);
74 ~FillGradientAttribute();
76 // checks if the incarnation is default constructed
77 bool isDefault() const;
79 // MCGR: Check if rendering cannot be handled by old vcl stuff
80 // due to various restrictions, based on local parameters. There
81 // may be even more reasons on caller's side, e.g. a
82 // ViewTransformation that uses shear/rotate/mirror (what VCL
84 bool cannotBeHandledByVCL() const;
86 // check if local and given FillGradientAttribute are identical,
87 // do take care of exceptions (e.g. no offset for linear/axial, ...)
88 bool sameDefinitionThanAlpha(const FillGradientAttribute
& rAlpha
) const;
91 bool operator==(const FillGradientAttribute
& rCandidate
) const;
94 css::awt::GradientStyle
getStyle() const;
95 double getBorder() const;
96 double getOffsetX() const;
97 double getOffsetY() const;
98 double getAngle() const;
99 const basegfx::BColorStops
& getColorStops() const;
100 sal_uInt16
getSteps() const;
103 } // end of namespace drawinglayer::attribute
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */