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