summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CFilter.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/CFilter.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CFilter.h93
1 files changed, 67 insertions, 26 deletions
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h
index 2d0c30f..0a03b3e 100644
--- a/noncore/apps/opie-reader/CFilter.h
+++ b/noncore/apps/opie-reader/CFilter.h
@@ -1,23 +1,27 @@
1#ifndef __CFILTER_H 1#ifndef __CFILTER_H
2#define __CFILTER_H 2#define __CFILTER_H
3 3
4#include "CExpander.h" 4#include "CExpander.h"
5#include "CEncoding.h" 5#include "CEncoding.h"
6 6
7class CFilter : public CCharacterSource 7class CFilter : public CCharacterSource
8{ 8{
9 friend class CFilterChain; 9 friend class CFilterChain;
10 protected: 10 protected:
11 CCharacterSource* parent; 11 CCharacterSource* parent;
12 linkType hyperlink(unsigned int n, QString& w)
13 {
14 return parent->hyperlink(n,w);
15 }
12 public: 16 public:
13 CFilter() : parent(NULL) {} 17 CFilter() : parent(NULL) {}
14 void setparent(CCharacterSource* p) { parent = p; } 18 void setparent(CCharacterSource* p) { parent = p; }
15 virtual ~CFilter() {}; 19 virtual ~CFilter() {};
16}; 20};
17 21
18class CFilterChain 22class CFilterChain
19{ 23{
20 CExpander* expander; 24 CExpander* expander;
21 CEncoding* encoder; 25 CEncoding* encoder;
22 CFilter* first; 26 CFilter* first;
23 CCharacterSource* front; 27 CCharacterSource* front;
@@ -60,44 +64,44 @@ class CFilterChain
60 { 64 {
61 delete encoder; 65 delete encoder;
62 encoder = p; 66 encoder = p;
63 first->setparent(p); 67 first->setparent(p);
64 encoder->setparent(expander); 68 encoder->setparent(expander);
65 } 69 }
66}; 70};
67 71
68class stripcr : public CFilter 72class stripcr : public CFilter
69{ 73{
70 public: 74 public:
71 stripcr() {} 75 stripcr() {}
72 virtual ~stripcr() {} 76 ~stripcr() {}
73 virtual void getch(tchar& ch, CStyle& sty) 77 void getch(tchar& ch, CStyle& sty)
74 { 78 {
75 do 79 do
76 { 80 {
77 parent->getch(ch, sty); 81 parent->getch(ch, sty);
78 } 82 }
79 while (ch == 13); 83 while (ch == 13);
80 } 84 }
81}; 85};
82 86
83class dehyphen : public CFilter 87class dehyphen : public CFilter
84{ 88{
85 bool m_bCharWaiting; 89 bool m_bCharWaiting;
86 tchar m_nextChar; 90 tchar m_nextChar;
87 CStyle m_nextSty; 91 CStyle m_nextSty;
88 public: 92 public:
89 dehyphen() : m_bCharWaiting(false) {} 93 dehyphen() : m_bCharWaiting(false) {}
90 virtual ~dehyphen() {} 94 ~dehyphen() {}
91 virtual void getch(tchar& ch, CStyle& sty) 95 void getch(tchar& ch, CStyle& sty)
92 { 96 {
93 if (m_bCharWaiting) 97 if (m_bCharWaiting)
94 { 98 {
95 m_bCharWaiting = false; 99 m_bCharWaiting = false;
96 ch = m_nextChar; 100 ch = m_nextChar;
97 sty = m_nextSty; 101 sty = m_nextSty;
98 return; 102 return;
99 } 103 }
100 parent->getch(ch, sty); 104 parent->getch(ch, sty);
101 if (ch != '-') return; 105 if (ch != '-') return;
102 parent->getch(m_nextChar, m_nextSty); 106 parent->getch(m_nextChar, m_nextSty);
103 if (m_nextChar != 10) 107 if (m_nextChar != 10)
@@ -110,57 +114,57 @@ class dehyphen : public CFilter
110 } 114 }
111}; 115};
112 116
113class striphtml : public CFilter 117class striphtml : public CFilter
114{ 118{
115 CStyle currentstyle; 119 CStyle currentstyle;
116 unsigned short skip_ws(); 120 unsigned short skip_ws();
117 unsigned short skip_ws_end(); 121 unsigned short skip_ws_end();
118 unsigned short parse_m(); 122 unsigned short parse_m();
119 void mygetch(tchar& ch, CStyle& sty); 123 void mygetch(tchar& ch, CStyle& sty);
120 public: 124 public:
121 striphtml() {} 125 striphtml() {}
122 virtual ~striphtml() {} 126 ~striphtml() {}
123 virtual void getch(tchar& ch, CStyle& sty); 127 void getch(tchar& ch, CStyle& sty);
124}; 128};
125 129
126class unindent : public CFilter 130class unindent : public CFilter
127{ 131{
128 tchar lc; 132 tchar lc;
129 public: 133 public:
130 unindent() : lc(0) {} 134 unindent() : lc(0) {}
131 virtual ~unindent() {} 135 ~unindent() {}
132 virtual void getch(tchar& ch, CStyle& sty) 136 void getch(tchar& ch, CStyle& sty)
133 { 137 {
134 if (lc == 10) 138 if (lc == 10)
135 { 139 {
136 do 140 do
137 { 141 {
138 parent->getch(ch, sty); 142 parent->getch(ch, sty);
139 } 143 }
140 while (ch == ' '); 144 while (ch == ' ');
141 } 145 }
142 else parent->getch(ch, sty); 146 else parent->getch(ch, sty);
143 lc = ch; 147 lc = ch;
144 return; 148 return;
145 } 149 }
146}; 150};
147 151
148class repara : public CFilter 152class repara : public CFilter
149{ 153{
150 tchar tch; 154 tchar tch;
151 public: 155 public:
152 repara() : tch(0) {} 156 repara() : tch(0) {}
153 virtual ~repara() {} 157 ~repara() {}
154 virtual void getch(tchar& ch, CStyle& sty) 158 void getch(tchar& ch, CStyle& sty)
155 { 159 {
156 parent->getch(ch, sty); 160 parent->getch(ch, sty);
157 if (ch == 10) 161 if (ch == 10)
158 { 162 {
159 if (tch == 10) 163 if (tch == 10)
160 { 164 {
161 return; 165 return;
162 } 166 }
163 else 167 else
164 { 168 {
165 tch = ch; 169 tch = ch;
166 ch = ' '; 170 ch = ' ';
@@ -170,52 +174,52 @@ class repara : public CFilter
170 tch = ch; 174 tch = ch;
171 return; 175 return;
172 } 176 }
173}; 177};
174 178
175class indenter : public CFilter 179class indenter : public CFilter
176{ 180{
177 int amnt; 181 int amnt;
178 int indent; 182 int indent;
179 CStyle lsty; 183 CStyle lsty;
180 public: 184 public:
181 indenter(int _a=5) : amnt(_a), indent(0) {} 185 indenter(int _a=5) : amnt(_a), indent(0) {}
182 virtual ~indenter() {} 186 ~indenter() {}
183 virtual void getch(tchar& ch, CStyle& sty) 187 void getch(tchar& ch, CStyle& sty)
184 { 188 {
185 if (indent > 0) 189 if (indent > 0)
186 { 190 {
187 indent--; 191 indent--;
188 ch = ' '; 192 ch = ' ';
189 sty = lsty; 193 sty = lsty;
190 return; 194 return;
191 } 195 }
192 parent->getch(ch, sty); 196 parent->getch(ch, sty);
193 if (ch == 10) 197 if (ch == 10)
194 { 198 {
195 indent = amnt; 199 indent = amnt;
196 lsty = sty; 200 lsty = sty;
197 } 201 }
198 return; 202 return;
199 } 203 }
200}; 204};
201 205
202class dblspce : public CFilter 206class dblspce : public CFilter
203{ 207{
204 bool lastlf; 208 bool lastlf;
205 CStyle lsty; 209 CStyle lsty;
206 public: 210 public:
207 dblspce() : lastlf(false) {} 211 dblspce() : lastlf(false) {}
208 virtual ~dblspce() {} 212 ~dblspce() {}
209 virtual void getch(tchar& ch, CStyle& sty) 213 void getch(tchar& ch, CStyle& sty)
210 { 214 {
211 if (lastlf) 215 if (lastlf)
212 { 216 {
213 lastlf = false; 217 lastlf = false;
214 ch = 10; 218 ch = 10;
215 sty = lsty; 219 sty = lsty;
216 return; 220 return;
217 } 221 }
218 parent->getch(ch, sty); 222 parent->getch(ch, sty);
219 if (lastlf = (ch == 10)) 223 if (lastlf = (ch == 10))
220 { 224 {
221 lsty = sty; 225 lsty = sty;
@@ -223,65 +227,102 @@ class dblspce : public CFilter
223 return; 227 return;
224 } 228 }
225}; 229};
226 230
227class textfmt : public CFilter 231class textfmt : public CFilter
228{ 232{
229 CStyle currentstyle; 233 CStyle currentstyle;
230 tchar lastchar; 234 tchar lastchar;
231 bool uselast; 235 bool uselast;
232 void mygetch(tchar&, CStyle&); 236 void mygetch(tchar&, CStyle&);
233 public: 237 public:
234 textfmt() : lastchar(0), uselast(false) {} 238 textfmt() : lastchar(0), uselast(false) {}
235 virtual ~textfmt() {} 239 ~textfmt() {}
236 virtual void getch(tchar& ch, CStyle& sty); 240 void getch(tchar& ch, CStyle& sty);
237}; 241};
238 242
239class embolden : public CFilter 243class embolden : public CFilter
240{ 244{
241 public: 245 public:
242 embolden() {} 246 embolden() {}
243 virtual ~embolden() {} 247 ~embolden() {}
244 virtual void getch(tchar& ch, CStyle& sty) 248 void getch(tchar& ch, CStyle& sty)
245 { 249 {
246 parent->getch(ch, sty); 250 parent->getch(ch, sty);
247 sty.setBold(); 251 sty.setBold();
248 } 252 }
249}; 253};
250 254
251class remap : public CFilter 255class remap : public CFilter
252{ 256{
253 tchar q[3]; 257 tchar q[3];
254 int offset; 258 int offset;
255 CStyle currentstyle; 259 CStyle currentstyle;
256 public: 260 public:
257 remap() : offset(0) { q[0] = 0; } 261 remap() : offset(0) { q[0] = 0; }
258 virtual ~remap() {} 262 ~remap() {}
259 virtual void getch(tchar& ch, CStyle& sty); 263 void getch(tchar& ch, CStyle& sty);
260}; 264};
261 265
262class PeanutFormatter : public CFilter 266class PeanutFormatter : public CFilter
263{ 267{
264 CStyle currentstyle; 268 CStyle currentstyle;
265 public: 269 public:
266 virtual ~PeanutFormatter() {} 270 ~PeanutFormatter() {}
267 virtual void getch(tchar& ch, CStyle& sty); 271 void getch(tchar& ch, CStyle& sty);
268}; 272};
269 273
270class OnePara : public CFilter 274class OnePara : public CFilter
271{ 275{
272 tchar m_lastchar; 276 tchar m_lastchar;
273 public: 277 public:
274 OnePara() : m_lastchar(0) {} 278 OnePara() : m_lastchar(0) {}
275 virtual ~OnePara() {} 279 ~OnePara() {}
276 virtual void getch(tchar& ch, CStyle& sty); 280 void getch(tchar& ch, CStyle& sty);
281};
282
283class DePluck : public CFilter
284{
285 tchar* nextpart;
286 tchar m_buffer;
287 int m_buffed;
288 int m_current;
289 bool m_debuff;
290 CStyle m_laststyle;
291 public:
292 DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {}
293 ~DePluck() {}
294 void getch(tchar& ch, CStyle& sty);
277}; 295};
278 296
279#ifdef REPALM 297#ifdef REPALM
280class repalm : public CFilter 298class repalm : public CFilter
281{ 299{
282 public: 300 public:
283 virtual ~repalm() {} 301 ~repalm() {}
284 virtual void getch(tchar& ch, CStyle& sty); 302 void getch(tchar& ch, CStyle& sty);
285}; 303};
286#endif 304#endif
305
306class FullJust : public CFilter
307{
308 public:
309 void getch(tchar& ch, CStyle& sty)
310 {
311 parent->getch(ch, sty);
312 if (sty.getJustify() == m_AlignLeft) sty.setFullJustify();
313 }
314};
315/*
316class AddSpace : public CFilter
317{
318 unsigned char m_espc;
319 public:
320 AddSpace(unsigned char s) : m_espc(s) {}
321 void getch(tchar& ch, CStyle& sty)
322 {
323 parent->getch(ch, sty);
324 sty.setExtraSpace(m_espc);
325 }
326};
327*/
287#endif 328#endif