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