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_SVGSVGNODE_HXX 23 #define INCLUDED_SVGIO_SVGREADER_SVGSVGNODE_HXX 24 25 #include <svgio/svgiodllapi.h> 26 #include <svgio/svgreader/svgstyleattributes.hxx> 27 28 ////////////////////////////////////////////////////////////////////////////// 29 30 namespace svgio 31 { 32 namespace svgreader 33 { 34 class SvgSvgNode : public SvgNode 35 { 36 private: 37 /// use styles 38 SvgStyleAttributes maSvgStyleAttributes; 39 40 /// variable scan values, dependent of given XAttributeList 41 basegfx::B2DRange* mpViewBox; 42 SvgAspectRatio maSvgAspectRatio; 43 SvgNumber maX; 44 SvgNumber maY; 45 SvgNumber maWidth; 46 SvgNumber maHeight; 47 SvgNumber maVersion; 48 49 /// #125258# bitfield 50 bool mbStyleAttributesInitialized : 1; 51 52 // #125258# on-demand init hard attributes when this is the outmost svg element 53 // and more (see implementation) 54 void initializeStyleAttributes(); 55 56 public: 57 SvgSvgNode( 58 SvgDocument& rDocument, 59 SvgNode* pParent); 60 virtual ~SvgSvgNode(); 61 62 virtual const SvgStyleAttributes* getSvgStyleAttributes() const; 63 virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent); 64 virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const; 65 66 /// Seeks width and height of viewport, which is current before the new viewport is set. 67 // needed for percentage unit in x, y, width or height 68 virtual void seekReferenceWidth(double& fWidth, bool& bHasFound) const; 69 virtual void seekReferenceHeight(double& fHeight, bool& bHasFound) const; 70 71 /// InfoProvider support for % values in childs 72 // The returned 'CurrentViewPort' is the viewport as it is set by this svg element 73 // and as it is needed to resolve relative values in childs 74 // The method does not check for invalid width and height 75 virtual const basegfx::B2DRange getCurrentViewPort() const; 76 77 /// viewBox content getViewBox() const78 const basegfx::B2DRange* getViewBox() const { return mpViewBox; } setViewBox(const basegfx::B2DRange * pViewBox=0)79 void setViewBox(const basegfx::B2DRange* pViewBox = 0) { if(mpViewBox) delete mpViewBox; mpViewBox = 0; if(pViewBox) mpViewBox = new basegfx::B2DRange(*pViewBox); } 80 81 /// SvgAspectRatio content getSvgAspectRatio() const82 const SvgAspectRatio& getSvgAspectRatio() const { return maSvgAspectRatio; } setSvgAspectRatio(const SvgAspectRatio & rSvgAspectRatio=SvgAspectRatio ())83 void setSvgAspectRatio(const SvgAspectRatio& rSvgAspectRatio = SvgAspectRatio()) { maSvgAspectRatio = rSvgAspectRatio; } 84 85 /// x content getX() const86 const SvgNumber& getX() const { return maX; } setX(const SvgNumber & rX=SvgNumber ())87 void setX(const SvgNumber& rX = SvgNumber()) { maX = rX; } 88 89 /// y content getY() const90 const SvgNumber& getY() const { return maY; } setY(const SvgNumber & rY=SvgNumber ())91 void setY(const SvgNumber& rY = SvgNumber()) { maY = rY; } 92 93 /// width content getWidth() const94 const SvgNumber& getWidth() const { return maWidth; } setWidth(const SvgNumber & rWidth=SvgNumber ())95 void setWidth(const SvgNumber& rWidth = SvgNumber()) { maWidth = rWidth; } 96 97 /// height content getHeight() const98 const SvgNumber& getHeight() const { return maHeight; } setHeight(const SvgNumber & rHeight=SvgNumber ())99 void setHeight(const SvgNumber& rHeight = SvgNumber()) { maHeight = rHeight; } 100 101 /// version content getVersion() const102 const SvgNumber& getVersion() const { return maVersion; } setVersion(const SvgNumber & rVersion=SvgNumber ())103 void setVersion(const SvgNumber& rVersion = SvgNumber()) { maVersion = rVersion; } 104 }; 105 } // end of namespace svgreader 106 } // end of namespace svgio 107 108 ////////////////////////////////////////////////////////////////////////////// 109 110 #endif //INCLUDED_SVGIO_SVGREADER_SVGSVGNODE_HXX 111 112 // eof 113