Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / svgio / inc / svgpatternnode.hxx
blob79dc7581c59026dc653780a60a2242b355838943
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVGIO_INC_SVGPATTERNNODE_HXX
21 #define INCLUDED_SVGIO_INC_SVGPATTERNNODE_HXX
23 #include "svgnode.hxx"
24 #include "svgstyleattributes.hxx"
25 #include <memory>
27 namespace svgio
29 namespace svgreader
31 class SvgPatternNode : public SvgNode
33 private:
34 /// buffered decomposition
35 drawinglayer::primitive2d::Primitive2DContainer aPrimitives;
37 /// use styles
38 SvgStyleAttributes maSvgStyleAttributes;
40 /// variable scan values, dependent of given XAttributeList
41 std::unique_ptr<basegfx::B2DRange>
42 mpViewBox;
43 SvgAspectRatio maSvgAspectRatio;
44 SvgNumber maX;
45 SvgNumber maY;
46 SvgNumber maWidth;
47 SvgNumber maHeight;
48 std::unique_ptr<SvgUnits>
49 mpPatternUnits;
50 std::unique_ptr<SvgUnits>
51 mpPatternContentUnits;
52 std::unique_ptr<basegfx::B2DHomMatrix>
53 mpaPatternTransform;
55 /// link to another pattern used as style. If maXLink
56 /// is set, the node can be fetched on demand by using
57 // tryToFindLink (buffered)
58 mutable bool mbResolvingLink; // protect against infinite link recursion
59 OUString maXLink;
60 const SvgPatternNode* mpXLink;
62 /// link on demand
63 void tryToFindLink();
65 public:
66 SvgPatternNode(
67 SvgDocument& rDocument,
68 SvgNode* pParent);
69 virtual ~SvgPatternNode() override;
71 virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
72 virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
74 /// global helpers
75 void getValuesRelative(double& rfX, double& rfY, double& rfW, double& rfH, const basegfx::B2DRange& rGeoRange, SvgNode const & rUser) const;
77 /// get pattern primitives buffered, uses decomposeSvgNode internally
78 const drawinglayer::primitive2d::Primitive2DContainer& getPatternPrimitives() const;
80 /// InfoProvider support for % values
81 virtual basegfx::B2DRange getCurrentViewPort() const override;
83 /// viewBox content
84 const basegfx::B2DRange* getViewBox() const;
85 void setViewBox(const basegfx::B2DRange* pViewBox) { mpViewBox.reset(); if(pViewBox) mpViewBox.reset(new basegfx::B2DRange(*pViewBox)); }
87 /// SvgAspectRatio content
88 const SvgAspectRatio& getSvgAspectRatio() const;
90 /// X content, set if found in current context
91 const SvgNumber& getX() const;
93 /// Y content, set if found in current context
94 const SvgNumber& getY() const;
96 /// Width content, set if found in current context
97 const SvgNumber& getWidth() const;
99 /// Height content, set if found in current context
100 const SvgNumber& getHeight() const;
102 /// PatternUnits content
103 const SvgUnits* getPatternUnits() const;
104 void setPatternUnits(const SvgUnits aPatternUnits) { mpPatternUnits.reset( new SvgUnits(aPatternUnits) ); }
106 /// PatternContentUnits content
107 const SvgUnits* getPatternContentUnits() const;
108 void setPatternContentUnits(const SvgUnits aPatternContentUnits) { mpPatternContentUnits.reset( new SvgUnits(aPatternContentUnits) ); }
110 /// PatternTransform content
111 const basegfx::B2DHomMatrix* getPatternTransform() const;
112 void setPatternTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaPatternTransform.reset(); if(pMatrix) mpaPatternTransform.reset(new basegfx::B2DHomMatrix(*pMatrix)); }
115 } // end of namespace svgreader
116 } // end of namespace svgio
118 #endif // INCLUDED_SVGIO_INC_SVGPATTERNNODE_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */