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 typedef ::std::vector< const SvgStyleAttributes* > SvgStyleAttributeVector; 54 55 enum XmlSpace 56 { 57 XmlSpace_notset, 58 XmlSpace_default, 59 XmlSpace_preserve 60 }; 61 62 class SvgNode : private boost::noncopyable, public InfoProvider 63 { 64 private: 65 /// basic data, Type, document we belong to and parent (if not root) 66 SVGToken maType; 67 SvgDocument& mrDocument; 68 const SvgNode* mpParent; 69 const SvgNode* mpAlternativeParent; 70 71 /// sub hierarchy 72 SvgNodeVector maChildren; 73 74 /// Id svan value 75 rtl::OUString* mpId; 76 77 /// Class svan value 78 rtl::OUString* mpClass; 79 80 /// XmlSpace value 81 XmlSpace maXmlSpace; 82 83 /// CSS styles 84 SvgStyleAttributeVector maCssStyleVector; 85 86 protected: 87 /// helper to evtl. link to css style 88 const SvgStyleAttributes* checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const; 89 90 public: 91 SvgNode( 92 SVGToken aType, 93 SvgDocument& rDocument, 94 SvgNode* pParent); 95 virtual ~SvgNode(); 96 97 void parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs); 98 virtual const SvgStyleAttributes* getSvgStyleAttributes() const; 99 virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent); 100 virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const; 101 102 /// basic data read access 103 SVGToken getType() const { return maType; } 104 const SvgDocument& getDocument() const { return mrDocument; } 105 const SvgNode* getParent() const { if(mpAlternativeParent) return mpAlternativeParent; return mpParent; } 106 const SvgNodeVector& getChildren() const { return maChildren; } 107 108 /// InfoProvider support for %, em and ex values 109 virtual const basegfx::B2DRange* getCurrentViewPort() const; 110 virtual double getCurrentFontSize() const; 111 virtual double getCurrentXHeight() const; 112 113 /// Id access 114 const rtl::OUString* getId() const { return mpId; } 115 void setId(const rtl::OUString* pfId = 0); 116 117 /// Class access 118 const rtl::OUString* getClass() const { return mpClass; } 119 void setClass(const rtl::OUString* pfClass = 0); 120 121 /// XmlSpace access 122 XmlSpace getXmlSpace() const; 123 void setXmlSpace(XmlSpace eXmlSpace = XmlSpace_notset) { maXmlSpace = eXmlSpace; } 124 125 /// alternative parent 126 void setAlternativeParent(const SvgNode* pAlternativeParent = 0) { mpAlternativeParent = pAlternativeParent; } 127 }; 128 } // end of namespace svgreader 129 } // end of namespace svgio 130 131 ////////////////////////////////////////////////////////////////////////////// 132 133 #endif //INCLUDED_SVGIO_SVGREADER_SVGNODE_HXX 134 135 // eof 136