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 "WPXTableList.h"
31 #include "libwpd_internal.h"
32 #include "WPXSubDocument.h"
33 #include "WPXPageSpan.h"
34 #include "WPXListener.h"
35 #include <cstddef>
36 #include <memory>
37 #include <vector>
38 #include <list>
39 #include <set>
40 
42 {
44  unsigned char m_positionBits;
45  double m_leftOffset;
46  std::vector < WPXColumnDefinition > m_columns;
47  std::vector < WPXColumnProperties > m_columnsProperties;
48 };
49 
51 {
54 
56  double m_fontSize;
57  std::unique_ptr<librevenge::RVNGString> m_fontName;
58  std::unique_ptr<RGBSColor> m_fontColor;
59  std::unique_ptr<RGBSColor> m_highlightColor;
60 
63  unsigned char m_paragraphJustification;
64  unsigned char m_tempParagraphJustification; // TODO: remove this one after the tabs are properly implemented
66 
72 
76 
78 
79  std::vector<unsigned int> m_numRowsToSkip;
93 
94  unsigned m_currentPage;
97 
99  unsigned m_numColumns;
100  std::vector < WPXColumnDefinition > m_textColumns;
102 
106 
111  double m_paragraphMarginLeft; // resulting paragraph margin that is one of the paragraph
112  double m_paragraphMarginRight; // properties
115  double m_leftMarginByPageMarginChange; // part of the margin due to the PAGE margin change
116  double m_rightMarginByPageMarginChange; // inside a page that already has content.
117  double m_sectionMarginLeft; // In multicolumn sections, the above two will be rather interpreted
118  double m_sectionMarginRight; // as section margin change
119  double m_leftMarginByParagraphMarginChange; // part of the margin due to the PARAGRAPH
120  double m_rightMarginByParagraphMarginChange; // margin change (in WP6)
121  double m_leftMarginByTabs; // part of the margin due to the LEFT or LEFT/RIGHT Indent; the
122  double m_rightMarginByTabs; // only part of the margin that is reset at the end of a paragraph
123 
124  double m_listReferencePosition; // position from the left page margin of the list number/bullet
125  double m_listBeginPosition; // position from the left page margin of the beginning of the list
126 
127  double m_paragraphTextIndent; // resulting first line indent that is one of the paragraph properties
128  double m_textIndentByParagraphIndentChange; // part of the indent due to the PARAGRAPH indent (WP6???)
129  double m_textIndentByTabs; // part of the indent due to the "Back Tab" or "Left Tab"
130 
131  unsigned char m_currentListLevel;
132 
134  std::vector<WPXTabStop> m_tabStops;
136 
137  std::set <const WPXSubDocument *> m_subDocuments;
138 
140  bool m_isNote;
142 
143 private:
146 };
147 
149 {
150 protected:
151  WPXContentListener(std::list<WPXPageSpan> &pageList, librevenge::RVNGTextInterface *documentInterface);
152  ~WPXContentListener() override;
153 
154  void startDocument();
155  void startSubDocument();
156  void endDocument();
157  void endSubDocument();
158  void handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice);
159  void insertBreak(const unsigned char breakType);
160  void lineSpacingChange(const double lineSpacing);
161  void justificationChange(const unsigned char justification);
162 
163  std::unique_ptr<WPXContentParsingState> m_ps; // parse state
164  librevenge::RVNGTextInterface *m_documentInterface;
165  librevenge::RVNGPropertyList m_metaData;
166 
167  virtual void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice) = 0;
168  virtual void _flushText() = 0;
169  virtual void _changeList() = 0;
170 
171  void _openSection();
172  void _closeSection();
173 
174  void _openPageSpan();
175  void _closePageSpan();
176 
177  void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false);
178  void _getTabStops(librevenge::RVNGPropertyListVector &tabStops);
179  void _appendJustification(librevenge::RVNGPropertyList &propList, int justification);
180  void _resetParagraphState(const bool isListElement=false);
181  virtual void _openParagraph();
182  void _closeParagraph();
183 
184  void _openListElement();
185  void _closeListElement();
186 
187  void _openSpan();
188  void _closeSpan();
189 
190  void _openTable();
191  void _closeTable();
192  void _openTableRow(const double height, const bool isMinimumHeight, const bool isHeaderRow);
193  void _closeTableRow();
194  void _openTableCell(const unsigned char colSpan, const unsigned char rowSpan, const unsigned char borderBits,
195  const RGBSColor *cellFgColor, const RGBSColor *cellBgColor,
196  const RGBSColor *cellBorderColor,
197  const WPXVerticalAlignment cellVerticalAlignment);
198  void _closeTableCell();
199 
200  double _movePositionToFirstColumn(double position);
201 
202  double _getNextTabStop() const;
203  double _getPreviousTabStop() const;
204 
205  void _insertText(const librevenge::RVNGString &textBuffer);
206 
207  void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList);
208 
209  void _insertPageNumberParagraph(WPXPageNumberPosition position, WPXNumberingType type, librevenge::RVNGString fontName, double fontSize);
210 
211  unsigned _mapNonUnicodeCharacter(unsigned character);
212 
213 private:
216  librevenge::RVNGString _colorToString(const RGBSColor *color);
217  librevenge::RVNGString _mergeColorsToString(const RGBSColor *fgColor, const RGBSColor *bgColor);
218  unsigned _mapSymbolFontCharacter(unsigned character);
219  unsigned _mapDingbatsFontCharacter(unsigned character);
220 };
221 
222 #endif /* WPXCONTENTLISTENER_H */
223 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
WPXNumberingType
Definition: libwpd_internal.h:92
void _openTableCell(const unsigned char colSpan, const unsigned char rowSpan, const unsigned char borderBits, const RGBSColor *cellFgColor, const RGBSColor *cellBgColor, const RGBSColor *cellBorderColor, const WPXVerticalAlignment cellVerticalAlignment)
Definition: WPXContentListener.cpp:1101
unsigned m_textAttributeBits
Definition: WPXContentListener.h:55
librevenge::RVNGString _colorToString(const RGBSColor *color)
Definition: WPXContentListener.cpp:1380
void handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice)
Creates an new document state.
Definition: WPXContentListener.cpp:1195
double m_listReferencePosition
Definition: WPXContentListener.h:124
double m_leftOffset
Definition: WPXContentListener.h:45
bool m_isSectionOpened
Definition: WPXContentListener.h:69
virtual void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice)=0
WPXContentListener & operator=(const WPXContentListener &)
std::set< const WPXSubDocument * > m_subDocuments
Definition: WPXContentListener.h:137
WPXContentListener(std::list< WPXPageSpan > &pageList, librevenge::RVNGTextInterface *documentInterface)
Definition: WPXContentListener.cpp:126
void _openTableRow(const double height, const bool isMinimumHeight, const bool isHeaderRow)
Definition: WPXContentListener.cpp:999
unsigned m_numPagesRemainingInSpan
Definition: WPXContentListener.h:95
double _getPreviousTabStop() const
Definition: WPXContentListener.cpp:1362
void justificationChange(const unsigned char justification)
Definition: WPXContentListener.cpp:1304
~WPXContentParsingState()
Definition: WPXContentListener.cpp:122
bool m_isTableCellOpened
Definition: WPXContentListener.h:87
void startSubDocument()
Definition: WPXContentListener.cpp:153
double m_pageMarginBottom
Definition: WPXContentListener.h:110
WPXContentParsingState()
Definition: WPXContentListener.cpp:31
std::vector< WPXColumnDefinition > m_textColumns
Definition: WPXContentListener.h:100
void endDocument()
Definition: WPXContentListener.cpp:159
void _resetParagraphState(const bool isListElement=false)
Definition: WPXContentListener.cpp:528
void _openSection()
Definition: WPXContentListener.cpp:193
double m_pageFormWidth
Definition: WPXContentListener.h:104
std::unique_ptr< WPXContentParsingState > m_ps
Definition: WPXContentListener.h:163
void _closeListElement()
Definition: WPXContentListener.cpp:772
unsigned _mapDingbatsFontCharacter(unsigned character)
Definition: WPXContentListener.cpp:1506
bool m_isListElementOpened
Definition: WPXContentListener.h:75
virtual void _changeList()=0
std::vector< WPXColumnDefinition > m_columns
Definition: WPXContentListener.h:46
void _closeSection()
Definition: WPXContentListener.cpp:233
Definition: WPXListener.h:34
WPXTableDefinition m_tableDefinition
Definition: WPXContentListener.h:80
Definition: WPXContentListener.h:41
void _openSpan()
Definition: WPXContentListener.cpp:791
bool m_isHeaderFooterWithoutParagraph
Definition: WPXContentListener.h:71
std::vector< WPXColumnProperties > m_columnsProperties
Definition: WPXContentListener.h:47
bool m_isPageSpanOpened
Definition: WPXContentListener.h:68
void insertBreak(const unsigned char breakType)
Definition: WPXContentListener.cpp:1242
bool m_isSpanOpened
Definition: WPXContentListener.h:73
double m_sectionMarginRight
Definition: WPXContentListener.h:118
std::vector< WPXTabStop > m_tabStops
Definition: WPXContentListener.h:134
int m_currentTableCellNumberInRow
Definition: WPXContentListener.h:83
unsigned char m_tempParagraphJustification
Definition: WPXContentListener.h:64
void _getTabStops(librevenge::RVNGPropertyListVector &tabStops)
Definition: WPXContentListener.cpp:673
virtual void _openParagraph()
Definition: WPXContentListener.cpp:496
double m_pageMarginLeft
Definition: WPXContentListener.h:107
double m_paragraphLineSpacing
Definition: WPXContentListener.h:65
librevenge::RVNGPropertyList m_metaData
Definition: WPXContentListener.h:165
bool m_firstParagraphInPageSpan
Definition: WPXContentListener.h:77
WPXSubDocumentType
Definition: libwpd_internal.h:111
WPXContentParsingState & operator=(const WPXContentParsingState &)
unsigned char m_paragraphJustificationBeforeTable
Definition: WPXContentListener.h:92
void _closeTableCell()
Definition: WPXContentListener.cpp:1172
bool m_isTableOpened
Definition: WPXContentListener.h:84
double m_pageMarginTop
Definition: WPXContentListener.h:109
void _openPageSpan()
Definition: WPXContentListener.cpp:295
unsigned m_currentPageNumber
Definition: WPXContentListener.h:96
unsigned char m_positionBits
Definition: WPXContentListener.h:44
Definition: WPXContentListener.h:148
void _insertBreakIfNecessary(librevenge::RVNGPropertyList &propList)
Definition: WPXContentListener.cpp:660
unsigned _mapSymbolFontCharacter(unsigned character)
Definition: WPXContentListener.cpp:1461
Definition: WPXTableList.h:35
bool m_isTableRowOpened
Definition: WPXContentListener.h:85
void _openTable()
Definition: WPXContentListener.cpp:911
void _insertText(const librevenge::RVNGString &textBuffer)
Definition: WPXContentListener.cpp:624
double m_textIndentByParagraphIndentChange
Definition: WPXContentListener.h:128
double m_paragraphMarginTop
Definition: WPXContentListener.h:113
double m_paragraphMarginBottom
Definition: WPXContentListener.h:114
double m_leftMarginByPageMarginChange
Definition: WPXContentListener.h:115
Definition: WPXContentListener.h:50
WPXTableDefinition()
Definition: WPXContentListener.h:43
double m_paragraphMarginLeft
Definition: WPXContentListener.h:111
bool m_isParagraphColumnBreak
Definition: WPXContentListener.h:61
double m_listBeginPosition
Definition: WPXContentListener.h:125
void _insertPageNumberParagraph(WPXPageNumberPosition position, WPXNumberingType type, librevenge::RVNGString fontName, double fontSize)
Definition: WPXContentListener.cpp:250
WPXFormOrientation m_pageFormOrientation
Definition: WPXContentListener.h:105
unsigned char m_paragraphJustification
Definition: WPXContentListener.h:63
double m_fontSize
Definition: WPXContentListener.h:56
bool m_isCellWithoutParagraph
Definition: WPXContentListener.h:89
WPXFormOrientation
Definition: libwpd_internal.h:105
unsigned char m_currentListLevel
Definition: WPXContentListener.h:131
bool m_isParagraphOpened
Definition: WPXContentListener.h:74
bool m_isTabPositionRelative
Definition: WPXContentListener.h:135
bool m_isTableColumnOpened
Definition: WPXContentListener.h:86
double m_textIndentByTabs
Definition: WPXContentListener.h:129
double m_rightMarginByParagraphMarginChange
Definition: WPXContentListener.h:120
Definition: WPXSubDocument.h:36
int m_currentTableRow
Definition: WPXContentListener.h:82
bool m_sectionAttributesChanged
Definition: WPXContentListener.h:98
double m_paragraphMarginRight
Definition: WPXContentListener.h:112
WPXVerticalAlignment
Definition: libwpd_internal.h:107
double _movePositionToFirstColumn(double position)
Definition: WPXContentListener.cpp:1430
librevenge::RVNGString _mergeColorsToString(const RGBSColor *fgColor, const RGBSColor *bgColor)
Definition: WPXContentListener.cpp:1399
bool m_isRowWithoutCell
Definition: WPXContentListener.h:90
void _closeTableRow()
Definition: WPXContentListener.cpp:1034
void _closeTable()
Definition: WPXContentListener.cpp:970
double m_sectionMarginLeft
Definition: WPXContentListener.h:117
double m_rightMarginByPageMarginChange
Definition: WPXContentListener.h:116
int m_currentTableCol
Definition: WPXContentListener.h:81
bool m_inSubDocument
Definition: WPXContentListener.h:139
std::vector< unsigned int > m_numRowsToSkip
Definition: WPXContentListener.h:79
unsigned m_numColumns
Definition: WPXContentListener.h:99
unsigned m_currentPage
Definition: WPXContentListener.h:94
void endSubDocument()
Definition: WPXContentListener.cpp:180
void _openListElement()
Definition: WPXContentListener.cpp:742
std::unique_ptr< RGBSColor > m_highlightColor
Definition: WPXContentListener.h:59
double m_pageFormLength
Definition: WPXContentListener.h:103
bool m_wasHeaderRow
Definition: WPXContentListener.h:88
void _appendJustification(librevenge::RVNGPropertyList &propList, int justification)
Definition: WPXContentListener.cpp:556
Definition: libwpd_internal.h:166
double m_rightMarginByTabs
Definition: WPXContentListener.h:122
~WPXContentListener() override
Definition: WPXContentListener.cpp:134
bool m_isNote
Definition: WPXContentListener.h:140
void _closeSpan()
Definition: WPXContentListener.cpp:899
double m_paragraphTextIndent
Definition: WPXContentListener.h:127
std::unique_ptr< RGBSColor > m_fontColor
Definition: WPXContentListener.h:58
double m_leftMarginByTabs
Definition: WPXContentListener.h:121
void _closeParagraph()
Definition: WPXContentListener.cpp:725
WPXPageNumberPosition
Definition: libwpd_internal.h:97
unsigned m_alignmentCharacter
Definition: WPXContentListener.h:133
bool m_isParagraphPageBreak
Definition: WPXContentListener.h:62
virtual void _flushText()=0
double m_pageMarginRight
Definition: WPXContentListener.h:108
std::unique_ptr< librevenge::RVNGString > m_fontName
Definition: WPXContentListener.h:57
void startDocument()
Definition: WPXContentListener.cpp:138
unsigned m_cellAttributeBits
Definition: WPXContentListener.h:91
void lineSpacingChange(const double lineSpacing)
Definition: WPXContentListener.cpp:1296
double _getNextTabStop() const
Definition: WPXContentListener.cpp:1344
bool m_isPageSpanBreakDeferred
Definition: WPXContentListener.h:70
librevenge::RVNGTextInterface * m_documentInterface
Definition: WPXContentListener.h:164
double m_leftMarginByParagraphMarginChange
Definition: WPXContentListener.h:119
void _closePageSpan()
Definition: WPXContentListener.cpp:482
WPXSubDocumentType m_subDocumentType
Definition: WPXContentListener.h:141
bool m_isDocumentStarted
Definition: WPXContentListener.h:67
void _appendParagraphProperties(librevenge::RVNGPropertyList &propList, const bool isListElement=false)
Definition: WPXContentListener.cpp:582
bool m_isTextColumnWithoutParagraph
Definition: WPXContentListener.h:101
unsigned _mapNonUnicodeCharacter(unsigned character)
Definition: WPXContentListener.cpp:1450

Generated for libwpd by doxygen 1.8.14