00001 /* libwps 00002 * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch) 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 00017 * 00018 * For further information visit http://libwps.sourceforge.net 00019 */ 00020 00021 /* 00022 * This file is in sync with CVS 00023 * /libwpd2/src/lib/WPXContentListener.h 1.9 00024 */ 00025 00026 00027 #ifndef WPSCONTENTLISTENER_H 00028 #define WPSCONTENTLISTENER_H 00029 00030 #include "libwps_internal.h" 00031 #include "WPSPageSpan.h" 00032 #include <libwpd/WPXPropertyListVector.h> 00033 #include <libwpd/WPXDocumentInterface.h> 00034 #include <list> 00035 00036 typedef struct _WPSContentParsingState WPSContentParsingState; 00037 struct _WPSContentParsingState 00038 { 00039 _WPSContentParsingState(); 00040 ~_WPSContentParsingState(); 00041 00042 uint32_t m_textAttributeBits; 00043 float m_fontSize; 00044 WPXString m_fontName; 00045 00046 bool m_isParagraphColumnBreak; 00047 bool m_isParagraphPageBreak; 00048 uint8_t m_paragraphJustification; 00049 float m_paragraphLineSpacing; 00050 00051 bool m_isDocumentStarted; 00052 bool m_isPageSpanOpened; 00053 bool m_isSectionOpened; 00054 bool m_isPageSpanBreakDeferred; 00055 00056 bool m_isSpanOpened; 00057 bool m_isParagraphOpened; 00058 00059 std::list<WPSPageSpan>::iterator m_nextPageSpanIter; 00060 int m_numPagesRemainingInSpan; 00061 00062 bool m_sectionAttributesChanged; 00063 00064 float m_pageFormLength; 00065 float m_pageFormWidth; 00066 WPSFormOrientation m_pageFormOrientation; 00067 00068 float m_pageMarginLeft; 00069 float m_pageMarginRight; 00070 float m_paragraphMarginLeft; 00071 float m_paragraphMarginRight; 00072 float m_paragraphMarginTop; 00073 float m_paragraphMarginBottom; 00074 00075 WPXString m_textBuffer; 00076 00077 private: 00078 _WPSContentParsingState(const _WPSContentParsingState&); 00079 _WPSContentParsingState& operator=(const _WPSContentParsingState&); 00080 }; 00081 00082 class WPSContentListener 00083 { 00084 public: 00085 void startDocument(); 00086 void endDocument(); 00087 void insertBreak(const uint8_t breakType); 00088 void insertCharacter(const uint16_t character); 00089 00090 void setTextFont(const WPXString fontName); 00091 void setFontSize(const uint16_t fontSize); 00092 00093 void insertEOL(); 00094 00095 protected: 00096 WPSContentListener(std::list<WPSPageSpan> &pageList, WPXDocumentInterface *documentInterface); 00097 virtual ~WPSContentListener(); 00098 00099 WPSContentParsingState *m_ps; // parse state 00100 WPXDocumentInterface * m_documentInterface; 00101 WPXPropertyList m_metaData; 00102 00103 void _flushText(); 00104 00105 void _openSection(); 00106 void _closeSection(); 00107 00108 void _openPageSpan(); 00109 void _closePageSpan(); 00110 00111 void _openParagraph(); 00112 void _closeParagraph(); 00113 00114 void _openSpan(); 00115 void _closeSpan(); 00116 00117 void _insertText(const WPXString &textBuffer); 00118 00119 private: 00120 WPSContentListener(const WPSContentListener&); 00121 WPSContentListener& operator=(const WPSContentListener&); 00122 00123 std::list<WPSPageSpan> &m_pageList; 00124 }; 00125 00126 #endif /* WPSCONTENTLISTENER_H */