Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/svgio/inc/svggradientnode.hxx
Line
Count
Source (jump to first uncovered line)
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
#pragma once
21
22
#include "svgnode.hxx"
23
#include "svgstyleattributes.hxx"
24
#include "svgtools.hxx"
25
#include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
26
27
namespace svgio::svgreader
28
    {
29
        class SvgGradientNode final : public SvgNode
30
        {
31
        private:
32
            /// use styles
33
            SvgStyleAttributes          maSvgStyleAttributes;
34
35
            /// linear gradient values
36
            SvgNumber                   maX1;
37
            SvgNumber                   maY1;
38
            SvgNumber                   maX2;
39
            SvgNumber                   maY2;
40
41
            /// radial gradient values
42
            SvgNumber                   maCx;
43
            SvgNumber                   maCy;
44
            SvgNumber                   maR;
45
            SvgNumber                   maFx;
46
            SvgNumber                   maFy;
47
48
            /// variable scan values, dependent of given XAttributeList
49
            SvgUnits                    maGradientUnits;
50
            drawinglayer::primitive2d::SpreadMethod   maSpreadMethod;
51
            std::optional<basegfx::B2DHomMatrix>    mpaGradientTransform;
52
53
            /// link to another gradient 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
57
            OUString               maXLink;
58
            const SvgGradientNode*      mpXLink;
59
60
            /// link on demand
61
            void tryToFindLink();
62
63
        public:
64
            SvgGradientNode(
65
                SVGToken aType,
66
                SvgDocument& rDocument,
67
                SvgNode* pParent);
68
            virtual ~SvgGradientNode() override;
69
70
            virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
71
            virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
72
73
            /// collect gradient stop entries
74
            void collectGradientEntries(drawinglayer::primitive2d::SvgGradientEntryVector& aVector) const;
75
76
            /// x1 content
77
            SvgNumber getX1() const;
78
79
            /// y1 content
80
            SvgNumber getY1() const;
81
82
            /// x2 content
83
            SvgNumber getX2() const;
84
85
            /// y2 content
86
            SvgNumber getY2() const;
87
88
            /// Cx content
89
            SvgNumber getCx() const;
90
91
            /// Cy content
92
            SvgNumber getCy() const;
93
94
            /// R content
95
            SvgNumber getR() const;
96
97
            /// Fx content
98
            const SvgNumber* getFx() const;
99
100
            /// Fy content
101
            const SvgNumber* getFy() const;
102
103
            /// gradientUnits content
104
0
            SvgUnits getGradientUnits() const { return maGradientUnits; }
105
0
            void setGradientUnits(const SvgUnits aGradientUnits) { maGradientUnits = aGradientUnits; }
106
107
            /// SpreadMethod content
108
0
            drawinglayer::primitive2d::SpreadMethod getSpreadMethod() const { return maSpreadMethod; }
109
0
            void setSpreadMethod(const drawinglayer::primitive2d::SpreadMethod aSpreadMethod) { maSpreadMethod = aSpreadMethod; }
110
111
            /// transform content, set if found in current context
112
            std::optional<basegfx::B2DHomMatrix> getGradientTransform() const;
113
0
            void setGradientTransform(const std::optional<basegfx::B2DHomMatrix>& pMatrix) { mpaGradientTransform = pMatrix; }
114
        };
115
116
} // end of namespace svgio::svgreader
117
118
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */