1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef INCLUDED_SVGIO_SVGREADER_SVGMARKERNODE_HXX
23 #define INCLUDED_SVGIO_SVGREADER_SVGMARKERNODE_HXX
24 
25 #include <svgio/svgiodllapi.h>
26 #include <svgio/svgreader/svgnode.hxx>
27 #include <svgio/svgreader/svgstyleattributes.hxx>
28 
29 //////////////////////////////////////////////////////////////////////////////
30 
31 namespace svgio
32 {
33     namespace svgreader
34     {
35         class SvgMarkerNode : public SvgNode
36         {
37         public:
38             enum MarkerUnits
39             {
40                 strokeWidth,
41                 userSpaceOnUse
42             };
43 
44         private:
45             /// buffered decomposition
46             drawinglayer::primitive2d::Primitive2DSequence aPrimitives;
47 
48             /// use styles
49             SvgStyleAttributes      maSvgStyleAttributes;
50 
51             /// variable scan values, dependent of given XAttributeList
52             basegfx::B2DRange*      mpViewBox;
53             SvgAspectRatio          maSvgAspectRatio;
54             SvgNumber               maRefX;
55             SvgNumber               maRefY;
56             MarkerUnits             maMarkerUnits;
57             SvgNumber               maMarkerWidth;
58             SvgNumber               maMarkerHeight;
59             double                  mfAngle;
60 
61             /// bitfield
62             bool                    mbOrientAuto : 1; // true == on, false == fAngle valid
63 
64         public:
65             SvgMarkerNode(
66                 SvgDocument& rDocument,
67                 SvgNode* pParent);
68             virtual ~SvgMarkerNode();
69 
70             virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
71             virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
72 
73             /// get marker primitives buffered, uses decomposeSvgNode internally
74             const drawinglayer::primitive2d::Primitive2DSequence& getMarkerPrimitives() const;
75 
76             /// InfoProvider support for % values
77             virtual const basegfx::B2DRange* getCurrentViewPort() const;
78 
79             /// viewBox content
80             const basegfx::B2DRange* getViewBox() const { return mpViewBox; }
81             void setViewBox(const basegfx::B2DRange* pViewBox = 0) { if(mpViewBox) delete mpViewBox; mpViewBox = 0; if(pViewBox) mpViewBox = new basegfx::B2DRange(*pViewBox); }
82 
83             /// SvgAspectRatio content
84             const SvgAspectRatio& getSvgAspectRatio() const { return maSvgAspectRatio; }
85             void setSvgAspectRatio(const SvgAspectRatio& rSvgAspectRatio = SvgAspectRatio()) { maSvgAspectRatio = rSvgAspectRatio; }
86 
87             /// RefX content, set if found in current context
88             const SvgNumber& getRefX() const { return maRefX; }
89             void setRefX(const SvgNumber& rRefX = SvgNumber()) { maRefX = rRefX; }
90 
91             /// RefY content, set if found in current context
92             const SvgNumber& getRefY() const { return maRefY; }
93             void setRefY(const SvgNumber& rRefY = SvgNumber()) { maRefY = rRefY; }
94 
95             /// MarkerUnits content
96             MarkerUnits getMarkerUnits() const { return maMarkerUnits; }
97             void setMarkerUnits(const MarkerUnits aMarkerUnits) { maMarkerUnits = aMarkerUnits; }
98 
99             /// MarkerWidth content, set if found in current context
100             const SvgNumber& getMarkerWidth() const { return maMarkerWidth; }
101             void setMarkerWidth(const SvgNumber& rMarkerWidth = SvgNumber()) { maMarkerWidth = rMarkerWidth; }
102 
103             /// MarkerHeight content, set if found in current context
104             const SvgNumber& getMarkerHeight() const { return maMarkerHeight; }
105             void setMarkerHeight(const SvgNumber& rMarkerHeight = SvgNumber()) { maMarkerHeight = rMarkerHeight; }
106 
107             /// Angle content, set if found in current context
108             double getAngle() const { return mfAngle; }
109             void setAngle(double fAngle = 0.0) { mfAngle = fAngle; mbOrientAuto = false; }
110 
111             /// OrientAuto content, set if found in current context
112             bool getOrientAuto() const { return mbOrientAuto; }
113             void setOrientAuto(bool bOrientAuto = true) { mbOrientAuto = bOrientAuto; }
114 
115         };
116     } // end of namespace svgreader
117 } // end of namespace svgio
118 
119 //////////////////////////////////////////////////////////////////////////////
120 
121 #endif //INCLUDED_SVGIO_SVGREADER_SVGMARKERNODE_HXX
122 
123 // eof
124