LibreOffice Module svgio (master) 1
svgdocument.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 <svgdocument.hxx>
21#include <utility>
22
23namespace svgio::svgreader
24{
25 SvgDocument::SvgDocument(OUString aAbsolutePath)
26 : maAbsolutePath(std::move(aAbsolutePath))
27 {
28 }
29
31 {
32 }
33
34 void SvgDocument::appendNode(std::unique_ptr<SvgNode> pNode)
35 {
36 assert(pNode);
37 maNodes.push_back(std::move(pNode));
38 }
39
40 void SvgDocument::addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode)
41 {
42 if(!rStr.isEmpty())
43 {
44 maIdTokenMapperList.emplace(rStr, &rNode);
45 }
46 }
47
48 void SvgDocument::removeSvgNodeFromMapper(const OUString& rStr)
49 {
50 if(!rStr.isEmpty())
51 {
52 maIdTokenMapperList.erase(rStr);
53 }
54 }
55
56 const SvgNode* SvgDocument::findSvgNodeById(const OUString& rStr) const
57 {
58 const IdTokenMapper::const_iterator aResult(maIdTokenMapperList.find(rStr));
59
60 if(aResult == maIdTokenMapperList.end())
61 {
62 return nullptr;
63 }
64 else
65 {
66 return aResult->second;
67 }
68 }
69
70 void SvgDocument::addSvgStyleAttributesToMapper(const OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes)
71 {
72 if(!rStr.isEmpty())
73 {
74 maIdStyleTokenMapperList.emplace(rStr, &rSvgStyleAttributes);
75 }
76 }
77
79 {
80 const IdStyleTokenMapper::const_iterator aResult(maIdStyleTokenMapperList.find(rStr));
81
82 if(aResult == maIdStyleTokenMapperList.end())
83 {
84 return nullptr;
85 }
86 else
87 {
88 return aResult->second;
89 }
90 }
91
92} // end of namespace svgio::svgreader
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void removeSvgNodeFromMapper(const OUString &rStr)
Definition: svgdocument.cxx:48
void addSvgNodeToMapper(const OUString &rStr, const SvgNode &rNode)
add/remove nodes with Id to mapper
Definition: svgdocument.cxx:40
const SvgStyleAttributes * findGlobalCssStyleAttributes(const OUString &rStr) const
Definition: svgdocument.cxx:78
void appendNode(std::unique_ptr< SvgNode > pNode)
append another root node, ownership changes
Definition: svgdocument.cxx:34
SvgDocument(OUString aAbsolutePath)
Definition: svgdocument.cxx:25
const SvgNode * findSvgNodeById(const OUString &rStr) const
find a node by its Id
Definition: svgdocument.cxx:56
SvgNodeVector maNodes
the document hierarchy with all root nodes
Definition: svgdocument.hxx:35
void addSvgStyleAttributesToMapper(const OUString &rStr, const SvgStyleAttributes &rSvgStyleAttributes)
add/remove styles to mapper
Definition: svgdocument.cxx:70
IdStyleTokenMapper maIdStyleTokenMapperList
Definition: svgdocument.hxx:49