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         uint16_t m_colSpan;
00040         uint16_t m_rowSpan;
00041         WPXString m_textBuffer;
00042         RGBSColor *m_cellFillColor;
00043         WPXString 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, WPXDocumentInterface *documentInterface);
00055         ~WP3ContentListener();
00056 
00057         void startDocument()
00058         {
00059                 WPXContentListener::startDocument();
00060         }
00061         void startSubDocument()
00062         {
00063                 WPXContentListener::startSubDocument();
00064         }
00065         void insertCharacter(uint32_t character);
00066         void insertTab();
00067         void insertTab(uint8_t tabType, double tabPosition);
00068         void insertBreak(uint8_t breakType)
00069         {
00070                 WPXContentListener::insertBreak(breakType);
00071         }
00072         void insertEOL();
00073         void attributeChange(bool isOn, uint8_t attribute);
00074         void lineSpacingChange(double lineSpacing)
00075         {
00076                 WPXContentListener::lineSpacingChange(lineSpacing);
00077         }
00078         void pageMarginChange(uint8_t /* side */, uint16_t /* margin */) {}
00079         void pageFormChange(uint16_t /* length */, uint16_t /* width */, WPXFormOrientation /* orientation */) {}
00080         void marginChange(uint8_t side, uint16_t margin);
00081         void indentFirstLineChange(double offset);
00082         void setTabs(bool isRelative, const std::vector<WPXTabStop> tabStops);
00083         void columnChange(WPXTextColumnType columnType, uint8_t 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(uint8_t position, uint16_t leftOffset);
00095         void addTableColumnDefinition(uint32_t width, uint32_t leftGutter, uint32_t rightGutter,
00096                                       uint32_t attributes, uint8_t alignment);
00097         void startTable();
00098         void insertRow();
00099         void insertCell();
00100         void closeCell();
00101         void closeRow();
00102         void setTableCellSpan(uint16_t colSpan, uint16_t rowSpan);
00103         void setTableCellFillColor(const RGBSColor *cellFillColor);
00104         void endTable();
00105         void undoChange(uint8_t undoType, uint16_t undoLevel);
00106         void justificationChange(uint8_t justification);
00107         void setTextColor(const RGBSColor *fontColor);
00108         void setTextFont(const WPXString &fontName);
00109         void setFontSize(uint16_t fontSize);
00110         void insertPageNumber(const WPXString &pageNumber);
00111         void insertNoteReference(const WPXString &noteReference);
00112         void insertNote(WPXNoteType noteType, const WP3SubDocument *subDocument);
00113         void headerFooterGroup(uint8_t headerFooterType, uint8_t occurenceBits, WP3SubDocument *subDocument);
00114         void suppressPage(uint16_t /* 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, uint8_t leftColumn, uint8_t rightColumn,
00121                            uint16_t figureFlags, const WPXBinaryData &binaryData);
00122         void insertTextBox(double height, double width, double verticalOffset, double horizontalOffset, uint8_t leftColumn, uint8_t rightColumn,
00123                            uint16_t figureFlags, const WP3SubDocument *subDocument, const WP3SubDocument *caption);
00124         void insertWP51Table(double height, double width, double verticalOffset, double horizontalOffset, uint8_t leftColumn, uint8_t rightColumn,
00125                              uint16_t 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( WPXPropertyList &propList, double height, double width, double verticalOffset, double horizontalOffset, uint8_t leftColumn, uint8_t rightColumn,
00135                                      uint16_t 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: */