WPGXParser.h

Go to the documentation of this file.
00001 /* libwpg
00002  * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
00003  * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
00004  * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the 
00018  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00019  * Boston, MA  02111-1301 USA
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_x(0.0),
00066                 m_y(0.0),
00067                 m_width(0.0),
00068                 m_height(0.0),
00069                 m_fontName("Times New Roman"),
00070                 m_fontSize(12.0),
00071                 m_paragraphStyle(),
00072                 m_textStyle() {}
00073                 
00074         ~WPGTextDataHandler() {}
00075         void setDocumentMetaData(const WPXPropertyList & /* propList */) {}
00076 
00077         void startDocument() {}
00078         void endDocument() {}
00079 
00080         void startSubDocument() {}
00081         void endSubDocument();
00082 
00083         void definePageStyle(const WPXPropertyList & /* propList */) {}
00084         void openPageSpan(const WPXPropertyList & /* propList */) {}
00085         void closePageSpan() {}
00086         void openHeader(const WPXPropertyList & /* propList */) {}
00087         void closeHeader() {}
00088         void openFooter(const WPXPropertyList & /* propList */) {}
00089         void closeFooter() {}
00090 
00091         void defineParagraphStyle(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* tabStops */) {}
00092         void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
00093         void closeParagraph();
00094 
00095         void defineCharacterStyle(const WPXPropertyList & /* propList */) {}
00096         void openSpan(const WPXPropertyList &propList);
00097         void closeSpan();
00098 
00099         void defineSectionStyle(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* columns */) {}
00100         void openSection(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* columns */) {}
00101         void closeSection() {}
00102 
00103         void insertTab();
00104         void insertSpace();
00105         void insertText(const WPXString &text);
00106         void insertLineBreak();
00107         void insertField(const WPXString & /* type */, const WPXPropertyList & /* propList */) {}
00108 
00109         void defineOrderedListLevel(const WPXPropertyList & /* propList */) {}
00110         void defineUnorderedListLevel(const WPXPropertyList & /* propList */) {}
00111         void openOrderedListLevel(const WPXPropertyList & /* propList */) {}
00112         void openUnorderedListLevel(const WPXPropertyList & /* propList */) {}
00113         void closeOrderedListLevel() {}
00114         void closeUnorderedListLevel() {}
00115         void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
00116         void closeListElement();
00117 
00118         void openFootnote(const WPXPropertyList & /* propList */) {}
00119         void closeFootnote() {}
00120         void openEndnote(const WPXPropertyList & /* propList */) {}
00121         void closeEndnote() {}
00122         void openComment(const WPXPropertyList & /* propList */) {}
00123         void closeComment() {}
00124         void openTextBox(const WPXPropertyList & /* propList */) {}
00125         void closeTextBox() {}
00126 
00127         void openTable(const WPXPropertyList & /* propList */, const WPXPropertyListVector & /* columns */) {}
00128         void openTableRow(const WPXPropertyList & /* propList */) {}
00129         void closeTableRow() {}
00130         void openTableCell(const WPXPropertyList & /* propList */) {}
00131         void closeTableCell() {}
00132         void insertCoveredTableCell(const WPXPropertyList & /* propList */) {}
00133         void closeTable() {}
00134 
00135         void openFrame(const WPXPropertyList & /* propList */) {}
00136         void closeFrame() {}
00137         
00138         void insertBinaryObject(const WPXPropertyList & /* propList */, const WPXBinaryData & /* data */) {}
00139         void insertEquation(const WPXPropertyList & /* propList */, const WPXString & /* data */) {}
00140 
00141 private:
00142         libwpg::WPGPaintInterface *m_painter;
00143         double m_x, m_y, m_width, m_height;
00144         ::WPXString m_fontName;
00145         double m_fontSize;
00146         ::WPXPropertyList m_paragraphStyle, m_textStyle;
00147 };
00148 
00149 
00150 #endif // __WPGXPARSER_H__