Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef IE_IMP_MATHML_H
00025 #define IE_IMP_MATHML_H
00026
00027 #include <stdio.h>
00028 #include "ie_imp.h"
00029 #include "ut_mbtowc.h"
00030 #include "ut_vector.h"
00031 #include "ut_bytebuf.h"
00032 #include "pd_Document.h"
00033
00034 class ImportStream;
00035
00036 typedef struct {
00037 const char * szEntity;
00038 const char * szVal;
00039 } AbiMathViewEntityMapItem;
00040
00041 class IE_Imp_MathML_EntityTable
00042 {
00043 public:
00044 IE_Imp_MathML_EntityTable ();
00045
00046 ~IE_Imp_MathML_EntityTable ();
00047
00048 bool convert(const char * buffer, unsigned long length, const UT_ByteBufPtr & To) const;
00049
00050 private:
00051 mutable UT_GenericVector<AbiMathViewEntityMapItem *> m_vecEntityMap;
00052 };
00053
00054
00055
00056 class IE_Imp_MathML_Sniffer : public IE_ImpSniffer
00057 {
00058 friend class IE_Imp;
00059 friend class IE_Imp_MathML;
00060
00061 public:
00062 IE_Imp_MathML_Sniffer(const IE_Imp_MathML_EntityTable & EntityTable);
00063 virtual ~IE_Imp_MathML_Sniffer() {}
00064
00065 virtual const IE_SuffixConfidence * getSuffixConfidence ();
00066 virtual const IE_MimeConfidence * getMimeConfidence ();
00067 virtual UT_Confidence_t recognizeContents (const char * szBuf,
00068 UT_uint32 iNumbytes);
00069 const char * recognizeContentsType (const char * szBuf,
00070 UT_uint32 iNumbytes);
00071 virtual bool getDlgLabels (const char ** szDesc,
00072 const char ** szSuffixList,
00073 IEFileType * ft);
00074 virtual UT_Error constructImporter (PD_Document * pDocument,
00075 IE_Imp ** ppie);
00076
00077 protected:
00078 enum UCS2_Endian { UE_BigEnd = -1, UE_NotUCS = 0, UE_LittleEnd };
00079
00080 static bool _recognizeUTF8 (const char * szBuf,
00081 UT_uint32 iNumbytes);
00082 static UCS2_Endian _recognizeUCS2 (const char * szBuf,
00083 UT_uint32 iNumbytes,
00084 bool bDeep);
00085
00086 const IE_Imp_MathML_EntityTable * m_EntityTable;
00087 };
00088
00089
00090
00091 class IE_Imp_MathML : public IE_Imp
00092 {
00093 public:
00094 IE_Imp_MathML(PD_Document * pDocument, const IE_Imp_MathML_EntityTable & EntityTable);
00095 virtual ~IE_Imp_MathML();
00096
00097 virtual bool pasteFromBuffer(PD_DocumentRange * pDocRange,
00098 const unsigned char * pData, UT_uint32 lenData, const char * szEncoding = 0);
00099 const UT_ByteBufPtr & getByteBuf(void) const {return m_pByteBuf;}
00100
00101 protected:
00102 virtual UT_Error _loadFile(GsfInput * input);
00103 UT_Error _parseStream(ImportStream * pStream);
00104
00105 private:
00106 UT_ByteBufPtr m_pByteBuf;
00107
00108 const IE_Imp_MathML_EntityTable * m_EntityTable;
00109 };
00110
00111 #endif