00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef IE_IMP_APPLIX_H
00025 #define IE_IMP_APPLIX_H
00026
00027 #include <stdio.h>
00028 #include "ie_imp.h"
00029 #include "ut_mbtowc.h"
00030 #include "ut_growbuf.h"
00031 #include "ut_bytebuf.h"
00032
00033 class PD_Document;
00034
00035
00036
00037 class IE_Imp_Applix_Sniffer : public IE_ImpSniffer
00038 {
00039 friend class IE_Imp;
00040
00041 public:
00042 IE_Imp_Applix_Sniffer(const char * name);
00043 virtual ~IE_Imp_Applix_Sniffer() {}
00044
00045 virtual const IE_SuffixConfidence * getSuffixConfidence ();
00046 virtual const IE_MimeConfidence * getMimeConfidence ();
00047 virtual UT_Confidence_t recognizeContents (const char * szBuf,
00048 UT_uint32 iNumbytes);
00049 virtual bool getDlgLabels (const char ** szDesc,
00050 const char ** szSuffixList,
00051 IEFileType * ft);
00052 virtual UT_Error constructImporter (PD_Document * pDocument,
00053 IE_Imp ** ppie);
00054
00055 };
00056
00057 class IE_Imp_Applix : public IE_Imp
00058 {
00059 public:
00060 IE_Imp_Applix(PD_Document * pDocument);
00061 ~IE_Imp_Applix();
00062
00063 protected:
00064 virtual UT_Error _loadFile(GsfInput * fp);
00065 UT_Error _parseFile(GsfInput * fp);
00066 UT_Error _writeHeader(GsfInput * fp);
00067
00068 private:
00069 UT_GrowBuf m_textBuf;
00070 UT_UCS4_mbtowc m_mbtowc;
00071
00072
00073 typedef enum {
00074 APPLIX_T,
00075 GLOBALS_T,
00076 START_STYLES_T,
00077 END_STYLES_T,
00078 STYLE_T,
00079 COLOR_T,
00080 START_FLOW_T,
00081 END_FLOW_T,
00082 WP400_T,
00083 TEXT_T,
00084 PAGE_BREAK_T,
00085 PARA_T,
00086 START_VARS_T,
00087 END_VARS_T,
00088 VARIABLE_T,
00089 END_DOCUMENT_T,
00090 OBJECT_T,
00091 PICTURE_T,
00092 SECTION_T,
00093 MARKER_T,
00094 START_FIELD_T,
00095 END_FIELD_T,
00096 FIELD_VALUE_T,
00097 NOT_A_TAG,
00098 tag_Unknown
00099 } Applix_tag_t;
00100
00101
00102 typedef enum {
00103 axCtnNone,
00104 axCtnText,
00105 axCtnField,
00106 axCtnGlossary
00107 } Applix_content_t;
00108
00109
00110
00111 typedef enum {
00112 axCtxNone,
00113 axCtxDef,
00114 axCtxFlow,
00115 axCtxHdrFtr,
00116 axCtxFootnote,
00117 axCtxVar
00118 } Applix_context_t;
00119
00120 Applix_context_t m_axContext;
00121
00122 void _dispatchTag (Applix_tag_t tag, const char *buf, size_t len);
00123
00124 typedef struct {
00125 const char * name;
00126 Applix_tag_t tag;
00127 } Applix_mapping_t;
00128 static Applix_mapping_t axwords[];
00129 static Applix_tag_t s_name_2_tag (const char *name, size_t n);
00130 static Applix_tag_t s_getTagName(const char *str, size_t len);
00131 static short s_8bitsToUCS (const char *str, size_t len, UT_UCSChar * c);
00132 static short s_16bitsToUCS (const char *str, size_t len, UT_UCSChar * c);
00133 static short s_decodeToUCS (const char *str, size_t len, UT_UCSChar * c);
00134 bool _applixGetLine (const UT_ByteBufPtr & pBuf, GsfInput *fp);
00135 void _applixDecodeText (const char * buf, size_t len);
00136 void _applixNewPara (const char * buf, size_t len);
00137 void _applixPageBreak (const char * buf, size_t len);
00138 };
00139
00140 #endif