update credits
[LibreOffice.git] / svgio / source / svgreader / svgdocument.cxx
blob705df546838af184bb208cb700a049d7942671c4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svgio/svgreader/svgdocument.hxx>
22 //////////////////////////////////////////////////////////////////////////////
24 namespace svgio
26 namespace svgreader
28 SvgDocument::SvgDocument(const OUString& rAbsolutePath)
29 : maNodes(),
30 maAbsolutePath(rAbsolutePath),
31 maIdTokenMapperList(),
32 maIdStyleTokenMapperList()
36 SvgDocument::~SvgDocument()
38 while(!maNodes.empty())
40 SvgNode* pCandidate = maNodes[maNodes.size() - 1];
41 delete pCandidate;
42 maNodes.pop_back();
46 void SvgDocument::appendNode(SvgNode* pNode)
48 OSL_ENSURE(pNode, "OOps, empty node added (!)");
49 maNodes.push_back(pNode);
52 void SvgDocument::addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode)
54 if(rStr.getLength())
56 maIdTokenMapperList.insert(IdTokenValueType(rStr, &rNode));
60 void SvgDocument::removeSvgNodeFromMapper(const OUString& rStr)
62 if(rStr.getLength())
64 maIdTokenMapperList.erase(rStr);
68 const SvgNode* SvgDocument::findSvgNodeById(const OUString& rStr) const
70 const IdTokenMapper::const_iterator aResult(maIdTokenMapperList.find(rStr));
72 if(aResult == maIdTokenMapperList.end())
74 return 0;
76 else
78 return aResult->second;
82 void SvgDocument::addSvgStyleAttributesToMapper(const OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes)
84 if(rStr.getLength())
86 maIdStyleTokenMapperList.insert(IdStyleTokenValueType(rStr, &rSvgStyleAttributes));
90 const SvgStyleAttributes* SvgDocument::findSvgStyleAttributesById(const OUString& rStr) const
92 const IdStyleTokenMapper::const_iterator aResult(maIdStyleTokenMapperList.find(rStr));
94 if(aResult == maIdStyleTokenMapperList.end())
96 return 0;
98 else
100 return aResult->second;
104 } // end of namespace svgreader
105 } // end of namespace svgio
107 //////////////////////////////////////////////////////////////////////////////
108 // eof
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */