Diffstat (limited to 'noncore/apps/opie-reader/CFilter.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CFilter.h | 301 |
1 files changed, 224 insertions, 77 deletions
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h index 0a03b3e..cec9618 100644 --- a/noncore/apps/opie-reader/CFilter.h +++ b/noncore/apps/opie-reader/CFilter.h | |||
@@ -3,47 +3,89 @@ | |||
3 | 3 | ||
4 | #include "CExpander.h" | 4 | #include "CExpander.h" |
5 | #include "CEncoding.h" | 5 | #include "CEncoding.h" |
6 | 6 | ||
7 | class CFilter : public CCharacterSource | 7 | class CFilter_IFace : public CCharacterSource |
8 | { | ||
9 | public: | ||
10 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) = 0; | ||
11 | virtual void setparent(CCharacterSource* p) = 0; | ||
12 | virtual ~CFilter_IFace() {}; | ||
13 | virtual void locate(unsigned int n) = 0; | ||
14 | virtual bool findanchor(const QString& nm) = 0; | ||
15 | virtual void saveposn(const QString& f, size_t posn) = 0; | ||
16 | virtual void writeposn(const QString& f, size_t posn) = 0; | ||
17 | virtual linkType forward(QString& f, size_t& loc) = 0; | ||
18 | virtual linkType back(QString& f, size_t& loc) = 0; | ||
19 | virtual bool hasnavigation() = 0; | ||
20 | virtual int getwidth() = 0; | ||
21 | virtual CCharacterSource* getparent() = 0; | ||
22 | }; | ||
23 | |||
24 | class CFilter : public CFilter_IFace | ||
8 | { | 25 | { |
9 | friend class CFilterChain; | ||
10 | protected: | 26 | protected: |
11 | CCharacterSource* parent; | 27 | CCharacterSource* parent; |
12 | linkType hyperlink(unsigned int n, QString& w) | 28 | public: |
29 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) | ||
13 | { | 30 | { |
14 | return parent->hyperlink(n,w); | 31 | return parent->hyperlink(n,noff,w,nm); |
15 | } | 32 | } |
16 | public: | ||
17 | CFilter() : parent(NULL) {} | 33 | CFilter() : parent(NULL) {} |
18 | void setparent(CCharacterSource* p) { parent = p; } | 34 | void setparent(CCharacterSource* p) { parent = p; } |
35 | CCharacterSource* getparent() { return parent; } | ||
19 | virtual ~CFilter() {}; | 36 | virtual ~CFilter() {}; |
37 | virtual void locate(unsigned int n) | ||
38 | { | ||
39 | parent->locate(n); | ||
40 | } | ||
41 | virtual bool findanchor(const QString& nm) | ||
42 | { | ||
43 | return parent->findanchor(nm); | ||
44 | } | ||
45 | virtual void saveposn(const QString& f, size_t posn) { parent->saveposn(f, posn); } | ||
46 | virtual void writeposn(const QString& f, size_t posn) { parent->writeposn(f, posn); } | ||
47 | virtual linkType forward(QString& f, size_t& loc) { return parent->forward(f, loc); } | ||
48 | virtual linkType back(QString& f, size_t& loc) { return parent->back(f, loc); } | ||
49 | virtual bool hasnavigation() { return parent->hasnavigation(); } | ||
50 | virtual int getwidth() { return parent->getwidth(); } | ||
51 | QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } | ||
52 | QImage* getPicture(const QString& href) { return parent->getPicture(href); } | ||
53 | bool getFile(const QString& href) { return parent->getFile(href); } | ||
20 | }; | 54 | }; |
21 | 55 | ||
22 | class CFilterChain | 56 | class CFilterChain |
23 | { | 57 | { |
24 | CExpander* expander; | 58 | CExpander_Interface* expander; |
25 | CEncoding* encoder; | 59 | CEncoding* encoder; |
26 | CFilter* first; | 60 | CFilter_IFace* first; |
27 | CCharacterSource* front; | 61 | CCharacterSource* front; |
28 | public: | 62 | public: |
29 | CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; | 63 | CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; |
30 | ~CFilterChain() | 64 | ~CFilterChain() |
31 | { | 65 | { |
32 | CCharacterSource* p = front; | 66 | CCharacterSource* p = front; |
33 | while (p != encoder) | 67 | while (p != encoder) |
34 | { | 68 | { |
35 | CFilter* pnext = (CFilter*)p; | 69 | CFilter_IFace* pnext = (CFilter_IFace*)p; |
36 | p = ((CFilter*)p)->parent; | 70 | p = ((CFilter_IFace*)p)->getparent(); |
37 | delete pnext; | 71 | delete pnext; |
38 | } | 72 | } |
39 | delete encoder; | 73 | delete encoder; |
40 | } | 74 | } |
41 | void getch(tchar& ch, CStyle& sty) | 75 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) |
76 | { | ||
77 | return front->hyperlink(n, noff, wrd, nm); | ||
78 | } | ||
79 | void locate(unsigned int n) | ||
80 | { | ||
81 | front->locate(n); | ||
82 | } | ||
83 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
42 | { | 84 | { |
43 | front->getch(ch, sty); | 85 | front->getch(ch, sty, pos); |
44 | } | 86 | } |
45 | void addfilter(CFilter* p) | 87 | void addfilter(CFilter_IFace* p) |
46 | { | 88 | { |
47 | if (first == NULL) | 89 | if (first == NULL) |
48 | { | 90 | { |
49 | front = first = p; | 91 | front = first = p; |
@@ -54,35 +96,46 @@ class CFilterChain | |||
54 | p->setparent(front); | 96 | p->setparent(front); |
55 | front = p; | 97 | front = p; |
56 | } | 98 | } |
57 | } | 99 | } |
58 | void setsource(CExpander* p) | 100 | void setsource(CExpander_Interface* p) |
59 | { | 101 | { |
60 | expander = p; | 102 | expander = p; |
61 | encoder->setparent(p); | 103 | encoder->setparent(p); |
62 | } | 104 | } |
63 | void setencoder(CEncoding* p) | 105 | void setencoder(CEncoding* p) |
64 | { | 106 | { |
65 | delete encoder; | 107 | delete encoder; |
66 | encoder = p; | 108 | encoder = p; |
67 | first->setparent(p); | 109 | first->setparent(p); |
68 | encoder->setparent(expander); | 110 | encoder->setparent(expander); |
69 | } | 111 | } |
112 | bool findanchor(const QString& nm) | ||
113 | { | ||
114 | return front->findanchor(nm); | ||
115 | } | ||
116 | void saveposn(const QString& f, size_t posn) { front->saveposn(f, posn); } | ||
117 | void writeposn(const QString& f, size_t posn) { front->writeposn(f, posn); } | ||
118 | linkType forward(QString& f, size_t& loc) { return front->forward(f, loc); } | ||
119 | linkType back(QString& f, size_t& loc) { return front->back(f, loc); } | ||
120 | bool hasnavigation() { return front->hasnavigation(); } | ||
121 | QString about() { return QString("Filter chain (c) Tim Wentford\n")+front->about(); } | ||
70 | }; | 122 | }; |
71 | 123 | ||
72 | class stripcr : public CFilter | 124 | class stripcr : public CFilter |
73 | { | 125 | { |
74 | public: | 126 | public: |
75 | stripcr() {} | 127 | stripcr() {} |
76 | ~stripcr() {} | 128 | ~stripcr() {} |
77 | void getch(tchar& ch, CStyle& sty) | 129 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
78 | { | 130 | { |
79 | do | 131 | do |
80 | { | 132 | { |
81 | parent->getch(ch, sty); | 133 | parent->getch(ch, sty, pos); |
82 | } | 134 | } |
83 | while (ch == 13); | 135 | while (ch == 13); |
84 | } | 136 | } |
137 | QString about() { return QString("StripCR filter (c) Tim Wentford\n")+parent->about(); } | ||
85 | }; | 138 | }; |
86 | 139 | ||
87 | class dehyphen : public CFilter | 140 | class dehyphen : public CFilter |
88 | { | 141 | { |
@@ -91,90 +144,79 @@ class dehyphen : public CFilter | |||
91 | CStyle m_nextSty; | 144 | CStyle m_nextSty; |
92 | public: | 145 | public: |
93 | dehyphen() : m_bCharWaiting(false) {} | 146 | dehyphen() : m_bCharWaiting(false) {} |
94 | ~dehyphen() {} | 147 | ~dehyphen() {} |
95 | void getch(tchar& ch, CStyle& sty) | 148 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
96 | { | 149 | { |
97 | if (m_bCharWaiting) | 150 | if (m_bCharWaiting) |
98 | { | 151 | { |
99 | m_bCharWaiting = false; | 152 | m_bCharWaiting = false; |
100 | ch = m_nextChar; | 153 | ch = m_nextChar; |
101 | sty = m_nextSty; | 154 | sty = m_nextSty; |
102 | return; | 155 | return; |
103 | } | 156 | } |
104 | parent->getch(ch, sty); | 157 | parent->getch(ch, sty, pos); |
105 | if (ch != '-') return; | 158 | if (ch != '-') return; |
106 | parent->getch(m_nextChar, m_nextSty); | 159 | parent->getch(m_nextChar, m_nextSty, pos); |
107 | if (m_nextChar != 10) | 160 | if (m_nextChar != 10) |
108 | { | 161 | { |
109 | m_bCharWaiting = true; | 162 | m_bCharWaiting = true; |
110 | ch = '-'; | 163 | ch = '-'; |
111 | return; | 164 | return; |
112 | } | 165 | } |
113 | parent->getch(ch, sty); | 166 | parent->getch(ch, sty, pos); |
114 | } | 167 | } |
168 | QString about() { return QString("Hyphenation filter (c) Tim Wentford\n")+parent->about(); } | ||
115 | }; | 169 | }; |
116 | 170 | ||
117 | class striphtml : public CFilter | 171 | template<class A, class B>class QMap; |
172 | |||
173 | const int m_cmaxdepth = 8; | ||
174 | |||
175 | class htmlmark | ||
118 | { | 176 | { |
119 | CStyle currentstyle; | 177 | QString file; |
120 | unsigned short skip_ws(); | 178 | size_t pos; |
121 | unsigned short skip_ws_end(); | ||
122 | unsigned short parse_m(); | ||
123 | void mygetch(tchar& ch, CStyle& sty); | ||
124 | public: | 179 | public: |
125 | striphtml() {} | 180 | htmlmark() : file(), pos(0) {} |
126 | ~striphtml() {} | 181 | htmlmark(const QString& _f, size_t _p) : file(_f), pos(_p) {} |
127 | void getch(tchar& ch, CStyle& sty); | 182 | QString filename() { return file; } |
183 | size_t posn() { return pos; } | ||
128 | }; | 184 | }; |
129 | 185 | ||
130 | class unindent : public CFilter | 186 | class unindent : public CFilter |
131 | { | 187 | { |
132 | tchar lc; | 188 | tchar lc; |
133 | public: | 189 | public: |
134 | unindent() : lc(0) {} | 190 | unindent() : lc(0) {} |
135 | ~unindent() {} | 191 | ~unindent() {} |
136 | void getch(tchar& ch, CStyle& sty) | 192 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
137 | { | 193 | { |
138 | if (lc == 10) | 194 | if (lc == 10) |
139 | { | 195 | { |
140 | do | 196 | do |
141 | { | 197 | { |
142 | parent->getch(ch, sty); | 198 | parent->getch(ch, sty, pos); |
143 | } | 199 | } |
144 | while (ch == ' '); | 200 | while (ch == ' '); |
145 | } | 201 | } |
146 | else parent->getch(ch, sty); | 202 | else parent->getch(ch, sty, pos); |
147 | lc = ch; | 203 | lc = ch; |
148 | return; | 204 | return; |
149 | } | 205 | } |
206 | QString about() { return QString("Unindent filter (c) Tim Wentford\n")+parent->about(); } | ||
150 | }; | 207 | }; |
151 | 208 | ||
209 | class CRegExpFilt; | ||
152 | class repara : public CFilter | 210 | class repara : public CFilter |
153 | { | 211 | { |
154 | tchar tch; | 212 | tchar tch; |
213 | CRegExpFilt* flt; | ||
155 | public: | 214 | public: |
156 | repara() : tch(0) {} | 215 | repara(const QString&); |
157 | ~repara() {} | 216 | ~repara(); |
158 | void getch(tchar& ch, CStyle& sty) | 217 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
159 | { | 218 | QString about() { return QString("Reparagraph filter (c) Tim Wentford\n")+parent->about(); } |
160 | parent->getch(ch, sty); | ||
161 | if (ch == 10) | ||
162 | { | ||
163 | if (tch == 10) | ||
164 | { | ||
165 | return; | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | tch = ch; | ||
170 | ch = ' '; | ||
171 | return; | ||
172 | } | ||
173 | } | ||
174 | tch = ch; | ||
175 | return; | ||
176 | } | ||
177 | }; | 219 | }; |
178 | 220 | ||
179 | class indenter : public CFilter | 221 | class indenter : public CFilter |
180 | { | 222 | { |
@@ -183,25 +225,26 @@ class indenter : public CFilter | |||
183 | CStyle lsty; | 225 | CStyle lsty; |
184 | public: | 226 | public: |
185 | indenter(int _a=5) : amnt(_a), indent(0) {} | 227 | indenter(int _a=5) : amnt(_a), indent(0) {} |
186 | ~indenter() {} | 228 | ~indenter() {} |
187 | void getch(tchar& ch, CStyle& sty) | 229 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
188 | { | 230 | { |
189 | if (indent > 0) | 231 | if (indent > 0) |
190 | { | 232 | { |
191 | indent--; | 233 | indent--; |
192 | ch = ' '; | 234 | ch = ' '; |
193 | sty = lsty; | 235 | sty = lsty; |
194 | return; | 236 | return; |
195 | } | 237 | } |
196 | parent->getch(ch, sty); | 238 | parent->getch(ch, sty, pos); |
197 | if (ch == 10) | 239 | if (ch == 10) |
198 | { | 240 | { |
199 | indent = amnt; | 241 | indent = amnt; |
200 | lsty = sty; | 242 | lsty = sty; |
201 | } | 243 | } |
202 | return; | 244 | return; |
203 | } | 245 | } |
246 | QString about() { return QString("Indentation filter (c) Tim Wentford\n")+parent->about(); } | ||
204 | }; | 247 | }; |
205 | 248 | ||
206 | class dblspce : public CFilter | 249 | class dblspce : public CFilter |
207 | { | 250 | { |
@@ -209,48 +252,51 @@ class dblspce : public CFilter | |||
209 | CStyle lsty; | 252 | CStyle lsty; |
210 | public: | 253 | public: |
211 | dblspce() : lastlf(false) {} | 254 | dblspce() : lastlf(false) {} |
212 | ~dblspce() {} | 255 | ~dblspce() {} |
213 | void getch(tchar& ch, CStyle& sty) | 256 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
214 | { | 257 | { |
215 | if (lastlf) | 258 | if (lastlf) |
216 | { | 259 | { |
217 | lastlf = false; | 260 | lastlf = false; |
218 | ch = 10; | 261 | ch = 10; |
219 | sty = lsty; | 262 | sty = lsty; |
220 | return; | 263 | return; |
221 | } | 264 | } |
222 | parent->getch(ch, sty); | 265 | parent->getch(ch, sty, pos); |
223 | if (lastlf = (ch == 10)) | 266 | if (lastlf = (ch == 10)) |
224 | { | 267 | { |
225 | lsty = sty; | 268 | lsty = sty; |
226 | } | 269 | } |
227 | return; | 270 | return; |
228 | } | 271 | } |
272 | QString about() { return QString("Double space (c) Tim Wentford\n")+parent->about(); } | ||
229 | }; | 273 | }; |
230 | 274 | ||
231 | class textfmt : public CFilter | 275 | class textfmt : public CFilter |
232 | { | 276 | { |
233 | CStyle currentstyle; | 277 | CStyle currentstyle; |
234 | tchar lastchar; | 278 | tchar lastchar; |
235 | bool uselast; | 279 | bool uselast; |
236 | void mygetch(tchar&, CStyle&); | 280 | void mygetch(tchar&, CStyle&, unsigned long& pos); |
237 | public: | 281 | public: |
238 | textfmt() : lastchar(0), uselast(false) {} | 282 | textfmt() : lastchar(0), uselast(false) {} |
239 | ~textfmt() {} | 283 | ~textfmt() {} |
240 | void getch(tchar& ch, CStyle& sty); | 284 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
285 | QString about() { return QString("Text formatting filter (c) Tim Wentford\n")+parent->about(); } | ||
241 | }; | 286 | }; |
242 | 287 | ||
243 | class embolden : public CFilter | 288 | class embolden : public CFilter |
244 | { | 289 | { |
245 | public: | 290 | public: |
246 | embolden() {} | 291 | embolden() {} |
247 | ~embolden() {} | 292 | ~embolden() {} |
248 | void getch(tchar& ch, CStyle& sty) | 293 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
249 | { | 294 | { |
250 | parent->getch(ch, sty); | 295 | parent->getch(ch, sty, pos); |
251 | sty.setBold(); | 296 | sty.setBold(); |
252 | } | 297 | } |
298 | QString about() { return QString("Emboldening filter (c) Tim Wentford\n")+parent->about(); } | ||
253 | }; | 299 | }; |
254 | 300 | ||
255 | class remap : public CFilter | 301 | class remap : public CFilter |
256 | { | 302 | { |
@@ -259,26 +305,29 @@ class remap : public CFilter | |||
259 | CStyle currentstyle; | 305 | CStyle currentstyle; |
260 | public: | 306 | public: |
261 | remap() : offset(0) { q[0] = 0; } | 307 | remap() : offset(0) { q[0] = 0; } |
262 | ~remap() {} | 308 | ~remap() {} |
263 | void getch(tchar& ch, CStyle& sty); | 309 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
310 | QString about() { return QString("Character remapping filter (c) Tim Wentford\n")+parent->about(); } | ||
264 | }; | 311 | }; |
265 | 312 | ||
266 | class PeanutFormatter : public CFilter | 313 | class PeanutFormatter : public CFilter |
267 | { | 314 | { |
268 | CStyle currentstyle; | 315 | CStyle currentstyle; |
269 | public: | 316 | public: |
270 | ~PeanutFormatter() {} | 317 | ~PeanutFormatter() {} |
271 | void getch(tchar& ch, CStyle& sty); | 318 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
319 | QString about() { return QString("PML filter (c) Tim Wentford\n")+parent->about(); } | ||
272 | }; | 320 | }; |
273 | 321 | ||
274 | class OnePara : public CFilter | 322 | class OnePara : public CFilter |
275 | { | 323 | { |
276 | tchar m_lastchar; | 324 | tchar m_lastchar; |
277 | public: | 325 | public: |
278 | OnePara() : m_lastchar(0) {} | 326 | OnePara() : m_lastchar(0) {} |
279 | ~OnePara() {} | 327 | ~OnePara() {} |
280 | void getch(tchar& ch, CStyle& sty); | 328 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
329 | QString about() { return QString("Single space filter (c) Tim Wentford\n")+parent->about(); } | ||
281 | }; | 330 | }; |
282 | 331 | ||
283 | class DePluck : public CFilter | 332 | class DePluck : public CFilter |
284 | { | 333 | { |
@@ -290,39 +339,137 @@ class DePluck : public CFilter | |||
290 | CStyle m_laststyle; | 339 | CStyle m_laststyle; |
291 | public: | 340 | public: |
292 | DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {} | 341 | DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {} |
293 | ~DePluck() {} | 342 | ~DePluck() {} |
294 | void getch(tchar& ch, CStyle& sty); | 343 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
344 | QString about() { return QString("Depluck filter (c) Tim Wentford\n")+parent->about(); } | ||
295 | }; | 345 | }; |
296 | 346 | ||
297 | #ifdef REPALM | ||
298 | class repalm : public CFilter | 347 | class repalm : public CFilter |
299 | { | 348 | { |
300 | public: | 349 | public: |
301 | ~repalm() {} | 350 | ~repalm() {} |
302 | void getch(tchar& ch, CStyle& sty); | 351 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
352 | QString about() { return QString("Repalm filter (c) Tim Wentford\n")+parent->about(); } | ||
303 | }; | 353 | }; |
304 | #endif | ||
305 | 354 | ||
306 | class FullJust : public CFilter | 355 | class FullJust : public CFilter |
307 | { | 356 | { |
308 | public: | 357 | public: |
309 | void getch(tchar& ch, CStyle& sty) | 358 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
310 | { | 359 | { |
311 | parent->getch(ch, sty); | 360 | parent->getch(ch, sty, pos); |
312 | if (sty.getJustify() == m_AlignLeft) sty.setFullJustify(); | 361 | if (sty.getJustify() == m_AlignLeft) sty.setFullJustify(); |
313 | } | 362 | } |
363 | QString about() { return QString("Full justification filter (c) Tim Wentford\n")+parent->about(); } | ||
314 | }; | 364 | }; |
315 | /* | 365 | /* |
316 | class AddSpace : public CFilter | 366 | class AddSpace : public CFilter |
317 | { | 367 | { |
318 | unsigned char m_espc; | 368 | unsigned char m_espc; |
319 | public: | 369 | public: |
320 | AddSpace(unsigned char s) : m_espc(s) {} | 370 | AddSpace(unsigned char s) : m_espc(s) {} |
321 | void getch(tchar& ch, CStyle& sty) | 371 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
322 | { | 372 | { |
323 | parent->getch(ch, sty); | 373 | parent->getch(ch, sty, pos); |
324 | sty.setExtraSpace(m_espc); | 374 | sty.setExtraSpace(m_espc); |
325 | } | 375 | } |
326 | }; | 376 | }; |
327 | */ | 377 | */ |
378 | |||
379 | class QTReader; | ||
380 | |||
381 | class HighlightFilter : public CFilter | ||
382 | { | ||
383 | QTReader* pReader; | ||
384 | unsigned long lastpos, nextpos; | ||
385 | unsigned char red, green, blue; | ||
386 | CList<Bkmk>* bkmks; | ||
387 | public: | ||
388 | HighlightFilter(QTReader*); | ||
389 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
390 | void refresh(unsigned long); | ||
391 | QString about() { return QString("High-lighting filter (c) Tim Wentford\n")+parent->about(); } | ||
392 | }; | ||
393 | |||
394 | #include "static.h" | ||
395 | #ifndef __STATIC | ||
396 | #include <dlfcn.h> | ||
397 | |||
398 | class ExternFilter : public CFilter_IFace | ||
399 | { | ||
400 | CFilter* filt; | ||
401 | void *handle; | ||
402 | public: | ||
403 | linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) | ||
404 | { | ||
405 | return filt->hyperlink(n, noff, w, nm); | ||
406 | } | ||
407 | void setparent(CCharacterSource* p) { filt->setparent(p); } | ||
408 | ExternFilter(const QString& nm, const QString& optional); | ||
409 | ~ExternFilter() | ||
410 | { | ||
411 | if (filt != NULL) delete filt; | ||
412 | if (handle != NULL) dlclose(handle); | ||
413 | } | ||
414 | void locate(unsigned int n) { filt->locate(n); } | ||
415 | bool findanchor(const QString& nm) { return filt->findanchor(nm); } | ||
416 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } | ||
417 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } | ||
418 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } | ||
419 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } | ||
420 | bool hasnavigation() { return filt->hasnavigation(); } | ||
421 | int getwidth() { return filt->getwidth(); } | ||
422 | CCharacterSource* getparent() { return filt->getparent(); } | ||
423 | void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } | ||
424 | QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } | ||
425 | CFilter* filter() { return filt; } | ||
426 | QImage* getPicture(const QString& href) { return filt->getPicture(href); } | ||
427 | bool getFile(const QString& href) { return filt->getFile(href); } | ||
428 | QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); } | ||
429 | }; | ||
430 | #endif | ||
431 | |||
432 | class kern : public CFilter | ||
433 | { | ||
434 | tchar lastchar; | ||
435 | bool uselast; | ||
436 | CStyle laststy; | ||
437 | public: | ||
438 | kern() : lastchar(0), uselast(false) {} | ||
439 | ~kern() {} | ||
440 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
441 | QString about() { return QString("Kerning filter (c) Tim Wentford\n")+parent->about(); } | ||
442 | }; | ||
443 | |||
444 | class makeInverse : public CFilter | ||
445 | { | ||
446 | public: | ||
447 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
448 | QString about() { return QString("Colourmap inversion filter (c) Tim Wentford\n")+parent->about(); } | ||
449 | }; | ||
450 | /* | ||
451 | class makeNegative : public CFilter | ||
452 | { | ||
453 | public: | ||
454 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
455 | }; | ||
456 | */ | ||
457 | class setbg : public CFilter | ||
458 | { | ||
459 | int m_r, m_g, m_b; | ||
460 | public: | ||
461 | setbg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} | ||
462 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
463 | QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } | ||
464 | }; | ||
465 | |||
466 | class setfg : public CFilter | ||
467 | { | ||
468 | int m_r, m_g, m_b; | ||
469 | public: | ||
470 | setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} | ||
471 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | ||
472 | QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } | ||
473 | }; | ||
474 | |||
328 | #endif | 475 | #endif |