1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <basegfx/matrix/b2dhommatrix.hxx>
28 namespace svgio::svgreader
30 class SvgPatternNode
: public SvgNode
33 /// buffered decomposition
34 drawinglayer::primitive2d::Primitive2DContainer aPrimitives
;
37 SvgStyleAttributes maSvgStyleAttributes
;
39 /// variable scan values, dependent of given XAttributeList
40 std::unique_ptr
<basegfx::B2DRange
>
42 SvgAspectRatio maSvgAspectRatio
;
47 std::unique_ptr
<SvgUnits
>
49 std::unique_ptr
<SvgUnits
>
50 mpPatternContentUnits
;
51 std::unique_ptr
<basegfx::B2DHomMatrix
>
54 /// link to another pattern used as style. If maXLink
55 /// is set, the node can be fetched on demand by using
56 // tryToFindLink (buffered)
57 mutable bool mbResolvingLink
; // protect against infinite link recursion
59 const SvgPatternNode
* mpXLink
;
66 SvgDocument
& rDocument
,
68 virtual ~SvgPatternNode() override
;
70 virtual const SvgStyleAttributes
* getSvgStyleAttributes() const override
;
71 virtual void parseAttribute(const OUString
& rTokenName
, SVGToken aSVGToken
, const OUString
& aContent
) override
;
74 void getValuesRelative(double& rfX
, double& rfY
, double& rfW
, double& rfH
, const basegfx::B2DRange
& rGeoRange
, SvgNode
const & rUser
) const;
76 /// get pattern primitives buffered, uses decomposeSvgNode internally
77 const drawinglayer::primitive2d::Primitive2DContainer
& getPatternPrimitives() const;
79 /// InfoProvider support for % values
80 virtual basegfx::B2DRange
getCurrentViewPort() const override
;
83 const basegfx::B2DRange
* getViewBox() const;
84 void setViewBox(const basegfx::B2DRange
* pViewBox
) { mpViewBox
.reset(); if(pViewBox
) mpViewBox
.reset(new basegfx::B2DRange(*pViewBox
)); }
86 /// SvgAspectRatio content
87 const SvgAspectRatio
& getSvgAspectRatio() const;
89 /// X content, set if found in current context
90 const SvgNumber
& getX() const;
92 /// Y content, set if found in current context
93 const SvgNumber
& getY() const;
95 /// Width content, set if found in current context
96 const SvgNumber
& getWidth() const;
98 /// Height content, set if found in current context
99 const SvgNumber
& getHeight() const;
101 /// PatternUnits content
102 const SvgUnits
* getPatternUnits() const;
103 void setPatternUnits(const SvgUnits aPatternUnits
) { mpPatternUnits
.reset( new SvgUnits(aPatternUnits
) ); }
105 /// PatternContentUnits content
106 const SvgUnits
* getPatternContentUnits() const;
107 void setPatternContentUnits(const SvgUnits aPatternContentUnits
) { mpPatternContentUnits
.reset( new SvgUnits(aPatternContentUnits
) ); }
109 /// PatternTransform content
110 const basegfx::B2DHomMatrix
* getPatternTransform() const;
111 void setPatternTransform(const basegfx::B2DHomMatrix
* pMatrix
) { mpaPatternTransform
.reset(); if(pMatrix
) mpaPatternTransform
.reset(new basegfx::B2DHomMatrix(*pMatrix
)); }
115 } // end of namespace svgio::svgreader
117 #endif // INCLUDED_SVGIO_INC_SVGPATTERNNODE_HXX
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */