EPUBSpanStyleManager.h
Go to the documentation of this file.
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 
31 {
32  typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
33 
34 public:
36  EPUBSpanStyleManager(std::string classNamePrefix) : m_contentNameMap(), m_idNameMap(), m_classNamePrefix(classNamePrefix)
37  {
38  }
41  {
42  }
44  void defineSpan(librevenge::RVNGPropertyList const &pList);
46  std::string getClass(librevenge::RVNGPropertyList const &pList);
48  std::string getStyle(librevenge::RVNGPropertyList const &pList);
50  void send(EPUBCSSContent &out);
51 protected:
53  virtual void extractProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
54 
55 private:
57  void extractTextPosition(char const *value, EPUBCSSProperties &cssProps) const;
59  void extractDecorations(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
60 protected:
64  std::map<int, std::string> m_idNameMap;
65 
66  std::string m_classNamePrefix;
67 
68 private:
71 };
72 
73 }
74 
75 #endif
76 
77 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libepubgen::EPUBCSSContent
Definition: EPUBCSSContent.h:23
libepubgen::EPUBPresentationGenerator::Impl::Impl
Impl(EPUBPackage *const package, int version)
Definition: EPUBPresentationGenerator.cpp:29
libepubgen::EPUBSpanStyleManager::getClass
std::string getClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBSpanStyleManager.cpp:25
EPUBGEN_DEBUG_MSG
#define EPUBGEN_DEBUG_MSG(M)
Definition: libepubgen_utils.h:41
libepubgen::EPUBCSSContent::insertRule
void insertRule(const librevenge::RVNGString &selector, const librevenge::RVNGPropertyList &properties)
Definition: EPUBCSSContent.cpp:22
libepubgen::fillPropertyList
void fillPropertyList(const EPUBCSSProperties &cssProps, librevenge::RVNGPropertyList &props)
Definition: EPUBCSSProperties.cpp:15
libepubgen::EPUBSpanStyleManager::~EPUBSpanStyleManager
virtual ~EPUBSpanStyleManager()
destructor
Definition: EPUBSpanStyleManager.h:40
libepubgen
Definition: EPUBBinaryContent.cpp:14
libepubgen::EPUBPresentationGenerator::Impl
Definition: EPUBPresentationGenerator.cpp:23
libepubgen::EPUBSpanStyleManager::m_classNamePrefix
std::string m_classNamePrefix
Definition: EPUBSpanStyleManager.h:66
libepubgen::EPUBSpanStyleManager::m_idNameMap
std::map< int, std::string > m_idNameMap
a map id -> name
Definition: EPUBSpanStyleManager.h:64
libepubgen::EPUBSpanStyleManager::extractProperties
virtual void extractProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBSpanStyleManager.cpp:85
libepubgen::EPUBCSSProperties
std::map< std::string, std::string > EPUBCSSProperties
Definition: EPUBCSSProperties.h:21
EPUBCSSContent.h
EPUBCSSProperties.h
libepubgen::EPUBSpanStyleManager::getStyle
std::string getStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBSpanStyleManager.cpp:49
libepubgen::EPUBSpanStyleManager
Small class to manage the span style.
Definition: EPUBSpanStyleManager.h:30
libepubgen::EPUBSpanStyleManager::send
void send(EPUBCSSContent &out)
send the data to the sink
Definition: EPUBSpanStyleManager.cpp:75
libepubgen::EPUBSpanStyleManager::extractTextPosition
void extractTextPosition(char const *value, EPUBCSSProperties &cssProps) const
add data corresponding to a text position into the map
Definition: EPUBSpanStyleManager.cpp:184
EPUBCounter.h
libepubgen::EPUBSpanStyleManager::ContentNameMap_t
std::unordered_map< EPUBCSSProperties, std::string, boost::hash< EPUBCSSProperties > > ContentNameMap_t
Definition: EPUBSpanStyleManager.h:32
libepubgen::EPUBSpanStyleManager::m_contentNameMap
ContentNameMap_t m_contentNameMap
a map content -> name
Definition: EPUBSpanStyleManager.h:62
libepubgen::EPUBSpanStyleManager::defineSpan
void defineSpan(librevenge::RVNGPropertyList const &pList)
define a span style
Definition: EPUBSpanStyleManager.cpp:60
libepubgen::EPUBSpanStyleManager::EPUBSpanStyleManager
EPUBSpanStyleManager(std::string classNamePrefix)
constructor
Definition: EPUBSpanStyleManager.h:36
libepubgen::EPUBSpanStyleManager::extractDecorations
void extractDecorations(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
add data corresponding to the line decoration into the map
Definition: EPUBSpanStyleManager.cpp:153
EPUBSpanStyleManager.h
EPUBPagedGenerator.h
libepubgen_utils.h
libepubgen::EPUBPagedGenerator
Definition: EPUBPagedGenerator.h:25
libepubgen::EPUBSpanStyleManager::operator=
EPUBSpanStyleManager operator=(EPUBSpanStyleManager const &orig)

Generated for libepubgen by doxygen 1.8.17