bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svgio / inc / svgdocument.hxx
blobe414b19390db6b9ee3624103f11a4c5d4a416b09
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
30 namespace svgreader
32 typedef std::vector< std::unique_ptr<SvgNode> > SvgNodeVector;
34 class SvgDocument
36 private:
37 /// the document hierarchy with all root nodes
38 SvgNodeVector maNodes;
40 /// the absolute path of the Svg file in progress (if available)
41 const OUString maAbsolutePath;
43 /// hash mapper to find nodes by their id
44 typedef std::unordered_map< OUString, const SvgNode* > IdTokenMapper;
45 IdTokenMapper maIdTokenMapperList;
47 /// hash mapper to find css styles by their id
48 typedef std::unordered_map< OUString, const SvgStyleAttributes* > IdStyleTokenMapper;
49 IdStyleTokenMapper maIdStyleTokenMapperList;
51 public:
52 explicit SvgDocument(const OUString& rAbsolutePath);
53 ~SvgDocument();
55 SvgDocument(const SvgDocument&) = delete;
56 SvgDocument& operator=(const SvgDocument&) = delete;
58 /// append another root node, ownership changes
59 void appendNode(std::unique_ptr<SvgNode> pNode);
61 /// add/remove nodes with Id to mapper
62 void addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode);
63 void removeSvgNodeFromMapper(const OUString& rStr);
65 /// find a node by its Id
66 const SvgNode* findSvgNodeById(const OUString& rStr) const;
68 /// add/remove styles to mapper
69 void addSvgStyleAttributesToMapper(const OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes);
71 /// find a style by its Id
72 bool hasGlobalCssStyleAttributes() const { return !maIdStyleTokenMapperList.empty(); }
73 const SvgStyleAttributes* findGlobalCssStyleAttributes(const OUString& rStr) const;
75 /// data read access
76 const SvgNodeVector& getSvgNodeVector() const { return maNodes; }
77 const OUString& getAbsolutePath() const { return maAbsolutePath; }
79 } // end of namespace svgreader
80 } // end of namespace svgio
82 #endif // INCLUDED_SVGIO_INC_SVGDOCUMENT_HXX
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */