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

ie_imp_MathML.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  * Copyright (C) 2004 Martin Sevior <msevior@physics.unimelb.edu.au>
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_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 // The importer/reader for MathML Files.
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 // The importer/reader for MathML Files.
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 /* IE_IMP_MATHML_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1