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 #ifndef IE_IMP_MSWRITE_H
00023 #define IE_IMP_MSWRITE_H
00024
00025 #include <string>
00026
00027 #include "ie_impexp_MSWrite.h"
00028 #include "ie_imp.h"
00029 #include "ut_bytebuf.h"
00030 #include "ut_mbtowc.h"
00031 #include "ut_string_class.h"
00032
00033 typedef struct
00034 {
00035 short ffid;
00036 const char *name;
00037 const char *codepage;
00038 } wri_font;
00039
00040 class IE_Imp_MSWrite_Sniffer : public IE_ImpSniffer
00041 {
00042 public:
00043 IE_Imp_MSWrite_Sniffer();
00044 virtual ~IE_Imp_MSWrite_Sniffer() {}
00045 virtual bool getDlgLabels(const char **szDesc, const char **szSuffixList, IEFileType *ft);
00046 virtual const IE_SuffixConfidence *getSuffixConfidence();
00047 virtual const IE_MimeConfidence *getMimeConfidence() { return 0; }
00048 virtual UT_Confidence_t recognizeContents(const char *szBuf, UT_uint32 iNumbytes);
00049 virtual UT_Error constructImporter(PD_Document *pDocument, IE_Imp **ppie);
00050
00051 private:
00052 friend class IE_Imp;
00053 };
00054
00055 class IE_Imp_MSWrite : public IE_Imp
00056 {
00057 public:
00058 IE_Imp_MSWrite(PD_Document *pDocument);
00059 ~IE_Imp_MSWrite();
00060
00061 protected:
00062 virtual UT_Error _loadFile(GsfInput *input);
00063
00064 private:
00065 enum pap_t {All, Header, Footer};
00066 enum hdrftr_t {headerfirst, header, footerfirst, footer};
00067
00068 GsfInput *mFile;
00069 UT_ByteBufPtr mData;
00070 UT_UCS4String mText;
00071
00072 wri_struct *wri_file_header;
00073 wri_struct *wri_picture_header;
00074 wri_struct *wri_ole_header;
00075
00076 UT_UCS4_mbtowc charconv;
00077
00078 std::string mDefaultCodepage;
00079 int xaLeft, xaRight;
00080 bool hasHeader, hasFooter, page1Header, page1Footer;
00081 wri_font *wri_fonts;
00082 int wri_fonts_count;
00083 unsigned int pic_nr;
00084 bool lf;
00085
00086 UT_Error parse_file();
00087 bool read_ffntb();
00088 bool read_sep();
00089 bool read_pap(pap_t process);
00090 bool read_txt(int from, int to);
00091 bool read_pic(int from, int size);
00092 void _append_hdrftr(hdrftr_t which);
00093
00094 void free_ffntb();
00095 const char *get_codepage(const char *facename, int *facelen) const;
00096 void set_codepage(const char *charset);
00097 void translate_char(const UT_Byte ch, UT_UCS4String &buf);
00098 };
00099
00100 #endif