summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/BuffDoc.h
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/BuffDoc.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/BuffDoc.h100
1 files changed, 23 insertions, 77 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
@@ -3,3 +3,2 @@
-#include "CBuffer.h"
#include "ZText.h"
@@ -8,2 +7,3 @@
#include "ppm_expander.h"
+#include "CDrawBuffer.h"
#include "CFilter.h"
@@ -14,3 +14,3 @@ class BuffDoc
{
- CBuffer lastword;
+ CDrawBuffer lastword;
CSizeBuffer lastsizes, allsizes;
@@ -20,3 +20,2 @@ class BuffDoc
CFilterChain* filt;
- QFontMetrics* m_fm;
public:
@@ -27,3 +26,3 @@ class BuffDoc
}
- BuffDoc() : m_fm(NULL)
+ BuffDoc()
{
@@ -31,2 +30,3 @@ class BuffDoc
filt = NULL;
+ lastword.empty();
// qDebug("Buffdoc created");
@@ -34,7 +34,2 @@ class BuffDoc
bool empty() { return (exp == NULL); }
- void setfm(QFontMetrics* fm)
- {
- m_fm = fm;
- // qDebug("Buffdoc:setfm");
- }
void setfilter(CFilterChain* _f)
@@ -48,79 +43,29 @@ class BuffDoc
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);
+ return ch;
}
-#ifndef SMALL
- if (ret != 0)
+ void getch(tchar& ch, CStyle& sty)
{
- delete exp;
-// qDebug("Trying ppms");
- exp = new ppm_expander;
- ret = exp->openfile(src);
- }
-
- if (ret != 0)
+ if (exp != NULL)
{
- 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)
- {
- 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); }
@@ -128,3 +73,4 @@ class BuffDoc
{
- int ch, i = 0;
+ tchar ch;
+ int i = 0;
while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch;