RVNGHTMLTextTextStyle.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* librevenge
00003  * Version: MPL 2.0 / LGPLv2.1+
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  * Major Contributor(s):
00010  * Copyright (C) 2002-2004 William Lachance (wrlach@gmail.com)
00011  * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
00012  * Copyright (C) 2004 Fridrich Strba (fridrich.strba@bluewin.ch)
00013  * Copyright (C) 2005 Net Integration Technologies (http://www.net-itech.com)
00014  *
00015  * For minor contributions see the git repository.
00016  *
00017  * Alternatively, the contents of this file may be used under the terms
00018  * of the GNU Lesser General Public License Version 2.1 or later
00019  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00020  * applicable instead of those above.
00021  */
00022 
00023 #ifndef RVNGHTMLTEXT_TEXTSTYLE_H
00024 #define RVNGHTMLTEXT_TEXTSTYLE_H
00025 
00026 #include <ostream>
00027 #include <string>
00028 #include <map>
00029 #include <vector>
00030 
00031 #include <librevenge-generators/librevenge-generators.h>
00032 
00033 namespace librevenge
00034 {
00036 class RVNGHTMLTextParagraphStyleManager
00037 {
00038 public:
00040         RVNGHTMLTextParagraphStyleManager() : m_contentNameMap(), m_idNameMap()
00041         {
00042         }
00044         virtual ~RVNGHTMLTextParagraphStyleManager()
00045         {
00046         }
00048         void defineParagraph(RVNGPropertyList const &pList);
00050         std::string getClass(RVNGPropertyList const &pList);
00052         void send(std::ostream &out);
00053 protected:
00055         std::string getContent(RVNGPropertyList const &pList, bool isList) const;
00057         std::map<std::string, std::string> m_contentNameMap;
00059         std::map<int, std::string> m_idNameMap;
00061         void parseBorders(RVNGPropertyList const &pList, std::ostream &out) const;
00062 private:
00063         RVNGHTMLTextParagraphStyleManager(RVNGHTMLTextParagraphStyleManager const &orig);
00064         RVNGHTMLTextParagraphStyleManager operator=(RVNGHTMLTextParagraphStyleManager const &orig);
00065 };
00066 
00068 class RVNGHTMLTextListStyleManager : public RVNGHTMLTextParagraphStyleManager
00069 {
00070 public:
00071         struct List
00072         {
00074                 List() : m_contentsList(), m_level(0)
00075                 {
00076                 }
00078                 ~List()
00079                 {
00080                 }
00082                 void setLevel(int lvl, RVNGPropertyList const &property, bool ordered);
00084                 void openLevel() const
00085                 {
00086                         m_level++;
00087                 }
00089                 void closeLevel() const
00090                 {
00091                         if (m_level <= 0)
00092                                 return;
00093                         m_level--;
00094                 }
00095 
00097                 std::string str() const;
00098         protected:
00100                 std::vector<std::string> m_contentsList;
00102                 mutable int m_level;
00103         };
00105         RVNGHTMLTextListStyleManager() : RVNGHTMLTextParagraphStyleManager(), m_levelNameMap(),
00106                 m_idListMap(), m_actualIdStack()
00107         {
00108         }
00110         ~RVNGHTMLTextListStyleManager()
00111         {
00112         }
00114         void defineLevel(RVNGPropertyList const &property, bool ordered);
00116         std::string openLevel(RVNGPropertyList const &pList, bool ordered);
00118         void closeLevel();
00120         std::string getClass(RVNGPropertyList const &pList);
00121 
00123         void send(std::ostream &out);
00124 protected:
00126         std::map<std::string, std::string> m_levelNameMap;
00128         std::map<int, List> m_idListMap;
00130         std::vector<int> m_actualIdStack;
00131 private:
00132         RVNGHTMLTextListStyleManager(RVNGHTMLTextListStyleManager const &orig);
00133         RVNGHTMLTextListStyleManager operator=(RVNGHTMLTextListStyleManager const &orig);
00134 };
00135 
00137 class RVNGHTMLTextSpanStyleManager
00138 {
00139 public:
00141         RVNGHTMLTextSpanStyleManager() : m_contentNameMap(), m_idNameMap()
00142         {
00143         }
00145         ~RVNGHTMLTextSpanStyleManager()
00146         {
00147         }
00149         void defineSpan(RVNGPropertyList const &pList);
00151         std::string getClass(RVNGPropertyList const &pList);
00153         void send(std::ostream &out);
00154 protected:
00156         std::string getContent(RVNGPropertyList const &pList) const;
00158         void parseTextPosition(char const *value, std::ostream &out) const;
00160         void parseDecorations(RVNGPropertyList const &pList, std::ostream &out) const;
00162         std::map<std::string, std::string> m_contentNameMap;
00164         std::map<int, std::string> m_idNameMap;
00165 
00166 private:
00167         RVNGHTMLTextSpanStyleManager(RVNGHTMLTextSpanStyleManager const &orig);
00168         RVNGHTMLTextSpanStyleManager operator=(RVNGHTMLTextSpanStyleManager const &orig);
00169 };
00170 }
00171 
00172 #endif
00173 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */