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 .
22 #include "svgnode.hxx"
23 #include "svgstyleattributes.hxx"
24 #include <basegfx/matrix/b2dhommatrix.hxx>
27 namespace svgio::svgreader
29 class SvgPatternNode final
: public SvgNode
32 /// buffered decomposition
33 drawinglayer::primitive2d::Primitive2DContainer aPrimitives
;
36 SvgStyleAttributes maSvgStyleAttributes
;
38 /// variable scan values, dependent of given XAttributeList
39 std::unique_ptr
<basegfx::B2DRange
>
41 SvgAspectRatio maSvgAspectRatio
;
46 std::unique_ptr
<SvgUnits
>
48 std::unique_ptr
<SvgUnits
>
49 mpPatternContentUnits
;
50 std::optional
<basegfx::B2DHomMatrix
>
53 /// link to another pattern used as style. If maXLink
54 /// is set, the node can be fetched on demand by using
55 // tryToFindLink (buffered)
56 mutable bool mbResolvingLink
; // protect against infinite link recursion
58 const SvgPatternNode
* mpXLink
;
65 SvgDocument
& rDocument
,
67 virtual ~SvgPatternNode() override
;
69 virtual const SvgStyleAttributes
* getSvgStyleAttributes() const override
;
70 virtual void parseAttribute(const OUString
& rTokenName
, SVGToken aSVGToken
, const OUString
& aContent
) override
;
73 void getValuesRelative(double& rfX
, double& rfY
, double& rfW
, double& rfH
, const basegfx::B2DRange
& rGeoRange
, SvgNode
const & rUser
) const;
75 /// get pattern primitives buffered, uses decomposeSvgNode internally
76 const drawinglayer::primitive2d::Primitive2DContainer
& getPatternPrimitives() const;
78 /// InfoProvider support for % values
79 virtual basegfx::B2DRange
getCurrentViewPort() const override
;
82 const basegfx::B2DRange
* getViewBox() const;
83 void setViewBox(const basegfx::B2DRange
* pViewBox
) { mpViewBox
.reset(); if(pViewBox
) mpViewBox
.reset(new basegfx::B2DRange(*pViewBox
)); }
85 /// SvgAspectRatio content
86 const SvgAspectRatio
& getSvgAspectRatio() const;
88 /// X content, set if found in current context
89 const SvgNumber
& getX() const;
91 /// Y content, set if found in current context
92 const SvgNumber
& getY() const;
94 /// Width content, set if found in current context
95 const SvgNumber
& getWidth() const;
97 /// Height content, set if found in current context
98 const SvgNumber
& getHeight() const;
100 /// PatternUnits content
101 const SvgUnits
* getPatternUnits() const;
102 void setPatternUnits(const SvgUnits aPatternUnits
) { mpPatternUnits
.reset( new SvgUnits(aPatternUnits
) ); }
104 /// PatternContentUnits content
105 const SvgUnits
* getPatternContentUnits() const;
106 void setPatternContentUnits(const SvgUnits aPatternContentUnits
) { mpPatternContentUnits
.reset( new SvgUnits(aPatternContentUnits
) ); }
108 /// PatternTransform content
109 std::optional
<basegfx::B2DHomMatrix
> getPatternTransform() const;
110 void setPatternTransform(const std::optional
<basegfx::B2DHomMatrix
>& pMatrix
) { mpaPatternTransform
= pMatrix
; }
114 } // end of namespace svgio::svgreader
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */