author | llornkcor <llornkcor> | 2002-09-14 02:19:09 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-09-14 02:19:09 (UTC) |
commit | 2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975 (patch) (side-by-side diff) | |
tree | eeed16b5f80dd5883991a7a06133f5f7a6936256 /noncore/apps/opie-reader/BuffDoc.h | |
parent | 5a95ed6a000a56849b8f093deea500214856c626 (diff) | |
download | opie-2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975.zip opie-2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975.tar.gz opie-2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975.tar.bz2 |
update by Tim
Diffstat (limited to 'noncore/apps/opie-reader/BuffDoc.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/BuffDoc.h | 104 |
1 files changed, 25 insertions, 79 deletions
diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h index 7c5ef9a..1aac817 100644 --- a/noncore/apps/opie-reader/BuffDoc.h +++ b/noncore/apps/opie-reader/BuffDoc.h @@ -1,138 +1,84 @@ #ifndef __BuffDoc_h #define __BuffDoc_h -#include "CBuffer.h" #include "ZText.h" #include "Aportis.h" #include "ztxt.h" #include "ppm_expander.h" +#include "CDrawBuffer.h" #include "CFilter.h" #include <qfontmetrics.h> #include <qmessagebox.h> class BuffDoc { - CBuffer lastword; + CDrawBuffer lastword; CSizeBuffer lastsizes, allsizes; size_t laststartline; bool lastispara; CExpander* exp; CFilterChain* filt; - QFontMetrics* m_fm; public: ~BuffDoc() { delete filt; delete exp; } - BuffDoc() : m_fm(NULL) + BuffDoc() { exp = NULL; filt = NULL; + lastword.empty(); // qDebug("Buffdoc created"); } bool empty() { return (exp == NULL); } - void setfm(QFontMetrics* fm) - { - m_fm = fm; - // qDebug("Buffdoc:setfm"); - } void setfilter(CFilterChain* _f) { if (filt != NULL) delete filt; filt = _f; filt->setsource(exp); } CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); } bool iseol() { return (lastword[0] == '\0'); } - int openfile(QWidget* _parent, const char *src) + int openfile(QWidget* _parent, const char *src); + tchar getch() { - // qDebug("BuffDoc:Openfile:%s", src); - // qDebug("Trying aportis %x",exp); - if (exp != NULL) delete exp; - lastword[0] = '\0'; - lastsizes[0] = laststartline = 0; - lastispara = false; - /* - exp = new Text; - int ret = exp->openfile(src); - */ - - exp = new Aportis; - // qDebug("Calling openfile"); - int ret = exp->openfile(src); - // qDebug("Called openfile"); - if (ret == -1) + tchar ch = UEOF; + CStyle sty; + if (exp != NULL) { - // qDebug("problem opening source file:%s",src); - delete exp; - exp = NULL; - return ret; + filt->getch(ch, sty); } - if (ret == -2) - { - - delete exp; -// qDebug("Trying ztxt"); - exp = new ztxt; - ret = exp->openfile(src); - } -#ifndef SMALL - if (ret != 0) - { - delete exp; -// qDebug("Trying ppms"); - exp = new ppm_expander; - ret = exp->openfile(src); - } - - if (ret != 0) - { - delete exp; - exp = new Text; -// qDebug("Trying text"); - ret = exp->openfile(src); - } -#else - if (ret != 0) - { - delete exp; - exp = new Text; - ret = exp->openfile(src); - } -#endif - if (ret != 0) + return ch; + } + void getch(tchar& ch, CStyle& sty) + { + if (exp != NULL) { - delete exp; - QMessageBox::information(_parent, "QTReader", "Unknown file compression type","Try another file"); - return ret; + filt->getch(ch, sty); } - // qDebug("Doing final open:%x:%x",exp,filt); - - lastword[0] = '\0'; - lastsizes[0] = laststartline = 0; - lastispara = false; - exp->locate(0); - filt->setsource(exp); - // qDebug("BuffDoc:file opened"); - return 0; + else + ch = UEOF; } - int getch() { return (exp == NULL) ? UEOF : filt->getch(); } unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } + unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } + MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } + bool hyperlink(unsigned int n); void locate(unsigned int n); - bool getline(CBuffer* buff, int w); - bool getline(CBuffer* buff, int w, int cw); + bool getline(CDrawBuffer* buff, int w); + bool getline(CDrawBuffer* buff, int w, int cw); void sizes(unsigned long& fs, unsigned long& ts) { exp->sizes(fs,ts); } int getpara(CBuffer& buff) { - int ch, i = 0; + tchar ch; + int i = 0; while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; buff[i] = '\0'; if (i == 0 && ch == UEOF) i = -1; laststartline = exp->locate(); return i; } }; #endif |