00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 00002 00003 /* AbiWord 00004 * Copyright (C) 1998 AbiSource, Inc. 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 00023 #ifndef IE_IMP_PALMDOC_H 00024 #define IE_IMP_PALMDOC_H 00025 00026 #include <stdio.h> 00027 #include "ie_imp.h" 00028 #include "ie_impexp_Palm.h" 00029 00030 #include"ut_mbtowc.h" 00031 class PD_Document; 00032 00033 // The importer/reader for Palm Doc Database Files. 00034 00035 class IE_Imp_PalmDoc_Sniffer : public IE_ImpSniffer 00036 { 00037 friend class IE_Imp; 00038 00039 public: 00040 IE_Imp_PalmDoc_Sniffer(const char * name); 00041 virtual ~IE_Imp_PalmDoc_Sniffer() {} 00042 00043 virtual const IE_SuffixConfidence * getSuffixConfidence (); 00044 virtual const IE_MimeConfidence * getMimeConfidence (); 00045 virtual UT_Confidence_t recognizeContents (const char * szBuf, 00046 UT_uint32 iNumbytes); 00047 virtual bool getDlgLabels (const char ** szDesc, 00048 const char ** szSuffixList, 00049 IEFileType * ft); 00050 virtual UT_Error constructImporter (PD_Document * pDocument, 00051 IE_Imp ** ppie); 00052 00053 }; 00054 00055 class IE_Imp_PalmDoc : public IE_Imp 00056 { 00057 public: 00058 IE_Imp_PalmDoc(PD_Document * pDocument); 00059 ~IE_Imp_PalmDoc(); 00060 00061 protected: 00062 virtual UT_Error _loadFile(GsfInput * fp); 00063 UT_Error _parseFile(GsfInput * fp); 00064 UT_Error _writeHeader(GsfInput * fp); 00065 00066 void _selectSwap(); 00067 void _uncompress( buffer* ); 00068 Byte* _mem_find( Byte *t, int t_len, Byte *m, int m_len ); 00069 Word _swap_Word( Word ); 00070 DWord _swap_DWord( DWord ); 00071 00072 private: 00073 00074 UT_UCS4_mbtowc m_Mbtowc; 00075 GsfInput * m_pdfp; 00076 pdb_header m_header; 00077 doc_record0 m_rec0; 00078 unsigned long m_index; 00079 DWord m_recOffset; 00080 UT_uint32 m_numRecords; 00081 DWord m_fileSize; 00082 buffer * m_buf; 00083 UT_uint32 m_bufLen; 00084 UT_uint32 m_bufPosition; 00085 bool m_littlendian; 00086 }; 00087 00088 #endif /* IE_IMP_PALMDOC_H */