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 :
20 : #ifndef INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGGRADIENTNODE_HXX
21 : #define INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGGRADIENTNODE_HXX
22 :
23 : #include <svgio/svgreader/svgnode.hxx>
24 : #include <svgio/svgreader/svgstyleattributes.hxx>
25 : #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
26 :
27 : namespace svgio
28 : {
29 : namespace svgreader
30 : {
31 : class SvgGradientNode : public SvgNode
32 : {
33 : private:
34 : /// use styles
35 : SvgStyleAttributes maSvgStyleAttributes;
36 :
37 : /// linear gradient values
38 : SvgNumber maX1;
39 : SvgNumber maY1;
40 : SvgNumber maX2;
41 : SvgNumber maY2;
42 :
43 : /// radial gradient values
44 : SvgNumber maCx;
45 : SvgNumber maCy;
46 : SvgNumber maR;
47 : SvgNumber maFx;
48 : SvgNumber maFy;
49 :
50 : /// variable scan values, dependent of given XAttributeList
51 : SvgUnits maGradientUnits;
52 : drawinglayer::primitive2d::SpreadMethod maSpreadMethod;
53 : basegfx::B2DHomMatrix* mpaGradientTransform;
54 :
55 : /// link to another gradient used as style. If maXLink
56 : /// is set, the node can be fetched on demand by using
57 : // tryToFindLink (buffered)
58 : OUString maXLink;
59 : const SvgGradientNode* mpXLink;
60 :
61 : /// link on demand
62 : void tryToFindLink();
63 :
64 : public:
65 : SvgGradientNode(
66 : SVGToken aType,
67 : SvgDocument& rDocument,
68 : SvgNode* pParent);
69 : virtual ~SvgGradientNode();
70 :
71 : virtual const SvgStyleAttributes* getSvgStyleAttributes() const SAL_OVERRIDE;
72 : virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) SAL_OVERRIDE;
73 :
74 : /// collect gradient stop entries
75 : void collectGradientEntries(drawinglayer::primitive2d::SvgGradientEntryVector& aVector) const;
76 :
77 : /// x1 content
78 : const SvgNumber getX1() const;
79 1197 : void setX1(const SvgNumber& rX1 = SvgNumber()) { maX1 = rX1; }
80 :
81 : /// y1 content
82 : const SvgNumber getY1() const;
83 1197 : void setY1(const SvgNumber& rY1 = SvgNumber()) { maY1 = rY1; }
84 :
85 : /// x2 content
86 : const SvgNumber getX2() const;
87 1197 : void setX2(const SvgNumber& rX2 = SvgNumber()) { maX2 = rX2; }
88 :
89 : /// y2 content
90 : const SvgNumber getY2() const;
91 1197 : void setY2(const SvgNumber& rY2 = SvgNumber()) { maY2 = rY2; }
92 :
93 : /// Cx content
94 : const SvgNumber getCx() const;
95 103 : void setCx(const SvgNumber& rCx = SvgNumber()) { maCx = rCx; }
96 :
97 : /// Cy content
98 : const SvgNumber getCy() const;
99 103 : void setCy(const SvgNumber& rCy = SvgNumber()) { maCy = rCy; }
100 :
101 : /// R content
102 : const SvgNumber getR() const;
103 103 : void setR(const SvgNumber& rR = SvgNumber()) { maR = rR; }
104 :
105 : /// Fx content
106 : const SvgNumber* getFx() const;
107 0 : void setFx(const SvgNumber& rFx = SvgNumber()) { maFx = rFx; }
108 :
109 : /// Fy content
110 : const SvgNumber* getFy() const;
111 0 : void setFy(const SvgNumber& rFy = SvgNumber()) { maFy = rFy; }
112 :
113 : /// gradientUnits content
114 3732 : SvgUnits getGradientUnits() const { return maGradientUnits; }
115 1300 : void setGradientUnits(const SvgUnits aGradientUnits) { maGradientUnits = aGradientUnits; }
116 :
117 : /// SpreadMethod content
118 1244 : drawinglayer::primitive2d::SpreadMethod getSpreadMethod() const { return maSpreadMethod; }
119 0 : void setSpreadMethod(const drawinglayer::primitive2d::SpreadMethod aSpreadMethod) { maSpreadMethod = aSpreadMethod; }
120 :
121 : /// transform content, set if found in current context
122 : const basegfx::B2DHomMatrix* getGradientTransform() const;
123 : void setGradientTransform(const basegfx::B2DHomMatrix* pMatrix = 0);
124 : };
125 : } // end of namespace svgreader
126 : } // end of namespace svgio
127 :
128 : #endif // INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGGRADIENTNODE_HXX
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|