Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/svgio/source/svgreader/svganode.cxx
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
#include <svganode.hxx>
21
22
namespace svgio::svgreader
23
{
24
        SvgANode::SvgANode(
25
            SvgDocument& rDocument,
26
            SvgNode* pParent)
27
6
        :   SvgNode(SVGToken::A, rDocument, pParent),
28
6
            maSvgStyleAttributes(*this)
29
6
        {
30
6
        }
31
32
        SvgANode::~SvgANode()
33
6
        {
34
6
        }
35
36
        const SvgStyleAttributes* SvgANode::getSvgStyleAttributes() const
37
0
        {
38
0
            return checkForCssStyle(maSvgStyleAttributes);
39
0
        }
40
41
        void SvgANode::parseAttribute(SVGToken aSVGToken, const OUString& aContent)
42
0
        {
43
            // call parent
44
0
            SvgNode::parseAttribute(aSVGToken, aContent);
45
46
            // read style attributes
47
0
            maSvgStyleAttributes.parseStyleAttribute(aSVGToken, aContent);
48
49
            // parse own
50
0
            switch(aSVGToken)
51
0
            {
52
0
                case SVGToken::Style:
53
0
                {
54
0
                    readLocalCssStyle(aContent);
55
0
                    break;
56
0
                }
57
0
                case SVGToken::Transform:
58
0
                {
59
0
                    const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
60
61
0
                    if(!aMatrix.isIdentity())
62
0
                    {
63
0
                        setTransform(aMatrix);
64
0
                    }
65
0
                    break;
66
0
                }
67
0
                case SVGToken::Href:
68
0
                case SVGToken::XlinkHref:
69
                    //TODO: add support for xlink:href
70
0
                    break;
71
0
                default:
72
0
                {
73
0
                    break;
74
0
                }
75
0
            }
76
0
        }
77
78
        void SvgANode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const
79
0
        {
80
            // #i125258# for SVGTokenA decompose children
81
0
            const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
82
83
0
            if(!pStyle)
84
0
                return;
85
86
0
            if (Display::None != getDisplay())
87
0
            {
88
0
                drawinglayer::primitive2d::Primitive2DContainer aContent;
89
90
                // decompose children
91
0
                SvgNode::decomposeSvgNode(aContent, bReferenced);
92
93
0
                if(!aContent.empty())
94
0
                {
95
0
                    pStyle->add_postProcess(rTarget, std::move(aContent), getTransform());
96
0
                }
97
0
            }
98
0
        }
99
} // end of namespace svgio::svgreader
100
101
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */