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

ie_exp_HTML_Listener.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiWord
00004  * Copyright (C) 1998 AbiSource, Inc.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program 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
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 #ifndef IE_EXP_HTML_LISTENER_H
00022 #define IE_EXP_HTML_LISTENER_H
00023 
00024 // External includes
00025 #include <vector>
00026 #include <string>
00027 
00028 // ABiword includes
00029 #include <pd_Document.h>
00030 #include <pl_Listener.h>
00031 #include <px_ChangeRecord.h>
00032 #include <px_CR_Span.h>
00033 #include <px_CR_Strux.h>
00034 #include <px_CR_Object.h>
00035 #include <fd_Field.h>
00036 #include <fl_TOCLayout.h>
00037 #include <ie_Table.h>
00038 #include <ie_TOC.h>
00039 #include <ut_mbtowc.h>
00040 
00041 #include "ie_exp_HTML_util.h"
00042 #include "ie_exp_HTML_NavigationHelper.h"
00043 #include "ie_exp_HTML_StyleTree.h"
00044 
00045 
00050 class ABI_EXPORT IE_Exp_HTML_ListenerImpl {
00051 public:
00052     virtual ~IE_Exp_HTML_ListenerImpl(){}
00053     virtual void openSpan(const gchar * szStyleName,
00054                           const UT_UTF8String& style) = 0;
00055     virtual void closeSpan() = 0;
00056 
00057     virtual void openHeading(size_t level, const gchar * id,
00058                              const gchar * szStyleName,
00059                              const PP_AttrProp* pAP) = 0;
00060     virtual void closeHeading() = 0;
00061 
00062     virtual void openBlock(const gchar * szStyleName,
00063                            const UT_UTF8String & style,
00064                            const PP_AttrProp* pAP) = 0;
00065     virtual void closeBlock() = 0;
00066 
00067     virtual void openSection(const gchar * szStyleName) = 0;
00068     virtual void closeSection() = 0;
00069 
00070     virtual void openField(const UT_UTF8String& fieldType,
00071                            const UT_UTF8String& fieldValue) = 0;
00072     virtual void closeField(const UT_UTF8String& fieldType) = 0;
00073 
00074     virtual void openTable(const UT_UTF8String &style,
00075                            const UT_UTF8String &cellPadding,
00076                            const UT_UTF8String &border) = 0;
00077     virtual void closeTable() = 0;
00078 
00079     virtual void openRow() = 0;
00080     virtual void closeRow() = 0;
00081 
00082     virtual void openCell(const UT_UTF8String &/*style*/,
00083                           const UT_UTF8String &/*rowSpan*/,
00084                           const UT_UTF8String &/*colSpan*/) = 0;
00085     virtual void closeCell() = 0;
00086 
00087     virtual void openAnnotation() = 0;
00088     virtual void closeAnnotation() = 0;
00089 
00090     virtual void openTextbox(const UT_UTF8String &style) = 0;
00091     virtual void closeTextbox() = 0;
00092 
00093     virtual void openBookmark(const gchar * szBookmarkName) = 0;
00094     virtual void closeBookmark() = 0;
00095 
00096     virtual void openHyperlink(const gchar * szUri,
00097                                const gchar * szStyleName,
00098                                const gchar * szId) = 0;
00099     virtual void closeHyperlink() = 0;
00100 
00101     virtual void openList(bool ordered, const gchar * szStyleName,
00102                           const PP_AttrProp* pAP) = 0;
00103     virtual void closeList() = 0;
00104 
00105     virtual void openListItem() = 0;
00106     virtual void closeListItem() = 0;
00107 
00108     virtual void openDocument() = 0;
00109     virtual void closeDocument() = 0;
00110 
00111     virtual void openHead() = 0;
00112     virtual void closeHead() = 0;
00113 
00114     virtual void openBody() = 0;
00115     virtual void closeBody() = 0;
00116 
00117     virtual void insertDTD() = 0;
00118     virtual void insertLink(const UT_UTF8String &rel,
00119                             const UT_UTF8String &type,
00120                             const UT_UTF8String &uri) = 0;
00121     virtual void insertMeta(const std::string & name,
00122         const std::string & content, const std::string& httpEquiv) = 0;
00123     virtual void insertMath(const UT_UTF8String &mathml,
00124                             const UT_UTF8String &width,
00125                             const UT_UTF8String &height) = 0;
00126 
00127     virtual void insertImage(const UT_UTF8String &url,
00128                              const UT_UTF8String &align,
00129                              const UT_UTF8String& style,
00130                              const UT_UTF8String &title,
00131                              const UT_UTF8String &alt) = 0;
00132 
00133     virtual void insertText(const UT_UTF8String &text) = 0;
00134 
00135     virtual void insertTOC(const gchar * title,
00136                            const std::vector<UT_UTF8String> &items,
00137                            const std::vector<UT_UTF8String> &itemUri) = 0;
00138 
00139     virtual void insertEndnotes(const std::vector<UT_UTF8String> &endnotes) = 0;
00140     virtual void insertFootnotes(const std::vector<UT_UTF8String> &footnotes) = 0;
00141     virtual void insertAnnotations(const std::vector<UT_UTF8String> &titles,
00142                                    const std::vector<UT_UTF8String> &authors,
00143                                    const std::vector<UT_UTF8String> &annotations) = 0;
00144 
00145     virtual void insertStyle(const UT_UTF8String &style) = 0;
00146     virtual void insertJavaScript(const gchar* src,
00147                                   const gchar* script) = 0;
00148     virtual void insertTitle(const std::string& title) = 0;
00149 };
00150 
00151 
00152 struct ListInfo
00153 {
00154     const gchar *szId;
00155     UT_uint32 iLevel;
00156     UT_uint32 iItemCount;
00157 };
00158 
00163 class IE_Exp_HTML_Listener : public PL_Listener {
00164 public:
00165     IE_Exp_HTML_Listener(PD_Document *pDocument,
00166             IE_Exp_HTML_DataExporter *pDataExporter,
00167             IE_Exp_HTML_StyleTree    *pStyleTree,
00168             IE_Exp_HTML_NavigationHelper *pNavigationHelper,
00169             IE_Exp_HTML_ListenerImpl *pListenerImpl,
00170             const UT_UTF8String &filename);
00171 
00172     virtual bool populate(fl_ContainerLayout* sfh,
00173             const PX_ChangeRecord * pcr);
00174 
00175     virtual bool populateStrux(pf_Frag_Strux* sdh,
00176             const PX_ChangeRecord * pcr,
00177             fl_ContainerLayout* * psfh);
00178 
00179     virtual bool endOfDocument();
00180 
00181     virtual bool change(fl_ContainerLayout* sfh,
00182             const PX_ChangeRecord * pcr);
00183 
00184     virtual bool insertStrux(fl_ContainerLayout* sfh,
00185             const PX_ChangeRecord * pcr,
00186             pf_Frag_Strux* sdh,
00187             PL_ListenerId lid,
00188             void (*pfnBindHandles) (pf_Frag_Strux* sdhNew,
00189             PL_ListenerId lid,
00190             fl_ContainerLayout* sfhNew));
00191 
00192     virtual bool signal(UT_uint32 iSignal);
00193 
00194     void set_EmbedCSS(bool bEmbed = true)
00195         { m_bEmbedCss = bEmbed; }
00196     void set_EmbedImages(bool bEmbed = true)
00197         { m_bEmbedImages = bEmbed; }
00198     void set_SplitDocument(bool bSplit = true)
00199         { m_bSplitDocument = bSplit; }
00200     void set_RenderMathMLToPng (bool bRender = true)
00201         { m_bRenderMathToPng = bRender; }
00202     bool get_HasMathML() const
00203         { return m_bHasMathMl; }
00204 private:
00205     const gchar* _getObjectKey(const PT_AttrPropIndex& api,
00206             const gchar* key);
00207     virtual bool _beginOfDocument(const PT_AttrPropIndex& api);
00208     void _outputData(const UT_UCSChar* pData, UT_uint32 length);
00209     void _openSpan(PT_AttrPropIndex api);
00210     void _closeSpan();
00211 
00212     void _openHeading(PT_AttrPropIndex api, size_t level,
00213         const gchar *szStyleName = NULL);
00214     void _closeHeading();
00215 
00216     void _openBlock(PT_AttrPropIndex api);
00217     void _closeBlock();
00218 
00219     void _openSection(PT_AttrPropIndex api, bool recursiveCall = false);
00220     void _closeSection(bool recursiveCall = false);
00221 
00222     void _openField(const PX_ChangeRecord_Object* pcro, PT_AttrPropIndex api);
00223     void _closeField();
00224 
00225     void _openTable(PT_AttrPropIndex api, bool recursiveCall = false);
00226     void _closeTable(bool recursiveCall = false);
00227 
00228     void _openRow(PT_AttrPropIndex api, bool recursiveCall = false);
00229     void _closeRow(bool recursiveCall = false);
00230 
00231     void _openCell(PT_AttrPropIndex api, bool recursiveCall = false);
00232     void _closeCell(bool recursiveCall = false);
00233 
00234     void _openList(PT_AttrPropIndex api, bool recursiveCall = false);
00235     void _closeList(bool recursiveCall = false);
00236     void _closeLists();
00237 
00238     void _openListItem(bool recursiveCall = false);
00239     void _closeListItem(bool recursiveCall = false);
00240 
00241     void _openFootnote(PT_AttrPropIndex api);
00242     void _closeFootnote();
00243 
00244     void _openEndnote(PT_AttrPropIndex api);
00245     void _closeEndnote();
00246 
00247     void _openAnnotation(PT_AttrPropIndex api);
00248     void _closeAnnotation();
00249 
00250     void _openFrame(PT_AttrPropIndex api, const PX_ChangeRecord* pcr);
00251     void _closeFrame();
00252 
00253     void _openBookmark(PT_AttrPropIndex api);
00254     void _closeBookmark();
00255 
00256     void _openHyperlink(PT_AttrPropIndex api);
00257     void _closeHyperlink();
00258 
00259     void _openDocument();
00260     void _closeDocument();
00261 
00262     void _openHead();
00263     void _closeHead();
00264 
00265     void _openBody();
00266     void _closeBody();
00267 
00268     void _openTextbox(PT_AttrPropIndex api);
00269     void _closeTextbox();
00270 
00271     void _insertPosImage (PT_AttrPropIndex api);
00272     void _insertDTD();
00273     void _insertLinks();
00274     void _insertTitle();
00275     void _insertMeta();
00276     void _insertImage(PT_AttrPropIndex api);
00277     void _insertEmbeddedImage(PT_AttrPropIndex api);
00278     void _insertMath(PT_AttrPropIndex api);
00279     void _insertTOC(PT_AttrPropIndex api);
00280     void _insertEndnotes();
00281     void _insertFootnotes();
00282     void _insertAnnotations();
00283     void _insertStyle();
00284     void _insertLinkToStyle();
00285     void _handleAnnotationData(PT_AttrPropIndex api);
00286     void _handleImage(PT_AttrPropIndex api, const gchar *szDataId,
00287                       bool bIsPositioned);
00288     void _makeStylesheet(PT_AttrPropIndex api);
00289     void _setCellWidthInches();
00290     void _fillColWidthsVector();
00291 
00292     bool m_bFirstWrite;
00293     bool m_bInSpan;
00294     bool m_bInBlock;
00295     bool m_bInBookmark;
00296     bool m_bInHyperlink;
00297     bool m_bInSection;
00298     bool m_bInAnnotation;
00299     bool m_bInAnnotationSection;
00300     bool m_bInEndnote;
00301     bool m_bInFootnote;
00302     bool m_bInHeading;
00303     bool m_bInTextbox;
00304     bool m_bSkipSection;
00305     fd_Field* m_pCurrentField;
00306     UT_UTF8String m_currentFieldType;
00307     UT_UTF8String m_bookmarkName;
00308     PT_AttrPropIndex m_apiLastSpan;
00309 
00310     UT_sint32 m_iInTable;
00311     UT_sint32 m_iInRow;
00312     UT_sint32 m_iInCell;
00313 
00314     bool m_bFirstRow;
00315     PD_Document *m_pDocument;
00316     IE_Exp_HTML_ListenerImpl *m_pCurrentImpl;
00317     ie_Table m_tableHelper;
00318 
00319     UT_GenericVector<ListInfo> m_listInfoStack;
00320     std::vector<UT_UTF8String> m_endnotes;
00321     std::vector<UT_UTF8String> m_footnotes;
00322     std::vector<UT_UTF8String> m_annotationTitles;
00323     std::vector<UT_UTF8String> m_annotationAuthors;
00324     std::vector<UT_UTF8String> m_annotationContents;
00325 
00326     IE_Exp_HTML_DataExporter *m_pDataExporter;
00327 
00328     bool m_bEmbedCss;
00329     bool m_bEmbedImages;
00330     bool m_bRenderMathToPng;
00331     bool m_bSplitDocument;
00332     bool m_bScaleUnits;
00333     bool m_bAbsUnits;
00334     UT_UTF8String m_filename;
00335 
00336     IE_Exp_HTML_StyleTree *m_pStyleTree;
00337     IE_Exp_HTML_NavigationHelper *m_pNavigationHelper;
00338     UT_UTF8String m_stylesheet;
00339     UT_uint32 m_iHeadingCount;
00340 
00341     double m_dPageWidthInches;
00342     double m_dSecLeftMarginInches;
00343     double m_dSecRightMarginInches;
00344     double m_dSecTopMarginInches;
00345     double m_dSecBottomMarginInches;
00346     double m_dCellWidthInches;
00347     UT_GenericVector<double> m_vecDWidths;
00348     bool m_bHasMathMl;
00349 };
00350 
00351 
00352 
00353 #endif  /* IE_EXP_HTML_LISTENER_H */
00354 

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1