Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BuffDoc.h

Go to the documentation of this file.
00001 #ifndef __BuffDoc_h
00002 #define __BuffDoc_h
00003 
00004 #include "CDrawBuffer.h"
00005 #include "CFilter.h"
00006 #include "CExpander.h"
00007 #include <qfontmetrics.h>
00008 #include <qmessagebox.h>
00009 
00010 class BuffDoc
00011 {
00012     CDrawBuffer lastword;
00013     CSizeBuffer lastsizes, allsizes;
00014     size_t laststartline;
00015     bool lastispara;
00016     CExpander_Interface* exp;
00017     CFilterChain* filt;
00018     int m_hyphenthreshold;
00019     //    bool m_customhyphen;
00020  public:
00021     QString about();
00022     bool findanchor(const QString& nm)
00023       {
00024         return filt->findanchor(nm);
00025       }
00026     //    void setCustomHyphen(bool _v) { m_customhyphen = _v; }
00027     //    bool getCustomHyphen() { return m_customhyphen; }
00028     void setHyphenThreshold(int _v) { m_hyphenthreshold = _v; }
00029     void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
00030         {
00031             if (exp == NULL)
00032             {
00033                 data = NULL;
00034                 len = 0;
00035             }
00036             else
00037             {
00038                 exp->setSaveData(data, len, src, srclen);
00039             }
00040         }
00041     void putSaveData(unsigned char*& src, unsigned short& srclen)
00042         {
00043             if (exp != NULL)
00044             {
00045                 exp->putSaveData(src, srclen);
00046             }
00047         }
00048 #ifdef USEQPE
00049     void suspend() { if (exp != NULL) exp->suspend(); }
00050 #else
00051     void suspend() {}
00052 #endif
00053     ~BuffDoc()
00054         {
00055             delete filt;
00056             delete exp;
00057         }
00058     BuffDoc()
00059         {
00060             exp = NULL;
00061             filt = NULL;
00062             lastword.empty();
00063 //          //    qDebug("Buffdoc created");
00064         }
00065     bool empty() { return (exp == NULL); }
00066     void setfilter(CFilterChain* _f)
00067         {
00068             if (filt != NULL) delete filt;
00069             filt = _f;
00070             filt->setsource(exp);
00071         }
00072     CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); }
00073     bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); }
00074     bool iseol() { return (lastword[0] == '\0'); }
00075     int openfile(QWidget* _parent, const char *src);
00076     tchar getch()
00077         {
00078             tchar ch = UEOF;
00079             CStyle sty;
00080             if (exp != NULL)
00081             {
00082               unsigned long dummy;
00083                 filt->getch(ch, sty, dummy);
00084             }
00085             return ch;
00086         }
00087     void getch(tchar& ch, CStyle& sty, unsigned long& pos)
00088         {
00089             if (exp != NULL)
00090             {
00091                 filt->getch(ch, sty, pos);
00092             }
00093             else
00094                 ch = UEOF;
00095         }
00096     /*
00097     void rawgetch(tchar& ch, CStyle& sty, unsigned long& pos)
00098         {
00099             if (exp != NULL)
00100             {
00101                 filt->rawgetch(ch, sty, pos);
00102             }
00103             else
00104                 ch = UEOF;
00105         }
00106     */
00107     void setwidth(int w) { if (exp != NULL) exp->setwidth(w); }
00108     QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); }
00109     unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); }
00110     unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); }
00111     void resetPos();
00112     unsigned int locate() { return (exp == NULL) ? 0 : laststartline; }
00113     unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); }
00114     void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); }
00115     MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); }
00116     linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm);
00117     size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); }
00118     void locate(unsigned int n);
00119     bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht);
00120     bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht);
00121     void sizes(unsigned long& fs, unsigned long& ts)
00122       {
00123         if (exp != NULL)
00124           {
00125             exp->sizes(fs,ts);
00126           }
00127         else
00128           {
00129             fs = ts = 0;
00130           }
00131       }
00132     int getpara(CBuffer& buff)
00133         {
00134             tchar ch;
00135             int i = 0;
00136             while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch;
00137             buff[i] = '\0';
00138             if (i == 0 && ch == UEOF) i = -1;
00139             laststartline = exp->locate();
00140             return i;
00141         }
00142     int getsentence(CBuffer& buff);
00143     void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); }
00144     void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); }
00145     linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); }
00146     linkType back(QString& f, size_t& loc) { return filt->back(f, loc); }
00147     bool hasnavigation() { return (exp == NULL) ? false : filt->hasnavigation(); }
00148     bool getFile(const QString& href, QString& nm)
00149       {
00150         return (exp == NULL) ? false : exp->getFile(href, nm);
00151       }
00152     QString getTableAsHtml(unsigned long loc)
00153       {
00154         return (exp != NULL) ? filt->getTableAsHtml(loc) : QString("");
00155       }
00156 };
00157 
00158 #endif

Generated on Sat Nov 5 16:16:53 2005 for OPIE by  doxygen 1.4.2