xref: /AOO41X/main/svgio/inc/svgio/svgreader/svgnode.hxx (revision ddde725d65c83fe3ba1186d46f6e3e08f12ba47e)
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_SVGNODE_HXX
23*ddde725dSArmin Le Grand #define INCLUDED_SVGIO_SVGREADER_SVGNODE_HXX
24*ddde725dSArmin Le Grand 
25*ddde725dSArmin Le Grand #include <svgio/svgiodllapi.h>
26*ddde725dSArmin Le Grand #include <svgio/svgreader/svgtools.hxx>
27*ddde725dSArmin Le Grand #include <svgio/svgreader/svgtoken.hxx>
28*ddde725dSArmin Le Grand #include <svgio/svgreader/svgpaint.hxx>
29*ddde725dSArmin Le Grand #include <basegfx/matrix/b2dhommatrix.hxx>
30*ddde725dSArmin Le Grand #include <com/sun/star/xml/sax/XAttributeList.hpp>
31*ddde725dSArmin Le Grand #include <vector>
32*ddde725dSArmin Le Grand #include <hash_map>
33*ddde725dSArmin Le Grand 
34*ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
35*ddde725dSArmin Le Grand // predefines
36*ddde725dSArmin Le Grand namespace svgio
37*ddde725dSArmin Le Grand {
38*ddde725dSArmin Le Grand     namespace svgreader
39*ddde725dSArmin Le Grand     {
40*ddde725dSArmin Le Grand         class SvgNode;
41*ddde725dSArmin Le Grand         class SvgDocument;
42*ddde725dSArmin Le Grand         class SvgStyleAttributes;
43*ddde725dSArmin Le Grand     }
44*ddde725dSArmin Le Grand }
45*ddde725dSArmin Le Grand 
46*ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
47*ddde725dSArmin Le Grand 
48*ddde725dSArmin Le Grand namespace svgio
49*ddde725dSArmin Le Grand {
50*ddde725dSArmin Le Grand     namespace svgreader
51*ddde725dSArmin Le Grand     {
52*ddde725dSArmin Le Grand         typedef ::std::vector< SvgNode* > SvgNodeVector;
53*ddde725dSArmin Le Grand 
54*ddde725dSArmin Le Grand         enum XmlSpace
55*ddde725dSArmin Le Grand         {
56*ddde725dSArmin Le Grand             XmlSpace_notset,
57*ddde725dSArmin Le Grand             XmlSpace_default,
58*ddde725dSArmin Le Grand             XmlSpace_preserve
59*ddde725dSArmin Le Grand         };
60*ddde725dSArmin Le Grand 
61*ddde725dSArmin Le Grand         class SvgNode : private boost::noncopyable, public InfoProvider
62*ddde725dSArmin Le Grand         {
63*ddde725dSArmin Le Grand         private:
64*ddde725dSArmin Le Grand             /// basic data, Type, document we belong to and parent (if not root)
65*ddde725dSArmin Le Grand             SVGToken                    maType;
66*ddde725dSArmin Le Grand             SvgDocument&                mrDocument;
67*ddde725dSArmin Le Grand             const SvgNode*              mpParent;
68*ddde725dSArmin Le Grand             const SvgNode*              mpAlternativeParent;
69*ddde725dSArmin Le Grand 
70*ddde725dSArmin Le Grand             /// sub hierarchy
71*ddde725dSArmin Le Grand             SvgNodeVector               maChildren;
72*ddde725dSArmin Le Grand 
73*ddde725dSArmin Le Grand             /// Id svan value
74*ddde725dSArmin Le Grand             rtl::OUString*              mpId;
75*ddde725dSArmin Le Grand 
76*ddde725dSArmin Le Grand             /// Class svan value
77*ddde725dSArmin Le Grand             rtl::OUString*              mpClass;
78*ddde725dSArmin Le Grand 
79*ddde725dSArmin Le Grand             /// XmlSpace value
80*ddde725dSArmin Le Grand             XmlSpace                    maXmlSpace;
81*ddde725dSArmin Le Grand 
82*ddde725dSArmin Le Grand         public:
83*ddde725dSArmin Le Grand             SvgNode(
84*ddde725dSArmin Le Grand                 SVGToken aType,
85*ddde725dSArmin Le Grand                 SvgDocument& rDocument,
86*ddde725dSArmin Le Grand                 SvgNode* pParent);
87*ddde725dSArmin Le Grand             virtual ~SvgNode();
88*ddde725dSArmin Le Grand 
89*ddde725dSArmin Le Grand             void parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs);
90*ddde725dSArmin Le Grand             virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
91*ddde725dSArmin Le Grand             virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
92*ddde725dSArmin Le Grand             virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const;
93*ddde725dSArmin Le Grand 
94*ddde725dSArmin Le Grand             /// basic data read access
95*ddde725dSArmin Le Grand             const SVGToken getType() const { return maType; }
96*ddde725dSArmin Le Grand             const SvgDocument& getDocument() const { return mrDocument; }
97*ddde725dSArmin Le Grand             const SvgNode* getParent() const { if(mpAlternativeParent) return mpAlternativeParent; return mpParent; }
98*ddde725dSArmin Le Grand             const SvgNodeVector& getChildren() const { return maChildren; }
99*ddde725dSArmin Le Grand 
100*ddde725dSArmin Le Grand             /// InfoProvider support for %, em and ex values
101*ddde725dSArmin Le Grand             virtual const basegfx::B2DRange* getCurrentViewPort() const;
102*ddde725dSArmin Le Grand             virtual double getCurrentFontSize() const;
103*ddde725dSArmin Le Grand             virtual double getCurrentXHeight() const;
104*ddde725dSArmin Le Grand 
105*ddde725dSArmin Le Grand             /// Id access
106*ddde725dSArmin Le Grand             const rtl::OUString* getId() const { return mpId; }
107*ddde725dSArmin Le Grand             void setId(const rtl::OUString* pfId = 0);
108*ddde725dSArmin Le Grand 
109*ddde725dSArmin Le Grand             /// Class access
110*ddde725dSArmin Le Grand             const rtl::OUString* getClass() const { return mpClass; }
111*ddde725dSArmin Le Grand             void setClass(const rtl::OUString* pfClass = 0);
112*ddde725dSArmin Le Grand 
113*ddde725dSArmin Le Grand             /// XmlSpace access
114*ddde725dSArmin Le Grand             XmlSpace getXmlSpace() const;
115*ddde725dSArmin Le Grand             void setXmlSpace(XmlSpace eXmlSpace = XmlSpace_notset) { maXmlSpace = eXmlSpace; }
116*ddde725dSArmin Le Grand 
117*ddde725dSArmin Le Grand             /// alternative parent
118*ddde725dSArmin Le Grand             void setAlternativeParent(const SvgNode* pAlternativeParent = 0) { mpAlternativeParent = pAlternativeParent; }
119*ddde725dSArmin Le Grand         };
120*ddde725dSArmin Le Grand     } // end of namespace svgreader
121*ddde725dSArmin Le Grand } // end of namespace svgio
122*ddde725dSArmin Le Grand 
123*ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
124*ddde725dSArmin Le Grand 
125*ddde725dSArmin Le Grand #endif //INCLUDED_SVGIO_SVGREADER_SVGNODE_HXX
126*ddde725dSArmin Le Grand 
127*ddde725dSArmin Le Grand // eof
128