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_SVGPATTERNNODE_HXX
21 : #define INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGPATTERNNODE_HXX
22 :
23 : #include <svgio/svgreader/svgnode.hxx>
24 : #include <svgio/svgreader/svgstyleattributes.hxx>
25 :
26 : namespace svgio
27 : {
28 : namespace svgreader
29 : {
30 : class SvgPatternNode : public SvgNode
31 : {
32 : private:
33 : /// buffered decomposition
34 : drawinglayer::primitive2d::Primitive2DSequence aPrimitives;
35 :
36 : /// use styles
37 : SvgStyleAttributes maSvgStyleAttributes;
38 :
39 : /// variable scan values, dependent of given XAttributeList
40 : basegfx::B2DRange* mpViewBox;
41 : SvgAspectRatio maSvgAspectRatio;
42 : SvgNumber maX;
43 : SvgNumber maY;
44 : SvgNumber maWidth;
45 : SvgNumber maHeight;
46 : SvgUnits* mpPatternUnits;
47 : SvgUnits* mpPatternContentUnits;
48 : basegfx::B2DHomMatrix* mpaPatternTransform;
49 :
50 : /// link to another pattern used as style. If maXLink
51 : /// is set, the node can be fetched on demand by using
52 : // tryToFindLink (buffered)
53 : OUString maXLink;
54 : const SvgPatternNode* mpXLink;
55 :
56 : /// link on demand
57 : void tryToFindLink();
58 :
59 : public:
60 : SvgPatternNode(
61 : SvgDocument& rDocument,
62 : SvgNode* pParent);
63 : virtual ~SvgPatternNode();
64 :
65 : virtual const SvgStyleAttributes* getSvgStyleAttributes() const SAL_OVERRIDE;
66 : virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) SAL_OVERRIDE;
67 :
68 : /// global helpers
69 : void getValuesRelative(double& rfX, double& rfY, double& rfW, double& rfH, const basegfx::B2DRange& rGeoRange, SvgNode& rUser) const;
70 :
71 : /// get pattern primitives buffered, uses decomposeSvgNode internally
72 : const drawinglayer::primitive2d::Primitive2DSequence& getPatternPrimitives() const;
73 :
74 : /// InfoProvider support for % values
75 : virtual const basegfx::B2DRange getCurrentViewPort() const SAL_OVERRIDE;
76 :
77 : /// viewBox content
78 : const basegfx::B2DRange* getViewBox() const;
79 0 : void setViewBox(const basegfx::B2DRange* pViewBox = 0) { if(mpViewBox) delete mpViewBox; mpViewBox = 0; if(pViewBox) mpViewBox = new basegfx::B2DRange(*pViewBox); }
80 :
81 : /// SvgAspectRatio content
82 : const SvgAspectRatio& getSvgAspectRatio() const;
83 0 : void setSvgAspectRatio(const SvgAspectRatio& rSvgAspectRatio = SvgAspectRatio()) { maSvgAspectRatio = rSvgAspectRatio; }
84 :
85 : /// X content, set if found in current context
86 : const SvgNumber& getX() const;
87 0 : void setX(const SvgNumber& rX = SvgNumber()) { maX = rX; }
88 :
89 : /// Y content, set if found in current context
90 : const SvgNumber& getY() const;
91 0 : void setY(const SvgNumber& rY = SvgNumber()) { maY = rY; }
92 :
93 : /// Width content, set if found in current context
94 : const SvgNumber& getWidth() const;
95 0 : void setWidth(const SvgNumber& rWidth = SvgNumber()) { maWidth = rWidth; }
96 :
97 : /// Height content, set if found in current context
98 : const SvgNumber& getHeight() const;
99 0 : void setHeight(const SvgNumber& rHeight = SvgNumber()) { maHeight = rHeight; }
100 :
101 : /// PatternUnits content
102 : const SvgUnits* getPatternUnits() const;
103 0 : void setPatternUnits(const SvgUnits aPatternUnits) { if(mpPatternUnits) delete mpPatternUnits; mpPatternUnits = 0; mpPatternUnits = new SvgUnits(aPatternUnits); }
104 :
105 : /// PatternContentUnits content
106 : const SvgUnits* getPatternContentUnits() const;
107 0 : void setPatternContentUnits(const SvgUnits aPatternContentUnits) { if(mpPatternContentUnits) delete mpPatternContentUnits; mpPatternContentUnits = 0; mpPatternContentUnits = new SvgUnits(aPatternContentUnits); }
108 :
109 : /// PatternTransform content
110 : const basegfx::B2DHomMatrix* getPatternTransform() const;
111 0 : void setPatternTransform(const basegfx::B2DHomMatrix* pMatrix = 0) { if(mpaPatternTransform) delete mpaPatternTransform; mpaPatternTransform = 0; if(pMatrix) mpaPatternTransform = new basegfx::B2DHomMatrix(*pMatrix); }
112 :
113 : };
114 : } // end of namespace svgreader
115 : } // end of namespace svgio
116 :
117 : #endif // INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGPATTERNNODE_HXX
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|