EPUBTableStyleManager.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libepubgen project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef INCLUDED_EPUBTABLESTYLEMANAGER_H
00011 #define INCLUDED_EPUBTABLESTYLEMANAGER_H
00012 
00013 #include <librevenge/librevenge.h>
00014 
00015 #include <string>
00016 #include <unordered_map>
00017 #include <vector>
00018 
00019 #include <boost/functional/hash.hpp>
00020 
00021 #include "EPUBCSSProperties.h"
00022 
00023 namespace libepubgen
00024 {
00025 
00026 class EPUBCSSSink;
00027 
00029 class EPUBTableStyleManager
00030 {
00031   typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
00032 
00033 public:
00035   EPUBTableStyleManager() : m_cellContentNameMap(), m_rowContentNameMap(), m_tableContentNameMap(), m_columnWidthsStack(), m_relColumnWidthsStack()
00036   {
00037   }
00039   ~EPUBTableStyleManager()
00040   {
00041   }
00043   void openTable(librevenge::RVNGPropertyList const &propList);
00045   void closeTable();
00047   std::string getCellClass(librevenge::RVNGPropertyList const &pList);
00049   std::string getCellStyle(librevenge::RVNGPropertyList const &pList);
00051   std::string getRowClass(librevenge::RVNGPropertyList const &pList);
00053   std::string getRowStyle(librevenge::RVNGPropertyList const &pList);
00055   std::string getTableClass(librevenge::RVNGPropertyList const &pList);
00057   std::string getTableStyle(librevenge::RVNGPropertyList const &pList);
00059   void send(EPUBCSSSink &out);
00060 private:
00062   void extractCellProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
00064   void extractRowProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
00066   void extractTableProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
00068   bool getColumnsWidth(int i, int numSpanned, double &w) const;
00070   bool getRelColumnsWidth(int i, int numSpanned, double &w) const;
00072   ContentNameMap_t m_cellContentNameMap;
00074   ContentNameMap_t m_rowContentNameMap;
00076   ContentNameMap_t m_tableContentNameMap;
00078   std::vector<std::vector<double> > m_columnWidthsStack;
00080   std::vector<std::vector<double> > m_relColumnWidthsStack;
00081 
00082   EPUBTableStyleManager(EPUBTableStyleManager const &orig);
00083   EPUBTableStyleManager operator=(EPUBTableStyleManager const &orig);
00084 };
00085 
00086 }
00087 
00088 #endif
00089 
00090 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */