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