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  * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
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 "WPXPropertyListVector.h"
31 #include "WPXPropertyList.h"
32 #include "libwpd_internal.h"
33 #include "WPXSubDocument.h"
34 #include "WPXPageSpan.h"
35 #include "WPXDocumentInterface.h"
36 #include "WPXListener.h"
37 #include <vector>
38 #include <list>
39 #include <set>
40 
43 {
45  uint8_t m_positionBits;
46  double m_leftOffset;
47  std::vector < WPXColumnDefinition > m_columns;
48  std::vector < WPXColumnProperties > m_columnsProperties;
49 };
50 
53 {
56 
58  double m_fontSize;
62 
66  uint8_t m_tempParagraphJustification; // TODO: remove this one after the tabs are properly implemented
68 
74 
78 
80 
81  std::vector<unsigned int> m_numRowsToSkip;
95 
96  unsigned m_currentPage;
99 
102  std::vector < WPXColumnDefinition > m_textColumns;
104 
108 
113  double m_paragraphMarginLeft; // resulting paragraph margin that is one of the paragraph
114  double m_paragraphMarginRight; // properties
117  double m_leftMarginByPageMarginChange; // part of the margin due to the PAGE margin change
118  double m_rightMarginByPageMarginChange; // inside a page that already has content.
119  double m_sectionMarginLeft; // In multicolumn sections, the above two will be rather interpreted
120  double m_sectionMarginRight; // as section margin change
121  double m_leftMarginByParagraphMarginChange; // part of the margin due to the PARAGRAPH
122  double m_rightMarginByParagraphMarginChange; // margin change (in WP6)
123  double m_leftMarginByTabs; // part of the margin due to the LEFT or LEFT/RIGHT Indent; the
124  double m_rightMarginByTabs; // only part of the margin that is reset at the end of a paragraph
125 
126  double m_listReferencePosition; // position from the left page margin of the list number/bullet
127  double m_listBeginPosition; // position from the left page margin of the beginning of the list
128 
129  double m_paragraphTextIndent; // resulting first line indent that is one of the paragraph properties
130  double m_textIndentByParagraphIndentChange; // part of the indent due to the PARAGRAPH indent (WP6???)
131  double m_textIndentByTabs; // part of the indent due to the "Back Tab" or "Left Tab"
132 
134 
136  std::vector<WPXTabStop> m_tabStops;
138 
139  std::set <const WPXSubDocument *> m_subDocuments;
140 
142  bool m_isNote;
144 
145 private:
148 };
149 
151 {
152 protected:
153  WPXContentListener(std::list<WPXPageSpan> &pageList, WPXDocumentInterface *documentInterface);
154  virtual ~WPXContentListener();
155 
156  void startDocument();
157  void startSubDocument();
158  void endDocument();
159  void endSubDocument();
160  void handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, int nextTableIndice);
161  void insertBreak(const uint8_t breakType);
162  void lineSpacingChange(const double lineSpacing);
163  void justificationChange(const uint8_t justification);
164 
165  WPXContentParsingState *m_ps; // parse state
168 
169  virtual void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, int nextTableIndice) = 0;
170  virtual void _flushText() = 0;
171  virtual void _changeList() = 0;
172 
173  void _openSection();
174  void _closeSection();
175 
176  void _openPageSpan();
177  void _closePageSpan();
178 
179  void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
180  void _getTabStops(WPXPropertyListVector &tabStops);
181  void _appendJustification(WPXPropertyList &propList, int justification);
182  void _resetParagraphState(const bool isListElement=false);
183  virtual void _openParagraph();
184  void _closeParagraph();
185 
186  void _openListElement();
187  void _closeListElement();
188 
189  void _openSpan();
190  void _closeSpan();
191 
192  void _openTable();
193  void _closeTable();
194  void _openTableRow(const double height, const bool isMinimumHeight, const bool isHeaderRow);
195  void _closeTableRow();
196  void _openTableCell(const uint8_t colSpan, const uint8_t rowSpan, const uint8_t borderBits,
197  const RGBSColor *cellFgColor, const RGBSColor *cellBgColor,
198  const RGBSColor *cellBorderColor,
199  const WPXVerticalAlignment cellVerticalAlignment);
200  void _closeTableCell();
201 
202  double _movePositionToFirstColumn(double position);
203 
204  double _getNextTabStop() const;
205  double _getPreviousTabStop() const;
206 
207  void _insertText(const WPXString &textBuffer);
208 
210 
211  void _insertPageNumberParagraph(WPXPageNumberPosition position, WPXNumberingType type, WPXString fontName, double fontSize);
212 
213  uint32_t _mapNonUnicodeCharacter(uint32_t character);
214 
215 private:
218  WPXString _colorToString(const RGBSColor *color);
219  WPXString _mergeColorsToString(const RGBSColor *fgColor, const RGBSColor *bgColor);
220  uint32_t _mapSymbolFontCharacter(uint32_t character);
221  uint32_t _mapDingbatsFontCharacter(uint32_t character);
222 };
223 
224 #endif /* WPXCONTENTLISTENER_H */
225 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */

Generated for libwpd by doxygen 1.8.1.2