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

ie_imp_Applix.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */
00002 
00003 /* AbiWord
00004  * Copyright (C) 1998-2001 AbiSource, Inc.
00005  * Copyright (C) 2001 Hubert Figuiere
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 USA.
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 // The importer/reader for Applix Word files
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     // the applix tags that i know about && maybe handle
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     // container
00102     typedef enum {
00103         axCtnNone,
00104         axCtnText,
00105         axCtnField,
00106         axCtnGlossary
00107     } Applix_content_t;
00108 
00109     // context in the file
00110     // because T tag have different meanings.
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     // tokenizer helpers
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 /* IE_IMP_APPLIX_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1