ABWCollector.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libabw project.
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 
00010 #ifndef __ABWCOLLECTOR_H__
00011 #define __ABWCOLLECTOR_H__
00012 
00013 #include <string>
00014 #include <map>
00015 #include <libwpd/libwpd.h>
00016 
00017 namespace libabw
00018 {
00019 
00020 enum ABWUnit
00021 {
00022   ABW_NONE,
00023   ABW_CM,
00024   ABW_IN,
00025   ABW_MM,
00026   ABW_PI,
00027   ABW_PT,
00028   ABW_PX,
00029   ABW_PERCENT
00030 };
00031 
00032 enum ABWListType
00033 {
00034   ABW_ORDERED,
00035   ABW_UNORDERED
00036 };
00037 
00038 bool findInt(const std::string &str, int &res);
00039 bool findDouble(const std::string &str, double &res, ABWUnit &unit);
00040 void parsePropString(const std::string &str, std::map<std::string, std::string> &props);
00041 
00042 struct ABWData
00043 {
00044   ABWData()
00045     : m_mimeType(), m_binaryData() {}
00046   ABWData(const ABWData &data)
00047     : m_mimeType(data.m_mimeType), m_binaryData(data.m_binaryData) {}
00048   ABWData(const WPXString &mimeType, const WPXBinaryData binaryData)
00049     : m_mimeType(mimeType), m_binaryData(binaryData) {}
00050   ~ABWData() {}
00051 
00052   WPXString m_mimeType;
00053   WPXBinaryData m_binaryData;
00054 };
00055 
00056 struct ABWListElement
00057 {
00058   ABWListElement()
00059     : m_listLevel(-1), m_minLabelWidth(0.0), m_spaceBefore(0.0), m_parentId() {}
00060   virtual ~ABWListElement() {}
00061   virtual void writeOut(WPXPropertyList &propList) const;
00062   virtual ABWListType getType() const = 0;
00063 
00064   int m_listLevel;
00065   double m_minLabelWidth;
00066   double m_spaceBefore;
00067   int m_parentId;
00068 };
00069 
00070 struct ABWOrderedListElement : public ABWListElement
00071 {
00072   ABWOrderedListElement()
00073     : ABWListElement(), m_numFormat(), m_numPrefix(), m_numSuffix(), m_startValue(-1) {}
00074   ~ABWOrderedListElement() {}
00075   void writeOut(WPXPropertyList &propList) const;
00076   ABWListType getType() const
00077   {
00078     return ABW_ORDERED;
00079   }
00080 
00081   WPXString m_numFormat;
00082   WPXString m_numPrefix;
00083   WPXString m_numSuffix;
00084   int m_startValue;
00085 };
00086 
00087 struct ABWUnorderedListElement : public ABWListElement
00088 {
00089   ABWUnorderedListElement()
00090     : ABWListElement(), m_bulletChar() {}
00091   ~ABWUnorderedListElement() {}
00092   void writeOut(WPXPropertyList &propList) const;
00093   ABWListType getType() const
00094   {
00095     return ABW_UNORDERED;
00096   }
00097 
00098   WPXString m_bulletChar;
00099 };
00100 
00101 class ABWCollector
00102 {
00103 public:
00104   ABWCollector() {}
00105   virtual ~ABWCollector() {}
00106 
00107   // collector functions
00108 
00109   virtual void collectTextStyle(const char *name, const char *basedon, const char *followedby, const char *props) = 0;
00110   virtual void collectParagraphProperties(const char *level, const char *listid, const char *parentid,
00111                                           const char *style, const char *props) = 0;
00112   virtual void collectSectionProperties(const char *footer, const char *footerLeft, const char *footerFirst,
00113                                         const char *footerLast, const char *header, const char *headerLeft,
00114                                         const char *headerFirst, const char *headerLast, const char *props) = 0;
00115   virtual void collectCharacterProperties(const char *style, const char *props) = 0;
00116   virtual void collectPageSize(const char *width, const char *height, const char *units, const char *pageScale) = 0;
00117   virtual void closeParagraphOrListElement() = 0;
00118   virtual void closeSpan() = 0;
00119   virtual void openLink(const char *href) = 0;
00120   virtual void closeLink() = 0;
00121   virtual void openFoot(const char *id) = 0;
00122   virtual void closeFoot() = 0;
00123   virtual void openEndnote(const char *id) = 0;
00124   virtual void closeEndnote() = 0;
00125   virtual void endSection() = 0;
00126   virtual void startDocument() = 0;
00127   virtual void endDocument() = 0;
00128   virtual void insertLineBreak() = 0;
00129   virtual void insertColumnBreak() = 0;
00130   virtual void insertPageBreak() = 0;
00131   virtual void insertText(const char *text) = 0;
00132   virtual void insertImage(const char *dataid, const char *props) = 0;
00133   virtual void collectList(const char *id, const char *listDecimal, const char *listDelim,
00134                            const char *parentid, const char *startValue, const char *type) = 0;
00135 
00136   virtual void collectData(const char *name, const char *mimeType, const WPXBinaryData &data) = 0;
00137   virtual void collectHeaderFooter(const char *id, const char *type) = 0;
00138 
00139   virtual void openTable(const char *props) = 0;
00140   virtual void closeTable() = 0;
00141   virtual void openCell(const char *props) = 0;
00142   virtual void closeCell() = 0;
00143 };
00144 
00145 } // namespace libabw
00146 
00147 #endif /* __ABWCOLLECTOR_H__ */
00148 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */