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