Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef WPXCONTENTLISTENER_H
00027 #define WPXCONTENTLISTENER_H
00028
00029 #include "WPXTable.h"
00030 #include "WPXPropertyListVector.h"
00031 #include "WPXPropertyList.h"
00032 #include "libwpd_internal.h"
00033 #include "WPXSubDocument.h"
00034 #include "WPXPageSpan.h"
00035 #include "WPXDocumentInterface.h"
00036 #include "WPXListener.h"
00037 #include <vector>
00038 #include <list>
00039 #include <set>
00040
00041 typedef struct _WPXTableDefinition WPXTableDefinition;
00042 struct _WPXTableDefinition
00043 {
00044 _WPXTableDefinition() : m_positionBits(0), m_leftOffset(0.0), m_columns(), m_columnsProperties() {};
00045 uint8_t m_positionBits;
00046 double m_leftOffset;
00047 std::vector < WPXColumnDefinition > m_columns;
00048 std::vector < WPXColumnProperties > m_columnsProperties;
00049 };
00050
00051 typedef struct _WPXContentParsingState WPXContentParsingState;
00052 struct _WPXContentParsingState
00053 {
00054 _WPXContentParsingState();
00055 ~_WPXContentParsingState();
00056
00057 uint32_t m_textAttributeBits;
00058 double m_fontSize;
00059 WPXString *m_fontName;
00060 RGBSColor *m_fontColor;
00061 RGBSColor *m_highlightColor;
00062
00063 bool m_isParagraphColumnBreak;
00064 bool m_isParagraphPageBreak;
00065 uint8_t m_paragraphJustification;
00066 uint8_t m_tempParagraphJustification;
00067 double m_paragraphLineSpacing;
00068
00069 bool m_isDocumentStarted;
00070 bool m_isPageSpanOpened;
00071 bool m_isSectionOpened;
00072 bool m_isPageSpanBreakDeferred;
00073 bool m_isHeaderFooterWithoutParagraph;
00074
00075 bool m_isSpanOpened;
00076 bool m_isParagraphOpened;
00077 bool m_isListElementOpened;
00078
00079 bool m_firstParagraphInPageSpan;
00080
00081 std::vector<unsigned int> m_numRowsToSkip;
00082 WPXTableDefinition m_tableDefinition;
00083 int m_currentTableCol;
00084 int m_currentTableRow;
00085 int m_currentTableCellNumberInRow;
00086 bool m_isTableOpened;
00087 bool m_isTableRowOpened;
00088 bool m_isTableColumnOpened;
00089 bool m_isTableCellOpened;
00090 bool m_wasHeaderRow;
00091 bool m_isCellWithoutParagraph;
00092 bool m_isRowWithoutCell;
00093 uint32_t m_cellAttributeBits;
00094 uint8_t m_paragraphJustificationBeforeTable;
00095
00096 unsigned m_currentPage;
00097 int m_numPagesRemainingInSpan;
00098 int m_currentPageNumber;
00099
00100 bool m_sectionAttributesChanged;
00101 int m_numColumns;
00102 std::vector < WPXColumnDefinition > m_textColumns;
00103 bool m_isTextColumnWithoutParagraph;
00104
00105 double m_pageFormLength;
00106 double m_pageFormWidth;
00107 WPXFormOrientation m_pageFormOrientation;
00108
00109 double m_pageMarginLeft;
00110 double m_pageMarginRight;
00111 double m_pageMarginTop;
00112 double m_pageMarginBottom;
00113 double m_paragraphMarginLeft;
00114 double m_paragraphMarginRight;
00115 double m_paragraphMarginTop;
00116 double m_paragraphMarginBottom;
00117 double m_leftMarginByPageMarginChange;
00118 double m_rightMarginByPageMarginChange;
00119 double m_sectionMarginLeft;
00120 double m_sectionMarginRight;
00121 double m_leftMarginByParagraphMarginChange;
00122 double m_rightMarginByParagraphMarginChange;
00123 double m_leftMarginByTabs;
00124 double m_rightMarginByTabs;
00125
00126 double m_listReferencePosition;
00127 double m_listBeginPosition;
00128
00129 double m_paragraphTextIndent;
00130 double m_textIndentByParagraphIndentChange;
00131 double m_textIndentByTabs;
00132
00133 uint8_t m_currentListLevel;
00134
00135 uint16_t m_alignmentCharacter;
00136 std::vector<WPXTabStop> m_tabStops;
00137 bool m_isTabPositionRelative;
00138
00139 std::set <const WPXSubDocument *> m_subDocuments;
00140
00141 bool m_inSubDocument;
00142 bool m_isNote;
00143 WPXSubDocumentType m_subDocumentType;
00144
00145 private:
00146 _WPXContentParsingState(const _WPXContentParsingState &);
00147 _WPXContentParsingState &operator=(const _WPXContentParsingState &);
00148 };
00149
00150 class WPXContentListener : public WPXListener
00151 {
00152 protected:
00153 WPXContentListener(std::list<WPXPageSpan> &pageList, WPXDocumentInterface *documentInterface);
00154 virtual ~WPXContentListener();
00155
00156 void startDocument();
00157 void startSubDocument();
00158 void endDocument();
00159 void endSubDocument();
00160 void handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, int nextTableIndice);
00161 void insertBreak(const uint8_t breakType);
00162 void lineSpacingChange(const double lineSpacing);
00163 void justificationChange(const uint8_t justification);
00164
00165 WPXContentParsingState *m_ps;
00166 WPXDocumentInterface *m_documentInterface;
00167 WPXPropertyList m_metaData;
00168
00169 virtual void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, int nextTableIndice) = 0;
00170 virtual void _flushText() = 0;
00171 virtual void _changeList() = 0;
00172
00173 void _openSection();
00174 void _closeSection();
00175
00176 void _openPageSpan();
00177 void _closePageSpan();
00178
00179 void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
00180 void _getTabStops(WPXPropertyListVector &tabStops);
00181 void _appendJustification(WPXPropertyList &propList, int justification);
00182 void _resetParagraphState(const bool isListElement=false);
00183 virtual void _openParagraph();
00184 void _closeParagraph();
00185
00186 void _openListElement();
00187 void _closeListElement();
00188
00189 void _openSpan();
00190 void _closeSpan();
00191
00192 void _openTable();
00193 void _closeTable();
00194 void _openTableRow(const double height, const bool isMinimumHeight, const bool isHeaderRow);
00195 void _closeTableRow();
00196 void _openTableCell(const uint8_t colSpan, const uint8_t rowSpan, const uint8_t borderBits,
00197 const RGBSColor *cellFgColor, const RGBSColor *cellBgColor,
00198 const RGBSColor *cellBorderColor,
00199 const WPXVerticalAlignment cellVerticalAlignment);
00200 void _closeTableCell();
00201
00202 double _movePositionToFirstColumn(double position);
00203
00204 double _getNextTabStop() const;
00205 double _getPreviousTabStop() const;
00206
00207 void _insertText(const WPXString &textBuffer);
00208
00209 void _insertBreakIfNecessary(WPXPropertyList &propList);
00210
00211 void _insertPageNumberParagraph(WPXPageNumberPosition position, WPXNumberingType type, WPXString fontName, double fontSize);
00212
00213 uint32_t _mapNonUnicodeCharacter(uint32_t character);
00214
00215 private:
00216 WPXContentListener(const WPXContentListener &);
00217 WPXContentListener &operator=(const WPXContentListener &);
00218 WPXString _colorToString(const RGBSColor *color);
00219 WPXString _mergeColorsToString(const RGBSColor *fgColor, const RGBSColor *bgColor);
00220 uint32_t _mapSymbolFontCharacter(uint32_t character);
00221 uint32_t _mapDingbatsFontCharacter(uint32_t character);
00222 };
00223
00224 #endif
00225