WP5ContentListener.h

Go to the documentation of this file.
00001 /* libwpd
00002  * Copyright (C) 2003 William Lachance (wrlach@gmail.com)
00003  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
00004  * Copyright (C) 2005-2007 Fridrich Strba (fridrich.strba@bluewin.ch)
00005  * Copyright (C) 2007 Novell, Inc. (http://www.novell.com)
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 WP5CONTENTLISTENER_H
00029 #define WP5CONTENTLISTENER_H
00030 
00031 #include "WP5Listener.h"
00032 #include "WPXContentListener.h"
00033 #include "WP5SubDocument.h"
00034 #include "WPXString.h"
00035 #include "libwpd_internal.h"
00036 #include "WPXDocumentInterface.h"
00037 #include <vector>
00038 
00039 typedef struct _WP5ContentParsingState WP5ContentParsingState;
00040 struct _WP5ContentParsingState
00041 {
00042         _WP5ContentParsingState();
00043         ~_WP5ContentParsingState();
00044         WPXString m_textBuffer;
00045         WPXString m_noteReference;
00046 
00047         WPXTableList m_tableList;
00048 
00049         bool m_isFrameOpened;
00050 };
00051 
00052 class WP5ContentListener : public WP5Listener, protected WPXContentListener
00053 {
00054 public:
00055         WP5ContentListener(std::list<WPXPageSpan> &pageList, std::vector<WP5SubDocument *> &subDocuments, WPXDocumentInterface *documentInterface);
00056         ~WP5ContentListener();
00057 
00058         void startDocument() { WPXContentListener::startDocument(); };
00059         void startSubDocument() { WPXContentListener::startSubDocument(); };
00060         void setFont(const WPXString &fontName, double fontSize);
00061         void setTabs(const std::vector<WPXTabStop> &tabStops, uint16_t tabOffset);
00062         void insertCharacter(uint32_t character);
00063         void insertTab(uint8_t tabType, double tabPosition);
00064         void insertIndent(uint8_t indentType, double indentPosition);
00065         void insertEOL();
00066         void insertBreak(uint8_t breakType) { WPXContentListener::insertBreak(breakType); };
00067         void lineSpacingChange(double lineSpacing) { WPXContentListener::lineSpacingChange(lineSpacing); };
00068         void justificationChange(uint8_t justification) { WPXContentListener::justificationChange(justification); };
00069         void characterColorChange(uint8_t red, uint8_t green, uint8_t blue);
00070         void attributeChange(bool isOn, uint8_t attribute);
00071         void pageMarginChange(uint8_t /* side */, uint16_t /* margin */) {};
00072         void pageFormChange(uint16_t /* length */, uint16_t /* width */, WPXFormOrientation /* orientation */) {};
00073         void marginChange(uint8_t side, uint16_t margin);
00074         void paragraphMarginChange(uint8_t /* side */, int16_t /* margin */) {};
00075         void endDocument() { WPXContentListener::endDocument(); };
00076         void endSubDocument() { WPXContentListener::endSubDocument(); };
00077 
00078         void defineTable(uint8_t position, uint16_t leftOffset);
00079         void addTableColumnDefinition(uint32_t width, uint32_t leftGutter, uint32_t rightGutter,
00080                                 uint32_t attributes, uint8_t alignment);
00081         void startTable();
00082         void insertRow(uint16_t rowHeight, bool isMinimumHeight, bool isHeaderRow);
00083         void insertCell(uint8_t colSpan, uint8_t rowSpan, uint8_t borderBits,
00084                                 const RGBSColor * cellFgColor, const RGBSColor * cellBgColor, 
00085                                 const RGBSColor * cellBorderColor, WPXVerticalAlignment cellVerticalAlignment, 
00086                                 bool useCellAttributes, uint32_t cellAttributes);
00087         void endTable();
00088 
00089         void insertNoteReference(const WPXString &noteReference);
00090         void insertNote(WPXNoteType noteType, const WP5SubDocument *subDocument);
00091         void headerFooterGroup(uint8_t headerFooterType, uint8_t occurenceBits, WP5SubDocument *subDocument);
00092         void suppressPageCharacteristics(uint8_t /* suppressCode */) {};
00093         
00094         void setDefaultFont(const WPXString &fontName, double fontSize);
00095         
00096         void boxOn(uint8_t positionAndType, uint8_t alignment, uint16_t width, uint16_t height, uint16_t x, uint16_t y);
00097         virtual void boxOff();
00098         virtual void insertGraphicsData(const WPXBinaryData *data);
00099 
00100 protected:
00101         void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, int nextTableIndice = 0);
00102 
00103         void _flushText();
00104         void _changeList() {};
00105 
00106 private:
00107         WP5ContentListener(const WP5ContentListener&);
00108         WP5ContentListener& operator=(const WP5ContentListener&);
00109         WP5ContentParsingState *m_parseState;
00110         std::vector<WP5SubDocument *> &m_subDocuments;
00111         double m_defaultFontSize;
00112         WPXString m_defaultFontName;
00113 };
00114 
00115 #endif /* WP5CONTENTLISTENER_H */