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 "libwpd_internal.h"
00035 #include <vector>
00036 
00037 typedef struct _WP5ContentParsingState WP5ContentParsingState;
00038 struct _WP5ContentParsingState
00039 {
00040         _WP5ContentParsingState();
00041         ~_WP5ContentParsingState();
00042         WPXString m_textBuffer;
00043         WPXString m_noteReference;
00044 
00045         WPXTableList m_tableList;
00046 
00047         bool m_isFrameOpened;
00048 };
00049 
00050 class WP5ContentListener : public WP5Listener, protected WPXContentListener
00051 {
00052 public:
00053         WP5ContentListener(std::list<WPXPageSpan> &pageList, std::vector<WP5SubDocument *> &subDocuments, WPXDocumentInterface *documentInterface);
00054         ~WP5ContentListener();
00055 
00056         void startDocument()
00057         {
00058                 WPXContentListener::startDocument();
00059         }
00060         void startSubDocument()
00061         {
00062                 WPXContentListener::startSubDocument();
00063         }
00064         void setFont(const WPXString &fontName, double fontSize);
00065         void setTabs(const std::vector<WPXTabStop> &tabStops, uint16_t tabOffset);
00066         void insertCharacter(uint32_t character);
00067         void insertTab(uint8_t tabType, double tabPosition);
00068         void insertIndent(uint8_t indentType, double indentPosition);
00069         void insertEOL();
00070         void insertBreak(uint8_t breakType)
00071         {
00072                 WPXContentListener::insertBreak(breakType);
00073         }
00074         void lineSpacingChange(double lineSpacing)
00075         {
00076                 WPXContentListener::lineSpacingChange(lineSpacing);
00077         }
00078         void justificationChange(uint8_t justification)
00079         {
00080                 WPXContentListener::justificationChange(justification);
00081         }
00082         void characterColorChange(uint8_t red, uint8_t green, uint8_t blue);
00083         void attributeChange(bool isOn, uint8_t attribute);
00084         void pageMarginChange(uint8_t /* side */, uint16_t /* margin */) {}
00085         void pageFormChange(uint16_t /* length */, uint16_t /* width */, WPXFormOrientation /* orientation */) {}
00086         void marginChange(uint8_t side, uint16_t margin);
00087         void paragraphMarginChange(uint8_t /* side */, int16_t /* margin */) {}
00088         void endDocument()
00089         {
00090                 WPXContentListener::endDocument();
00091         }
00092         void endSubDocument()
00093         {
00094                 WPXContentListener::endSubDocument();
00095         }
00096 
00097         void defineTable(uint8_t position, uint16_t leftOffset);
00098         void addTableColumnDefinition(uint32_t width, uint32_t leftGutter, uint32_t rightGutter,
00099                                       uint32_t attributes, uint8_t alignment);
00100         void startTable();
00101         void insertRow(uint16_t rowHeight, bool isMinimumHeight, bool isHeaderRow);
00102         void insertCell(uint8_t colSpan, uint8_t rowSpan, uint8_t borderBits,
00103                         const RGBSColor *cellFgColor, const RGBSColor *cellBgColor,
00104                         const RGBSColor *cellBorderColor, WPXVerticalAlignment cellVerticalAlignment,
00105                         bool useCellAttributes, uint32_t cellAttributes);
00106         void endTable();
00107 
00108         void insertNoteReference(const WPXString &noteReference);
00109         void insertNote(WPXNoteType noteType, const WP5SubDocument *subDocument);
00110         void headerFooterGroup(uint8_t headerFooterType, uint8_t occurenceBits, WP5SubDocument *subDocument);
00111         void suppressPageCharacteristics(uint8_t /* suppressCode */) {}
00112 
00113         void setDefaultFont(const WPXString &fontName, double fontSize);
00114 
00115         void boxOn(uint8_t positionAndType, uint8_t alignment, uint16_t width, uint16_t height, uint16_t x, uint16_t y);
00116         virtual void boxOff();
00117         virtual void insertGraphicsData(const WPXBinaryData *data);
00118 
00119 protected:
00120         void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice = 0);
00121 
00122         void _flushText();
00123         void _changeList() {}
00124 
00125 private:
00126         WP5ContentListener(const WP5ContentListener &);
00127         WP5ContentListener &operator=(const WP5ContentListener &);
00128         WP5ContentParsingState *m_parseState;
00129         std::vector<WP5SubDocument *> &m_subDocuments;
00130         double m_defaultFontSize;
00131         WPXString m_defaultFontName;
00132 };
00133 
00134 #endif /* WP5CONTENTLISTENER_H */
00135 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */