summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/BuffDoc.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/BuffDoc.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/BuffDoc.h104
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
@@ -3,3 +3,2 @@
3 3
4#include "CBuffer.h"
5#include "ZText.h" 4#include "ZText.h"
@@ -8,2 +7,3 @@
8#include "ppm_expander.h" 7#include "ppm_expander.h"
8#include "CDrawBuffer.h"
9#include "CFilter.h" 9#include "CFilter.h"
@@ -14,3 +14,3 @@ class BuffDoc
14{ 14{
15 CBuffer lastword; 15 CDrawBuffer lastword;
16 CSizeBuffer lastsizes, allsizes; 16 CSizeBuffer lastsizes, allsizes;
@@ -20,3 +20,2 @@ class BuffDoc
20 CFilterChain* filt; 20 CFilterChain* filt;
21 QFontMetrics* m_fm;
22 public: 21 public:
@@ -27,3 +26,3 @@ class BuffDoc
27 } 26 }
28 BuffDoc() : m_fm(NULL) 27 BuffDoc()
29 { 28 {
@@ -31,2 +30,3 @@ class BuffDoc
31 filt = NULL; 30 filt = NULL;
31 lastword.empty();
32 // qDebug("Buffdoc created"); 32 // qDebug("Buffdoc created");
@@ -34,7 +34,2 @@ class BuffDoc
34 bool empty() { return (exp == NULL); } 34 bool empty() { return (exp == NULL); }
35 void setfm(QFontMetrics* fm)
36 {
37 m_fm = fm;
38 // qDebug("Buffdoc:setfm");
39 }
40 void setfilter(CFilterChain* _f) 35 void setfilter(CFilterChain* _f)
@@ -48,79 +43,29 @@ class BuffDoc
48 bool iseol() { return (lastword[0] == '\0'); } 43 bool iseol() { return (lastword[0] == '\0'); }
49 int openfile(QWidget* _parent, const char *src) 44 int openfile(QWidget* _parent, const char *src);
45 tchar getch()
50 { 46 {
51 // qDebug("BuffDoc:Openfile:%s", src); 47 tchar ch = UEOF;
52 // qDebug("Trying aportis %x",exp); 48 CStyle sty;
53 if (exp != NULL) delete exp; 49 if (exp != NULL)
54 lastword[0] = '\0';
55 lastsizes[0] = laststartline = 0;
56 lastispara = false;
57 /*
58 exp = new Text;
59 int ret = exp->openfile(src);
60 */
61
62 exp = new Aportis;
63 // qDebug("Calling openfile");
64 int ret = exp->openfile(src);
65 // qDebug("Called openfile");
66 if (ret == -1)
67 { 50 {
68 // qDebug("problem opening source file:%s",src); 51 filt->getch(ch, sty);
69 delete exp;
70 exp = NULL;
71 return ret;
72 } 52 }
73 if (ret == -2) 53 return ch;
74 { 54 }
75 55 void getch(tchar& ch, CStyle& sty)
76 delete exp; 56 {
77 // qDebug("Trying ztxt"); 57 if (exp != NULL)
78 exp = new ztxt;
79 ret = exp->openfile(src);
80 }
81#ifndef SMALL
82 if (ret != 0)
83 {
84 delete exp;
85 // qDebug("Trying ppms");
86 exp = new ppm_expander;
87 ret = exp->openfile(src);
88 }
89
90 if (ret != 0)
91 {
92 delete exp;
93 exp = new Text;
94 // qDebug("Trying text");
95 ret = exp->openfile(src);
96 }
97#else
98 if (ret != 0)
99 {
100 delete exp;
101 exp = new Text;
102 ret = exp->openfile(src);
103 }
104#endif
105 if (ret != 0)
106 { 58 {
107 delete exp; 59 filt->getch(ch, sty);
108 QMessageBox::information(_parent, "QTReader", "Unknown file compression type","Try another file");
109 return ret;
110 } 60 }
111 // qDebug("Doing final open:%x:%x",exp,filt); 61 else
112 62 ch = UEOF;
113 lastword[0] = '\0';
114 lastsizes[0] = laststartline = 0;
115 lastispara = false;
116 exp->locate(0);
117 filt->setsource(exp);
118 // qDebug("BuffDoc:file opened");
119 return 0;
120 } 63 }
121 int getch() { return (exp == NULL) ? UEOF : filt->getch(); }
122 unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } 64 unsigned int locate() { return (exp == NULL) ? 0 : laststartline; }
65 unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); }
66 MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); }
67 bool hyperlink(unsigned int n);
123 void locate(unsigned int n); 68 void locate(unsigned int n);
124 bool getline(CBuffer* buff, int w); 69 bool getline(CDrawBuffer* buff, int w);
125 bool getline(CBuffer* buff, int w, int cw); 70 bool getline(CDrawBuffer* buff, int w, int cw);
126 void sizes(unsigned long& fs, unsigned long& ts) { exp->sizes(fs,ts); } 71 void sizes(unsigned long& fs, unsigned long& ts) { exp->sizes(fs,ts); }
@@ -128,3 +73,4 @@ class BuffDoc
128 { 73 {
129 int ch, i = 0; 74 tchar ch;
75 int i = 0;
130 while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; 76 while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch;