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