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