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

ie_imp_MSWrite.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 1998 AbiSource, Inc.
00003  * Copyright (C) 2000 Hubert Figuiere
00004  * Copyright (C) 2010-2011 Ingo Brueckl
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
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;             // unused
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;      // complete data buffer as extracted out of the file
00070     UT_UCS4String mText;   // text buffer
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;   // Windows codepage to unicode conversion
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

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1