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 <libwpg/libwpg.h>
00032 #include <librevenge-stream/librevenge-stream.h>
00033 #include <librevenge/librevenge.h>
00034 #include "WPGColor.h"
00035 
00036 #include <map>
00037 
00038 class WPGXParser
00039 {
00040 public:
00041         WPGXParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *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         librevenge::RVNGInputStream *m_input;
00056         librevenge::RVNGDrawingInterface *m_painter;
00057         std::map<int,libwpg::WPGColor> m_colorPalette;
00058 };
00059 
00060 class WPGTextDataHandler : public ::librevenge::RVNGTextInterface
00061 {
00062 public:
00063         WPGTextDataHandler(librevenge::RVNGDrawingInterface *painter) :
00064                 m_painter(painter),
00065                 m_fontName("Times New Roman"),
00066                 m_paragraphStyle(),
00067                 m_textStyle() {}
00068 
00069         ~WPGTextDataHandler() {}
00070         void setDocumentMetaData(const librevenge::RVNGPropertyList & /* propList */) {}
00071 
00072         void startDocument(const librevenge::RVNGPropertyList & /* propList */) {}
00073         void endDocument() {}
00074 
00075         void defineEmbeddedFont(const librevenge::RVNGPropertyList & /* propList */) {}
00076 
00077         void definePageStyle(const librevenge::RVNGPropertyList & /* propList */) {}
00078         void openPageSpan(const librevenge::RVNGPropertyList & /* propList */) {}
00079         void closePageSpan() {}
00080         void openHeader(const librevenge::RVNGPropertyList & /* propList */) {}
00081         void closeHeader() {}
00082         void openFooter(const librevenge::RVNGPropertyList & /* propList */) {}
00083         void closeFooter() {}
00084 
00085         void defineParagraphStyle(const librevenge::RVNGPropertyList & /* propList */) {}
00086         void openParagraph(const librevenge::RVNGPropertyList &propList);
00087         void closeParagraph();
00088 
00089         void defineCharacterStyle(const librevenge::RVNGPropertyList & /* propList */) {}
00090         void openSpan(const librevenge::RVNGPropertyList &propList);
00091         void closeSpan();
00092 
00093         void openLink(const librevenge::RVNGPropertyList & /* propList */) {}
00094         void closeLink() {}
00095 
00096         void defineSectionStyle(const librevenge::RVNGPropertyList & /* propList */) {}
00097         void openSection(const librevenge::RVNGPropertyList & /* propList */) {}
00098         void closeSection() {}
00099 
00100         void insertTab();
00101         void insertSpace();
00102         void insertText(const librevenge::RVNGString &text);
00103         void insertLineBreak();
00104         void insertField(const librevenge::RVNGPropertyList & /* propList */) {}
00105 
00106         void openOrderedListLevel(const librevenge::RVNGPropertyList & /* propList */) {}
00107         void openUnorderedListLevel(const librevenge::RVNGPropertyList & /* propList */) {}
00108         void closeOrderedListLevel() {}
00109         void closeUnorderedListLevel() {}
00110         void openListElement(const librevenge::RVNGPropertyList &propList);
00111         void closeListElement();
00112 
00113         void openFootnote(const librevenge::RVNGPropertyList & /* propList */) {}
00114         void closeFootnote() {}
00115         void openEndnote(const librevenge::RVNGPropertyList & /* propList */) {}
00116         void closeEndnote() {}
00117         void openComment(const librevenge::RVNGPropertyList & /* propList */) {}
00118         void closeComment() {}
00119         void openTextBox(const librevenge::RVNGPropertyList & /* propList */) {}
00120         void closeTextBox() {}
00121 
00122         void openTable(const librevenge::RVNGPropertyList & /* propList */) {}
00123         void openTableRow(const librevenge::RVNGPropertyList & /* propList */) {}
00124         void closeTableRow() {}
00125         void openTableCell(const librevenge::RVNGPropertyList & /* propList */) {}
00126         void closeTableCell() {}
00127         void insertCoveredTableCell(const librevenge::RVNGPropertyList & /* propList */) {}
00128         void closeTable() {}
00129 
00130         void openFrame(const librevenge::RVNGPropertyList & /* propList */) {}
00131         void closeFrame() {}
00132 
00133         void openGroup(const librevenge::RVNGPropertyList & /* propList */) {}
00134         void closeGroup() {}
00135 
00136         void defineGraphicStyle(const librevenge::RVNGPropertyList & /* propList */) {}
00137         void drawRectangle(const librevenge::RVNGPropertyList & /* propList */) {}
00138         void drawEllipse(const librevenge::RVNGPropertyList & /* propList */) {}
00139         void drawPolygon(const librevenge::RVNGPropertyList & /* propList */) {}
00140         void drawPolyline(const librevenge::RVNGPropertyList & /* propList */) {}
00141         void drawPath(const librevenge::RVNGPropertyList & /* propList */) {}
00142         void drawConnector(const librevenge::RVNGPropertyList & /* propList */) {}
00143 
00144         void insertBinaryObject(const librevenge::RVNGPropertyList & /* propList */) {}
00145         void insertEquation(const librevenge::RVNGPropertyList & /* propList */) {}
00146 
00147 private:
00148         librevenge::RVNGDrawingInterface *m_painter;
00149         ::librevenge::RVNGString m_fontName;
00150         ::librevenge::RVNGPropertyList m_paragraphStyle, m_textStyle;
00151         // Unimplemented to prevent compiler from creating crasher ones
00152         WPGTextDataHandler(const WPGTextDataHandler &);
00153         WPGTextDataHandler &operator=(const WPGTextDataHandler &);
00154 };
00155 
00156 
00157 #endif // __WPGXPARSER_H__
00158 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */