WPXContentListener.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwpd
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) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
11  *
12  * For minor contributions see the git repository.
13  *
14  * Alternatively, the contents of this file may be used under the terms
15  * of the GNU Lesser General Public License Version 2.1 or later
16  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
17  * applicable instead of those above.
18  *
19  * For further information visit http://libwpd.sourceforge.net
20  */
21 
22 /* "This product is not manufactured, approved, or supported by
23  * Corel Corporation or Corel Corporation Limited."
24  */
25 
26 #ifndef WPXCONTENTLISTENER_H
27 #define WPXCONTENTLISTENER_H
28 
29 #include "WPXTable.h"
30 #include "libwpd_internal.h"
31 #include "WPXSubDocument.h"
32 #include "WPXPageSpan.h"
33 #include "WPXListener.h"
34 #include <vector>
35 #include <list>
36 #include <set>
37 
39 {
41  unsigned char m_positionBits;
42  double m_leftOffset;
43  std::vector < WPXColumnDefinition > m_columns;
44  std::vector < WPXColumnProperties > m_columnsProperties;
45 };
46 
48 {
51 
53  double m_fontSize;
54  librevenge::RVNGString *m_fontName;
57 
60  unsigned char m_paragraphJustification;
61  unsigned char m_tempParagraphJustification; // TODO: remove this one after the tabs are properly implemented
63 
69 
73 
75 
76  std::vector<unsigned int> m_numRowsToSkip;
90 
91  unsigned m_currentPage;
94 
96  unsigned m_numColumns;
97  std::vector < WPXColumnDefinition > m_textColumns;
99 
103 
108  double m_paragraphMarginLeft; // resulting paragraph margin that is one of the paragraph
109  double m_paragraphMarginRight; // properties
112  double m_leftMarginByPageMarginChange; // part of the margin due to the PAGE margin change
113  double m_rightMarginByPageMarginChange; // inside a page that already has content.
114  double m_sectionMarginLeft; // In multicolumn sections, the above two will be rather interpreted
115  double m_sectionMarginRight; // as section margin change
116  double m_leftMarginByParagraphMarginChange; // part of the margin due to the PARAGRAPH
117  double m_rightMarginByParagraphMarginChange; // margin change (in WP6)
118  double m_leftMarginByTabs; // part of the margin due to the LEFT or LEFT/RIGHT Indent; the
119  double m_rightMarginByTabs; // only part of the margin that is reset at the end of a paragraph
120 
121  double m_listReferencePosition; // position from the left page margin of the list number/bullet
122  double m_listBeginPosition; // position from the left page margin of the beginning of the list
123 
124  double m_paragraphTextIndent; // resulting first line indent that is one of the paragraph properties
125  double m_textIndentByParagraphIndentChange; // part of the indent due to the PARAGRAPH indent (WP6???)
126  double m_textIndentByTabs; // part of the indent due to the "Back Tab" or "Left Tab"
127 
128  unsigned char m_currentListLevel;
129 
131  std::vector<WPXTabStop> m_tabStops;
133 
134  std::set <const WPXSubDocument *> m_subDocuments;
135 
137  bool m_isNote;
139 
140 private:
143 };
144 
146 {
147 protected:
148  WPXContentListener(std::list<WPXPageSpan> &pageList, librevenge::RVNGTextInterface *documentInterface);
149  virtual ~WPXContentListener();
150 
151  void startDocument();
152  void startSubDocument();
153  void endDocument();
154  void endSubDocument();
155  void handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice);
156  void insertBreak(const unsigned char breakType);
157  void lineSpacingChange(const double lineSpacing);
158  void justificationChange(const unsigned char justification);
159 
160  WPXContentParsingState *m_ps; // parse state
161  librevenge::RVNGTextInterface *m_documentInterface;
162  librevenge::RVNGPropertyList m_metaData;
163 
164  virtual void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice) = 0;
165  virtual void _flushText() = 0;
166  virtual void _changeList() = 0;
167 
168  void _openSection();
169  void _closeSection();
170 
171  void _openPageSpan();
172  void _closePageSpan();
173 
174  void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
175  void _getTabStops(librevenge::RVNGPropertyListVector &tabStops);
176  void _appendJustification(librevenge::RVNGPropertyList &propList, int justification);
177  void _resetParagraphState(const bool isListElement=false);
178  virtual void _openParagraph();
179  void _closeParagraph();
180 
181  void _openListElement();
182  void _closeListElement();
183 
184  void _openSpan();
185  void _closeSpan();
186 
187  void _openTable();
188  void _closeTable();
189  void _openTableRow(const double height, const bool isMinimumHeight, const bool isHeaderRow);
190  void _closeTableRow();
191  void _openTableCell(const unsigned char colSpan, const unsigned char rowSpan, const unsigned char borderBits,
192  const RGBSColor *cellFgColor, const RGBSColor *cellBgColor,
193  const RGBSColor *cellBorderColor,
194  const WPXVerticalAlignment cellVerticalAlignment);
195  void _closeTableCell();
196 
197  double _movePositionToFirstColumn(double position);
198 
199  double _getNextTabStop() const;
200  double _getPreviousTabStop() const;
201 
202  void _insertText(const librevenge::RVNGString &textBuffer);
203 
204  void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
205 
206  void _insertPageNumberParagraph(WPXPageNumberPosition position, WPXNumberingType type, librevenge::RVNGString fontName, double fontSize);
207 
208  unsigned _mapNonUnicodeCharacter(unsigned character);
209 
210 private:
212  WPXContentListener &operator=(const WPXContentListener &);
213  librevenge::RVNGString _colorToString(const RGBSColor *color);
214  librevenge::RVNGString _mergeColorsToString(const RGBSColor *fgColor, const RGBSColor *bgColor);
215  unsigned _mapSymbolFontCharacter(unsigned character);
216  unsigned _mapDingbatsFontCharacter(unsigned character);
217 };
218 
219 #endif /* WPXCONTENTLISTENER_H */
220 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPXNumberingType
Definition: libwpd_internal.h:86
unsigned m_textAttributeBits
Definition: WPXContentListener.h:52
double m_listReferencePosition
Definition: WPXContentListener.h:121
double m_leftOffset
Definition: WPXContentListener.h:42
bool m_isSectionOpened
Definition: WPXContentListener.h:66
std::set< const WPXSubDocument * > m_subDocuments
Definition: WPXContentListener.h:134
unsigned m_numPagesRemainingInSpan
Definition: WPXContentListener.h:92
bool m_isTableCellOpened
Definition: WPXContentListener.h:84
double m_pageMarginBottom
Definition: WPXContentListener.h:107
std::vector< WPXColumnDefinition > m_textColumns
Definition: WPXContentListener.h:97
double m_pageFormWidth
Definition: WPXContentListener.h:101
bool m_isListElementOpened
Definition: WPXContentListener.h:72
std::vector< WPXColumnDefinition > m_columns
Definition: WPXContentListener.h:43
Definition: WPXListener.h:34
WPXTableDefinition m_tableDefinition
Definition: WPXContentListener.h:77
Definition: WPXContentListener.h:38
bool m_isHeaderFooterWithoutParagraph
Definition: WPXContentListener.h:68
std::vector< WPXColumnProperties > m_columnsProperties
Definition: WPXContentListener.h:44
bool m_isPageSpanOpened
Definition: WPXContentListener.h:65
bool m_isSpanOpened
Definition: WPXContentListener.h:70
double m_sectionMarginRight
Definition: WPXContentListener.h:115
std::vector< WPXTabStop > m_tabStops
Definition: WPXContentListener.h:131
int m_currentTableCellNumberInRow
Definition: WPXContentListener.h:80
unsigned char m_tempParagraphJustification
Definition: WPXContentListener.h:61
double m_pageMarginLeft
Definition: WPXContentListener.h:104
double m_paragraphLineSpacing
Definition: WPXContentListener.h:62
librevenge::RVNGPropertyList m_metaData
Definition: WPXContentListener.h:162
bool m_firstParagraphInPageSpan
Definition: WPXContentListener.h:74
WPXSubDocumentType
Definition: libwpd_internal.h:105
unsigned char m_paragraphJustificationBeforeTable
Definition: WPXContentListener.h:89
bool m_isTableOpened
Definition: WPXContentListener.h:81
double m_pageMarginTop
Definition: WPXContentListener.h:106
unsigned m_currentPageNumber
Definition: WPXContentListener.h:93
unsigned char m_positionBits
Definition: WPXContentListener.h:41
Definition: WPXContentListener.h:145
Definition: WPXTable.h:79
bool m_isTableRowOpened
Definition: WPXContentListener.h:82
double m_textIndentByParagraphIndentChange
Definition: WPXContentListener.h:125
double m_paragraphMarginTop
Definition: WPXContentListener.h:110
double m_paragraphMarginBottom
Definition: WPXContentListener.h:111
double m_leftMarginByPageMarginChange
Definition: WPXContentListener.h:112
Definition: WPXContentListener.h:47
WPXTableDefinition()
Definition: WPXContentListener.h:40
double m_paragraphMarginLeft
Definition: WPXContentListener.h:108
bool m_isParagraphColumnBreak
Definition: WPXContentListener.h:58
double m_listBeginPosition
Definition: WPXContentListener.h:122
WPXFormOrientation m_pageFormOrientation
Definition: WPXContentListener.h:102
unsigned char m_paragraphJustification
Definition: WPXContentListener.h:60
double m_fontSize
Definition: WPXContentListener.h:53
bool m_isCellWithoutParagraph
Definition: WPXContentListener.h:86
WPXFormOrientation
Definition: libwpd_internal.h:99
unsigned char m_currentListLevel
Definition: WPXContentListener.h:128
bool m_isParagraphOpened
Definition: WPXContentListener.h:71
bool m_isTabPositionRelative
Definition: WPXContentListener.h:132
bool m_isTableColumnOpened
Definition: WPXContentListener.h:83
double m_textIndentByTabs
Definition: WPXContentListener.h:126
double m_rightMarginByParagraphMarginChange
Definition: WPXContentListener.h:117
Definition: WPXSubDocument.h:34
int m_currentTableRow
Definition: WPXContentListener.h:79
bool m_sectionAttributesChanged
Definition: WPXContentListener.h:95
double m_paragraphMarginRight
Definition: WPXContentListener.h:109
WPXVerticalAlignment
Definition: libwpd_internal.h:101
bool m_isRowWithoutCell
Definition: WPXContentListener.h:87
librevenge::RVNGString * m_fontName
Definition: WPXContentListener.h:54
double m_sectionMarginLeft
Definition: WPXContentListener.h:114
double m_rightMarginByPageMarginChange
Definition: WPXContentListener.h:113
int m_currentTableCol
Definition: WPXContentListener.h:78
bool m_inSubDocument
Definition: WPXContentListener.h:136
std::vector< unsigned int > m_numRowsToSkip
Definition: WPXContentListener.h:76
unsigned m_numColumns
Definition: WPXContentListener.h:96
unsigned m_currentPage
Definition: WPXContentListener.h:91
double m_pageFormLength
Definition: WPXContentListener.h:100
bool m_wasHeaderRow
Definition: WPXContentListener.h:85
double m_rightMarginByTabs
Definition: WPXContentListener.h:119
Definition: libwpd_internal.h:160
RGBSColor * m_highlightColor
Definition: WPXContentListener.h:56
bool m_isNote
Definition: WPXContentListener.h:137
double m_paragraphTextIndent
Definition: WPXContentListener.h:124
double m_leftMarginByTabs
Definition: WPXContentListener.h:118
WPXPageNumberPosition
Definition: libwpd_internal.h:91
unsigned m_alignmentCharacter
Definition: WPXContentListener.h:130
bool m_isParagraphPageBreak
Definition: WPXContentListener.h:59
double m_pageMarginRight
Definition: WPXContentListener.h:105
unsigned m_cellAttributeBits
Definition: WPXContentListener.h:88
bool m_isPageSpanBreakDeferred
Definition: WPXContentListener.h:67
librevenge::RVNGTextInterface * m_documentInterface
Definition: WPXContentListener.h:161
RGBSColor * m_fontColor
Definition: WPXContentListener.h:55
double m_leftMarginByParagraphMarginChange
Definition: WPXContentListener.h:116
WPXContentParsingState * m_ps
Definition: WPXContentListener.h:160
WPXSubDocumentType m_subDocumentType
Definition: WPXContentListener.h:138
bool m_isDocumentStarted
Definition: WPXContentListener.h:64
bool m_isTextColumnWithoutParagraph
Definition: WPXContentListener.h:98

Generated for libwpd by doxygen 1.8.13