ABWContentCollector.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 libabw 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 __ABWCONTENTCOLLECTOR_H__
11 #define __ABWCONTENTCOLLECTOR_H__
12 
13 #include <vector>
14 #include <stack>
15 #include <set>
16 #include <librevenge/librevenge.h>
17 #include "ABWOutputElements.h"
18 #include "ABWCollector.h"
19 
20 namespace libabw
21 {
22 
24 {
28 };
29 
30 struct ABWStyle
31 {
33  ~ABWStyle() {}
34  std::string basedon;
35  std::string followedby;
37 };
38 
40 {
44 
47 
57 };
58 
60 {
64 
70 
75 
79 
80  double m_pageWidth;
81  double m_pageHeight;
95  librevenge::RVNGString m_currentHeaderFooterOccurrence;
97 
100 
101  bool m_isNote;
102 
106 
107  std::stack<ABWContentTableState> m_tableStates;
108  std::stack<std::pair<int, ABWListElement *> > m_listLevels;
109 };
110 
112 {
113 public:
114  ABWContentCollector(librevenge::RVNGTextInterface *iface, const std::map<int, int> &tableSizes,
115  const std::map<std::string, ABWData> &data,
116  const std::map<int, ABWListElement *> &listElements);
117  virtual ~ABWContentCollector();
118 
119  // collector functions
120 
121  void collectTextStyle(const char *name, const char *basedon, const char *followedby, const char *props);
122  void collectDocumentProperties(const char *props);
123  void collectParagraphProperties(const char *level, const char *listid, const char *parentid, const char *style, const char *props);
124  void collectSectionProperties(const char *footer, const char *footerLeft, const char *footerFirst, const char *footerLast,
125  const char *header, const char *headerLeft, const char *headerFirst, const char *headerLast,
126  const char *props);
127  void collectCharacterProperties(const char *style, const char *props);
128  void collectPageSize(const char *width, const char *height, const char *units, const char *pageScale);
129  void closeParagraphOrListElement();
130  void closeSpan();
131  void openLink(const char *href);
132  void closeLink();
133  void openFoot(const char *id);
134  void closeFoot();
135  void openEndnote(const char *id);
136  void closeEndnote();
137  void endSection();
138  void startDocument();
139  void endDocument();
140  void insertLineBreak();
141  void insertColumnBreak();
142  void insertPageBreak();
143  void insertText(const char *text);
144  void insertImage(const char *dataid, const char *props);
145  void collectList(const char *, const char *, const char *, const char *, const char *, const char *) {}
146 
147  void collectData(const char *name, const char *mimeType, const librevenge::RVNGBinaryData &data);
148  void collectHeaderFooter(const char *id, const char *type);
149 
150  void openTable(const char *props);
151  void closeTable();
152  void openCell(const char *props);
153  void closeCell();
154 
155  void addMetadataEntry(const char *name, const char *value);
156 
157 private:
159  ABWContentCollector &operator=(const ABWContentCollector &);
160 
161  void _setMetadata();
162 
163  void _openPageSpan();
164  void _closePageSpan();
165 
166  void _openSection();
167  void _closeSection();
168 
169  void _openParagraph();
170  void _closeParagraph();
171 
172  void _openListElement();
173  void _closeListElement();
174 
175  void _handleListChange();
176  void _changeList();
177  void _recurseListLevels(int oldLevel, int newLevel, int listId);
178  void _writeOutDummyListLevels(int oldLevel, int newLevel);
179 
180  void _openSpan();
181  void _closeSpan();
182 
183  void _openTable();
184  void _closeTable();
185  void _openTableRow();
186  void _closeTableRow();
187  void _openTableCell();
188  void _closeTableCell();
189 
190  void _openHeader();
191  void _closeHeader();
192  void _openFooter();
193  void _closeFooter();
194 
195  void _recurseTextProperties(const char *name, ABWPropertyMap &styleProps);
196  std::string _findDocumentProperty(const char *name);
197  std::string _findParagraphProperty(const char *name);
198  std::string _findCharacterProperty(const char *name);
199  std::string _findTableProperty(const char *name);
200  std::string _findCellProperty(const char *name);
201  std::string _findSectionProperty(const char *name);
202  std::string _findMetadataEntry(const char *name);
203 
204  void _fillParagraphProperties(librevenge::RVNGPropertyList &propList, bool isListElement);
205 
207  librevenge::RVNGTextInterface *m_iface;
208  std::stack<ABWContentParsingState *> m_parsingStates;
209  std::set<std::string> m_dontLoop;
210  std::map<std::string, ABWStyle> m_textStyles;
211 
214 
215  const std::map<std::string, ABWData> &m_data;
216  const std::map<int, int> &m_tableSizes;
219  const std::map<int, ABWListElement *> &m_listElements;
220  std::vector<ABWListElement *> m_dummyListElements;
221 };
222 
223 } // namespace libabw
224 
225 #endif /* __ABWCOLLECTOR_H__ */
226 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
ABWPropertyMap m_currentTableProperties
Definition: ABWContentCollector.h:45
bool m_inParagraphOrListElement
Definition: ABWContentCollector.h:74
std::stack< ABWContentParsingState * > m_parsingStates
Definition: ABWContentCollector.h:208
bool m_isSpanOpened
Definition: ABWContentCollector.h:71
bool m_isRowWithoutCell
Definition: ABWContentCollector.h:56
Definition: ABWContentCollector.h:30
bool m_isCellWithoutParagraph
Definition: ABWContentCollector.h:55
int m_currentListId
Definition: ABWContentCollector.h:104
bool m_isFooterOpened
Definition: ABWContentCollector.h:69
ABWPropertyMap m_currentCharacterStyle
Definition: ABWContentCollector.h:78
std::map< std::string, ABWStyle > m_textStyles
Definition: ABWContentCollector.h:210
ABWPropertyMap m_documentStyle
Definition: ABWContentCollector.h:212
librevenge::RVNGTextInterface * m_iface
Definition: ABWContentCollector.h:207
bool m_deferredColumnBreak
Definition: ABWContentCollector.h:99
std::vector< ABWListElement * > m_dummyListElements
Definition: ABWContentCollector.h:220
int m_footerLeftId
Definition: ABWContentCollector.h:87
Definition: ABWContentCollector.h:111
const std::map< int, ABWListElement * > & m_listElements
Definition: ABWContentCollector.h:219
bool m_isPageSpanOpened
Definition: ABWContentCollector.h:66
bool m_isTableRowOpened
Definition: ABWContentCollector.h:52
Definition: ABWCollector.h:17
int m_currentTableCol
Definition: ABWContentCollector.h:48
ABWOutputElements m_outputElements
Definition: ABWContentCollector.h:218
int m_tableCounter
Definition: ABWContentCollector.h:217
Definition: ABWContentCollector.h:27
Definition: ABWContentCollector.h:25
Definition: ABWOutputElements.h:22
int m_currentTableRow
Definition: ABWContentCollector.h:49
Definition: ABWContentCollector.h:59
bool m_isHeaderOpened
Definition: ABWContentCollector.h:68
const std::map< std::string, ABWData > & m_data
Definition: ABWContentCollector.h:215
bool m_deferredPageBreak
Definition: ABWContentCollector.h:98
int m_headerId
Definition: ABWContentCollector.h:90
int m_footerId
Definition: ABWContentCollector.h:86
int m_headerFirstId
Definition: ABWContentCollector.h:92
Definition: ABWContentCollector.h:26
double m_pageMarginRight
Definition: ABWContentCollector.h:85
double m_pageMarginTop
Definition: ABWContentCollector.h:82
int m_footerLastId
Definition: ABWContentCollector.h:89
double m_pageHeight
Definition: ABWContentCollector.h:81
librevenge::RVNGString m_currentHeaderFooterOccurrence
Definition: ABWContentCollector.h:95
std::string basedon
Definition: ABWContentCollector.h:34
bool m_isTableCellOpened
Definition: ABWContentCollector.h:54
std::string followedby
Definition: ABWContentCollector.h:35
double m_pageWidth
Definition: ABWContentCollector.h:80
~ABWStyle()
Definition: ABWContentCollector.h:33
int m_currentListLevel
Definition: ABWContentCollector.h:103
double m_pageMarginBottom
Definition: ABWContentCollector.h:83
bool m_isTableColumnOpened
Definition: ABWContentCollector.h:53
std::set< std::string > m_dontLoop
Definition: ABWContentCollector.h:209
Definition: ABWCollector.h:103
int m_currentHeaderFooterId
Definition: ABWContentCollector.h:94
bool m_isDocumentStarted
Definition: ABWContentCollector.h:65
int m_headerLastId
Definition: ABWContentCollector.h:93
void collectList(const char *, const char *, const char *, const char *, const char *, const char *)
Definition: ABWContentCollector.h:145
ABWContext
Definition: ABWContentCollector.h:23
double m_pageMarginLeft
Definition: ABWContentCollector.h:84
std::stack< ABWContentTableState > m_tableStates
Definition: ABWContentCollector.h:107
ABWPropertyMap m_currentCellProperties
Definition: ABWContentCollector.h:46
int m_footerFirstId
Definition: ABWContentCollector.h:88
ABWPropertyMap properties
Definition: ABWContentCollector.h:36
int m_currentTableCellNumberInRow
Definition: ABWContentCollector.h:50
bool m_isNote
Definition: ABWContentCollector.h:101
std::stack< std::pair< int, ABWListElement * > > m_listLevels
Definition: ABWContentCollector.h:108
ABWStyle()
Definition: ABWContentCollector.h:32
bool m_isListElementOpened
Definition: ABWContentCollector.h:73
ABWPropertyMap m_currentParagraphStyle
Definition: ABWContentCollector.h:77
ABWPropertyMap m_currentSectionStyle
Definition: ABWContentCollector.h:76
Definition: ABWContentCollector.h:39
std::map< std::string, std::string > ABWPropertyMap
Definition: ABWCollector.h:38
bool m_isParagraphOpened
Definition: ABWContentCollector.h:72
int m_headerLeftId
Definition: ABWContentCollector.h:91
ABWContentParsingState * m_ps
Definition: ABWContentCollector.h:206
ABWPropertyMap m_metadata
Definition: ABWContentCollector.h:213
ABWContext m_parsingContext
Definition: ABWContentCollector.h:96
int m_currentTableId
Definition: ABWContentCollector.h:51
bool m_isFirstTextInListElement
Definition: ABWContentCollector.h:105
const std::map< int, int > & m_tableSizes
Definition: ABWContentCollector.h:216
bool m_isSectionOpened
Definition: ABWContentCollector.h:67

Generated for libwpd by doxygen 1.8.12