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

ie_imp_MHT.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiWord: ie_imp_MHT - plugin for Multipart [X]HTML
00004  *
00005  * Copyright (C) 2002 Francis James Franklin <fjf@alinameridon.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 
00023 
00024 #ifndef IE_IMP_MHT_H
00025 #define IE_IMP_MHT_H
00026 
00027 #include <stdio.h>
00028 
00029 extern "C" {
00030 #include <eps/eps.h>
00031 }
00032 
00033 #include "ut_string.h"
00034 
00035 #include "ie_imp_XHTML.h"
00036 
00037 #define IE_MIMETYPE_RELATED         "multipart/related"
00038 
00039 //class UT_ByteBuf;
00040 //class UT_StringPtrMap;
00041 //class UT_Vector;
00042 
00043 class UT_Multipart
00044 {
00045     enum ContentTransferEncoding
00046     {
00047         cte_other,
00048         cte_base64,
00049         cte_quoted
00050     };
00051     enum ContentType
00052     {
00053         ct_other,
00054         ct_image,
00055         ct_html4,
00056         ct_xhtml
00057     };
00058 
00059 public:
00060     UT_Multipart ();
00061 
00062     ~UT_Multipart ();
00063 
00064     bool                insert (const char * name, const char * value);
00065     const char *        lookup (const char * name);
00066 
00067     bool                append (const char * buffer, UT_uint32 length);
00068 
00069     const UT_ByteBuf *  getBuffer () const { return m_buf; }
00070     UT_ByteBuf *        detachBuffer ();
00071 
00072     void                clear ();
00073 
00074     const char *        contentLocation () const { return m_location; }
00075     const char *        contentID ()       const { return m_id; }
00076     const char *        contentType ()     const { return m_type; }
00077     const char *        contentEncoding () const { return m_encoding; }
00078 
00079     bool                isBase64 () const { return (m_cte == cte_base64); }
00080     bool                isQuoted () const { return (m_cte == cte_quoted); }
00081 
00082     bool                isImage () const { return (m_ct == ct_image); }
00083     bool                isHTML4 () const { return (m_ct == ct_html4); }
00084     bool                isXHTML () const { return (m_ct == ct_xhtml); }
00085 
00086 private:
00087     bool                append_Base64 (const char * buffer, UT_uint32 length);
00088     bool                append_Quoted (const char * buffer, UT_uint32 length);
00089 
00090     UT_StringPtrMap *   m_map;
00091     UT_ByteBuf *        m_buf;
00092 
00093     const char *        m_location;
00094     const char *        m_id;
00095     const char *        m_type;
00096     const char *        m_encoding;
00097 
00098     ContentTransferEncoding m_cte;
00099     ContentType             m_ct;
00100 
00101     size_t              m_b64length;
00102     char                m_b64buffer[80];
00103 };
00104 
00105 class IE_Imp_MHT_Sniffer : public IE_ImpSniffer
00106 {
00107     friend class IE_Imp;
00108 
00109 public:
00110     IE_Imp_MHT_Sniffer ();
00111     ~IE_Imp_MHT_Sniffer () { }
00112 
00113     virtual const IE_SuffixConfidence * getSuffixConfidence ();
00114 
00115     virtual const IE_MimeConfidence * getMimeConfidence ();
00116 
00117     UT_Confidence_t recognizeContents (const char * szBuf, UT_uint32 iNumbytes);
00118 
00119     bool getDlgLabels (const char ** szDesc, const char ** szSuffixList, IEFileType * ft);
00120 
00121     UT_Error constructImporter (PD_Document * pDocument, IE_Imp ** ppie);
00122 };
00123 
00124 class IE_Imp_MHT : public IE_Imp_XHTML
00125 {
00126 public:
00127     IE_Imp_MHT (PD_Document * pDocument);
00128 
00129     ~IE_Imp_MHT ();
00130 
00131     UT_Error        importFile (const char * szFilename);
00132 
00133 private:
00134     FG_Graphic *    importImage (const gchar * szSrc);
00135 
00136     UT_Error        importXHTML (const char * szFilename);
00137     UT_Error        importHTML4 (const char * szFilename);
00138 
00139     UT_Multipart *  importMultipart ();
00140 
00141     UT_Multipart *  m_document;
00142     UT_Vector *     m_parts;
00143 
00144     eps_t * m_eps;
00145 };
00146 
00147 class MultiReader : public UT_XML::Reader
00148 {
00149 public:
00150     MultiReader (const UT_Byte * buffer, UT_uint32 length);
00151     virtual ~MultiReader ();
00152 
00153     virtual bool      openFile (const char * szFilename);
00154     virtual UT_uint32 readBytes (char * buffer, UT_uint32 length);
00155     virtual void      closeFile (void);
00156 
00157 private:
00158     const UT_Byte * const   m_buffer;
00159     const UT_Byte *         m_bufptr;
00160     const UT_uint32         m_length;
00161 };
00162 
00163 #endif /* IE_IMP_MHT_H */

Generated on Sun May 27 2012 for AbiWord by  doxygen 1.7.1