Debian Codegraph @

src/lib/RVNGHTMLTextTextStyle.h

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* librevenge
3 * Version: MPL 2.0 / LGPLv2.1+
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 * Major Contributor(s):
10 * Copyright (C) 2002-2004 William Lachance ([email protected])
11 * Copyright (C) 2002 Marc Maurer ([email protected])
12 * Copyright (C) 2004 Fridrich Strba ([email protected])
13 * Copyright (C) 2005 Net Integration Technologies (http://www.net-itech.com)
14 *
15 * For minor contributions see the git repository.
16 *
17 * Alternatively, the contents of this file may be used under the terms
18 * of the GNU Lesser General Public License Version 2.1 or later
19 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
20 * applicable instead of those above.
21 */
22
23 #ifndef RVNGHTMLTEXT_TEXTSTYLE_H
24 #define RVNGHTMLTEXT_TEXTSTYLE_H
25
26 #include <ostream>
27 #include <string>
28 #include <map>
29 #include <vector>
30
31 #include <librevenge-generators/librevenge-generators.h>
32
33 namespace librevenge
34 {
35 /** Small class to manage the paragraph style */
36 class RVNGHTMLTextParagraphStyleManager
37 {
38 public:
39 //! constructor
40 RVNGHTMLTextParagraphStyleManager() : m_contentNameMap(), m_idNameMap()
41 {
42 }
43 //! destructor
44 virtual ~RVNGHTMLTextParagraphStyleManager()
45 {
46 }
47 //! define a paragraph style
48 void defineParagraph(RVNGPropertyList const &pList);
49 //! returns the class name corresponding to a propertylist
50 std::string getClass(RVNGPropertyList const &pList);
51 //! send the data to the stream
52 void send(std::ostream &out);
53 protected:
54 //! convert a property list in a html content string
55 static std::string getContent(RVNGPropertyList const &pList, bool isList);
56 //! a map content -> name
57 std::map<std::string, std::string> m_contentNameMap;
58 //! a map id -> name
59 std::map<int, std::string> m_idNameMap;
60 //! add data corresponding to the border
61 static void parseBorders(RVNGPropertyList const &pList, std::ostream &out);
62 private:
63 RVNGHTMLTextParagraphStyleManager(RVNGHTMLTextParagraphStyleManager const &orig);
64 RVNGHTMLTextParagraphStyleManager operator=(RVNGHTMLTextParagraphStyleManager const &orig);
65 };
66
67 /** Small class to manage the list style */
68 class RVNGHTMLTextListStyleManager : public RVNGHTMLTextParagraphStyleManager
69 {
70 public:
71 struct List
72 {
73 //! constructor
74 List() : m_contentsList(), m_level(0)
75 {
76 }
77 //! destructor
78 ~List()
79 {
80 }
81 //! set the property correspond to a level
82 void setLevel(int lvl, RVNGPropertyList const &property, bool ordered);
83 //! open a new level
84 void openLevel() const
85 {
86 m_level++;
87 }
88 //! open a new level
89 void closeLevel() const
90 {
91 if (m_level <= 0)
92 return;
93 m_level--;
94 }
95
96 //! return the content string
97 std::string str() const;
98 protected:
99 //! the properties
100 std::vector<std::string> m_contentsList;
101 //! the actual list level
102 mutable int m_level;
103 };
104 //! constructor
105 RVNGHTMLTextListStyleManager() : RVNGHTMLTextParagraphStyleManager(), m_levelNameMap(),
106 m_idListMap(), m_actualIdStack()
107 {
108 }
109 //! destructor
110 ~RVNGHTMLTextListStyleManager()
111 {
112 }
113 //! add a level to the corresponding list
114 void defineLevel(RVNGPropertyList const &property, bool ordered);
115 //! returns the class name corresponding to a propertylist
116 std::string openLevel(RVNGPropertyList const &pList, bool ordered);
117 //! close a level
118 void closeLevel();
119 //! returns the classname corresponding to a list element
120 std::string getClass(RVNGPropertyList const &pList);
121
122 //! send the data to the stream
123 void send(std::ostream &out);
124 protected:
125 //! a map content -> list level name
126 std::map<std::string, std::string> m_levelNameMap;
127 //! a map listId -> list
128 std::map<int, List> m_idListMap;
129 //! the actual list id
130 std::vector<int> m_actualIdStack;
131 private:
132 RVNGHTMLTextListStyleManager(RVNGHTMLTextListStyleManager const &orig);
133 RVNGHTMLTextListStyleManager operator=(RVNGHTMLTextListStyleManager const &orig);
134 };
135
136 /** Small class to manage the span style */
137 class RVNGHTMLTextSpanStyleManager
138 {
139 public:
140 //! constructor
141 RVNGHTMLTextSpanStyleManager() : m_contentNameMap(), m_idNameMap()
142 {
143 }
144 //! destructor
145 ~RVNGHTMLTextSpanStyleManager()
146 {
147 }
148 //! define a span style
149 void defineSpan(RVNGPropertyList const &pList);
150 //! returns the class name corresponding to a propertylist
151 std::string getClass(RVNGPropertyList const &pList);
152 //! send the data to the stream
153 void send(std::ostream &out);
154 protected:
155 //! convert a property list in a html content string
156 static std::string getContent(RVNGPropertyList const &pList);
157 //! add data corresponding to a text position in out
158 static void parseTextPosition(char const *value, std::ostream &out);
159 //! add data corresponding to the line decoration
160 static void parseDecorations(RVNGPropertyList const &pList, std::ostream &out);
161 //! a map content -> name
162 std::map<std::string, std::string> m_contentNameMap;
163 //! a map id -> name
164 std::map<int, std::string> m_idNameMap;
165
166 private:
167 RVNGHTMLTextSpanStyleManager(RVNGHTMLTextSpanStyleManager const &orig);
168 RVNGHTMLTextSpanStyleManager operator=(RVNGHTMLTextSpanStyleManager const &orig);
169 };
170 }
171
172 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */