1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_svgio.hxx"
24 
25 #include <svgio/svgreader/svgtrefnode.hxx>
26 #include <svgio/svgreader/svgdocument.hxx>
27 
28 //////////////////////////////////////////////////////////////////////////////
29 
30 namespace svgio
31 {
32     namespace svgreader
33     {
SvgTrefNode(SvgDocument & rDocument,SvgNode * pParent)34         SvgTrefNode::SvgTrefNode(
35             SvgDocument& rDocument,
36             SvgNode* pParent)
37         :   SvgNode(SVGTokenTref, rDocument, pParent),
38             maSvgStyleAttributes(*this),
39             maXLink()
40         {
41         }
42 
~SvgTrefNode()43         SvgTrefNode::~SvgTrefNode()
44         {
45         }
46 
getSvgStyleAttributes() const47         const SvgStyleAttributes* SvgTrefNode::getSvgStyleAttributes() const
48         {
49             return &maSvgStyleAttributes;
50         }
51 
parseAttribute(const rtl::OUString & rTokenName,SVGToken aSVGToken,const rtl::OUString & aContent)52         void SvgTrefNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
53         {
54             // call parent
55             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
56 
57             // read style attributes
58             maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
59 
60             // parse own
61             switch(aSVGToken)
62             {
63                 case SVGTokenStyle:
64                 {
65                     maSvgStyleAttributes.readStyle(aContent);
66                     break;
67                 }
68                 case SVGTokenXlinkHref:
69                 {
70                     const sal_Int32 nLen(aContent.getLength());
71 
72                     if(nLen && sal_Unicode('#') == aContent[0])
73                     {
74                         maXLink = aContent.copy(1);
75                     }
76                     break;
77                 }
78                 default:
79                 {
80                     break;
81                 }
82             }
83         }
84 
getReferencedSvgTextNode() const85         const SvgTextNode* SvgTrefNode::getReferencedSvgTextNode() const
86         {
87             return dynamic_cast< const SvgTextNode* >(getDocument().findSvgNodeById(maXLink));
88         }
89 
90     } // end of namespace svgreader
91 } // end of namespace svgio
92 
93 //////////////////////////////////////////////////////////////////////////////
94 // eof
95