Debian Codegraph @

src/lib/EPUBSpanStyleManager.h

raw
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libepubgen 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
10 #ifndef INCLUDED_EPUBSPANSTYLEMANAGER_H
11 #define INCLUDED_EPUBSPANSTYLEMANAGER_H
12
13 #include <map>
14 #include <string>
15 #include <unordered_map>
16
17 #include <boost/functional/hash.hpp>
18
19 #include <librevenge/librevenge.h>
20
21 #include "EPUBCSSProperties.h"
22 #include "EPUBCounter.h"
23
24 namespace libepubgen
25 {
26
27 class EPUBCSSContent;
28
29 /** Small class to manage the span style */
30 class EPUBSpanStyleManager
31 {
32 typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
33
34 public:
35 //! constructor
36 EPUBSpanStyleManager(std::string classNamePrefix) : m_contentNameMap(), m_idNameMap(), m_classNamePrefix(classNamePrefix)
37 {
38 }
39 //! destructor
40 virtual ~EPUBSpanStyleManager()
41 {
42 }
43 //! define a span style
44 void defineSpan(librevenge::RVNGPropertyList const &pList);
45 //! returns the class name corresponding to a propertylist
46 std::string getClass(librevenge::RVNGPropertyList const &pList);
47 //! returns the style string corresponding to a propertylist
48 std::string getStyle(librevenge::RVNGPropertyList const &pList);
49 //! send the data to the sink
50 void send(EPUBCSSContent &out);
51 protected:
52 //! convert a property list into a CSS property map
53 virtual void extractProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
54
55 private:
56 //! add data corresponding to a text position into the map
57 void extractTextPosition(char const *value, EPUBCSSProperties &cssProps) const;
58 //! add data corresponding to the line decoration into the map
59 void extractDecorations(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
60 protected:
61 //! a map content -> name
62 ContentNameMap_t m_contentNameMap;
63 //! a map id -> name
64 std::map<int, std::string> m_idNameMap;
65
66 std::string m_classNamePrefix;
67
68 private:
69 EPUBSpanStyleManager(EPUBSpanStyleManager const &orig);
70 EPUBSpanStyleManager operator=(EPUBSpanStyleManager const &orig);
71 };
72
73 }
74
75 #endif
76
77 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */