Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/svgio/inc/svgmarkernode.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 <memory>
25
26
namespace svgio::svgreader
27
    {
28
        class SvgMarkerNode final : public SvgNode
29
        {
30
        public:
31
            enum class MarkerUnits
32
            {
33
                strokeWidth,
34
                userSpaceOnUse
35
            };
36
37
            enum class MarkerOrient
38
            {
39
                notset,
40
                auto_start,
41
                auto_start_reverse
42
            };
43
44
        private:
45
            /// buffered decomposition
46
            drawinglayer::primitive2d::Primitive2DContainer aPrimitives;
47
48
            /// use styles
49
            SvgStyleAttributes      maSvgStyleAttributes;
50
51
            /// variable scan values, dependent of given XAttributeList
52
            std::unique_ptr<basegfx::B2DRange>
53
                                    mpViewBox;
54
            SvgAspectRatio          maSvgAspectRatio;
55
            SvgNumber               maRefX;
56
            SvgNumber               maRefY;
57
            MarkerUnits             maMarkerUnits;
58
            SvgNumber               maMarkerWidth;
59
            SvgNumber               maMarkerHeight;
60
            double                  mfAngle;
61
            MarkerOrient            maMarkerOrient;
62
63
            const SvgStyleAttributes* maContextStyleAttibutes;
64
65
        public:
66
            SvgMarkerNode(
67
                SvgDocument& rDocument,
68
                SvgNode* pParent);
69
            virtual ~SvgMarkerNode() override;
70
71
            virtual const SvgStyleAttributes* getSvgStyleAttributes() const override;
72
            virtual void parseAttribute(SVGToken aSVGToken, const OUString& aContent) override;
73
74
            /// get marker primitives buffered, uses decomposeSvgNode internally
75
            const drawinglayer::primitive2d::Primitive2DContainer& getMarkerPrimitives() const;
76
77
            /// InfoProvider support for % values
78
            virtual basegfx::B2DRange getCurrentViewPort() const override;
79
80
            /// viewBox content
81
0
            const basegfx::B2DRange* getViewBox() const { return mpViewBox.get(); }
82
0
            void setViewBox(const basegfx::B2DRange* pViewBox) { mpViewBox.reset(); if(pViewBox) mpViewBox.reset( new basegfx::B2DRange(*pViewBox) ); }
83
84
            /// SvgAspectRatio content
85
0
            const SvgAspectRatio& getSvgAspectRatio() const { return maSvgAspectRatio; }
86
87
            /// RefX content, set if found in current context
88
0
            const SvgNumber& getRefX() const { return maRefX; }
89
90
            /// RefY content, set if found in current context
91
0
            const SvgNumber& getRefY() const { return maRefY; }
92
93
            /// MarkerUnits content
94
0
            MarkerUnits getMarkerUnits() const { return maMarkerUnits; }
95
0
            void setMarkerUnits(const MarkerUnits aMarkerUnits) { maMarkerUnits = aMarkerUnits; }
96
97
            /// MarkerWidth content, set if found in current context
98
0
            const SvgNumber& getMarkerWidth() const { return maMarkerWidth; }
99
100
            /// MarkerHeight content, set if found in current context
101
0
            const SvgNumber& getMarkerHeight() const { return maMarkerHeight; }
102
103
            /// Angle content, set if found in current context
104
0
            double getAngle() const { return mfAngle; }
105
0
            void setAngle(double fAngle) { mfAngle = fAngle;}
106
107
            /// MarkerOrient content
108
0
            MarkerOrient getMarkerOrient() const { return maMarkerOrient; }
109
0
            void setMarkerOrient(const MarkerOrient aMarkerOrient) { maMarkerOrient = aMarkerOrient; }
110
111
0
            const SvgStyleAttributes* getContextStyleAttributes() const { return maContextStyleAttibutes; }
112
0
            void setContextStyleAttributes(const SvgStyleAttributes* aContextStyleAttibutes) { maContextStyleAttibutes = aContextStyleAttibutes; }
113
        };
114
115
} // end of namespace svgio::svgreader
116
117
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */