EPUBTableStyleManager.h Source File documentation

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 EPUBCSSContent;
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(EPUBCSSContent &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::EPUBCSSContent
Definition: EPUBCSSContent.h:24
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::EPUBTableStyleManager::getColumnsWidth
bool getColumnsWidth(int i, int numSpanned, double &w) const
try to return the col width
Definition: EPUBTableStyleManager.cpp:112
libepubgen::EPUBTableStyleManager::m_tableContentNameMap
ContentNameMap_t m_tableContentNameMap
a map table content -> name
Definition: EPUBTableStyleManager.h:76
libepubgen::EPUBTableStyleManager::getRelColumnsWidth
bool getRelColumnsWidth(int i, int numSpanned, double &w) const
try to return the relative col width
Definition: EPUBTableStyleManager.cpp:117
libepubgen
Definition: EPUBBinaryContent.cpp:15
libepubgen::EPUBTableStyleManager::openTable
void openTable(librevenge::RVNGPropertyList const &propList)
open a table
Definition: EPUBTableStyleManager.cpp:27
libepubgen::EPUBTableStyleManager::extractCellProperties
void extractCellProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBTableStyleManager.cpp:218
libepubgen::EPUBTableStyleManager
Small class to manage the tables style.
Definition: EPUBTableStyleManager.h:30
libepubgen::EPUBTableStyleManager::m_relColumnWidthsStack
std::vector< std::vector< double > > m_relColumnWidthsStack
a stack of relative column width (in percents )
Definition: EPUBTableStyleManager.h:80
libepubgen::EPUBCSSProperties
std::map< std::string, std::string > EPUBCSSProperties
Definition: EPUBCSSProperties.h:21
libepubgen::EPUBTableStyleManager::~EPUBTableStyleManager
~EPUBTableStyleManager()
destructor
Definition: EPUBTableStyleManager.h:39
EPUBCSSContent.h
EPUBCSSProperties.h
libepubgen::EPUBTableStyleManager::extractTableProperties
void extractTableProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBTableStyleManager.cpp:286
libepubgen::EPUBTableStyleManager::m_rowContentNameMap
ContentNameMap_t m_rowContentNameMap
a map row content -> name
Definition: EPUBTableStyleManager.h:74
libepubgen::EPUBTableStyleManager::EPUBTableStyleManager
EPUBTableStyleManager()
constructor
Definition: EPUBTableStyleManager.h:35
libepubgen::EPUBTableStyleManager::getCellStyle
std::string getCellStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:135
libepubgen::EPUBTableStyleManager::getRowClass
std::string getRowClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:146
libepubgen::EPUBTableStyleManager::closeTable
void closeTable()
close a table
Definition: EPUBTableStyleManager.cpp:61
libepubgen::EPUBTableStyleManager::send
void send(EPUBCSSContent &out)
send the data to the sink
Definition: EPUBTableStyleManager.cpp:194
libepubgen::EPUBTableStyleManager::getTableClass
std::string getTableClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:170
libepubgen::EPUBTableStyleManager::extractRowProperties
void extractRowProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
convert a property list into a CSS property map
Definition: EPUBTableStyleManager.cpp:278
libepubgen::EPUBTableStyleManager::ContentNameMap_t
std::unordered_map< EPUBCSSProperties, std::string, boost::hash< EPUBCSSProperties > > ContentNameMap_t
Definition: EPUBTableStyleManager.h:31
libepubgen::EPUBTableStyleManager::getRowStyle
std::string getRowStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:159
libepubgen::EPUBTableStyleManager::EPUBTableStyleManager
EPUBTableStyleManager(EPUBTableStyleManager const &orig)
libepubgen::EPUBTableStyleManager::getCellClass
std::string getCellClass(librevenge::RVNGPropertyList const &pList)
returns the class name corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:122
libepubgen::EPUBTableStyleManager::m_columnWidthsStack
std::vector< std::vector< double > > m_columnWidthsStack
a stack of column width (in inches )
Definition: EPUBTableStyleManager.h:78
libepubgen::EPUBTableStyleManager::getTableStyle
std::string getTableStyle(librevenge::RVNGPropertyList const &pList)
returns the style string corresponding to a propertylist
Definition: EPUBTableStyleManager.cpp:183
libepubgen::EPUBTableStyleManager::operator=
EPUBTableStyleManager operator=(EPUBTableStyleManager const &orig)
libepubgen_utils.h
libepubgen::EPUBTableStyleManager::m_cellContentNameMap
ContentNameMap_t m_cellContentNameMap
a map cell content -> name
Definition: EPUBTableStyleManager.h:72
EPUBTableStyleManager.h