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  * Version: MPL 2.0 / LGPLv2.1+
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Major Contributor(s):
00010  * Copyright (C) 2003 William Lachance (wrlach@gmail.com)
00011  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
00012  * Copyright (C) 2005-2007 Fridrich Strba (fridrich.strba@bluewin.ch)
00013  *
00014  * For minor contributions see the git repository.
00015  *
00016  * Alternatively, the contents of this file may be used under the terms
00017  * of the GNU Lesser General Public License Version 2.1 or later
00018  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00019  * applicable instead of those above.
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()
00059         {
00060                 WPXContentListener::startDocument();
00061         }
00062         void startSubDocument()
00063         {
00064                 WPXContentListener::startSubDocument();
00065         }
00066         void setFont(const WPXString &fontName, double fontSize);
00067         void setTabs(const std::vector<WPXTabStop> &tabStops, uint16_t tabOffset);
00068         void insertCharacter(uint32_t character);
00069         void insertTab(uint8_t tabType, double tabPosition);
00070         void insertIndent(uint8_t indentType, double indentPosition);
00071         void insertEOL();
00072         void insertBreak(uint8_t breakType)
00073         {
00074                 WPXContentListener::insertBreak(breakType);
00075         }
00076         void lineSpacingChange(double lineSpacing)
00077         {
00078                 WPXContentListener::lineSpacingChange(lineSpacing);
00079         }
00080         void justificationChange(uint8_t justification)
00081         {
00082                 WPXContentListener::justificationChange(justification);
00083         }
00084         void characterColorChange(uint8_t red, uint8_t green, uint8_t blue);
00085         void attributeChange(bool isOn, uint8_t attribute);
00086         void pageMarginChange(uint8_t /* side */, uint16_t /* margin */) {}
00087         void pageFormChange(uint16_t /* length */, uint16_t /* width */, WPXFormOrientation /* orientation */) {}
00088         void marginChange(uint8_t side, uint16_t margin);
00089         void paragraphMarginChange(uint8_t /* side */, int16_t /* margin */) {}
00090         void endDocument()
00091         {
00092                 WPXContentListener::endDocument();
00093         }
00094         void endSubDocument()
00095         {
00096                 WPXContentListener::endSubDocument();
00097         }
00098 
00099         void defineTable(uint8_t position, uint16_t leftOffset);
00100         void addTableColumnDefinition(uint32_t width, uint32_t leftGutter, uint32_t rightGutter,
00101                                       uint32_t attributes, uint8_t alignment);
00102         void startTable();
00103         void insertRow(uint16_t rowHeight, bool isMinimumHeight, bool isHeaderRow);
00104         void insertCell(uint8_t colSpan, uint8_t rowSpan, uint8_t borderBits,
00105                         const RGBSColor *cellFgColor, const RGBSColor *cellBgColor,
00106                         const RGBSColor *cellBorderColor, WPXVerticalAlignment cellVerticalAlignment,
00107                         bool useCellAttributes, uint32_t cellAttributes);
00108         void endTable();
00109 
00110         void insertNoteReference(const WPXString &noteReference);
00111         void insertNote(WPXNoteType noteType, const WP5SubDocument *subDocument);
00112         void headerFooterGroup(uint8_t headerFooterType, uint8_t occurenceBits, WP5SubDocument *subDocument);
00113         void suppressPageCharacteristics(uint8_t /* suppressCode */) {}
00114 
00115         void setDefaultFont(const WPXString &fontName, double fontSize);
00116 
00117         void boxOn(uint8_t positionAndType, uint8_t alignment, uint16_t width, uint16_t height, uint16_t x, uint16_t y);
00118         virtual void boxOff();
00119         virtual void insertGraphicsData(const WPXBinaryData *data);
00120 
00121 protected:
00122         void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice = 0);
00123 
00124         void _flushText();
00125         void _changeList() {}
00126 
00127 private:
00128         WP5ContentListener(const WP5ContentListener &);
00129         WP5ContentListener &operator=(const WP5ContentListener &);
00130         WP5ContentParsingState *m_parseState;
00131         std::vector<WP5SubDocument *> &m_subDocuments;
00132         double m_defaultFontSize;
00133         WPXString m_defaultFontName;
00134 };
00135 
00136 #endif /* WP5CONTENTLISTENER_H */
00137 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */