WP3ContentListener.h

Go to the documentation of this file.
00001 /* libwpd
00002  * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
00003  * Copyright (C) 2005-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00018  *
00019  * For further information visit http://libwpd.sourceforge.net
00020  */
00021 
00022 /* "This product is not manufactured, approved, or supported by
00023  * Corel Corporation or Corel Corporation Limited."
00024  */
00025 
00026 #ifndef WP3CONTENTLISTENER_H
00027 #define WP3CONTENTLISTENER_H
00028 
00029 #include "WP3Listener.h"
00030 #include "WPXContentListener.h"
00031 #include "WP3SubDocument.h"
00032 
00033 typedef struct _WP3ContentParsingState WP3ContentParsingState;
00034 struct _WP3ContentParsingState
00035 {
00036         _WP3ContentParsingState();
00037         ~_WP3ContentParsingState();
00038         uint16_t m_colSpan;
00039         uint16_t m_rowSpan;
00040         WPXString m_textBuffer;
00041         RGBSColor * m_cellFillColor;
00042         WPXString m_noteReference;
00043 
00044         WPXTableList m_tableList;
00045 private:
00046         _WP3ContentParsingState(const _WP3ContentParsingState&);
00047         _WP3ContentParsingState& operator=(const _WP3ContentParsingState&);
00048 };
00049 
00050 class WP3ContentListener : public WP3Listener, protected WPXContentListener
00051 {
00052 public:
00053         WP3ContentListener(std::list<WPXPageSpan> &pageList, std::vector<WP3SubDocument *> &subDocuments, WPXDocumentInterface *documentInterface);
00054         ~WP3ContentListener();
00055 
00056         void startDocument() { WPXContentListener::startDocument(); };
00057         void startSubDocument() { WPXContentListener::startSubDocument(); };
00058         void insertCharacter(uint16_t character);
00059         void insertTab();
00060         void insertTab(uint8_t tabType, double tabPosition);
00061         void insertBreak(uint8_t breakType) { WPXContentListener::insertBreak(breakType); };
00062         void insertEOL();
00063         void attributeChange(bool isOn, uint8_t attribute);
00064         void lineSpacingChange(double lineSpacing) { WPXContentListener::lineSpacingChange(lineSpacing); };
00065         void pageMarginChange(uint8_t /* side */, uint16_t /* margin */) {};
00066         void pageFormChange(uint16_t /* length */, uint16_t /* width */, WPXFormOrientation /* orientation */) {};
00067         void marginChange(uint8_t side, uint16_t margin);
00068         void indentFirstLineChange(int16_t offset);
00069         void setTabs(bool isRelative, const std::vector<WPXTabStop> tabStops);
00070         void columnChange(WPXTextColumnType columnType, uint8_t numColumns, const std::vector<double> &columnWidth,
00071                                         const std::vector<bool> &isFixedWidth);
00072         void endDocument() { WPXContentListener::endDocument(); };
00073         void endSubDocument() { WPXContentListener::endSubDocument(); };
00074 
00075         void defineTable(uint8_t position, uint16_t leftOffset);
00076         void addTableColumnDefinition(uint32_t width, uint32_t leftGutter, uint32_t rightGutter,
00077                                         uint32_t attributes, uint8_t alignment);
00078         void startTable();
00079         void insertRow();
00080         void insertCell();
00081         void closeCell();
00082         void closeRow();
00083         void setTableCellSpan(uint16_t colSpan, uint16_t rowSpan);
00084         void setTableCellFillColor(const RGBSColor * cellFillColor);
00085         void endTable();
00086         void undoChange(uint8_t undoType, uint16_t undoLevel);
00087         void justificationChange(uint8_t justification);
00088         void setTextColor(const RGBSColor * fontColor);
00089         void setTextFont(const WPXString &fontName);
00090         void setFontSize(uint16_t fontSize);
00091         void insertPageNumber(const WPXString &pageNumber);
00092         void insertNoteReference(const WPXString &noteReference);
00093         void insertNote(WPXNoteType noteType, const WP3SubDocument *subDocument);
00094         void headerFooterGroup(uint8_t headerFooterType, uint8_t occurenceBits, WP3SubDocument *subDocument);
00095         void suppressPage(uint16_t /* suppressCode */) {};
00096         void backTab();
00097         void leftIndent();
00098         void leftIndent(double offset);
00099         void leftRightIndent();
00100         void leftRightIndent(double offset);
00101         void insertPicture(double height, double width, double verticalOffset, double horizontalOffset, uint8_t leftColumn, uint8_t rightColumn,
00102                         uint16_t figureFlags, const WPXBinaryData &binaryData);
00103         void insertTextBox(double height, double width, double verticalOffset, double horizontalOffset, uint8_t leftColumn, uint8_t rightColumn,
00104                         uint16_t figureFlags, const WP3SubDocument *subDocument, const WP3SubDocument *caption);
00105         void insertWP51Table(double height, double width, double verticalOffset, double horizontalOffset, uint8_t leftColumn, uint8_t rightColumn,
00106                         uint16_t figureFlags, const WP3SubDocument *subDocument, const WP3SubDocument *caption);
00107         
00108 protected:
00109         void _handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, WPXTableList tableList, int nextTableIndice = 0);
00110         void _openParagraph();
00111 
00112         void _flushText();
00113         void _changeList() {};
00114         
00115         void _handleFrameParameters( WPXPropertyList &propList, double height, double width, double verticalOffset, double horizontalOffset, uint8_t leftColumn, uint8_t rightColumn,
00116                         uint16_t figureFlags );
00117 
00118 private:
00119         WP3ContentListener(const WP3ContentListener&);
00120         WP3ContentListener& operator=(const WP3ContentListener&);
00121         WP3ContentParsingState *m_parseState;
00122         std::vector<WP3SubDocument *> &m_subDocuments;
00123 };
00124 
00125 #endif /* WP3CONTENTLISTENER_H */