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         librevenge::RVNGString m_textBuffer;
00043         librevenge::RVNGString 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, librevenge::RVNGTextInterface *documentInterface);
00054         ~WP5ContentListener();
00055 
00056         void startDocument()
00057         {
00058                 WPXContentListener::startDocument();
00059         }
00060         void startSubDocument()
00061         {
00062                 WPXContentListener::startSubDocument();
00063         }
00064         void setFont(const librevenge::RVNGString &fontName, double fontSize);
00065         void setTabs(const std::vector<WPXTabStop> &tabStops, unsigned short tabOffset);
00066         void insertCharacter(unsigned character);
00067         void insertTab(unsigned char tabType, double tabPosition);
00068         void insertIndent(unsigned char indentType, double indentPosition);
00069         void insertEOL();
00070         void insertBreak(unsigned char breakType)
00071         {
00072                 WPXContentListener::insertBreak(breakType);
00073         }
00074         void lineSpacingChange(double lineSpacing)
00075         {
00076                 WPXContentListener::lineSpacingChange(lineSpacing);
00077         }
00078         void justificationChange(unsigned char justification)
00079         {
00080                 WPXContentListener::justificationChange(justification);
00081         }
00082         void characterColorChange(unsigned char red, unsigned char green, unsigned char blue);
00083         void attributeChange(bool isOn, unsigned char attribute);
00084         void pageMarginChange(unsigned char /* side */, unsigned short /* margin */) {}
00085         void pageFormChange(unsigned short /* length */, unsigned short /* width */, WPXFormOrientation /* orientation */) {}
00086         void marginChange(unsigned char side, unsigned short margin);
00087         void paragraphMarginChange(unsigned char /* side */, signed short /* margin */) {}
00088         void endDocument()
00089         {
00090                 WPXContentListener::endDocument();
00091         }
00092         void endSubDocument()
00093         {
00094                 WPXContentListener::endSubDocument();
00095         }
00096 
00097         void defineTable(unsigned char position, unsigned short leftOffset);
00098         void addTableColumnDefinition(unsigned width, unsigned leftGutter, unsigned rightGutter,
00099                                       unsigned attributes, unsigned char alignment);
00100         void startTable();
00101         void insertRow(unsigned short rowHeight, bool isMinimumHeight, bool isHeaderRow);
00102         void insertCell(unsigned char colSpan, unsigned char rowSpan, unsigned char borderBits,
00103                         const RGBSColor *cellFgColor, const RGBSColor *cellBgColor,
00104                         const RGBSColor *cellBorderColor, WPXVerticalAlignment cellVerticalAlignment,
00105                         bool useCellAttributes, unsigned cellAttributes);
00106         void endTable();
00107 
00108         void insertNoteReference(const librevenge::RVNGString &noteReference);
00109         void insertNote(WPXNoteType noteType, const WP5SubDocument *subDocument);
00110         void headerFooterGroup(unsigned char headerFooterType, unsigned char occurrenceBits, WP5SubDocument *subDocument);
00111         void suppressPageCharacteristics(unsigned char /* suppressCode */) {}
00112 
00113         void setDefaultFont(const librevenge::RVNGString &fontName, double fontSize);
00114 
00115         void boxOn(unsigned char positionAndType, unsigned char alignment, unsigned short width, unsigned short height, unsigned short x, unsigned short y);
00116         virtual void boxOff();
00117         virtual void insertGraphicsData(const librevenge::RVNGBinaryData *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         librevenge::RVNGString m_defaultFontName;
00132 };
00133 
00134 #endif /* WP5CONTENTLISTENER_H */
00135 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */