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 "svgnode.hxx"
23 #include "svgstyleattributes.hxx"
24 #include "svgtools.hxx"
25 #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
27 namespace svgio::svgreader
29 class SvgGradientNode final
: public SvgNode
33 SvgStyleAttributes maSvgStyleAttributes
;
35 /// linear gradient values
41 /// radial gradient values
48 /// variable scan values, dependent of given XAttributeList
49 SvgUnits maGradientUnits
;
50 drawinglayer::primitive2d::SpreadMethod maSpreadMethod
;
51 std::optional
<basegfx::B2DHomMatrix
> mpaGradientTransform
;
53 /// link to another gradient used as style. If maXLink
54 /// is set, the node can be fetched on demand by using
55 // tryToFindLink (buffered)
56 mutable bool mbResolvingLink
; // protect against infinite link recursion
58 const SvgGradientNode
* mpXLink
;
66 SvgDocument
& rDocument
,
68 virtual ~SvgGradientNode() override
;
70 virtual const SvgStyleAttributes
* getSvgStyleAttributes() const override
;
71 virtual void parseAttribute(const OUString
& rTokenName
, SVGToken aSVGToken
, const OUString
& aContent
) override
;
73 /// collect gradient stop entries
74 void collectGradientEntries(drawinglayer::primitive2d::SvgGradientEntryVector
& aVector
) const;
77 SvgNumber
getX1() const;
80 SvgNumber
getY1() const;
83 SvgNumber
getX2() const;
86 SvgNumber
getY2() const;
89 SvgNumber
getCx() const;
92 SvgNumber
getCy() const;
95 SvgNumber
getR() const;
98 const SvgNumber
* getFx() const;
101 const SvgNumber
* getFy() const;
103 /// gradientUnits content
104 SvgUnits
getGradientUnits() const { return maGradientUnits
; }
105 void setGradientUnits(const SvgUnits aGradientUnits
) { maGradientUnits
= aGradientUnits
; }
107 /// SpreadMethod content
108 drawinglayer::primitive2d::SpreadMethod
getSpreadMethod() const { return maSpreadMethod
; }
109 void setSpreadMethod(const drawinglayer::primitive2d::SpreadMethod aSpreadMethod
) { maSpreadMethod
= aSpreadMethod
; }
111 /// transform content, set if found in current context
112 std::optional
<basegfx::B2DHomMatrix
> getGradientTransform() const;
113 void setGradientTransform(const std::optional
<basegfx::B2DHomMatrix
>& pMatrix
) { mpaGradientTransform
= pMatrix
; }
116 } // end of namespace svgio::svgreader
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */