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.h168
1 files changed, 95 insertions, 73 deletions
diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h
index 61531c0..a7dd7bf 100644
--- a/noncore/apps/opie-reader/BuffDoc.h
+++ b/noncore/apps/opie-reader/BuffDoc.h
@@ -2,12 +2,9 @@
2#define __BuffDoc_h 2#define __BuffDoc_h
3 3
4#include "useqpe.h" 4#include "useqpe.h"
5#include "ZText.h"
6#include "Aportis.h"
7#include "ztxt.h"
8#include "ppm_expander.h"
9#include "CDrawBuffer.h" 5#include "CDrawBuffer.h"
10#include "CFilter.h" 6#include "CFilter.h"
7#include "CExpander.h"
11#include <qfontmetrics.h> 8#include <qfontmetrics.h>
12#include <qmessagebox.h> 9#include <qmessagebox.h>
13 10
@@ -17,28 +14,38 @@ class BuffDoc
17 CSizeBuffer lastsizes, allsizes; 14 CSizeBuffer lastsizes, allsizes;
18 size_t laststartline; 15 size_t laststartline;
19 bool lastispara; 16 bool lastispara;
20 CExpander* exp; 17 CExpander_Interface* exp;
21 CFilterChain* filt; 18 CFilterChain* filt;
19 int m_hyphenthreshold;
20 // bool m_customhyphen;
22 public: 21 public:
22 QString about();
23 bool findanchor(const QString& nm)
24 {
25 return filt->findanchor(nm);
26 }
27 // void setCustomHyphen(bool _v) { m_customhyphen = _v; }
28 // bool getCustomHyphen() { return m_customhyphen; }
29 void setHyphenThreshold(int _v) { m_hyphenthreshold = _v; }
23 void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) 30 void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
24 { 31 {
25 if (exp == NULL) 32 if (exp == NULL)
26 { 33 {
27 data = NULL; 34 data = NULL;
28 len = 0; 35 len = 0;
29 } 36 }
30 else 37 else
31 { 38 {
32 exp->setSaveData(data, len, src, srclen); 39 exp->setSaveData(data, len, src, srclen);
33 } 40 }
34 } 41 }
35 void putSaveData(unsigned char*& src, unsigned short& srclen) 42 void putSaveData(unsigned char*& src, unsigned short& srclen)
36 { 43 {
37 if (exp != NULL) 44 if (exp != NULL)
38 { 45 {
39 exp->putSaveData(src, srclen); 46 exp->putSaveData(src, srclen);
40 } 47 }
41 } 48 }
42#ifdef USEQPE 49#ifdef USEQPE
43 void suspend() { if (exp != NULL) exp->suspend(); } 50 void suspend() { if (exp != NULL) exp->suspend(); }
44 void unsuspend() { if (exp != NULL) exp->unsuspend(); } 51 void unsuspend() { if (exp != NULL) exp->unsuspend(); }
@@ -47,47 +54,48 @@ class BuffDoc
47 void unsuspend() {} 54 void unsuspend() {}
48#endif 55#endif
49 ~BuffDoc() 56 ~BuffDoc()
50 { 57 {
51 delete filt; 58 delete filt;
52 delete exp; 59 delete exp;
53 } 60 }
54 BuffDoc() 61 BuffDoc()
55 { 62 {
56 exp = NULL; 63 exp = NULL;
57 filt = NULL; 64 filt = NULL;
58 lastword.empty(); 65 lastword.empty();
59 // odebug << "Buffdoc created" << oendl; 66 // // qDebug("Buffdoc created");
60 } 67 }
61 bool empty() { return (exp == NULL); } 68 bool empty() { return (exp == NULL); }
62 void setfilter(CFilterChain* _f) 69 void setfilter(CFilterChain* _f)
63 { 70 {
64 if (filt != NULL) delete filt; 71 if (filt != NULL) delete filt;
65 filt = _f; 72 filt = _f;
66 filt->setsource(exp); 73 filt->setsource(exp);
67 } 74 }
68 CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } 75 CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); }
69 bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); } 76 bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); }
70 bool iseol() { return (lastword[0] == '\0'); } 77 bool iseol() { return (lastword[0] == '\0'); }
71 int openfile(QWidget* _parent, const char *src); 78 int openfile(QWidget* _parent, const char *src);
72 tchar getch() 79 tchar getch()
73 { 80 {
74 tchar ch = UEOF; 81 tchar ch = UEOF;
75 CStyle sty; 82 CStyle sty;
76 if (exp != NULL) 83 if (exp != NULL)
77 { 84 {
78 filt->getch(ch, sty); 85 unsigned long dummy;
79 } 86 filt->getch(ch, sty, dummy);
80 return ch; 87 }
81 } 88 return ch;
82 void getch(tchar& ch, CStyle& sty) 89 }
83 { 90 void getch(tchar& ch, CStyle& sty, unsigned long& pos)
84 if (exp != NULL) 91 {
85 { 92 if (exp != NULL)
86 filt->getch(ch, sty); 93 {
87 } 94 filt->getch(ch, sty, pos);
88 else 95 }
89 ch = UEOF; 96 else
90 } 97 ch = UEOF;
98 }
91 void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } 99 void setwidth(int w) { if (exp != NULL) exp->setwidth(w); }
92 QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } 100 QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); }
93 unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } 101 unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); }
@@ -96,27 +104,41 @@ class BuffDoc
96 unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } 104 unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); }
97 void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } 105 void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); }
98 MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } 106 MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); }
99 linkType hyperlink(unsigned int n, QString& wrd); 107 linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm);
100 size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } 108 size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); }
101 void locate(unsigned int n); 109 void locate(unsigned int n);
102 bool getline(CDrawBuffer* buff, int w, unsigned char _border); 110 bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht);
103 bool getline(CDrawBuffer* buff, int w, int cw, unsigned char _border); 111 bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht);
104 void sizes(unsigned long& fs, unsigned long& ts) { exp->sizes(fs,ts); } 112 void sizes(unsigned long& fs, unsigned long& ts)
113 {
114 if (exp != NULL)
115 {
116 exp->sizes(fs,ts);
117 }
118 else
119 {
120 fs = ts = 0;
121 }
122 }
105 int getpara(CBuffer& buff) 123 int getpara(CBuffer& buff)
106 { 124 {
107 tchar ch; 125 tchar ch;
108 int i = 0; 126 int i = 0;
109 while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; 127 while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch;
110 buff[i] = '\0'; 128 buff[i] = '\0';
111 if (i == 0 && ch == UEOF) i = -1; 129 if (i == 0 && ch == UEOF) i = -1;
112 laststartline = exp->locate(); 130 laststartline = exp->locate();
113 return i; 131 return i;
114 } 132 }
115 void saveposn(size_t posn) { exp->saveposn(posn); } 133 void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); }
116 void writeposn(size_t posn) { exp->writeposn(posn); } 134 void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); }
117 bool forward(size_t& loc) { return exp->forward(loc); } 135 linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); }
118 bool back(size_t& loc) { return exp->back(loc); } 136 linkType back(QString& f, size_t& loc) { return filt->back(f, loc); }
119 bool hasnavigation() { return exp->hasnavigation(); } 137 bool hasnavigation() { return filt->hasnavigation(); }
138 bool getFile(QString href)
139 {
140 return (exp == NULL) ? false : exp->getFile(href);
141 }
120}; 142};
121 143
122#endif 144#endif