nss: upgrade to release 3.73
[LibreOffice.git] / svgio / inc / svgdocument.hxx
blobd2044fca47b9c1798b8acdc8734c4a1ddf28f9fe
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 #ifndef INCLUDED_SVGIO_INC_SVGDOCUMENT_HXX
21 #define INCLUDED_SVGIO_INC_SVGDOCUMENT_HXX
23 #include "svgnode.hxx"
24 #include <memory>
25 #include <unordered_map>
26 #include <vector>
28 namespace svgio::svgreader
30 typedef std::vector< std::unique_ptr<SvgNode> > SvgNodeVector;
32 class SvgDocument
34 private:
35 /// the document hierarchy with all root nodes
36 SvgNodeVector maNodes;
38 /// the absolute path of the Svg file in progress (if available)
39 const OUString maAbsolutePath;
41 /// hash mapper to find nodes by their id
42 typedef std::unordered_map< OUString, const SvgNode* > IdTokenMapper;
43 IdTokenMapper maIdTokenMapperList;
45 /// hash mapper to find css styles by their id
46 typedef std::unordered_map< OUString, const SvgStyleAttributes* > IdStyleTokenMapper;
47 IdStyleTokenMapper maIdStyleTokenMapperList;
49 public:
50 explicit SvgDocument(const OUString& rAbsolutePath);
51 ~SvgDocument();
53 SvgDocument(const SvgDocument&) = delete;
54 SvgDocument& operator=(const SvgDocument&) = delete;
56 /// append another root node, ownership changes
57 void appendNode(std::unique_ptr<SvgNode> pNode);
59 /// add/remove nodes with Id to mapper
60 void addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode);
61 void removeSvgNodeFromMapper(const OUString& rStr);
63 /// find a node by its Id
64 const SvgNode* findSvgNodeById(const OUString& rStr) const;
66 /// add/remove styles to mapper
67 void addSvgStyleAttributesToMapper(const OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes);
69 /// find a style by its Id
70 bool hasGlobalCssStyleAttributes() const { return !maIdStyleTokenMapperList.empty(); }
71 const SvgStyleAttributes* findGlobalCssStyleAttributes(const OUString& rStr) const;
73 /// data read access
74 const SvgNodeVector& getSvgNodeVector() const { return maNodes; }
75 const OUString& getAbsolutePath() const { return maAbsolutePath; }
78 } // end of namespace svgio::svgreader
80 #endif // INCLUDED_SVGIO_INC_SVGDOCUMENT_HXX
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */