LibreOffice Module svgio (master) 1
svganode.cxx
Go to the documentation of this file.
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
23{
25 SvgDocument& rDocument,
26 SvgNode* pParent)
27 : SvgNode(SVGToken::A, rDocument, pParent),
28 maSvgStyleAttributes(*this)
29 {
30 }
31
33 {
34 }
35
37 {
39 }
40
41 void SvgANode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
42 {
43 // call parent
44 SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
45
46 // read style attributes
47 maSvgStyleAttributes.parseStyleAttribute(aSVGToken, aContent);
48
49 // parse own
50 switch(aSVGToken)
51 {
52 case SVGToken::Style:
53 {
54 readLocalCssStyle(aContent);
55 break;
56 }
58 {
59 const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
60
61 if(!aMatrix.isIdentity())
62 {
63 setTransform(aMatrix);
64 }
65 break;
66 }
67 case SVGToken::Href:
69 //TODO: add support for xlink:href
70 break;
71 default:
72 {
73 break;
74 }
75 }
76 }
77
79 {
80 // #i125258# for SVGTokenA decompose children
82
83 if(!pStyle)
84 return;
85
87 {
89
90 // decompose children
91 SvgNode::decomposeSvgNode(aContent, bReferenced);
92
93 if(!aContent.empty())
94 {
95 pStyle->add_postProcess(rTarget, std::move(aContent), getTransform());
96 }
97 }
98 }
99} // end of namespace svgio::svgreader
100
101/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool isIdentity() const
SvgANode(SvgDocument &rDocument, SvgNode *pParent)
Definition: svganode.cxx:24
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer &rTarget, bool bReferenced) const override
Definition: svganode.cxx:78
void setTransform(const std::optional< basegfx::B2DHomMatrix > &pMatrix)
Definition: svganode.hxx:49
virtual const SvgStyleAttributes * getSvgStyleAttributes() const override
Definition: svganode.cxx:36
virtual ~SvgANode() override
Definition: svganode.cxx:32
virtual void parseAttribute(const OUString &rTokenName, SVGToken aSVGToken, const OUString &aContent) override
Definition: svganode.cxx:41
SvgStyleAttributes maSvgStyleAttributes
use styles
Definition: svganode.hxx:32
const std::optional< basegfx::B2DHomMatrix > & getTransform() const
transform content
Definition: svganode.hxx:48
Display getDisplay() const
Display access #i121656#.
Definition: svgnode.hxx:182
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer &rTarget, bool bReferenced) const
Definition: svgnode.cxx:584
const SvgStyleAttributes * checkForCssStyle(const SvgStyleAttributes &rOriginal) const
helper to evtl. link to css style
Definition: svgnode.cxx:335
virtual void parseAttribute(const OUString &rTokenName, SVGToken aSVGToken, const OUString &aContent)
Definition: svgnode.cxx:534
void readLocalCssStyle(std::u16string_view aContent)
scan helper to read and interpret a local CssStyle to mpLocalCssStyle
Definition: svgnode.cxx:412
void add_postProcess(drawinglayer::primitive2d::Primitive2DContainer &rTarget, drawinglayer::primitive2d::Primitive2DContainer &&rSource, const std::optional< basegfx::B2DHomMatrix > &pTransform) const
void parseStyleAttribute(SVGToken aSVGToken, const OUString &rContent)
local attribute scanner
FilterGroup & rTarget
basegfx::B2DHomMatrix readTransform(std::u16string_view rCandidate, InfoProvider const &rInfoProvider)
Definition: svgtools.cxx:871
const sal_uInt8 A