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 
40 {
42  uint8_t m_positionBits;
43  double m_leftOffset;
44  std::vector < WPXColumnDefinition > m_columns;
45  std::vector < WPXColumnProperties > m_columnsProperties;
46 };
47 
50 {
53 
55  double m_fontSize;
59 
63  uint8_t m_tempParagraphJustification; // TODO: remove this one after the tabs are properly implemented
65 
71 
75 
77 
78  std::vector<unsigned int> m_numRowsToSkip;
92 
93  unsigned m_currentPage;
96 
98  unsigned m_numColumns;
99  std::vector < WPXColumnDefinition > m_textColumns;
101 
105 
110  double m_paragraphMarginLeft; // resulting paragraph margin that is one of the paragraph
111  double m_paragraphMarginRight; // properties
114  double m_leftMarginByPageMarginChange; // part of the margin due to the PAGE margin change
115  double m_rightMarginByPageMarginChange; // inside a page that already has content.
116  double m_sectionMarginLeft; // In multicolumn sections, the above two will be rather interpreted
117  double m_sectionMarginRight; // as section margin change
118  double m_leftMarginByParagraphMarginChange; // part of the margin due to the PARAGRAPH
119  double m_rightMarginByParagraphMarginChange; // margin change (in WP6)
120  double m_leftMarginByTabs; // part of the margin due to the LEFT or LEFT/RIGHT Indent; the
121  double m_rightMarginByTabs; // only part of the margin that is reset at the end of a paragraph
122 
123  double m_listReferencePosition; // position from the left page margin of the list number/bullet
124  double m_listBeginPosition; // position from the left page margin of the beginning of the list
125 
126  double m_paragraphTextIndent; // resulting first line indent that is one of the paragraph properties
127  double m_textIndentByParagraphIndentChange; // part of the indent due to the PARAGRAPH indent (WP6???)
128  double m_textIndentByTabs; // part of the indent due to the "Back Tab" or "Left Tab"
129 
131 
133  std::vector<WPXTabStop> m_tabStops;
135 
136  std::set <const WPXSubDocument *> m_subDocuments;
137 
139  bool m_isNote;
141 
142 private:
145 };
146 
148 {
149 protected:
150  WPXContentListener(std::list<WPXPageSpan> &pageList, WPXDocumentInterface *documentInterface);
151  virtual ~WPXContentListener();
152 
153  void startDocument();
154  void startSubDocument();
155  void endDocument();
156  void endSubDocument();
157  void handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice);
158  void insertBreak(const uint8_t breakType);
159  void lineSpacingChange(const double lineSpacing);
160  void justificationChange(const uint8_t justification);
161 
162  WPXContentParsingState *m_ps; // parse state
165 
166  virtual void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice) = 0;
167  virtual void _flushText() = 0;
168  virtual void _changeList() = 0;
169 
170  void _openSection();
171  void _closeSection();
172 
173  void _openPageSpan();
174  void _closePageSpan();
175 
176  void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
177  void _getTabStops(WPXPropertyListVector &tabStops);
178  void _appendJustification(WPXPropertyList &propList, int justification);
179  void _resetParagraphState(const bool isListElement=false);
180  virtual void _openParagraph();
181  void _closeParagraph();
182 
183  void _openListElement();
184  void _closeListElement();
185 
186  void _openSpan();
187  void _closeSpan();
188 
189  void _openTable();
190  void _closeTable();
191  void _openTableRow(const double height, const bool isMinimumHeight, const bool isHeaderRow);
192  void _closeTableRow();
193  void _openTableCell(const uint8_t colSpan, const uint8_t rowSpan, const uint8_t borderBits,
194  const RGBSColor *cellFgColor, const RGBSColor *cellBgColor,
195  const RGBSColor *cellBorderColor,
196  const WPXVerticalAlignment cellVerticalAlignment);
197  void _closeTableCell();
198 
199  double _movePositionToFirstColumn(double position);
200 
201  double _getNextTabStop() const;
202  double _getPreviousTabStop() const;
203 
204  void _insertText(const WPXString &textBuffer);
205 
207 
208  void _insertPageNumberParagraph(WPXPageNumberPosition position, WPXNumberingType type, WPXString fontName, double fontSize);
209 
210  uint32_t _mapNonUnicodeCharacter(uint32_t character);
211 
212 private:
215  WPXString _colorToString(const RGBSColor *color);
216  WPXString _mergeColorsToString(const RGBSColor *fgColor, const RGBSColor *bgColor);
217  uint32_t _mapSymbolFontCharacter(uint32_t character);
218  uint32_t _mapDingbatsFontCharacter(uint32_t character);
219 };
220 
221 #endif /* WPXCONTENTLISTENER_H */
222 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */

Generated for libwpd by doxygen 1.8.4