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