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

ie_mailmerge.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 2003 Dom Lachowicz
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 #ifndef IE_MAILMERGE_H
00021 #define IE_MAILMERGE_H
00022 
00023 #include "ut_types.h"
00024 #include "ut_hash.h"
00025 #include "pd_Document.h"
00026 
00027 typedef UT_sint32 IEMergeType;
00028 #define IEMT_Unknown ((IEMergeType)-1)
00029 
00030 class IE_MailMerge;
00031 
00032 class ABI_EXPORT IE_MergeSniffer
00033 {
00034   friend class IE_MailMerge;
00035 
00036 public:
00037 
00038     virtual ~IE_MergeSniffer();
00039 
00040     // these you get for free
00041     inline bool supportsFileType (IEMergeType type) {return m_type == type;}
00042     inline IEMergeType getFileType() const {return m_type;}
00043 
00044     // these you must override these next methods!!!
00045 
00051     virtual UT_Confidence_t recognizeContents (const char * szBuf,
00052                                                UT_uint32 iNumbytes) = 0;
00058     virtual UT_Confidence_t recognizeSuffix (const char * szSuffix) = 0;
00059 
00060     virtual bool getDlgLabels (const char ** szDesc,
00061                                const char ** szSuffixList,
00062                                IEMergeType * ft) = 0;
00063 
00064     virtual UT_Error constructMerger (IE_MailMerge ** ppie) = 0;
00065 
00066 protected:
00067 
00068     IE_MergeSniffer() {}
00069 
00070 private:
00071 
00072     // only IE_MailMerge ever calls this
00073     inline void setFileType (IEMergeType type) {m_type = type;}
00074     IEMergeType m_type;
00075 };
00076 
00077 class ABI_EXPORT IE_MailMerge
00078 {
00079 
00080 public:
00081 
00082     virtual ~IE_MailMerge ();
00083 
00084     // constructs an importer of the right type based upon
00085     // either the filename or sniffing the file.  caller is
00086     // responsible for destroying the importer when finished
00087     // with it.
00088 
00089     virtual UT_Error    mergeFile(const char * szFilename) = 0;
00090     virtual UT_Error getHeaders (const char * szFilename, UT_Vector & out_vec) = 0;
00091 
00092     static IEMergeType  fileTypeForContents(const char * szBuf,
00093                                             UT_uint32 iNumbytes);
00094 
00095     static IEMergeType  fileTypeForSuffix(const char * szSuffix);
00096     static IEMergeType  fileTypeForDescription(const char * szSuffix);
00097 
00098     static IEMergeType fileTypeForSuffixes(const char * suffixList);
00099 
00100     static IE_MergeSniffer * snifferForFileType(IEMergeType ieft);
00101     static const char * suffixesForFileType(IEMergeType ieft);
00102     static const char * descriptionForFileType(IEMergeType ieft);
00103 
00104     static UT_Error constructMerger(const char * szFilename,
00105                                     IEMergeType ieft,
00106                                     IE_MailMerge ** ppie,
00107                                     IEMergeType * pieft = NULL);
00108 
00109     static bool     enumerateDlgLabels(UT_uint32 ndx,
00110                                        const char ** pszDesc,
00111                                        const char ** pszSuffixList,
00112                                        IEMergeType * ft);
00113 
00114     static UT_uint32    getMergerCount(void);
00115     static void registerMerger (IE_MergeSniffer * sniffer);
00116     static void unregisterMerger (IE_MergeSniffer * sniffer);
00117     static void unregisterAllMergers ();
00118 
00119     class ABI_EXPORT IE_MailMerge_Listener
00120     {
00121     public:
00122         virtual ~IE_MailMerge_Listener ()
00123             {
00124             }
00125 
00126         virtual PD_Document* getMergeDocument () const = 0;
00127         virtual bool fireUpdate () = 0;
00128 
00129     protected:
00130 
00131         IE_MailMerge_Listener ()
00132             {
00133             }
00134     };
00135 
00136     void setListener (IE_MailMerge_Listener * listener);
00137 
00138     const UT_GenericStringMap<UT_UTF8String *> & getCurrentMapping() const { return m_map; }
00139 
00140 protected:
00141 
00142     IE_MailMerge ();
00143 
00144     bool fireMergeSet ();
00145     void addMergePair (const UT_UTF8String & key,
00146                        const UT_UTF8String & value);
00147 
00148 private:
00149 
00150     IE_MailMerge_Listener * m_pListener;
00151     UT_GenericStringMap<UT_UTF8String *> m_map;
00152 };
00153 
00154 void IE_MailMerge_RegisterXP ();
00155 void IE_MailMerge_UnRegisterXP ();
00156 
00157 #endif

Generated on Tue May 21 2013 for AbiWord by  doxygen 1.7.1