• 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., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 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_StringPtrMap;
00040 //class UT_Vector;
00041 
00042 class UT_Multipart
00043 {
00044     enum ContentTransferEncoding
00045     {
00046         cte_other,
00047         cte_base64,
00048         cte_quoted
00049     };
00050     enum ContentType
00051     {
00052         ct_other,
00053         ct_image,
00054         ct_html4,
00055         ct_xhtml
00056     };
00057 
00058 public:
00059     UT_Multipart ();
00060 
00061     ~UT_Multipart ();
00062 
00063     bool                insert (const char * name, const char * value);
00064     const char *        lookup (const char * name);
00065 
00066     bool                append (const char * buffer, UT_uint32 length);
00067 
00068     const UT_ConstByteBufPtr & getBuffer() const { return m_buf; }
00069     UT_ByteBufPtr && detachBuffer();
00070 
00071     void                clear ();
00072 
00073     const char *        contentLocation () const { return m_location; }
00074     const char *        contentID ()       const { return m_id; }
00075     const char *        contentType ()     const { return m_type; }
00076     const char *        contentEncoding () const { return m_encoding; }
00077 
00078     bool                isBase64 () const { return (m_cte == cte_base64); }
00079     bool                isQuoted () const { return (m_cte == cte_quoted); }
00080 
00081     bool                isImage () const { return (m_ct == ct_image); }
00082     bool                isHTML4 () const { return (m_ct == ct_html4); }
00083     bool                isXHTML () const { return (m_ct == ct_xhtml); }
00084 
00085 private:
00086     bool                append_Base64 (const char * buffer, UT_uint32 length);
00087     bool                append_Quoted (const char * buffer, UT_uint32 length);
00088 
00089     UT_StringPtrMap *   m_map;
00090     UT_ByteBufPtr       m_buf;
00091 
00092     const char *        m_location;
00093     const char *        m_id;
00094     const char *        m_type;
00095     const char *        m_encoding;
00096 
00097     ContentTransferEncoding m_cte;
00098     ContentType             m_ct;
00099 
00100     size_t              m_b64length;
00101     char                m_b64buffer[80];
00102 };
00103 
00104 class IE_Imp_MHT_Sniffer : public IE_ImpSniffer
00105 {
00106     friend class IE_Imp;
00107 
00108 public:
00109     IE_Imp_MHT_Sniffer ();
00110     ~IE_Imp_MHT_Sniffer () { }
00111 
00112     virtual const IE_SuffixConfidence * getSuffixConfidence ();
00113 
00114     virtual const IE_MimeConfidence * getMimeConfidence ();
00115 
00116     UT_Confidence_t recognizeContents (const char * szBuf, UT_uint32 iNumbytes);
00117 
00118     bool getDlgLabels (const char ** szDesc, const char ** szSuffixList, IEFileType * ft);
00119 
00120     UT_Error constructImporter (PD_Document * pDocument, IE_Imp ** ppie);
00121 };
00122 
00123 class IE_Imp_MHT : public IE_Imp_XHTML
00124 {
00125 public:
00126     IE_Imp_MHT (PD_Document * pDocument);
00127 
00128     ~IE_Imp_MHT ();
00129 
00130     UT_Error        importFile (const char * szFilename);
00131 
00132 private:
00133     FG_ConstGraphicPtr  importImage(const gchar * szSrc);
00134 
00135     UT_Error        importXHTML (const char * szFilename);
00136     UT_Error        importHTML4 (const char * szFilename);
00137 
00138     UT_Multipart *  importMultipart ();
00139 
00140     UT_Multipart *  m_document;
00141     UT_Vector *     m_parts;
00142 
00143     eps_t * m_eps;
00144 };
00145 
00146 class MultiReader : public UT_XML::Reader
00147 {
00148 public:
00149     MultiReader (const UT_Byte * buffer, UT_uint32 length);
00150     virtual ~MultiReader ();
00151 
00152     virtual bool      openFile (const char * szFilename);
00153     virtual UT_uint32 readBytes (char * buffer, UT_uint32 length);
00154     virtual void      closeFile (void);
00155 
00156 private:
00157     const UT_Byte * const   m_buffer;
00158     const UT_Byte *         m_bufptr;
00159     const UT_uint32         m_length;
00160 };
00161 
00162 #endif /* IE_IMP_MHT_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1