/src/libreoffice/svgio/source/svgreader/svggnode.cxx
Line | Count | Source |
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 <svggnode.hxx> |
21 | | #include <osl/diagnose.h> |
22 | | |
23 | | namespace svgio::svgreader |
24 | | { |
25 | | SvgGNode::SvgGNode( |
26 | | SVGToken aType, |
27 | | SvgDocument& rDocument, |
28 | | SvgNode* pParent) |
29 | 0 | : SvgNode(aType, rDocument, pParent), |
30 | 0 | maSvgStyleAttributes(*this) |
31 | 0 | { |
32 | 0 | OSL_ENSURE(aType == SVGToken::Defs || aType == SVGToken::G, "SvgGNode should only be used for Group and Defs (!)"); |
33 | 0 | } |
34 | | |
35 | | SvgGNode::~SvgGNode() |
36 | 0 | { |
37 | 0 | } |
38 | | |
39 | | const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const |
40 | 0 | { |
41 | | // tdf#98599 attributes may be inherit by the children, therefore read them |
42 | | // #i125258# for SVGToken::G take CssStyles into account |
43 | 0 | return checkForCssStyle(maSvgStyleAttributes); |
44 | 0 | } |
45 | | |
46 | | void SvgGNode::parseAttribute(SVGToken aSVGToken, const OUString& aContent) |
47 | 0 | { |
48 | | // call parent |
49 | 0 | SvgNode::parseAttribute(aSVGToken, aContent); |
50 | | |
51 | | // read style attributes |
52 | 0 | maSvgStyleAttributes.parseStyleAttribute(aSVGToken, aContent); |
53 | | |
54 | | // parse own |
55 | 0 | switch(aSVGToken) |
56 | 0 | { |
57 | 0 | case SVGToken::Style: |
58 | 0 | { |
59 | 0 | readLocalCssStyle(aContent); |
60 | 0 | break; |
61 | 0 | } |
62 | 0 | case SVGToken::Transform: |
63 | 0 | { |
64 | 0 | const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this)); |
65 | |
|
66 | 0 | if(!aMatrix.isIdentity()) |
67 | 0 | { |
68 | 0 | setTransform(aMatrix); |
69 | 0 | } |
70 | 0 | break; |
71 | 0 | } |
72 | 0 | default: |
73 | 0 | { |
74 | 0 | break; |
75 | 0 | } |
76 | 0 | } |
77 | 0 | } |
78 | | |
79 | | void SvgGNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const |
80 | 0 | { |
81 | 0 | if(SVGToken::Defs == getType()) |
82 | 0 | { |
83 | | // #i125258# no decompose needed for defs element, call parent for SVGTokenDefs |
84 | 0 | SvgNode::decomposeSvgNode(rTarget, bReferenced); |
85 | 0 | } |
86 | 0 | else |
87 | 0 | { |
88 | | // #i125258# for SVGTokenG decompose children |
89 | 0 | const SvgStyleAttributes* pStyle = getSvgStyleAttributes(); |
90 | |
|
91 | 0 | if(pStyle) |
92 | 0 | { |
93 | 0 | drawinglayer::primitive2d::Primitive2DContainer aContent; |
94 | | |
95 | | // decompose children |
96 | 0 | SvgNode::decomposeSvgNode(aContent, bReferenced); |
97 | |
|
98 | 0 | if(!aContent.empty()) |
99 | 0 | { |
100 | 0 | pStyle->add_postProcess(rTarget, std::move(aContent), getTransform()); |
101 | 0 | } |
102 | 0 | } |
103 | 0 | } |
104 | 0 | } |
105 | | } // end of namespace svgio::svgreader |
106 | | |
107 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |