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