Line data Source code
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 <svgio/svgreader/svgsymbolnode.hxx>
21 : #include <drawinglayer/geometry/viewinformation2d.hxx>
22 : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
23 :
24 : namespace svgio
25 : {
26 : namespace svgreader
27 : {
28 0 : SvgSymbolNode::SvgSymbolNode(
29 : SvgDocument& rDocument,
30 : SvgNode* pParent)
31 : : SvgNode(SVGTokenSvg, rDocument, pParent),
32 : maSvgStyleAttributes(*this),
33 : mpViewBox(0),
34 0 : maSvgAspectRatio()
35 : {
36 0 : }
37 :
38 0 : SvgSymbolNode::~SvgSymbolNode()
39 : {
40 0 : if(mpViewBox) delete mpViewBox;
41 0 : }
42 :
43 0 : const SvgStyleAttributes* SvgSymbolNode::getSvgStyleAttributes() const
44 : {
45 0 : return &maSvgStyleAttributes;
46 : }
47 :
48 0 : void SvgSymbolNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
49 : {
50 : // call parent
51 0 : SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
52 :
53 : // read style attributes
54 0 : maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
55 :
56 : // parse own
57 0 : switch(aSVGToken)
58 : {
59 : case SVGTokenStyle:
60 : {
61 0 : readLocalCssStyle(aContent);
62 0 : break;
63 : }
64 : case SVGTokenViewBox:
65 : {
66 0 : const basegfx::B2DRange aRange(readViewBox(aContent, *this));
67 :
68 0 : if(!aRange.isEmpty())
69 : {
70 0 : setViewBox(&aRange);
71 : }
72 0 : break;
73 : }
74 : case SVGTokenPreserveAspectRatio:
75 : {
76 0 : setSvgAspectRatio(readSvgAspectRatio(aContent));
77 0 : break;
78 : }
79 : default:
80 : {
81 0 : break;
82 : }
83 : }
84 0 : }
85 :
86 : } // end of namespace svgreader
87 : } // end of namespace svgio
88 :
89 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|