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
00027 #ifndef WPXHLLISTENER_H
00028 #define WPXHLLISTENER_H
00029
00030 #include "WPXLLListener.h"
00031 #include "WPXHLListenerImpl.h"
00032 #include "WPXTable.h"
00033 #include "WPXPropertyListVector.h"
00034 #include <set>
00035
00036 class WPXPageSpan;
00037
00038 typedef struct _WPXDocumentMetaData WPXDocumentMetaData;
00039 struct _WPXDocumentMetaData
00040 {
00041 WPXString m_author;
00042 WPXString m_subject;
00043 WPXString m_publisher;
00044 WPXString m_category;
00045 WPXString m_keywords;
00046 WPXString m_language;
00047 WPXString m_abstract;
00048 WPXString m_descriptiveName;
00049 WPXString m_descriptiveType;
00050 };
00051
00052 typedef struct _WPXTableDefinition WPXTableDefinition;
00053 struct _WPXTableDefinition
00054 {
00055 uint8_t m_positionBits;
00056 float m_leftOffset;
00057 std::vector < WPXColumnDefinition > columns;
00058 };
00059
00060 typedef struct _WPXParsingState WPXParsingState;
00061 struct _WPXParsingState
00062 {
00063 _WPXParsingState();
00064 ~_WPXParsingState();
00065
00066 #if 0
00067 WPXString m_bodyText;
00068 WPXString m_textBeforeNumber;
00069 WPXString m_textBeforeDisplayReference;
00070 WPXString m_numberText;
00071 WPXString m_textAfterDisplayReference;
00072 WPXString m_textAfterNumber;
00073 #endif
00074 uint32_t m_textAttributeBits;
00075 float m_fontSize;
00076 WPXString *m_fontName;
00077 RGBSColor *m_fontColor;
00078 RGBSColor *m_highlightColor;
00079
00080 bool m_isParagraphColumnBreak;
00081 bool m_isParagraphPageBreak;
00082 uint8_t m_paragraphJustification;
00083 uint8_t m_tempParagraphJustification;
00084 float m_paragraphLineSpacing;
00085
00086 bool m_isDocumentStarted;
00087 bool m_isPageSpanOpened;
00088 bool m_isSectionOpened;
00089 bool m_isPageSpanBreakDeferred;
00090
00091 bool m_isSpanOpened;
00092 bool m_isParagraphOpened;
00093 bool m_isListElementOpened;
00094
00095 WPXTableDefinition m_tableDefinition;
00096 int m_currentTableCol;
00097 int m_currentTableRow;
00098 bool m_isTableOpened;
00099 bool m_isTableRowOpened;
00100 bool m_isTableColumnOpened;
00101 bool m_isTableCellOpened;
00102 bool m_wasHeaderRow;
00103 bool m_isCellWithoutParagraph;
00104 uint32_t m_cellAttributeBits;
00105 uint8_t m_paragraphJustificationBeforeTable;
00106
00107 int m_nextPageSpanIndice;
00108 int m_numPagesRemainingInSpan;
00109
00110 bool m_sectionAttributesChanged;
00111 int m_numColumns;
00112 std::vector < WPXColumnDefinition > m_textColumns;
00113 bool m_isTextColumnWithoutParagraph;
00114
00115 float m_pageFormLength;
00116 float m_pageFormWidth;
00117 WPXFormOrientation m_pageFormOrientation;
00118
00119 float m_pageMarginLeft;
00120 float m_pageMarginRight;
00121 float m_paragraphMarginLeft;
00122 float m_paragraphMarginRight;
00123 float m_paragraphMarginTop;
00124 float m_paragraphMarginBottom;
00125 float m_leftMarginByPageMarginChange;
00126 float m_rightMarginByPageMarginChange;
00127 float m_leftMarginByParagraphMarginChange;
00128 float m_rightMarginByParagraphMarginChange;
00129 float m_leftMarginByTabs;
00130 float m_rightMarginByTabs;
00131
00132 float m_listReferencePosition;
00133 float m_listBeginPosition;
00134
00135 float m_paragraphTextIndent;
00136 float m_textIndentByParagraphIndentChange;
00137 float m_textIndentByTabs;
00138
00139 uint8_t m_currentListLevel;
00140
00141 #if 0
00142 stack<int> m_listLevelStack;
00143 uint16_t m_currentOutlineHash;
00144 uint8_t m_oldListLevel;
00145 WP6StyleStateSequence m_styleStateSequence;
00146 bool m_putativeListElementHasParagraphNumber;
00147 bool m_putativeListElementHasDisplayReferenceNumber;
00148
00149 int m_noteTextPID;
00150 #endif
00151 uint16_t m_alignmentCharacter;
00152 std::vector<WPXTabStop> m_tabStops;
00153 bool m_isTabPositionRelative;
00154
00155 std::set <int> m_subDocumentTextPIDs;
00156
00157 bool m_inSubDocument;
00158 bool m_isNote;
00159 };
00160
00161 class WPXHLListener : public WPXLLListener
00162 {
00163 public:
00164 WPXHLListener(std::vector<WPXPageSpan *> *pageList, WPXHLListenerImpl *listenerImpl);
00165 WPXHLListener::~WPXHLListener();
00166
00167 void startDocument();
00168 void handleSubDocument(uint16_t textPID, const bool isHeaderFooter, WPXTableList tableList, int nextTableIndice);
00169 virtual void insertBreak(const uint8_t breakType);
00170 virtual void lineSpacingChange(const float lineSpacing);
00171 virtual void justificationChange(const uint8_t justification);
00172
00173 WPXParsingState *m_ps;
00174 WPXHLListenerImpl * m_listenerImpl;
00175 WPXPropertyList m_metaData;
00176 std::vector <WPXPageSpan *> *m_pageList;
00177
00178 protected:
00179 virtual void _handleSubDocument(uint16_t textPID, const bool isHeaderFooter, WPXTableList tableList, int nextTableIndice) = 0;
00180 virtual void _flushText() = 0;
00181 virtual void _changeList() = 0;
00182
00183 void _openSection();
00184 void _closeSection();
00185
00186 void _openPageSpan();
00187 void _closePageSpan();
00188
00189 void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false);
00190 void _getTabStops(WPXPropertyListVector &tabStops);
00191 void _appendJustification(WPXPropertyList &propList, int justification);
00192 virtual void _openParagraph();
00193 virtual void _resetParagraphState(const bool isListElement=false);
00194 void _closeParagraph();
00195
00196 void _openListElement();
00197 void _closeListElement();
00198
00199 void _openSpan();
00200 void _closeSpan();
00201
00202 void _openTable();
00203 void _closeTable();
00204 void _openTableRow(const float height, const bool isMinimumHeight, const bool isHeaderRow);
00205 void _closeTableRow();
00206 void _openTableCell(const uint8_t colSpan, const uint8_t rowSpan, const bool boundFromLeft, const bool boundFromAbove,
00207 const uint8_t borderBits, const RGBSColor * cellFgColor, const RGBSColor * cellBgColor,
00208 const RGBSColor * cellBorderColor,
00209 const WPXVerticalAlignment cellVerticalAlignment);
00210 void _closeTableCell();
00211
00212 bool isUndoOn() { return m_isUndoOn; }
00213 bool m_isUndoOn;
00214
00215 private:
00216 WPXString _colorToString(const RGBSColor * color);
00217 WPXString _mergeColorsToString(const RGBSColor *fgColor, const RGBSColor *bgColor);
00218 };
00219
00220 #endif