00001 #ifndef __CExpander_h
00002 #define __CExpander_h
00003
00004 #ifndef _WINDOWS
00005 #include <unistd.h>
00006 #endif
00007 #include <stdio.h>
00008 #include <time.h>
00009 #include <sys/stat.h>
00010 #include <qmessagebox.h>
00011 #include "config.h"
00012 #include "StyleConsts.h"
00013 #include "Markups.h"
00014 #include "names.h"
00015 #include "linktype.h"
00016
00017 class QImage;
00018 class Bkmk;
00019 class QString;
00020
00021 template<class T>
00022 class CList;
00023
00024 class CCharacterSource
00025 {
00026 public:
00027 virtual QString getTableAsHtml(unsigned long loc) = 0;
00028 virtual void getch(tchar&, CStyle&, unsigned long&) = 0;
00029 virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0;
00030 virtual void locate(unsigned int n) = 0;
00031 virtual bool findanchor(const QString& nm) = 0;
00032 virtual void saveposn(const QString& f, size_t posn) = 0;
00033 virtual void writeposn(const QString& f, size_t posn) = 0;
00034 virtual linkType forward(QString& f, size_t& loc) = 0;
00035 virtual linkType back(QString& f, size_t& loc) = 0;
00036 virtual bool hasnavigation() = 0;
00037 virtual int getwidth() = 0;
00038 virtual QImage* getPicture(unsigned long) = 0;
00039 virtual QImage* getPicture(const QString& href) = 0;
00040 virtual bool getFile(const QString& href, const QString& nm) = 0;
00041 virtual QString about() = 0;
00042 virtual unsigned long startSection() = 0;
00043 };
00044
00045 class CExpander_Interface
00046 {
00047 public:
00048 #ifdef USEQPE
00049 virtual void suspend() = 0;
00050 virtual void unsuspend() = 0;
00051 #endif
00052 virtual QString about() = 0;
00053 virtual size_t getHome() = 0;
00054
00055
00056 virtual int openfile(const char *src) = 0;
00057
00058 virtual unsigned int locate() = 0;
00059 virtual void locate(unsigned int n) = 0;
00060 virtual bool hasrandomaccess() = 0;
00061 virtual void sizes(unsigned long& file, unsigned long& text) = 0;
00062 virtual CList<Bkmk>* getbkmklist() { return NULL; }
00063 virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos) = 0;
00064 virtual int getch() = 0;
00065 virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) = 0;
00066 virtual MarkupType PreferredMarkup() = 0;
00067 virtual void saveposn(size_t posn) {}
00068 virtual void writeposn(size_t posn) {}
00069 virtual linkType forward(size_t& loc) { return eNone; }
00070 virtual linkType back(size_t& loc) { return eNone; }
00071 virtual bool hasnavigation() { return false; }
00072 virtual unsigned long startSection() = 0;
00073 virtual unsigned long endSection() = 0;
00074 virtual void start2endSection() = 0;
00075 virtual QImage* getPicture(unsigned long tgt) { return NULL; }
00076 virtual void setContinuous(bool _b) = 0;
00077 #ifdef USEQPE
00078 virtual void suspend(FILE*& fin) = 0;
00079 virtual void unsuspend(FILE*& fin) = 0;
00080 #endif
00081 virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0;
00082 virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0;
00083 virtual void setwidth(int w) = 0;
00084
00085
00086 virtual int getwidth() = 0;
00087 virtual QImage* getPicture(const QString& href) = 0;
00088 virtual bool getFile(const QString& href, const QString& nm) = 0;
00089 virtual bool findanchor(const QString& nm) = 0;
00090 virtual QString getTableAsHtml(unsigned long loc) { return QString(""); }
00091 };
00092
00093 class CExpander : public CExpander_Interface
00094 {
00095 protected:
00096 size_t m_homepos;
00097 bool m_continuous;
00098 char* fname;
00099 bool bSuspended;
00100 size_t suspos;
00101 time_t sustime;
00102 int m_scrWidth;
00103 unsigned long m_currentstart, m_currentend;
00104 public:
00105 #ifdef USEQPE
00106 virtual void suspend() = 0;
00107 virtual void unsuspend() = 0;
00108 #endif
00109 size_t getHome();
00110 CExpander();
00111 virtual ~CExpander();
00112 int openfile(const char *src);
00113 virtual int OpenFile(const char *src) = 0;
00114 virtual unsigned int locate() = 0;
00115 virtual void locate(unsigned int n) = 0;
00116 virtual bool hasrandomaccess() = 0;
00117 virtual void sizes(unsigned long& file, unsigned long& text) = 0;
00118 virtual CList<Bkmk>* getbkmklist() { return NULL; }
00119 virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos);
00120 virtual int getch() = 0;
00121 virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm);
00122 virtual MarkupType PreferredMarkup() = 0;
00123 virtual void saveposn(size_t posn) {}
00124 virtual void writeposn(size_t posn) {}
00125 virtual linkType forward(size_t& loc) { return eNone; }
00126 virtual linkType back(size_t& loc) { return eNone; }
00127 virtual bool hasnavigation() { return false; }
00128 unsigned long startSection();
00129 unsigned long endSection();
00130 virtual void start2endSection();
00131 virtual QImage* getPicture(unsigned long tgt) { return NULL; }
00132 void setContinuous(bool _b) { m_continuous = _b; }
00133 #ifdef USEQPE
00134 virtual void suspend(FILE*& fin);
00135 virtual void unsuspend(FILE*& fin);
00136 #endif
00137 virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen);
00138 virtual void putSaveData(unsigned char*& src, unsigned short& srclen);
00139 void setwidth(int w)
00140 {
00141 m_scrWidth = w;
00142 }
00143 int getwidth()
00144 {
00145 return m_scrWidth;
00146 }
00147
00148
00149 virtual QImage* getPicture(const QString& href) { return NULL; }
00150 virtual bool getFile(const QString& href, const QString& nm) { return false; }
00151 virtual bool findanchor(const QString& nm)
00152 {
00153 return false;
00154 }
00155 };
00156 #endif