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