WP3ContentListener.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) 2004 Marc Maurer (uwog@uwog.net)
00011  * Copyright (C) 2005-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00012  *
00013  * For minor contributions see the git repository.
00014  *
00015  * Alternatively, the contents of this file may be used under the terms
00016  * of the GNU Lesser General Public License Version 2.1 or later
00017  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00018  * applicable instead of those above.
00019  *
00020  * For further information visit http://libwpd.sourceforge.net
00021  */
00022 
00023 /* "This product is not manufactured, approved, or supported by
00024  * Corel Corporation or Corel Corporation Limited."
00025  */
00026 
00027 #ifndef WP3CONTENTLISTENER_H
00028 #define WP3CONTENTLISTENER_H
00029 
00030 #include "WP3Listener.h"
00031 #include "WPXContentListener.h"
00032 #include "WP3SubDocument.h"
00033 
00034 typedef struct _WP3ContentParsingState WP3ContentParsingState;
00035 struct _WP3ContentParsingState
00036 {
00037         _WP3ContentParsingState();
00038         ~_WP3ContentParsingState();
00039         unsigned short m_colSpan;
00040         unsigned short m_rowSpan;
00041         librevenge::RVNGString m_textBuffer;
00042         RGBSColor *m_cellFillColor;
00043         librevenge::RVNGString m_noteReference;
00044 
00045         WPXTableList m_tableList;
00046 private:
00047         _WP3ContentParsingState(const _WP3ContentParsingState &);
00048         _WP3ContentParsingState &operator=(const _WP3ContentParsingState &);
00049 };
00050 
00051 class WP3ContentListener : public WP3Listener, protected WPXContentListener
00052 {
00053 public:
00054         WP3ContentListener(std::list<WPXPageSpan> &pageList, std::vector<WP3SubDocument *> &subDocuments, librevenge::RVNGTextInterface *documentInterface);
00055         ~WP3ContentListener();
00056 
00057         void startDocument()
00058         {
00059                 WPXContentListener::startDocument();
00060         }
00061         void startSubDocument()
00062         {
00063                 WPXContentListener::startSubDocument();
00064         }
00065         void insertCharacter(unsigned character);
00066         void insertTab();
00067         void insertTab(unsigned char tabType, double tabPosition);
00068         void insertBreak(unsigned char breakType)
00069         {
00070                 WPXContentListener::insertBreak(breakType);
00071         }
00072         void insertEOL();
00073         void attributeChange(bool isOn, unsigned char attribute);
00074         void lineSpacingChange(double lineSpacing)
00075         {
00076                 WPXContentListener::lineSpacingChange(lineSpacing);
00077         }
00078         void pageMarginChange(unsigned char /* side */, unsigned short /* margin */) {}
00079         void pageFormChange(unsigned short /* length */, unsigned short /* width */, WPXFormOrientation /* orientation */) {}
00080         void marginChange(unsigned char side, unsigned short margin);
00081         void indentFirstLineChange(double offset);
00082         void setTabs(bool isRelative, const std::vector<WPXTabStop> tabStops);
00083         void columnChange(WPXTextColumnType columnType, unsigned char numColumns, const std::vector<double> &columnWidth,
00084                           const std::vector<bool> &isFixedWidth);
00085         void endDocument()
00086         {
00087                 WPXContentListener::endDocument();
00088         }
00089         void endSubDocument()
00090         {
00091                 WPXContentListener::endSubDocument();
00092         }
00093 
00094         void defineTable(unsigned char position, unsigned short leftOffset);
00095         void addTableColumnDefinition(unsigned width, unsigned leftGutter, unsigned rightGutter,
00096                                       unsigned attributes, unsigned char alignment);
00097         void startTable();
00098         void insertRow();
00099         void insertCell();
00100         void closeCell();
00101         void closeRow();
00102         void setTableCellSpan(unsigned short colSpan, unsigned short rowSpan);
00103         void setTableCellFillColor(const RGBSColor *cellFillColor);
00104         void endTable();
00105         void undoChange(unsigned char undoType, unsigned short undoLevel);
00106         void justificationChange(unsigned char justification);
00107         void setTextColor(const RGBSColor *fontColor);
00108         void setTextFont(const librevenge::RVNGString &fontName);
00109         void setFontSize(unsigned short fontSize);
00110         void insertPageNumber(const librevenge::RVNGString &pageNumber);
00111         void insertNoteReference(const librevenge::RVNGString &noteReference);
00112         void insertNote(WPXNoteType noteType, const WP3SubDocument *subDocument);
00113         void headerFooterGroup(unsigned char headerFooterType, unsigned char occurrenceBits, WP3SubDocument *subDocument);
00114         void suppressPage(unsigned short /* suppressCode */) {}
00115         void backTab();
00116         void leftIndent();
00117         void leftIndent(double offset);
00118         void leftRightIndent();
00119         void leftRightIndent(double offset);
00120         void insertPicture(double height, double width, double verticalOffset, double horizontalOffset, unsigned char leftColumn, unsigned char rightColumn,
00121                            unsigned short figureFlags, const librevenge::RVNGBinaryData &binaryData);
00122         void insertTextBox(double height, double width, double verticalOffset, double horizontalOffset, unsigned char leftColumn, unsigned char rightColumn,
00123                            unsigned short figureFlags, const WP3SubDocument *subDocument, const WP3SubDocument *caption);
00124         void insertWP51Table(double height, double width, double verticalOffset, double horizontalOffset, unsigned char leftColumn, unsigned char rightColumn,
00125                              unsigned short figureFlags, const WP3SubDocument *subDocument, const WP3SubDocument *caption);
00126 
00127 protected:
00128         void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, unsigned nextTableIndice = 0);
00129         void _openParagraph();
00130 
00131         void _flushText();
00132         void _changeList() {}
00133 
00134         void _handleFrameParameters(librevenge::RVNGPropertyList &propList, double height, double width, double verticalOffset, double horizontalOffset, unsigned char leftColumn, unsigned char rightColumn,
00135                                     unsigned short figureFlags);
00136 
00137 private:
00138         WP3ContentListener(const WP3ContentListener &);
00139         WP3ContentListener &operator=(const WP3ContentListener &);
00140         WP3ContentParsingState *m_parseState;
00141         std::vector<WP3SubDocument *> &m_subDocuments;
00142 };
00143 
00144 #endif /* WP3CONTENTLISTENER_H */
00145 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */