WP5ContentListener.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-2007 Fridrich Strba (fridrich.strba@bluewin.ch)
00006  * Copyright (C) 2007 Novell, Inc. (http://www.novell.com)
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Library General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Library General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Library General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00021  *
00022  * For further information visit http://libwpd.sourceforge.net
00023  */
00024 
00025 /* "This product is not manufactured, approved, or supported by
00026  * Corel Corporation or Corel Corporation Limited."
00027  */
00028 
00029 #ifndef WP5CONTENTLISTENER_H
00030 #define WP5CONTENTLISTENER_H
00031 
00032 #include "WP5Listener.h"
00033 #include "WPXContentListener.h"
00034 #include "WP5SubDocument.h"
00035 #include "WPXString.h"
00036 #include "libwpd_internal.h"
00037 #include "WPXDocumentInterface.h"
00038 #include <vector>
00039 
00040 typedef struct _WP5ContentParsingState WP5ContentParsingState;
00041 struct _WP5ContentParsingState
00042 {
00043         _WP5ContentParsingState();
00044         ~_WP5ContentParsingState();
00045         WPXString m_textBuffer;
00046         WPXString m_noteReference;
00047 
00048         WPXTableList m_tableList;
00049 
00050         bool m_isFrameOpened;
00051 };
00052 
00053 class WP5ContentListener : public WP5Listener, protected WPXContentListener
00054 {
00055 public:
00056         WP5ContentListener(std::list<WPXPageSpan> &pageList, std::vector<WP5SubDocument *> &subDocuments, WPXDocumentInterface *documentInterface);
00057         ~WP5ContentListener();
00058 
00059         void startDocument()
00060         {
00061                 WPXContentListener::startDocument();
00062         };
00063         void startSubDocument()
00064         {
00065                 WPXContentListener::startSubDocument();
00066         };
00067         void setFont(const WPXString &fontName, double fontSize);
00068         void setTabs(const std::vector<WPXTabStop> &tabStops, uint16_t tabOffset);
00069         void insertCharacter(uint32_t character);
00070         void insertTab(uint8_t tabType, double tabPosition);
00071         void insertIndent(uint8_t indentType, double indentPosition);
00072         void insertEOL();
00073         void insertBreak(uint8_t breakType)
00074         {
00075                 WPXContentListener::insertBreak(breakType);
00076         };
00077         void lineSpacingChange(double lineSpacing)
00078         {
00079                 WPXContentListener::lineSpacingChange(lineSpacing);
00080         };
00081         void justificationChange(uint8_t justification)
00082         {
00083                 WPXContentListener::justificationChange(justification);
00084         };
00085         void characterColorChange(uint8_t red, uint8_t green, uint8_t blue);
00086         void attributeChange(bool isOn, uint8_t attribute);
00087         void pageMarginChange(uint8_t /* side */, uint16_t /* margin */) {};
00088         void pageFormChange(uint16_t /* length */, uint16_t /* width */, WPXFormOrientation /* orientation */) {};
00089         void marginChange(uint8_t side, uint16_t margin);
00090         void paragraphMarginChange(uint8_t /* side */, int16_t /* margin */) {};
00091         void endDocument()
00092         {
00093                 WPXContentListener::endDocument();
00094         };
00095         void endSubDocument()
00096         {
00097                 WPXContentListener::endSubDocument();
00098         };
00099 
00100         void defineTable(uint8_t position, uint16_t leftOffset);
00101         void addTableColumnDefinition(uint32_t width, uint32_t leftGutter, uint32_t rightGutter,
00102                                       uint32_t attributes, uint8_t alignment);
00103         void startTable();
00104         void insertRow(uint16_t rowHeight, bool isMinimumHeight, bool isHeaderRow);
00105         void insertCell(uint8_t colSpan, uint8_t rowSpan, uint8_t borderBits,
00106                         const RGBSColor *cellFgColor, const RGBSColor *cellBgColor,
00107                         const RGBSColor *cellBorderColor, WPXVerticalAlignment cellVerticalAlignment,
00108                         bool useCellAttributes, uint32_t cellAttributes);
00109         void endTable();
00110 
00111         void insertNoteReference(const WPXString &noteReference);
00112         void insertNote(WPXNoteType noteType, const WP5SubDocument *subDocument);
00113         void headerFooterGroup(uint8_t headerFooterType, uint8_t occurenceBits, WP5SubDocument *subDocument);
00114         void suppressPageCharacteristics(uint8_t /* suppressCode */) {};
00115 
00116         void setDefaultFont(const WPXString &fontName, double fontSize);
00117 
00118         void boxOn(uint8_t positionAndType, uint8_t alignment, uint16_t width, uint16_t height, uint16_t x, uint16_t y);
00119         virtual void boxOff();
00120         virtual void insertGraphicsData(const WPXBinaryData *data);
00121 
00122 protected:
00123         void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, int nextTableIndice = 0);
00124 
00125         void _flushText();
00126         void _changeList() {};
00127 
00128 private:
00129         WP5ContentListener(const WP5ContentListener &);
00130         WP5ContentListener &operator=(const WP5ContentListener &);
00131         WP5ContentParsingState *m_parseState;
00132         std::vector<WP5SubDocument *> &m_subDocuments;
00133         double m_defaultFontSize;
00134         WPXString m_defaultFontName;
00135 };
00136 
00137 #endif /* WP5CONTENTLISTENER_H */
00138 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */