1*ddde725dSArmin Le Grand /**************************************************************
2*ddde725dSArmin Le Grand  *
3*ddde725dSArmin Le Grand  * Licensed to the Apache Software Foundation (ASF) under one
4*ddde725dSArmin Le Grand  * or more contributor license agreements.  See the NOTICE file
5*ddde725dSArmin Le Grand  * distributed with this work for additional information
6*ddde725dSArmin Le Grand  * regarding copyright ownership.  The ASF licenses this file
7*ddde725dSArmin Le Grand  * to you under the Apache License, Version 2.0 (the
8*ddde725dSArmin Le Grand  * "License"); you may not use this file except in compliance
9*ddde725dSArmin Le Grand  * with the License.  You may obtain a copy of the License at
10*ddde725dSArmin Le Grand  *
11*ddde725dSArmin Le Grand  *   http://www.apache.org/licenses/LICENSE-2.0
12*ddde725dSArmin Le Grand  *
13*ddde725dSArmin Le Grand  * Unless required by applicable law or agreed to in writing,
14*ddde725dSArmin Le Grand  * software distributed under the License is distributed on an
15*ddde725dSArmin Le Grand  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ddde725dSArmin Le Grand  * KIND, either express or implied.  See the License for the
17*ddde725dSArmin Le Grand  * specific language governing permissions and limitations
18*ddde725dSArmin Le Grand  * under the License.
19*ddde725dSArmin Le Grand  *
20*ddde725dSArmin Le Grand  *************************************************************/
21*ddde725dSArmin Le Grand 
22*ddde725dSArmin Le Grand #ifndef INCLUDED_SVGIO_SVGREADER_SVGGRADIENTNODE_HXX
23*ddde725dSArmin Le Grand #define INCLUDED_SVGIO_SVGREADER_SVGGRADIENTNODE_HXX
24*ddde725dSArmin Le Grand 
25*ddde725dSArmin Le Grand #include <svgio/svgiodllapi.h>
26*ddde725dSArmin Le Grand #include <svgio/svgreader/svgnode.hxx>
27*ddde725dSArmin Le Grand #include <svgio/svgreader/svgstyleattributes.hxx>
28*ddde725dSArmin Le Grand #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
29*ddde725dSArmin Le Grand 
30*ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
31*ddde725dSArmin Le Grand 
32*ddde725dSArmin Le Grand namespace svgio
33*ddde725dSArmin Le Grand {
34*ddde725dSArmin Le Grand     namespace svgreader
35*ddde725dSArmin Le Grand     {
36*ddde725dSArmin Le Grand         class SvgGradientNode : public SvgNode
37*ddde725dSArmin Le Grand         {
38*ddde725dSArmin Le Grand         private:
39*ddde725dSArmin Le Grand             /// use styles
40*ddde725dSArmin Le Grand             SvgStyleAttributes          maSvgStyleAttributes;
41*ddde725dSArmin Le Grand 
42*ddde725dSArmin Le Grand             /// linear gradient values
43*ddde725dSArmin Le Grand             SvgNumber                   maX1;
44*ddde725dSArmin Le Grand             SvgNumber                   maY1;
45*ddde725dSArmin Le Grand             SvgNumber                   maX2;
46*ddde725dSArmin Le Grand             SvgNumber                   maY2;
47*ddde725dSArmin Le Grand 
48*ddde725dSArmin Le Grand             /// radial gradient values
49*ddde725dSArmin Le Grand             SvgNumber                   maCx;
50*ddde725dSArmin Le Grand             SvgNumber                   maCy;
51*ddde725dSArmin Le Grand             SvgNumber                   maR;
52*ddde725dSArmin Le Grand             SvgNumber                   maFx;
53*ddde725dSArmin Le Grand             SvgNumber                   maFy;
54*ddde725dSArmin Le Grand 
55*ddde725dSArmin Le Grand             /// variable scan values, dependent of given XAttributeList
56*ddde725dSArmin Le Grand             SvgUnits                    maGradientUnits;
57*ddde725dSArmin Le Grand             drawinglayer::primitive2d::SpreadMethod   maSpreadMethod;
58*ddde725dSArmin Le Grand             basegfx::B2DHomMatrix*      mpaGradientTransform;
59*ddde725dSArmin Le Grand 
60*ddde725dSArmin Le Grand             /// link to another gradient used as style. If maXLink
61*ddde725dSArmin Le Grand             /// is set, the node can be fetched on demand by using
62*ddde725dSArmin Le Grand             // tryToFindLink (buffered)
63*ddde725dSArmin Le Grand             rtl::OUString               maXLink;
64*ddde725dSArmin Le Grand             const SvgGradientNode*      mpXLink;
65*ddde725dSArmin Le Grand 
66*ddde725dSArmin Le Grand             /// link on demand
67*ddde725dSArmin Le Grand             void tryToFindLink();
68*ddde725dSArmin Le Grand 
69*ddde725dSArmin Le Grand         public:
70*ddde725dSArmin Le Grand             SvgGradientNode(
71*ddde725dSArmin Le Grand                 SVGToken aType,
72*ddde725dSArmin Le Grand                 SvgDocument& rDocument,
73*ddde725dSArmin Le Grand                 SvgNode* pParent);
74*ddde725dSArmin Le Grand             virtual ~SvgGradientNode();
75*ddde725dSArmin Le Grand 
76*ddde725dSArmin Le Grand             virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
77*ddde725dSArmin Le Grand             virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
78*ddde725dSArmin Le Grand 
79*ddde725dSArmin Le Grand             /// collect gradient stop entries
80*ddde725dSArmin Le Grand             void collectGradientEntries(drawinglayer::primitive2d::SvgGradientEntryVector& aVector) const;
81*ddde725dSArmin Le Grand 
82*ddde725dSArmin Le Grand             /// x1 content
83*ddde725dSArmin Le Grand             const SvgNumber getX1() const;
setX1(const SvgNumber & rX1=SvgNumber ())84*ddde725dSArmin Le Grand             void setX1(const SvgNumber& rX1 = SvgNumber()) { maX1 = rX1; }
85*ddde725dSArmin Le Grand 
86*ddde725dSArmin Le Grand             /// y1 content
87*ddde725dSArmin Le Grand             const SvgNumber getY1() const;
setY1(const SvgNumber & rY1=SvgNumber ())88*ddde725dSArmin Le Grand             void setY1(const SvgNumber& rY1 = SvgNumber()) { maY1 = rY1; }
89*ddde725dSArmin Le Grand 
90*ddde725dSArmin Le Grand             /// x2 content
91*ddde725dSArmin Le Grand             const SvgNumber getX2() const;
setX2(const SvgNumber & rX2=SvgNumber ())92*ddde725dSArmin Le Grand             void setX2(const SvgNumber& rX2 = SvgNumber()) { maX2 = rX2; }
93*ddde725dSArmin Le Grand 
94*ddde725dSArmin Le Grand             /// y2 content
95*ddde725dSArmin Le Grand             const SvgNumber getY2() const;
setY2(const SvgNumber & rY2=SvgNumber ())96*ddde725dSArmin Le Grand             void setY2(const SvgNumber& rY2 = SvgNumber()) { maY2 = rY2; }
97*ddde725dSArmin Le Grand 
98*ddde725dSArmin Le Grand             /// Cx content
99*ddde725dSArmin Le Grand             const SvgNumber getCx() const;
setCx(const SvgNumber & rCx=SvgNumber ())100*ddde725dSArmin Le Grand             void setCx(const SvgNumber& rCx = SvgNumber()) { maCx = rCx; }
101*ddde725dSArmin Le Grand 
102*ddde725dSArmin Le Grand             /// Cy content
103*ddde725dSArmin Le Grand             const SvgNumber getCy() const;
setCy(const SvgNumber & rCy=SvgNumber ())104*ddde725dSArmin Le Grand             void setCy(const SvgNumber& rCy = SvgNumber()) { maCy = rCy; }
105*ddde725dSArmin Le Grand 
106*ddde725dSArmin Le Grand             /// R content
107*ddde725dSArmin Le Grand             const SvgNumber getR() const;
setR(const SvgNumber & rR=SvgNumber ())108*ddde725dSArmin Le Grand             void setR(const SvgNumber& rR = SvgNumber()) { maR = rR; }
109*ddde725dSArmin Le Grand 
110*ddde725dSArmin Le Grand             /// Fx content
111*ddde725dSArmin Le Grand             const SvgNumber* getFx() const;
setFx(const SvgNumber & rFx=SvgNumber ())112*ddde725dSArmin Le Grand             void setFx(const SvgNumber& rFx = SvgNumber()) { maFx = rFx; }
113*ddde725dSArmin Le Grand 
114*ddde725dSArmin Le Grand             /// Fy content
115*ddde725dSArmin Le Grand             const SvgNumber* getFy() const;
setFy(const SvgNumber & rFy=SvgNumber ())116*ddde725dSArmin Le Grand             void setFy(const SvgNumber& rFy = SvgNumber()) { maFy = rFy; }
117*ddde725dSArmin Le Grand 
118*ddde725dSArmin Le Grand             /// gradientUnits content
getGradientUnits() const119*ddde725dSArmin Le Grand             SvgUnits getGradientUnits() const { return maGradientUnits; }
setGradientUnits(const SvgUnits aGradientUnits)120*ddde725dSArmin Le Grand             void setGradientUnits(const SvgUnits aGradientUnits) { maGradientUnits = aGradientUnits; }
121*ddde725dSArmin Le Grand 
122*ddde725dSArmin Le Grand             /// SpreadMethod content
getSpreadMethod() const123*ddde725dSArmin Le Grand             drawinglayer::primitive2d::SpreadMethod getSpreadMethod() const { return maSpreadMethod; }
setSpreadMethod(const drawinglayer::primitive2d::SpreadMethod aSpreadMethod)124*ddde725dSArmin Le Grand             void setSpreadMethod(const drawinglayer::primitive2d::SpreadMethod aSpreadMethod) { maSpreadMethod = aSpreadMethod; }
125*ddde725dSArmin Le Grand 
126*ddde725dSArmin Le Grand             /// transform content, set if found in current context
127*ddde725dSArmin Le Grand             const basegfx::B2DHomMatrix* getGradientTransform() const;
128*ddde725dSArmin Le Grand             void setGradientTransform(const basegfx::B2DHomMatrix* pMatrix = 0);
129*ddde725dSArmin Le Grand         };
130*ddde725dSArmin Le Grand     } // end of namespace svgreader
131*ddde725dSArmin Le Grand } // end of namespace svgio
132*ddde725dSArmin Le Grand 
133*ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
134*ddde725dSArmin Le Grand 
135*ddde725dSArmin Le Grand #endif //INCLUDED_SVGIO_SVGREADER_SVGGRADIENTNODE_HXX
136*ddde725dSArmin Le Grand 
137*ddde725dSArmin Le Grand // eof
138