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

ie_exp_Text.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 1998 AbiSource, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 
00021 #ifndef IE_EXP_TEXT_H
00022 #define IE_EXP_TEXT_H
00023 
00024 #include "ie_exp.h"
00025 #include "pl_Listener.h"
00026 #include "ut_wctomb.h"
00027 
00028 #define MY_MB_LEN_MAX 6
00029 
00030 class PD_Document;
00031 class Text_Listener;
00032 
00033 // The exporter/writer for Plain Text Files.
00034 
00035 class ABI_EXPORT IE_Exp_Text_Sniffer : public IE_ExpSniffer
00036 {
00037     friend class IE_Exp;
00038 
00039 public:
00040     IE_Exp_Text_Sniffer ();
00041     virtual ~IE_Exp_Text_Sniffer ();
00042 
00043     UT_Confidence_t supportsMIME (const char * szMIME);
00044 
00045     virtual bool recognizeSuffix (const char * szSuffix);
00046     virtual bool getDlgLabels (const char ** szDesc,
00047                                const char ** szSuffixList,
00048                                IEFileType * ft);
00049     virtual UT_Error constructExporter (PD_Document * pDocument,
00050                                         IE_Exp ** ppie);
00051 };
00052 
00053 // The exporter/writer for Plain Text Files with selectable encoding.
00054 
00055 class ABI_EXPORT IE_Exp_EncodedText_Sniffer : public IE_ExpSniffer
00056 {
00057     friend class IE_Exp;
00058 
00059 public:
00060     IE_Exp_EncodedText_Sniffer ();
00061     virtual ~IE_Exp_EncodedText_Sniffer ();
00062 
00063     virtual bool recognizeSuffix (const char * szSuffix);
00064     virtual bool getDlgLabels (const char ** szDesc,
00065                                const char ** szSuffixList,
00066                                IEFileType * ft);
00067     virtual UT_Error constructExporter (PD_Document * pDocument,
00068                                         IE_Exp ** ppie);
00069 };
00070 
00071 class ABI_EXPORT IE_Exp_Text : public IE_Exp
00072 {
00073 public:
00074     IE_Exp_Text(PD_Document * pDocument, bool bEncoded=false);
00075     IE_Exp_Text(PD_Document * pDocument, const char * encoding);
00076     virtual ~IE_Exp_Text();
00077 
00078 protected:
00079     virtual PL_Listener *   _constructListener(void);
00080     virtual UT_Error    _writeDocument(void);
00081     bool                _doEncodingDialog(const char *szEncoding);
00082     void                _setEncoding(const char *szEncoding);
00083 
00084  private:
00085     PL_Listener *       m_pListener;
00086     bool                m_bIsEncoded;
00087     const char *        m_szEncoding;
00088     bool m_bExplicitlySetEncoding;
00089     bool                m_bIs16Bit;
00090     bool                m_bUnicode;
00091     bool                m_bBigEndian;
00092     bool                m_bUseBOM;
00093 };
00094 
00096 // a private listener class to help us translate the document
00097 // into a text stream.
00099 
00100 class ABI_EXPORT Text_Listener : public PL_Listener
00101 {
00102 public:
00103     Text_Listener(PD_Document * pDocument,
00104                     IE_Exp_Text * pie,
00105                     bool bToClipboard = false,
00106                     const char *szEncoding = 0,
00107                     bool bIs16Bit = false,
00108                     bool m_bUnicode = false,
00109                     bool bUseBOM = false,
00110                     bool bBigEndian = false);
00111     virtual ~Text_Listener();
00112 
00113     virtual bool        populate(fl_ContainerLayout* sfh,
00114                                  const PX_ChangeRecord * pcr);
00115 
00116     virtual bool        populateStrux(pf_Frag_Strux* sdh,
00117                                       const PX_ChangeRecord * pcr,
00118                                       fl_ContainerLayout* * psfh);
00119 
00120     virtual bool        change(fl_ContainerLayout* sfh,
00121                                const PX_ChangeRecord * pcr);
00122 
00123     virtual bool        insertStrux(fl_ContainerLayout* sfh,
00124                                     const PX_ChangeRecord * pcr,
00125                                     pf_Frag_Strux* sdh,
00126                                     PL_ListenerId lid,
00127                                     void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00128                                                             PL_ListenerId lid,
00129                                                             fl_ContainerLayout* sfhNew));
00130 
00131     virtual bool        signal(UT_uint32 iSignal);
00132 
00133 protected:
00134     int         _wctomb(char * pC, int & length, UT_UCS4Char wc) { return m_wctomb.wctomb(pC,length,wc); }
00135     void                _genBOM(void);
00136     void                _genLineBreak(void);
00137     virtual void        _outputData(const UT_UCSChar * p, UT_uint32 length);
00138     void                _closeBlock(void);
00139     void                _handleDirMarker(PT_AttrPropIndex apiSpan);
00140 
00141  private:
00142     enum _dirOverride
00143     {
00144         DO_LTR,
00145         DO_RTL,
00146         DO_UNSET
00147     };
00148 
00149 
00150 
00151     PD_Document *       m_pDocument;
00152     IE_Exp_Text *       m_pie;
00153     UT_Wctomb           m_wctomb;
00154     char                m_mbBOM[MY_MB_LEN_MAX];
00155     int                 m_iBOMLen;
00156     char                m_mbLineBreak[MY_MB_LEN_MAX*2];
00157     int                 m_iLineBreakLen;
00158     bool                m_bInBlock;
00159     bool                m_bFirstWrite;
00160     const char *        m_szEncoding;
00161     bool                m_bIs16Bit;
00162     bool                m_bBigEndian;
00163     bool                m_bUnicode;
00164     bool                m_bUseBOM;
00165     bool                m_bBreakExtra;
00166     _dirOverride        m_eDirOverride;
00167     _dirOverride        m_eDirMarkerPending;
00168     _dirOverride        m_eSectionDir;
00169     _dirOverride        m_eDocDir;
00170 };
00171 
00172 #endif /* IE_EXP_TEXT_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1