EPUBListStyleManager.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_EPUBLISTSTYLEMANAGER_H
00011 #define INCLUDED_EPUBLISTSTYLEMANAGER_H
00012 
00013 #include <string>
00014 #include <map>
00015 #include <unordered_map>
00016 #include <vector>
00017 
00018 #include <boost/functional/hash.hpp>
00019 
00020 #include <librevenge/librevenge.h>
00021 
00022 #include "EPUBCSSProperties.h"
00023 #include "EPUBParagraphStyleManager.h"
00024 
00025 namespace libepubgen
00026 {
00027 
00028 class EPUBCSSSink;
00029 
00031 class EPUBListStyleManager : public EPUBParagraphStyleManager
00032 {
00033 public:
00034   struct List
00035   {
00036     typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
00037 
00039     List() : m_contentsList(), m_level(0)
00040     {
00041     }
00043     ~List()
00044     {
00045     }
00047     void setLevel(int lvl, librevenge::RVNGPropertyList const &property, bool ordered);
00049     void openLevel() const
00050     {
00051       m_level++;
00052     }
00054     void closeLevel() const
00055     {
00056       if (m_level <= 0)
00057         return;
00058       m_level--;
00059     }
00060 
00062     const EPUBCSSProperties &getCurrentProperties() const;
00063 
00064   protected:
00066     std::vector<EPUBCSSProperties> m_contentsList;
00068     mutable int m_level;
00069   };
00071   EPUBListStyleManager() : EPUBParagraphStyleManager(), m_levelNameMap(),
00072     m_idListMap(), m_actualIdStack()
00073   {
00074   }
00076   ~EPUBListStyleManager() override
00077   {
00078   }
00080   void defineLevel(librevenge::RVNGPropertyList const &property, bool ordered);
00082   std::string openLevel(librevenge::RVNGPropertyList const &pList, bool ordered);
00084   void closeLevel();
00086   std::string getClass(librevenge::RVNGPropertyList const &pList);
00087 
00089   void send(EPUBCSSSink &out);
00090 protected:
00092   List::ContentNameMap_t m_levelNameMap;
00094   std::map<int, List> m_idListMap;
00096   std::vector<int> m_actualIdStack;
00097 private:
00098   EPUBListStyleManager(EPUBListStyleManager const &orig);
00099   EPUBListStyleManager operator=(EPUBListStyleManager const &orig);
00100 };
00101 
00102 }
00103 
00104 #endif
00105 
00106 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */