WP1ContentListener.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwpd
00003  * Copyright (C) 2003 William Lachance (wrlach@gmail.com)
00004  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
00005  * Copyright (C) 2005-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00020  *
00021  * For further information visit http://libwpd.sourceforge.net
00022  */
00023 
00024 /* "This product is not manufactured, approved, or supported by
00025  * Corel Corporation or Corel Corporation Limited."
00026  */
00027 
00028 #ifndef WP1CONTENTLISTENER_H
00029 #define WP1CONTENTLISTENER_H
00030 
00031 #include "WP1Listener.h"
00032 #include "WPXContentListener.h"
00033 
00034 class WP1SubDocument;
00035 
00036 typedef struct _WP1ContentParsingState WP1ContentParsingState;
00037 struct _WP1ContentParsingState
00038 {
00039         _WP1ContentParsingState();
00040         ~_WP1ContentParsingState();
00041         WPXString m_textBuffer;
00042         int m_numDeferredTabs;
00043         int m_footNoteNumber, m_endNoteNumber;
00044 private:
00045         _WP1ContentParsingState(const _WP1ContentParsingState &);
00046         _WP1ContentParsingState &operator=(const _WP1ContentParsingState &);
00047 };
00048 
00049 class WP1ContentListener : public WP1Listener, protected WPXContentListener
00050 {
00051 public:
00052         WP1ContentListener(std::list<WPXPageSpan> &pageList, std::vector<WP1SubDocument *> &subDocuments, WPXDocumentInterface *documentInterface);
00053         ~WP1ContentListener();
00054 
00055         void startDocument()
00056         {
00057                 WPXContentListener::startDocument();
00058         }
00059         void startSubDocument()
00060         {
00061                 WPXContentListener::startSubDocument();
00062         }
00063         void insertCharacter(uint32_t character);
00064         void insertExtendedCharacter(uint8_t extendedCharacter);
00065         void insertTab();
00066         void insertBreak(uint8_t breakType)
00067         {
00068                 WPXContentListener::insertBreak(breakType);
00069         }
00070         void insertEOL();
00071         void insertNote(WPXNoteType noteType, WP1SubDocument *subDocument);
00072         void attributeChange(bool isOn, uint8_t attribute);
00073         void fontPointSize(uint8_t pointSize);
00074         void fontId(uint16_t id);
00075         void marginReset(uint16_t leftMargin, uint16_t rightMargin);
00076         void topMarginSet(uint16_t /* topMargin */) {}
00077         void bottomMarginSet(uint16_t /* bottomMargin */) {}
00078         void leftIndent(uint16_t leftMarginOffset);
00079         void leftRightIndent(uint16_t leftRightMarginOffset);
00080         void leftMarginRelease(uint16_t release);
00081         void setTabs(const std::vector<WPXTabStop> &tabStops);
00082         void headerFooterGroup(uint8_t headerFooterDefinition, WP1SubDocument *subDocument);
00083         void suppressPageCharacteristics(uint8_t /* suppressCode */) {}
00084         void justificationChange(uint8_t justification);
00085         void lineSpacingChange(uint8_t spacing)
00086         {
00087                 WPXContentListener::lineSpacingChange((double)((double)spacing/2.0));
00088         }
00089         void flushRightOn();
00090         void flushRightOff() {}
00091         void centerOn();
00092         void centerOff() {}
00093         void endDocument()
00094         {
00095                 WPXContentListener::endDocument();
00096         };
00097         void endSubDocument()
00098         {
00099                 WPXContentListener::endSubDocument();
00100         };
00101         void insertPicture(uint16_t width, uint16_t height, const WPXBinaryData &binaryData);
00102 
00103 protected:
00104         using WPXContentListener::lineSpacingChange;
00105         void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, int nextTableIndice = 0);
00106 
00107         void _flushText();
00108         void _changeList() {};
00109 
00110 private:
00111         WP1ContentParsingState *m_parseState;
00112         std::vector<WP1SubDocument *> &m_subDocuments;
00113         WP1ContentListener(const WP1ContentListener &);
00114         WP1ContentListener &operator=(WP1ContentListener &);
00115 };
00116 
00117 #endif /* WP1LISTENER_H */
00118 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */