Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / svgio / inc / svggradientnode.hxx
blobc55074f97a1099e952ce7000b12fd53eed479200
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 .
20 #ifndef INCLUDED_SVGIO_INC_SVGGRADIENTNODE_HXX
21 #define INCLUDED_SVGIO_INC_SVGGRADIENTNODE_HXX
23 #include "svgnode.hxx"
24 #include "svgstyleattributes.hxx"
25 #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
26 #include <memory>
28 namespace svgio
30 namespace svgreader
32 class SvgGradientNode : public SvgNode
34 private:
35 /// use styles
36 SvgStyleAttributes maSvgStyleAttributes;
38 /// linear gradient values
39 SvgNumber maX1;
40 SvgNumber maY1;
41 SvgNumber maX2;
42 SvgNumber maY2;
44 /// radial gradient values
45 SvgNumber maCx;
46 SvgNumber maCy;
47 SvgNumber maR;
48 SvgNumber maFx;
49 SvgNumber maFy;
51 /// variable scan values, dependent of given XAttributeList
52 SvgUnits maGradientUnits;
53 drawinglayer::primitive2d::SpreadMethod maSpreadMethod;
54 std::unique_ptr<basegfx::B2DHomMatrix> mpaGradientTransform;
56 /// link to another gradient used as style. If maXLink
57 /// is set, the node can be fetched on demand by using
58 // tryToFindLink (buffered)
59 mutable bool mbResolvingLink; // protect against infinite link recursion
60 OUString maXLink;
61 const SvgGradientNode* mpXLink;
63 /// link on demand
64 void tryToFindLink();
66 public:
67 SvgGradientNode(
68 SVGToken aType,
69 SvgDocument& rDocument,
70 SvgNode* pParent);
71 virtual ~SvgGradientNode() override;
73 virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
74 virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
76 /// collect gradient stop entries
77 void collectGradientEntries(drawinglayer::primitive2d::SvgGradientEntryVector& aVector) const;
79 /// x1 content
80 SvgNumber getX1() const;
82 /// y1 content
83 SvgNumber getY1() const;
85 /// x2 content
86 SvgNumber getX2() const;
88 /// y2 content
89 SvgNumber getY2() const;
91 /// Cx content
92 SvgNumber getCx() const;
94 /// Cy content
95 SvgNumber getCy() const;
97 /// R content
98 SvgNumber getR() const;
100 /// Fx content
101 const SvgNumber* getFx() const;
103 /// Fy content
104 const SvgNumber* getFy() const;
106 /// gradientUnits content
107 SvgUnits getGradientUnits() const { return maGradientUnits; }
108 void setGradientUnits(const SvgUnits aGradientUnits) { maGradientUnits = aGradientUnits; }
110 /// SpreadMethod content
111 drawinglayer::primitive2d::SpreadMethod getSpreadMethod() const { return maSpreadMethod; }
112 void setSpreadMethod(const drawinglayer::primitive2d::SpreadMethod aSpreadMethod) { maSpreadMethod = aSpreadMethod; }
114 /// transform content, set if found in current context
115 const basegfx::B2DHomMatrix* getGradientTransform() const;
116 void setGradientTransform(const basegfx::B2DHomMatrix* pMatrix);
118 } // end of namespace svgreader
119 } // end of namespace svgio
121 #endif // INCLUDED_SVGIO_INC_SVGGRADIENTNODE_HXX
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */