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