EPUBTableStyleManager.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_EPUBTABLESTYLEMANAGER_H
11 #define INCLUDED_EPUBTABLESTYLEMANAGER_H
12
13 #include <librevenge/librevenge.h>
14
15 #include <string>
16 #include <unordered_map>
17 #include <vector>
18
19 #include <boost/functional/hash.hpp>
20
21 #include "EPUBCSSProperties.h"
22
23 namespace libepubgen
24 {
25
26 class EPUBCSSSink;
27
29 class EPUBTableStyleManager
30 {
31 typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
32
33 public:
35 EPUBTableStyleManager() : m_cellContentNameMap(), m_rowContentNameMap(), m_tableContentNameMap(), m_columnWidthsStack(), m_relColumnWidthsStack()
36 {
37 }
39 ~EPUBTableStyleManager()
40 {
41 }
43 void openTable(librevenge::RVNGPropertyList const &propList);
45 void closeTable();
47 std::string getCellClass(librevenge::RVNGPropertyList const &pList);
49 std::string getCellStyle(librevenge::RVNGPropertyList const &pList);
51 std::string getRowClass(librevenge::RVNGPropertyList const &pList);
53 std::string getRowStyle(librevenge::RVNGPropertyList const &pList);
55 std::string getTableClass(librevenge::RVNGPropertyList const &pList);
57 std::string getTableStyle(librevenge::RVNGPropertyList const &pList);
59 void send(EPUBCSSSink &out);
60 private:
62 void extractCellProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
64 void extractRowProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
66 void extractTableProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
68 bool getColumnsWidth(int i, int numSpanned, double &w) const;
70 bool getRelColumnsWidth(int i, int numSpanned, double &w) const;
72 ContentNameMap_t m_cellContentNameMap;
74 ContentNameMap_t m_rowContentNameMap;
76 ContentNameMap_t m_tableContentNameMap;
78 std::vector<std::vector<double> > m_columnWidthsStack;
80 std::vector<std::vector<double> > m_relColumnWidthsStack;
81
82 EPUBTableStyleManager(EPUBTableStyleManager const &orig);
83 EPUBTableStyleManager operator=(EPUBTableStyleManager const &orig);
84 };
85
86 }
87
88 #endif
89
90 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libepubgen::EPUBTableStyleManager::m_rowContentNameMap
ContentNameMap_t m_rowContentNameMap
a map row content -> name
Definition: EPUBTableStyleManager.h:74
libepubgen::EPUBCSSSink
Definition: EPUBCSSSink.h:23
libepubgen::EPUBTableStyleManager::operator=
EPUBTableStyleManager operator=(EPUBTableStyleManager const &orig)
libepubgen
Definition: EPUBBinarySink.cpp:12
libepubgen::EPUBTableStyleManager::m_columnWidthsStack
std::vector< std::vector< double > > m_columnWidthsStack
a stack of column width (in inches )
Definition: EPUBTableStyleManager.h:78
libepubgen::EPUBTableStyleManager::getTableClass
std::string getTableClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:169
libepubgen::EPUBTableStyleManager::EPUBTableStyleManager
EPUBTableStyleManager()
constructor
Definition: EPUBTableStyleManager.h:35
libepubgen::EPUBTableStyleManager::getCellClass
std::string getCellClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:121
libepubgen::EPUBTableStyleManager
Small class to manage the tables style.
Definition: EPUBTableStyleManager.h:29
libepubgen::EPUBTableStyleManager::extractRowProperties
void extractRowProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBTableStyleManager.cpp:276
libepubgen::EPUBTableStyleManager::getTableStyle
std::string getTableStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:182
libepubgen::EPUBTableStyleManager::m_tableContentNameMap
ContentNameMap_t m_tableContentNameMap
a map table content -> name
Definition: EPUBTableStyleManager.h:76
EPUBCSSProperties.h
libepubgen::EPUBCSSProperties
std::map< std::string, std::string > EPUBCSSProperties
Definition: EPUBCSSProperties.h:21
libepubgen::EPUBTableStyleManager::extractTableProperties
void extractTableProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBTableStyleManager.cpp:284
libepubgen::EPUBTableStyleManager::~EPUBTableStyleManager
~EPUBTableStyleManager()
destructor
Definition: EPUBTableStyleManager.h:39
libepubgen::EPUBTableStyleManager::getRelColumnsWidth
bool getRelColumnsWidth(int i, int numSpanned, double &w) const
try to return the relative col width
Definition: EPUBTableStyleManager.cpp:116
libepubgen::EPUBTableStyleManager::closeTable
void closeTable()
close a table
Definition: EPUBTableStyleManager.cpp:60
libepubgen::EPUBTableStyleManager::extractCellProperties
void extractCellProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBTableStyleManager.cpp:217
libepubgen::EPUBTableStyleManager::getColumnsWidth
bool getColumnsWidth(int i, int numSpanned, double &w) const
try to return the col width
Definition: EPUBTableStyleManager.cpp:111
libepubgen::EPUBTableStyleManager::m_cellContentNameMap
ContentNameMap_t m_cellContentNameMap
a map cell content -> name
Definition: EPUBTableStyleManager.h:72
libepubgen::EPUBTableStyleManager::getCellStyle
std::string getCellStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:134
libepubgen::EPUBTableStyleManager::getRowClass
std::string getRowClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:145
libepubgen::EPUBTableStyleManager::getRowStyle
std::string getRowStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:158
libepubgen::EPUBTableStyleManager::m_relColumnWidthsStack
std::vector< std::vector< double > > m_relColumnWidthsStack
a stack of relative column width (in percents )
Definition: EPUBTableStyleManager.h:80
libepubgen::EPUBTableStyleManager::ContentNameMap_t
std::unordered_map< EPUBCSSProperties, std::string, boost::hash< EPUBCSSProperties > > ContentNameMap_t
Definition: EPUBTableStyleManager.h:31
libepubgen::EPUBTableStyleManager::openTable
void openTable(librevenge::RVNGPropertyList const &propList)
open a table
Definition: EPUBTableStyleManager.cpp:26
libepubgen::EPUBTableStyleManager::send
void send(EPUBCSSSink &out)
send the data to the sink
Definition: EPUBTableStyleManager.cpp:193