00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef IE_EXP_HTML_LISTENER_H
00022 #define IE_EXP_HTML_LISTENER_H
00023
00024
00025 #include <vector>
00026 #include <string>
00027
00028
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 &,
00083 const UT_UTF8String &,
00084 const UT_UTF8String &) = 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 virtual void insertLineFeed(void) = 0;
00150 };
00151
00152
00153 struct ListInfo
00154 {
00155 const gchar *szId;
00156 UT_uint32 iLevel;
00157 UT_uint32 iItemCount;
00158 };
00159
00164 class IE_Exp_HTML_Listener : public PL_Listener {
00165 public:
00166 IE_Exp_HTML_Listener(PD_Document *pDocument,
00167 IE_Exp_HTML_DataExporter *pDataExporter,
00168 IE_Exp_HTML_StyleTree *pStyleTree,
00169 IE_Exp_HTML_NavigationHelper *pNavigationHelper,
00170 IE_Exp_HTML_ListenerImpl *pListenerImpl,
00171 const UT_UTF8String &filename);
00172
00173 virtual bool populate(fl_ContainerLayout* sfh,
00174 const PX_ChangeRecord * pcr);
00175
00176 virtual bool populateStrux(pf_Frag_Strux* sdh,
00177 const PX_ChangeRecord * pcr,
00178 fl_ContainerLayout* * psfh);
00179
00180 virtual bool endOfDocument();
00181
00182 virtual bool change(fl_ContainerLayout* sfh,
00183 const PX_ChangeRecord * pcr);
00184
00185 virtual bool insertStrux(fl_ContainerLayout* sfh,
00186 const PX_ChangeRecord * pcr,
00187 pf_Frag_Strux* sdh,
00188 PL_ListenerId lid,
00189 void (*pfnBindHandles) (pf_Frag_Strux* sdhNew,
00190 PL_ListenerId lid,
00191 fl_ContainerLayout* sfhNew));
00192 void insertLineFeed(void);
00193
00194 virtual bool signal(UT_uint32 iSignal);
00195
00196 void set_EmbedCSS(bool bEmbed = true)
00197 { m_bEmbedCss = bEmbed; }
00198 void set_EmbedImages(bool bEmbed = true)
00199 { m_bEmbedImages = bEmbed; }
00200 void set_SplitDocument(bool bSplit = true)
00201 { m_bSplitDocument = bSplit; }
00202 void set_RenderMathMLToPng (bool bRender = true)
00203 { m_bRenderMathToPng = bRender; }
00204 bool get_HasMathML() const
00205 { return m_bHasMathMl; }
00206 private:
00207 const gchar* _getObjectKey(const PT_AttrPropIndex& api,
00208 const gchar* key);
00209 virtual bool _beginOfDocument(const PT_AttrPropIndex& api);
00210 void _outputData(const UT_UCSChar* pData, UT_uint32 length);
00211 void _openSpan(PT_AttrPropIndex api);
00212 void _closeSpan();
00213
00214 void _openHeading(PT_AttrPropIndex api, size_t level,
00215 const gchar *szStyleName = NULL);
00216 void _closeHeading();
00217
00218 void _openBlock(PT_AttrPropIndex api);
00219 void _closeBlock();
00220
00221 void _openSection(PT_AttrPropIndex api, bool recursiveCall = false);
00222 void _closeSection(bool recursiveCall = false);
00223
00224 void _openField(const PX_ChangeRecord_Object* pcro, PT_AttrPropIndex api);
00225 void _closeField();
00226
00227 void _openTable(PT_AttrPropIndex api, bool recursiveCall = false);
00228 void _closeTable(bool recursiveCall = false);
00229
00230 void _openRow(PT_AttrPropIndex api, bool recursiveCall = false);
00231 void _closeRow(bool recursiveCall = false);
00232
00233 void _openCell(PT_AttrPropIndex api, bool recursiveCall = false);
00234 void _closeCell(bool recursiveCall = false);
00235
00236 void _openList(PT_AttrPropIndex api, bool recursiveCall = false);
00237 void _closeList(bool recursiveCall = false);
00238 void _closeLists();
00239
00240 void _openListItem(bool recursiveCall = false);
00241 void _closeListItem(bool recursiveCall = false);
00242
00243 void _openFootnote(PT_AttrPropIndex api);
00244 void _closeFootnote();
00245
00246 void _openEndnote(PT_AttrPropIndex api);
00247 void _closeEndnote();
00248
00249 void _openAnnotation(PT_AttrPropIndex api);
00250 void _closeAnnotation();
00251
00252 void _openFrame(PT_AttrPropIndex api, const PX_ChangeRecord* pcr);
00253 void _closeFrame();
00254
00255 void _openBookmark(PT_AttrPropIndex api);
00256 void _closeBookmark();
00257
00258 void _openHyperlink(PT_AttrPropIndex api);
00259 void _closeHyperlink();
00260
00261 void _openDocument();
00262 void _closeDocument();
00263
00264 void _openHead();
00265 void _closeHead();
00266
00267 void _openBody();
00268 void _closeBody();
00269
00270 void _openTextbox(PT_AttrPropIndex api);
00271 void _closeTextbox();
00272
00273 void _insertPosImage (PT_AttrPropIndex api);
00274 void _insertDTD();
00275 void _insertLinks();
00276 void _insertTitle();
00277 void _insertMeta();
00278 void _insertImage(PT_AttrPropIndex api);
00279 void _insertEmbeddedImage(PT_AttrPropIndex api);
00280 void _insertMath(PT_AttrPropIndex api);
00281 void _insertTOC(PT_AttrPropIndex api);
00282 void _insertEndnotes();
00283 void _insertFootnotes();
00284 void _insertAnnotations();
00285 void _insertStyle();
00286 void _insertLinkToStyle();
00287 void _handleAnnotationData(PT_AttrPropIndex api);
00288 void _handleImage(PT_AttrPropIndex api, const gchar *szDataId,
00289 bool bIsPositioned);
00290 void _makeStylesheet(PT_AttrPropIndex api);
00291 void _setCellWidthInches();
00292 void _fillColWidthsVector();
00293
00294 bool m_bFirstWrite;
00295 bool m_bInSpan;
00296 bool m_bInBlock;
00297 bool m_bInBookmark;
00298 bool m_bInHyperlink;
00299 bool m_bInSection;
00300 bool m_bInAnnotation;
00301 bool m_bInAnnotationSection;
00302 bool m_bInEndnote;
00303 bool m_bInFootnote;
00304 bool m_bInHeading;
00305 bool m_bInTextbox;
00306 bool m_bSkipSection;
00307 fd_Field* m_pCurrentField;
00308 UT_UTF8String m_currentFieldType;
00309 UT_UTF8String m_bookmarkName;
00310 PT_AttrPropIndex m_apiLastSpan;
00311
00312 UT_sint32 m_iInTable;
00313 UT_sint32 m_iInRow;
00314 UT_sint32 m_iInCell;
00315
00316 bool m_bFirstRow;
00317 PD_Document *m_pDocument;
00318 IE_Exp_HTML_ListenerImpl *m_pCurrentImpl;
00319 ie_Table m_tableHelper;
00320
00321 UT_GenericVector<ListInfo> m_listInfoStack;
00322 std::vector<UT_UTF8String> m_endnotes;
00323 std::vector<UT_UTF8String> m_footnotes;
00324 std::vector<UT_UTF8String> m_annotationTitles;
00325 std::vector<UT_UTF8String> m_annotationAuthors;
00326 std::vector<UT_UTF8String> m_annotationContents;
00327
00328 IE_Exp_HTML_DataExporter *m_pDataExporter;
00329
00330 bool m_bEmbedCss;
00331 bool m_bEmbedImages;
00332 bool m_bRenderMathToPng;
00333 bool m_bSplitDocument;
00334 bool m_bScaleUnits;
00335 bool m_bAbsUnits;
00336 UT_UTF8String m_filename;
00337
00338 IE_Exp_HTML_StyleTree *m_pStyleTree;
00339 IE_Exp_HTML_NavigationHelper *m_pNavigationHelper;
00340 UT_UTF8String m_stylesheet;
00341 UT_uint32 m_iHeadingCount;
00342
00343 double m_dPageWidthInches;
00344 double m_dSecLeftMarginInches;
00345 double m_dSecRightMarginInches;
00346 double m_dSecTopMarginInches;
00347 double m_dSecBottomMarginInches;
00348 double m_dCellWidthInches;
00349 UT_GenericVector<double> m_vecDWidths;
00350 bool m_bHasMathMl;
00351 };
00352
00353
00354
00355 #endif
00356