00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 00002 00003 /* AbiWord 00004 * Copyright (C) 1998-2000 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_ABIWORD_1_H 00024 #define IE_IMP_ABIWORD_1_H 00025 00026 #include <stdio.h> 00027 00028 /* pre-emptive dismissal; ut_types.h is needed by just about everything, 00029 * so even if it's commented out in-file that's still a lot of work for 00030 * the preprocessor to do... 00031 */ 00032 #ifndef UT_TYPES_H 00033 #include "ut_types.h" 00034 #endif 00035 #include "ut_hash.h" 00036 00037 #include "ie_imp_XML.h" 00038 00039 #include <list> 00040 #include <string> 00041 00042 00043 class PD_Document; 00044 00045 // The importer/reader for AbiWord file format version 1. 00046 00047 class ABI_EXPORT IE_Imp_AbiWord_1_Sniffer : public IE_ImpSniffer 00048 { 00049 friend class IE_Imp; 00050 00051 public: 00052 IE_Imp_AbiWord_1_Sniffer(); 00053 virtual ~IE_Imp_AbiWord_1_Sniffer() {} 00054 00055 virtual const IE_SuffixConfidence * getSuffixConfidence (); 00056 virtual const IE_MimeConfidence * getMimeConfidence (); 00057 virtual UT_Confidence_t recognizeContents (const char * szBuf, 00058 UT_uint32 iNumbytes); 00059 virtual bool getDlgLabels (const char ** szDesc, 00060 const char ** szSuffixList, 00061 IEFileType * ft); 00062 virtual UT_Error constructImporter (PD_Document * pDocument, 00063 IE_Imp ** ppie); 00064 00065 }; 00066 00067 class ABI_EXPORT IE_Imp_AbiWord_1 : public IE_Imp_XML 00068 { 00069 std::list<std::string> xmlidStackForTextMeta; 00070 std::map<std::string, std::string> xmlidMapForBookmarks; 00071 00072 public: 00073 IE_Imp_AbiWord_1(PD_Document * pDocument); 00074 00075 virtual ~IE_Imp_AbiWord_1(); 00076 00077 void startElement(const gchar *name, const gchar **atts); 00078 void endElement(const gchar *name); 00079 00080 virtual bool supportsLoadStylesOnly() {return true;} 00081 00082 protected: 00083 00084 static const std::string & _getDataItemName(const PP_PropertyVector & atts); 00085 static std::string _getDataItemMimeType(const PP_PropertyVector & atts); 00086 static bool _getDataItemEncoded(const PP_PropertyVector & atts); 00087 00088 bool _handleImage(const gchar ** atts); 00089 bool _handleResource(const gchar ** atts, bool isResource); 00090 00091 private: 00092 bool m_bWroteSection; 00093 bool m_bWroteParagraph; 00094 bool m_bDocHasLists; 00095 bool m_bDocHasPageSize; 00096 00097 UT_uint32 m_iInlineStart; 00098 00099 UT_GenericStringMap<UT_UTF8String *> * m_refMap; 00100 bool m_bAutoRevisioning; 00101 bool m_bInMath; 00102 bool m_bInEmbed; 00103 UT_uint32 m_iImageId; 00104 }; 00105 00106 #endif /* IE_IMP_ABIWORD_1_H */