WPGXParser.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwpg
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) 2006 Ariya Hidayat (ariya@kde.org)
00011  * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
00012  * Copyright (C) 2005 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://libwpg.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 __WPGXPARSER_H__
00029 #define __WPGXPARSER_H__
00030 
00031 #include "WPGPaintInterface.h"
00032 #include <libwpd-stream/WPXStream.h>
00033 #include <libwpd/libwpd.h>
00034 #include "WPGColor.h"
00035 
00036 #include <map>
00037 
00038 class WPGXParser
00039 {
00040 public:
00041         WPGXParser(WPXInputStream *input, libwpg::WPGPaintInterface *painter);
00042         WPGXParser(const WPGXParser &parser);
00043         virtual ~WPGXParser() {};
00044         virtual bool parse() = 0;
00045 
00046         unsigned char readU8();
00047         unsigned short readU16();
00048         unsigned int readU32();
00049         short readS16();
00050         int readS32();
00051         unsigned int readVariableLengthInteger();
00052         WPGXParser &operator=(const WPGXParser &parser);
00053 
00054 protected:
00055         WPXInputStream *m_input;
00056         libwpg::WPGPaintInterface *m_painter;
00057         std::map<int,libwpg::WPGColor> m_colorPalette;
00058 };
00059 
00060 class WPGTextDataHandler : public ::WPXDocumentInterface
00061 {
00062 public:
00063         WPGTextDataHandler(libwpg::WPGPaintInterface *painter) :
00064                 m_painter(painter),
00065                 m_fontName("Times New Roman"),
00066                 m_paragraphStyle(),
00067                 m_textStyle() {}
00068 
00069         ~WPGTextDataHandler() {}
00070         void setDocumentMetaData(const WPXPropertyList & /* propList */) {}
00071 
00072         void startDocument() {}
00073         void endDocument() {}
00074 
00075         void startSubDocument() {}
00076         void endSubDocument();
00077 
00078         void definePageStyle(const WPXPropertyList & /* propList */) {}
00079         void openPageSpan(const WPXPropertyList & /* propList */) {}
00080         void closePageSpan() {}
00081         void openHeader(const WPXPropertyList & /* propList */) {}
00082         void closeHeader() {}
00083         void openFooter(const WPXPropertyList & /* propList */) {}
00084         void closeFooter() {}
00085 
00086         void defineParagraphStyle(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* tabStops */) {}
00087         void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
00088         void closeParagraph();
00089 
00090         void defineCharacterStyle(const WPXPropertyList & /* propList */) {}
00091         void openSpan(const WPXPropertyList &propList);
00092         void closeSpan();
00093 
00094         void defineSectionStyle(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* columns */) {}
00095         void openSection(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* columns */) {}
00096         void closeSection() {}
00097 
00098         void insertTab();
00099         void insertSpace();
00100         void insertText(const WPXString &text);
00101         void insertLineBreak();
00102         void insertField(const WPXString & /* type */, const WPXPropertyList & /* propList */) {}
00103 
00104         void defineOrderedListLevel(const WPXPropertyList & /* propList */) {}
00105         void defineUnorderedListLevel(const WPXPropertyList & /* propList */) {}
00106         void openOrderedListLevel(const WPXPropertyList & /* propList */) {}
00107         void openUnorderedListLevel(const WPXPropertyList & /* propList */) {}
00108         void closeOrderedListLevel() {}
00109         void closeUnorderedListLevel() {}
00110         void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
00111         void closeListElement();
00112 
00113         void openFootnote(const WPXPropertyList & /* propList */) {}
00114         void closeFootnote() {}
00115         void openEndnote(const WPXPropertyList & /* propList */) {}
00116         void closeEndnote() {}
00117         void openComment(const WPXPropertyList & /* propList */) {}
00118         void closeComment() {}
00119         void openTextBox(const WPXPropertyList & /* propList */) {}
00120         void closeTextBox() {}
00121 
00122         void openTable(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* columns */) {}
00123         void openTableRow(const WPXPropertyList & /* propList */) {}
00124         void closeTableRow() {}
00125         void openTableCell(const WPXPropertyList & /* propList */) {}
00126         void closeTableCell() {}
00127         void insertCoveredTableCell(const WPXPropertyList & /* propList */) {}
00128         void closeTable() {}
00129 
00130         void openFrame(const WPXPropertyList & /* propList */) {}
00131         void closeFrame() {}
00132 
00133         void insertBinaryObject(const WPXPropertyList & /* propList */, const WPXBinaryData & /* data */) {}
00134         void insertEquation(const WPXPropertyList & /* propList */, const WPXString & /* data */) {}
00135 
00136 private:
00137         libwpg::WPGPaintInterface *m_painter;
00138         ::WPXString m_fontName;
00139         ::WPXPropertyList m_paragraphStyle, m_textStyle;
00140         // Unimplemented to prevent compiler from creating crasher ones
00141         WPGTextDataHandler(const WPGTextDataHandler &);
00142         WPGTextDataHandler &operator=(const WPGTextDataHandler &);
00143 };
00144 
00145 
00146 #endif // __WPGXPARSER_H__
00147 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */