Line data Source code
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 : #ifndef INCLUDED_SVGIO_SVGREADER_SVGDOCUMENT_HXX
21 : #define INCLUDED_SVGIO_SVGREADER_SVGDOCUMENT_HXX
22 :
23 : #include <boost/utility.hpp>
24 : #include <svgio/svgreader/svgnode.hxx>
25 :
26 :
27 :
28 : namespace svgio
29 : {
30 : namespace svgreader
31 : {
32 : class SvgDocument : private boost::noncopyable
33 : {
34 : private:
35 : /// the document hierarchy with all root nodes
36 : SvgNodeVector maNodes;
37 :
38 : /// the absolute path of the Svg file in progress (if available)
39 : const OUString maAbsolutePath;
40 :
41 : /// hash mapper to find nodes by their id
42 : typedef boost::unordered_map< const OUString, const SvgNode*,
43 : OUStringHash,
44 : ::std::equal_to< OUString > > IdTokenMapper;
45 : typedef std::pair< const OUString, const SvgNode* > IdTokenValueType;
46 : IdTokenMapper maIdTokenMapperList;
47 :
48 : /// hash mapper to find css styles by their id
49 : typedef boost::unordered_map< const OUString, const SvgStyleAttributes*, OUStringHash, ::std::equal_to< OUString > > IdStyleTokenMapper;
50 : typedef std::pair< const OUString, const SvgStyleAttributes* > IdStyleTokenValueType;
51 : IdStyleTokenMapper maIdStyleTokenMapperList;
52 :
53 : public:
54 : SvgDocument(const OUString& rAbsolutePath);
55 : ~SvgDocument();
56 :
57 : /// append anopther root node, ownership changes
58 : void appendNode(SvgNode* pNode);
59 :
60 : /// add/remove nodes with Id to mapper
61 : void addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode);
62 : void removeSvgNodeFromMapper(const OUString& rStr);
63 :
64 : /// find a node by it's Id
65 : bool hasSvgNodesById() const { return !maIdTokenMapperList.empty(); }
66 : const SvgNode* findSvgNodeById(const OUString& rStr) const;
67 :
68 : /// add/remove styles to mapper
69 : void addSvgStyleAttributesToMapper(const OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes);
70 :
71 : /// find a style by it's Id
72 0 : bool hasSvgStyleAttributesById() const { return !maIdStyleTokenMapperList.empty(); }
73 : const SvgStyleAttributes* findSvgStyleAttributesById(const OUString& rStr) const;
74 :
75 : /// data read access
76 0 : const SvgNodeVector& getSvgNodeVector() const { return maNodes; }
77 0 : const OUString& getAbsolutePath() const { return maAbsolutePath; }
78 : };
79 : } // end of namespace svgreader
80 : } // end of namespace svgio
81 :
82 :
83 :
84 : #endif //INCLUDED_SVGIO_SVGREADER_SVGDOCUMENT_HXX
85 :
86 : // eof
87 :
88 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|