• 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., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 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     void insertLineFeed(void);
00138 protected:
00139     IE_Exp_HTML_DocumentWriter(){}
00140     void inline _handleStyleAndId(const gchar *szStyleName, const gchar *szId,
00141             const gchar *szStyle);
00142 
00143     IE_Exp_HTML_OutputWriter *m_pOutputWriter;
00144     IE_Exp_HTML_TagWriter *m_pTagWriter;
00145     UT_uint32 m_iEndnoteCount;
00146     UT_uint32 m_iEndnoteAnchorCount;
00147     UT_uint32 m_iFootnoteCount;
00148     UT_uint32 m_iAnnotationCount;
00149 
00150     bool m_bInsertPhp;
00151     bool m_bInsertSvgScript;
00152 };
00153 
00154 /*
00155  * Writer class for XHTML document creation
00156  */
00157 class ABI_EXPORT IE_Exp_HTML_XHTMLWriter : public IE_Exp_HTML_DocumentWriter
00158 {
00159 public:
00160     IE_Exp_HTML_XHTMLWriter(IE_Exp_HTML_OutputWriter* pOutputWriter);
00161     void insertDTD();
00162     void openDocument();
00163     void openHead();
00164     void openList(bool ordered, const gchar *szStyleName, const PP_AttrProp *pAP);
00165     void openHeading(size_t level, const gchar* szStyleName, const gchar *szId,
00166         const PP_AttrProp *pAP);
00167     void openBlock(const gchar* szStyleName, const UT_UTF8String& style,
00168         const PP_AttrProp *pAP);
00169     inline void enableXmlDeclaration(bool bEnable) { m_bEnableXmlDeclaration = bEnable; }
00170     inline void enableAwmlNamespace(bool bEnable) { m_bUseAwml = bEnable; }
00171 private:
00172     void _handleAwmlStyle(const PP_AttrProp *pAP);
00173     bool m_bEnableXmlDeclaration;
00174     bool m_bUseAwml;
00175 
00176 };
00177 
00178 class ABI_EXPORT IE_Exp_HTML_HTML4Writer : public IE_Exp_HTML_DocumentWriter
00179 {
00180 public:
00181     IE_Exp_HTML_HTML4Writer(IE_Exp_HTML_OutputWriter* pOutputWriter);
00182     void insertDTD();
00183     void openHead();
00184 };
00185 
00186 /*
00187  * This factory class gives ability to customize HTML exporter using
00188  * different content generators
00189  */
00190 class ABI_EXPORT IE_Exp_HTML_WriterFactory
00191 {
00192 public:
00193     virtual ~IE_Exp_HTML_WriterFactory() {}
00194     virtual IE_Exp_HTML_DocumentWriter *constructDocumentWriter(
00195         IE_Exp_HTML_OutputWriter *pOutputWriter) = 0;
00196 
00197 };
00198 
00199 
00200 class ABI_EXPORT IE_Exp_HTML_DefaultWriterFactory : public IE_Exp_HTML_WriterFactory
00201 {
00202 public:
00203     virtual ~IE_Exp_HTML_DefaultWriterFactory() {}
00204     IE_Exp_HTML_DefaultWriterFactory(PD_Document *pDocument,
00205             XAP_Exp_HTMLOptions &exp_opt);
00206     IE_Exp_HTML_DocumentWriter *constructDocumentWriter(
00207     IE_Exp_HTML_OutputWriter *pOutputWriter);
00208 private:
00209     XAP_Exp_HTMLOptions &m_exp_opt;
00210     PD_Document *m_pDocument;
00211 };
00212 #endif

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1