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