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 "WPSContentListener.h" 00033 #include <libwpd/WPXPropertyListVector.h> 00034 #include <libwpd/WPXHLListenerImpl.h> 00035 #include <list> 00036 00037 typedef struct _WPSContentParsingState WPSContentParsingState; 00038 struct _WPSContentParsingState 00039 { 00040 _WPSContentParsingState(); 00041 ~_WPSContentParsingState(); 00042 00043 uint32_t m_textAttributeBits; 00044 float m_fontSize; 00045 WPXString m_fontName; 00046 00047 bool m_isParagraphColumnBreak; 00048 bool m_isParagraphPageBreak; 00049 uint8_t m_paragraphJustification; 00050 float m_paragraphLineSpacing; 00051 00052 bool m_isDocumentStarted; 00053 bool m_isPageSpanOpened; 00054 bool m_isSectionOpened; 00055 bool m_isPageSpanBreakDeferred; 00056 00057 bool m_isSpanOpened; 00058 bool m_isParagraphOpened; 00059 00060 std::list<WPSPageSpan>::iterator m_nextPageSpanIter; 00061 int m_numPagesRemainingInSpan; 00062 00063 bool m_sectionAttributesChanged; 00064 00065 float m_pageFormLength; 00066 float m_pageFormWidth; 00067 WPSFormOrientation m_pageFormOrientation; 00068 00069 float m_pageMarginLeft; 00070 float m_pageMarginRight; 00071 float m_paragraphMarginLeft; 00072 float m_paragraphMarginRight; 00073 float m_paragraphMarginTop; 00074 float m_paragraphMarginBottom; 00075 00076 WPXString m_textBuffer; 00077 private: 00078 _WPSContentParsingState(const _WPSContentParsingState&); 00079 _WPSContentParsingState& operator=(const _WPSContentParsingState&); 00080 }; 00081 00082 class WPSContentListener 00083 { 00084 public: 00085 WPSContentListener(std::list<WPSPageSpan> &pageList, WPXHLListenerImpl *listenerImpl); 00086 virtual ~WPSContentListener(); 00087 00088 void startDocument(); 00089 void endDocument(); 00090 void insertBreak(const uint8_t breakType); 00091 00092 void setTextFont(const WPXString fontName); 00093 void setFontSize(const uint16_t fontSize); 00094 00095 void insertCharacter(const uint16_t character); 00096 void insertEOL(); 00097 00098 protected: 00099 WPSContentParsingState *m_ps; // parse state 00100 WPXHLListenerImpl * m_listenerImpl; 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 private: 00118 WPSContentListener(const WPSContentListener&); 00119 WPSContentListener& operator=(const WPSContentListener&); 00120 00121 std::list<WPSPageSpan> &m_pageList; 00122 }; 00123 00124 #endif /* WPSCONTENTLISTENER_H */