00001 #ifndef __PLUCKER_BASE_H
00002 #define __PLUCKER_BASE_H
00003
00004 #include "CExpander.h"
00005 #include <zlib.h>
00006 #include "ztxt.h"
00007 #include "pdb.h"
00008 #include "CBuffer.h"
00009 #include "my_list.h"
00010 #include "Navigation.h"
00011 #include "hrule.h"
00012
00013 struct CPlucker_record0
00014 {
00015 UInt16 uid;
00016 UInt16 version;
00017 UInt16 nRecords;
00018 };
00019
00020 struct CPluckerbkmk
00021 {
00022 UInt32 offset;
00023 tchar title[MAX_BMRK_LENGTH];
00024 };
00025
00026 #ifdef LOCALPICTURES
00027 class QScrollView;
00028 class QWidget;
00029 #endif
00030 class QString;
00031
00032 class CPlucker_base : public Cpdb
00033 {
00034 protected:
00035 static const UInt8 continuation_bit;
00036 virtual void setbuffersize() = 0;
00037 virtual void GetHeader(UInt16&, UInt16&, UInt32&, UInt8&, UInt8&) = 0;
00038 virtual int HeaderSize() = 0;
00039 unsigned short finduid(unsigned short);
00040 char* geturl(UInt16);
00041 void Expand(UInt32, UInt8, UInt8*, UInt32);
00042 CList<unsigned long> visited;
00043 bool m_lastIsBreak;
00044 #ifdef LOCALPICTURES
00045 QScrollView* m_viewer;
00046 QWidget* m_picture;
00047 #endif
00048 size_t textlength, m_lastBreak, m_offset;
00049 UInt16 uid;
00050 int m_nextPara, m_nextParaIndex;
00051 CBufferFace<UInt16> m_ParaOffsets;
00052 CBufferFace<UInt16> m_ParaAttrs;
00053 UInt16 m_nParas;
00054 CStyle mystyle;
00055
00056 UInt32 buffersize;
00057 UInt32 compressedbuffersize;
00058 UInt32 buffercontent;
00059 UInt8* expandedtextbuffer;
00060 UInt8* compressedtextbuffer;
00061
00062
00063 size_t bufferpos;
00064 int bufferrec;
00065 CPlucker_record0 hdr0;
00066 bool m_bufferisreserved;
00067 size_t currentpos;
00068 bool expand(int);
00069
00070 static size_t UnDoc(UInt8*, size_t, UInt8*, size_t);
00071
00072 size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t);
00073
00074 #ifdef LOCALPICTURES
00075 void showimg(UInt16 tgt);
00076 #endif
00077 QImage* getimg(UInt16 tgt);
00078 QImage* expandimg(UInt16 tgt, bool border=false);
00079 void home();
00080 virtual int bgetch() = 0;
00081 CNavigation m_nav;
00082 public:
00083 QString about();
00084 QImage* getPicture(unsigned long tgt);
00085 void sizes(unsigned long& _file, unsigned long& _text);
00086 bool hasrandomaccess() { return true; }
00087 virtual ~CPlucker_base();
00088 CPlucker_base();
00089 int OpenFile(const char *src);
00090 virtual tchar getch(bool) = 0;
00091 tchar getch_base(bool);
00092 int getch();
00093 void getch(tchar&, CStyle&, unsigned long& pos);
00094 unsigned int locate();
00095 void locate(unsigned int n);
00096 CList<Bkmk>* getbkmklist();
00097 linkType hyperlink(unsigned int, unsigned int, QString&, QString&);
00098 MarkupType PreferredMarkup()
00099 {
00100 return cNONE;
00101 }
00102 void saveposn(size_t posn) { m_nav.saveposn(posn); }
00103 void writeposn(size_t posn) { m_nav.writeposn(posn); }
00104 linkType forward(size_t& loc) { return (m_nav.forward(loc)) ? eLink : eNone; }
00105 linkType back(size_t& loc) { return (m_nav.back(loc)) ? eLink : eNone; }
00106 bool hasnavigation() { return true; }
00107 void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen);
00108 void putSaveData(unsigned char*& src, unsigned short& srclen);
00109
00110 virtual bool CorrectDecoder() = 0;
00111
00112 virtual QImage* imagefromdata(UInt8*, UInt32) = 0;
00113 QString getTableAsHtml(unsigned long loc);
00114 };
00115
00116 #endif