EPUBListStyleManager.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_EPUBLISTSTYLEMANAGER_H
11 #define INCLUDED_EPUBLISTSTYLEMANAGER_H
12 
13 #include <string>
14 #include <map>
15 #include <unordered_map>
16 #include <vector>
17 
18 #include <boost/functional/hash.hpp>
19 
20 #include <librevenge/librevenge.h>
21 
22 #include "EPUBCSSProperties.h"
24 
25 namespace libepubgen
26 {
27 
28 class EPUBCSSContent;
29 
32 {
33 public:
34  struct List
35  {
36  typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
37 
40  {
41  }
44  {
45  }
47  void setLevel(int lvl, librevenge::RVNGPropertyList const &property, bool ordered);
49  void openLevel() const
50  {
51  m_level++;
52  }
54  void closeLevel() const
55  {
56  if (m_level <= 0)
57  return;
58  m_level--;
59  }
60 
63 
64  protected:
66  std::vector<EPUBCSSProperties> m_contentsList;
68  mutable int m_level;
69  };
73  {
74  }
77  {
78  }
80  void defineLevel(librevenge::RVNGPropertyList const &property, bool ordered);
82  std::string openLevel(librevenge::RVNGPropertyList const &pList, bool ordered);
84  void closeLevel();
86  std::string getClass(librevenge::RVNGPropertyList const &pList);
87 
89  void send(EPUBCSSContent &out);
90 protected:
94  std::map<int, List> m_idListMap;
96  std::vector<int> m_actualIdStack;
97 private:
100 };
101 
102 }
103 
104 #endif
105 
106 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libepubgen::EPUBCSSContent
Definition: EPUBCSSContent.h:24
libepubgen::EPUBListStyleManager::~EPUBListStyleManager
~EPUBListStyleManager() override
destructor
Definition: EPUBListStyleManager.h:76
libepubgen::EPUBListStyleManager::List::m_level
int m_level
the actual list level
Definition: EPUBListStyleManager.h:68
EPUBGEN_DEBUG_MSG
#define EPUBGEN_DEBUG_MSG(M)
Definition: libepubgen_utils.h:41
libepubgen::EPUBListStyleManager::List::~List
~List()
destructor
Definition: EPUBListStyleManager.h:43
libepubgen::EPUBListStyleManager::openLevel
std::string openLevel(librevenge::RVNGPropertyList const &pList, bool ordered)
returns the class name corresponding to a propertylist
Definition: EPUBListStyleManager.cpp:118
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
Definition: EPUBBinaryContent.cpp:15
libepubgen::EPUBListStyleManager::List::closeLevel
void closeLevel() const
open a new level
Definition: EPUBListStyleManager.h:54
libepubgen::EPUBCSSProperties
std::map< std::string, std::string > EPUBCSSProperties
Definition: EPUBCSSProperties.h:21
libepubgen::EPUBListStyleManager::List::ContentNameMap_t
std::unordered_map< EPUBCSSProperties, std::string, boost::hash< EPUBCSSProperties > > ContentNameMap_t
Definition: EPUBListStyleManager.h:36
EPUBCSSContent.h
libepubgen::EPUBListStyleManager::List::List
List()
constructor
Definition: EPUBListStyleManager.h:39
EPUBCSSProperties.h
libepubgen::EPUBListStyleManager::closeLevel
void closeLevel()
close a level
Definition: EPUBListStyleManager.cpp:145
libepubgen::EPUBListStyleManager::EPUBListStyleManager
EPUBListStyleManager()
constructor
Definition: EPUBListStyleManager.h:71
libepubgen::EPUBParagraphStyleManager::send
void send(EPUBCSSContent &out)
send the data to the sink
Definition: EPUBParagraphStyleManager.cpp:68
libepubgen::EPUBListStyleManager::List::setLevel
void setLevel(int lvl, librevenge::RVNGPropertyList const &property, bool ordered)
set the property correspond to a level
Definition: EPUBListStyleManager.cpp:25
libepubgen::EPUBListStyleManager::List::m_contentsList
std::vector< EPUBCSSProperties > m_contentsList
the properties
Definition: EPUBListStyleManager.h:66
libepubgen::EPUBListStyleManager::getClass
std::string getClass(librevenge::RVNGPropertyList const &pList)
returns the classname corresponding to a list element
Definition: EPUBListStyleManager.cpp:90
libepubgen::EPUBListStyleManager::List::openLevel
void openLevel() const
open a new level
Definition: EPUBListStyleManager.h:49
libepubgen::EPUBListStyleManager
Small class to manage the list style.
Definition: EPUBListStyleManager.h:32
libepubgen::EPUBParagraphStyleManager
Small class to manage the paragraph style.
Definition: EPUBParagraphStyleManager.h:30
libepubgen::EPUBParagraphStyleManager::m_contentNameMap
ContentNameMap_t m_contentNameMap
a map content -> name
Definition: EPUBParagraphStyleManager.h:54
libepubgen::EPUBListStyleManager::m_idListMap
std::map< int, List > m_idListMap
a map listId -> list
Definition: EPUBListStyleManager.h:94
libepubgen::EPUBListStyleManager::operator=
EPUBListStyleManager operator=(EPUBListStyleManager const &orig)
libepubgen::EPUBListStyleManager::m_levelNameMap
List::ContentNameMap_t m_levelNameMap
a map content -> list level name
Definition: EPUBListStyleManager.h:92
libepubgen::EPUBListStyleManager::EPUBListStyleManager
EPUBListStyleManager(EPUBListStyleManager const &orig)
libepubgen::EPUBListStyleManager::defineLevel
void defineLevel(librevenge::RVNGPropertyList const &property, bool ordered)
add a level to the corresponding list
Definition: EPUBListStyleManager.cpp:103
libepubgen::EPUBListStyleManager::List::getCurrentProperties
const EPUBCSSProperties & getCurrentProperties() const
return the properties of the current level
Definition: EPUBListStyleManager.cpp:67
libepubgen::EPUBListStyleManager::m_actualIdStack
std::vector< int > m_actualIdStack
the actual list id
Definition: EPUBListStyleManager.h:96
libepubgen::EPUBParagraphStyleManager::extractProperties
void extractProperties(librevenge::RVNGPropertyList const &pList, bool isList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBParagraphStyleManager.cpp:78
libepubgen::EPUBListStyleManager::send
void send(EPUBCSSContent &out)
send the data to the sink
Definition: EPUBListStyleManager.cpp:78
libepubgen_utils.h
EPUBParagraphStyleManager.h
EPUBListStyleManager.h
libepubgen::EPUBListStyleManager::List
Definition: EPUBListStyleManager.h:35

Generated for libepubgen by doxygen 1.8.18