• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ie_exp_HTML_DocumentWriter.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiSource
00004  *
00005  * Copyright (C) 2011 Volodymyr Rudyj <vladimir.rudoy@gmail.com>
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00020  * 02111-1307, USA.
00021  */
00022 #ifndef IE_EXP_HTML_MAINLISTENER_H
00023 #define IE_EXP_HTML_MAINLISTENER_H
00024 
00025 // HTML exporter includes
00026 #include "ie_exp_HTML.h"
00027 #include "ie_exp_HTML_Listener.h"
00028 #include "ie_exp_HTML_util.h"
00029 #include "ie_exp_HTML_StyleTree.h"
00030 #include "xap_Dlg_HTMLOptions.h"
00031 
00032 #include "pp_AttrProp.h"
00033 
00034 #define XHTML_DTD "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \
00035 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
00036 #define XHTML_NS "http://www.w3.org/1999/xhtml"
00037 
00038 #define XHTML_AWML_DTD "<!DOCTYPE html PUBLIC \"-//ABISOURCE//DTD XHTML plus \
00039 AWML 2.2//EN\" \"http://www.abisource.com/2004/xhtml-awml/xhtml-awml.mod\">"
00040 #define AWML_NS "http://www.abisource.com/2004/xhtml-awml/"
00041 
00042 #define HTML4_DTD "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \
00043 \"http://www.w3.org/TR/html4/strict.dtd\">\n"
00044 
00045 
00046 
00047 #define XML_DECLARATION "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
00048 
00049 class ABI_EXPORT IE_Exp_HTML_DocumentWriter : public IE_Exp_HTML_ListenerImpl
00050 {
00051 public:
00052     IE_Exp_HTML_DocumentWriter(IE_Exp_HTML_OutputWriter* pOutputWriter);
00053 
00054     virtual ~IE_Exp_HTML_DocumentWriter();
00055 
00056     void openSpan(const gchar *szStyleNames, const UT_UTF8String& style);
00057     void closeSpan();
00058 
00059     void openBlock(const gchar* szStyleName, const UT_UTF8String& style,
00060         const PP_AttrProp *pAP);
00061     void closeBlock();
00062 
00063     void openHeading(size_t level, const gchar* szStyleName,
00064         const gchar *szId, const PP_AttrProp *pAP);
00065     void closeHeading();
00066 
00067     void openSection(const gchar* szStyleName);
00068     void closeSection();
00069 
00070     void openHyperlink(const gchar *szUri, const gchar *szStyleName,
00071         const gchar *szId);
00072     void closeHyperlink();
00073 
00074     void openDocument();
00075     void closeDocument();
00076 
00077     void openHead();
00078     void closeHead();
00079 
00080     void openBody();
00081     void closeBody();
00082 
00083     void openTable(const UT_UTF8String &style,
00084         const UT_UTF8String &cellPadding, const UT_UTF8String &border);
00085     void closeTable();
00086 
00087     void openRow();
00088     void closeRow();
00089 
00090     void openCell(const UT_UTF8String &style,
00091         const UT_UTF8String &rowspan, const UT_UTF8String &colspan);
00092     void closeCell();
00093 
00094     void openBookmark(const gchar* szBookmarkName);
00095     void closeBookmark();
00096 
00097     void openList(bool ordered, const gchar *szStyleName,
00098         const PP_AttrProp *pAP);
00099     void closeList();
00100 
00101     void openListItem();
00102     void closeListItem();
00103 
00104     void openField(const UT_UTF8String &fieldType, const UT_UTF8String &value);
00105     void closeField(const UT_UTF8String& fieldType);
00106 
00107     void openAnnotation();
00108     void closeAnnotation();
00109 
00110     void openTextbox(const UT_UTF8String &style);
00111     void closeTextbox();
00112 
00113     void insertDTD();
00114     void insertMeta(const std::string& name, const std::string& content,
00115             const std::string& httpEquiv);
00116     void insertText(const UT_UTF8String &text);
00117     void insertImage(const UT_UTF8String &url, const UT_UTF8String &width,
00118         const UT_UTF8String &align, const UT_UTF8String &style,
00119         const UT_UTF8String &alt);
00120     void insertTOC(const gchar *title, const std::vector<UT_UTF8String> &items,
00121         const std::vector<UT_UTF8String> &itemUriList);
00122     void insertEndnotes(const std::vector<UT_UTF8String> &endnotes);
00123     void insertFootnotes(const std::vector<UT_UTF8String> &footnotes);
00124     void insertAnnotations(const std::vector<UT_UTF8String> &titles,
00125        const std::vector<UT_UTF8String> &authors,
00126        const std::vector<UT_UTF8String> &annotations);
00127     void insertStyle(const UT_UTF8String &style);
00128     virtual void insertJavaScript(const gchar * /*src*/,
00129                                   const gchar* /*script*/) {}
00130     void insertTitle(const std::string& title);
00131     void insertLink(const UT_UTF8String &rel,
00132             const UT_UTF8String &type, const UT_UTF8String &uri);
00133     void insertMath(const UT_UTF8String &mathml,
00134     const UT_UTF8String &width, const UT_UTF8String &height);
00135     inline void enablePHP (bool bEnable = true) { m_bInsertPhp = bEnable; }
00136     inline void enableSVGScript (bool bEnable = true) { m_bInsertSvgScript = bEnable; }
00137 protected:
00138     IE_Exp_HTML_DocumentWriter(){}
00139     void inline _handleStyleAndId(const gchar *szStyleName, const gchar *szId,
00140             const gchar *szStyle);
00141 
00142     IE_Exp_HTML_OutputWriter *m_pOutputWriter;
00143     IE_Exp_HTML_TagWriter *m_pTagWriter;
00144     UT_uint32 m_iEndnoteCount;
00145     UT_uint32 m_iEndnoteAnchorCount;
00146     UT_uint32 m_iFootnoteCount;
00147     UT_uint32 m_iAnnotationCount;
00148 
00149     bool m_bInsertPhp;
00150     bool m_bInsertSvgScript;
00151 };
00152 
00153 /*
00154  * Writer class for XHTML document creation
00155  */
00156 class ABI_EXPORT IE_Exp_HTML_XHTMLWriter : public IE_Exp_HTML_DocumentWriter
00157 {
00158 public:
00159     IE_Exp_HTML_XHTMLWriter(IE_Exp_HTML_OutputWriter* pOutputWriter);
00160     void insertDTD();
00161     void openDocument();
00162     void openHead();
00163     void openList(bool ordered, const gchar *szStyleName, const PP_AttrProp *pAP);
00164     void openHeading(size_t level, const gchar* szStyleName, const gchar *szId,
00165         const PP_AttrProp *pAP);
00166     void openBlock(const gchar* szStyleName, const UT_UTF8String& style,
00167         const PP_AttrProp *pAP);
00168     inline void enableXmlDeclaration(bool bEnable) { m_bEnableXmlDeclaration = bEnable; }
00169     inline void enableAwmlNamespace(bool bEnable) { m_bUseAwml = bEnable; }
00170 private:
00171     void _handleAwmlStyle(const PP_AttrProp *pAP);
00172     bool m_bEnableXmlDeclaration;
00173     bool m_bUseAwml;
00174 
00175 };
00176 
00177 class ABI_EXPORT IE_Exp_HTML_HTML4Writer : public IE_Exp_HTML_DocumentWriter
00178 {
00179 public:
00180     IE_Exp_HTML_HTML4Writer(IE_Exp_HTML_OutputWriter* pOutputWriter);
00181     void insertDTD();
00182     void openHead();
00183 };
00184 
00185 /*
00186  * This factory class gives ability to customize HTML exporter using
00187  * different content generators
00188  */
00189 class ABI_EXPORT IE_Exp_HTML_WriterFactory
00190 {
00191 public:
00192     virtual ~IE_Exp_HTML_WriterFactory() {}
00193     virtual IE_Exp_HTML_DocumentWriter *constructDocumentWriter(
00194         IE_Exp_HTML_OutputWriter *pOutputWriter) = 0;
00195 
00196 };
00197 
00198 
00199 class ABI_EXPORT IE_Exp_HTML_DefaultWriterFactory : public IE_Exp_HTML_WriterFactory
00200 {
00201 public:
00202     virtual ~IE_Exp_HTML_DefaultWriterFactory() {}
00203     IE_Exp_HTML_DefaultWriterFactory(PD_Document *pDocument,
00204             XAP_Exp_HTMLOptions &exp_opt);
00205     IE_Exp_HTML_DocumentWriter *constructDocumentWriter(
00206     IE_Exp_HTML_OutputWriter *pOutputWriter);
00207 private:
00208     XAP_Exp_HTMLOptions &m_exp_opt;
00209     PD_Document *m_pDocument;
00210 };
00211 #endif

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1