author | pohly <pohly> | 2004-08-24 20:52:45 (UTC) |
---|---|---|
committer | pohly <pohly> | 2004-08-24 20:52:45 (UTC) |
commit | 73253e93327cf4ef0932de1b4afb56af22a0f37e (patch) (unidiff) | |
tree | 1c9a7a6dd3341e036a894d348a3372525d29acec /noncore/apps/opie-reader/CFilter.cpp | |
parent | e90847c784c48bd21bf8768cb38edb853b832697 (diff) | |
download | opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.zip opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.gz opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.bz2 |
updated source to opie-reader 0.7g
Diffstat (limited to 'noncore/apps/opie-reader/CFilter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CFilter.cpp | 600 |
1 files changed, 337 insertions, 263 deletions
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp index 0422ba6..6f76e9a 100644 --- a/noncore/apps/opie-reader/CFilter.cpp +++ b/noncore/apps/opie-reader/CFilter.cpp | |||
@@ -1,229 +1,21 @@ | |||
1 | #include <qmap.h> | ||
2 | #include <qfileinfo.h> | ||
3 | #include <qtextstream.h> | ||
4 | #include <qdir.h> | ||
5 | #include "useqpe.h" | ||
6 | #ifdef USEQPE | ||
7 | #include <qpe/global.h> | ||
8 | #endif | ||
9 | #include "CDrawBuffer.h" | ||
1 | #include "CFilter.h" | 10 | #include "CFilter.h" |
11 | #include "hrule.h" | ||
12 | #include "util.h" | ||
2 | 13 | ||
3 | unsigned short striphtml::skip_ws() | 14 | #include <qregexp.h> |
4 | { | 15 | #include <qimage.h> |
5 | tchar ch; | 16 | #include <qpixmap.h> |
6 | CStyle sty; | 17 | //#include <qprogressdialog.h> |
7 | do | 18 | //#include <qapplication.h> |
8 | { | ||
9 | parent->getch(ch, sty); | ||
10 | } | ||
11 | while (ch < 33); | ||
12 | return ch; | ||
13 | } | ||
14 | |||
15 | unsigned short striphtml::skip_ws_end() | ||
16 | { | ||
17 | tchar ch; | ||
18 | CStyle sty; | ||
19 | parent->getch(ch, sty); | ||
20 | if (ch == ' ') | ||
21 | { | ||
22 | do | ||
23 | { | ||
24 | parent->getch(ch, sty); | ||
25 | } | ||
26 | while (ch != '>'); | ||
27 | } | ||
28 | return ch; | ||
29 | } | ||
30 | |||
31 | unsigned short striphtml::parse_m() | ||
32 | { | ||
33 | tchar ch; | ||
34 | CStyle sty; | ||
35 | parent->getch(ch, sty); | ||
36 | if (ch == 'm' || ch == 'M') | ||
37 | { | ||
38 | ch = skip_ws_end(); | ||
39 | if (ch == '>') | ||
40 | { | ||
41 | return 0; | ||
42 | } | ||
43 | } | ||
44 | return ch; | ||
45 | } | ||
46 | |||
47 | void striphtml::mygetch(tchar& ch, CStyle& sty) | ||
48 | { | ||
49 | parent->getch(ch, sty); | ||
50 | if (ch == 10) ch = ' '; | ||
51 | } | ||
52 | |||
53 | void striphtml::getch(tchar& ch, CStyle& sty) | ||
54 | { | ||
55 | CStyle dummy; | ||
56 | mygetch(ch, dummy); | ||
57 | if (ch == 10) ch = ' '; | ||
58 | while (ch == '<') | ||
59 | { | ||
60 | ch = skip_ws(); | ||
61 | |||
62 | switch (ch) | ||
63 | { | ||
64 | case 'p': | ||
65 | case 'P': | ||
66 | ch = skip_ws_end(); | ||
67 | if (ch == '>') | ||
68 | { | ||
69 | ch = 10; | ||
70 | continue; | ||
71 | } | ||
72 | break; | ||
73 | case 'b': | ||
74 | case 'B': | ||
75 | ch = skip_ws_end(); | ||
76 | if (ch == '>') | ||
77 | { | ||
78 | currentstyle.setBold(); | ||
79 | mygetch(ch, dummy); | ||
80 | continue; | ||
81 | } | ||
82 | else if (ch == 'r' || ch == 'R') | ||
83 | { | ||
84 | ch = skip_ws_end(); | ||
85 | if (ch == '>') | ||
86 | { | ||
87 | ch = 10; | ||
88 | continue; | ||
89 | } | ||
90 | } | ||
91 | break; | ||
92 | case 'i': | ||
93 | case 'I': | ||
94 | ch = skip_ws_end(); | ||
95 | if (ch == '>') | ||
96 | { | ||
97 | currentstyle.setItalic(); | ||
98 | mygetch(ch, dummy); | ||
99 | continue; | ||
100 | } | ||
101 | break; | ||
102 | case 'e': | ||
103 | case 'E': | ||
104 | if ((ch = parse_m()) == 0) | ||
105 | { | ||
106 | currentstyle.setItalic(); | ||
107 | mygetch(ch, dummy); | ||
108 | continue; | ||
109 | } | ||
110 | break; | ||
111 | case 'h': | ||
112 | case 'H': | ||
113 | mygetch(ch, dummy); | ||
114 | if ('0' < ch && ch <= '9') | ||
115 | { | ||
116 | tchar hs = ch; | ||
117 | ch = skip_ws_end(); | ||
118 | if (ch == '>') | ||
119 | { | ||
120 | switch (hs) | ||
121 | { | ||
122 | case '1': | ||
123 | // currentstyle = ucBold | ucFontBase+2 | (ucAlignCentre << ucAlignShift); | ||
124 | currentstyle.unset(); | ||
125 | currentstyle.setFontSize(2); | ||
126 | currentstyle.setBold(); | ||
127 | currentstyle.setCentreJustify(); | ||
128 | break; | ||
129 | case '2': | ||
130 | // currentstyle = ucBold | ucFontBase+1; | ||
131 | currentstyle.unset(); | ||
132 | currentstyle.setFontSize(1); | ||
133 | currentstyle.setBold(); | ||
134 | break; | ||
135 | default: | ||
136 | // currentstyle = ucBold | ucFontBase; | ||
137 | currentstyle.unset(); | ||
138 | currentstyle.setBold(); | ||
139 | } | ||
140 | ch = 10; | ||
141 | // mygetch(ch, dummy); | ||
142 | continue; | ||
143 | } | ||
144 | } | ||
145 | break; | ||
146 | case '/': | ||
147 | mygetch(ch, dummy); | ||
148 | switch (ch) | ||
149 | { | ||
150 | case 'b': | ||
151 | case 'B': | ||
152 | ch = skip_ws_end(); | ||
153 | if (ch == '>') | ||
154 | { | ||
155 | currentstyle.unsetBold(); | ||
156 | mygetch(ch, dummy); | ||
157 | continue; | ||
158 | } | ||
159 | break; | ||
160 | case 'i': | ||
161 | case 'I': | ||
162 | ch = skip_ws_end(); | ||
163 | if (ch == '>') | ||
164 | { | ||
165 | currentstyle.unsetItalic(); | ||
166 | mygetch(ch, dummy); | ||
167 | continue; | ||
168 | } | ||
169 | break; | ||
170 | case 'e': | ||
171 | case 'E': | ||
172 | if ((ch = parse_m()) == 0) | ||
173 | { | ||
174 | currentstyle.unsetItalic(); | ||
175 | mygetch(ch, dummy); | ||
176 | continue; | ||
177 | } | ||
178 | break; | ||
179 | case 'h': | ||
180 | case 'H': | ||
181 | mygetch(ch, dummy); | ||
182 | if ('0' < ch && ch <= '9') | ||
183 | { | ||
184 | ch = skip_ws_end(); | ||
185 | if (ch == '>') | ||
186 | { | ||
187 | currentstyle.unset(); | ||
188 | //mygetch(ch, dummy); | ||
189 | ch = 10; | ||
190 | continue; | ||
191 | } | ||
192 | } | ||
193 | break; | ||
194 | default: | ||
195 | break; | ||
196 | } | ||
197 | break; | ||
198 | default: | ||
199 | break; | ||
200 | } | ||
201 | while (ch != '>' && ch != UEOF) | ||
202 | { | ||
203 | mygetch(ch, dummy); | ||
204 | } | ||
205 | mygetch(ch, dummy); | ||
206 | } | ||
207 | if (ch == '&') | ||
208 | { | ||
209 | mygetch(ch, dummy); | ||
210 | if (ch == '#') | ||
211 | { | ||
212 | int id = 0; | ||
213 | mygetch(ch, dummy); | ||
214 | while (ch != ';' && ch != UEOF) | ||
215 | { | ||
216 | id = 10*id+ch-'0'; | ||
217 | mygetch(ch, dummy); | ||
218 | } | ||
219 | ch = id; | ||
220 | } | ||
221 | } | ||
222 | // sty = (dummy == ucFontBase) ? currentstyle : dummy; | ||
223 | sty = currentstyle; | ||
224 | return; | ||
225 | } | ||
226 | |||
227 | 19 | ||
228 | void textfmt::mygetch(tchar& ch, CStyle& sty) | 20 | void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) |
229 | { | 21 | { |
@@ -236,3 +28,3 @@ void textfmt::mygetch(tchar& ch, CStyle& sty) | |||
236 | { | 28 | { |
237 | parent->getch(ch, sty); | 29 | parent->getch(ch, sty, pos); |
238 | } | 30 | } |
@@ -240,5 +32,5 @@ void textfmt::mygetch(tchar& ch, CStyle& sty) | |||
240 | 32 | ||
241 | void textfmt::getch(tchar& ch, CStyle& sty) | 33 | void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
242 | { | 34 | { |
243 | mygetch(ch, sty); | 35 | mygetch(ch, sty, pos); |
244 | do | 36 | do |
@@ -255,3 +47,3 @@ void textfmt::getch(tchar& ch, CStyle& sty) | |||
255 | // parent->getch(ch, sty); | 47 | // parent->getch(ch, sty); |
256 | mygetch(ch, sty); | 48 | mygetch(ch, sty, pos); |
257 | if (ch == '-') | 49 | if (ch == '-') |
@@ -279,3 +71,3 @@ void textfmt::getch(tchar& ch, CStyle& sty) | |||
279 | // parent->getch(ch, dummy); | 71 | // parent->getch(ch, dummy); |
280 | mygetch(ch, dummy); | 72 | mygetch(ch, dummy, pos); |
281 | } | 73 | } |
@@ -287,3 +79,3 @@ void textfmt::getch(tchar& ch, CStyle& sty) | |||
287 | // parent->getch(ch, dummy); | 79 | // parent->getch(ch, dummy); |
288 | mygetch(ch, dummy); | 80 | mygetch(ch, dummy, pos); |
289 | QChar c(ch); | 81 | QChar c(ch); |
@@ -314,3 +106,3 @@ void textfmt::getch(tchar& ch, CStyle& sty) | |||
314 | // parent->getch(ch, dummy); | 106 | // parent->getch(ch, dummy); |
315 | mygetch(ch, dummy); | 107 | mygetch(ch, dummy, pos); |
316 | } | 108 | } |
@@ -322,3 +114,3 @@ void textfmt::getch(tchar& ch, CStyle& sty) | |||
322 | // parent->getch(ch, dummy); | 114 | // parent->getch(ch, dummy); |
323 | mygetch(ch, dummy); | 115 | mygetch(ch, dummy, pos); |
324 | QChar c(ch); | 116 | QChar c(ch); |
@@ -344,3 +136,3 @@ void textfmt::getch(tchar& ch, CStyle& sty) | |||
344 | 136 | ||
345 | void remap::getch(tchar& ch, CStyle& sty) | 137 | void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
346 | { | 138 | { |
@@ -352,3 +144,3 @@ void remap::getch(tchar& ch, CStyle& sty) | |||
352 | } | 144 | } |
353 | parent->getch(ch, sty); | 145 | parent->getch(ch, sty, pos); |
354 | switch (ch) | 146 | switch (ch) |
@@ -425,2 +217,10 @@ void remap::getch(tchar& ch, CStyle& sty) | |||
425 | break; | 217 | break; |
218 | /* | ||
219 | case 0x0009: // tab | ||
220 | offset = 0; | ||
221 | q[0] = ' '; | ||
222 | q[1] = 0; | ||
223 | ch = ' '; | ||
224 | break; | ||
225 | */ | ||
426 | case 0x017e: | 226 | case 0x017e: |
@@ -435,3 +235,3 @@ void remap::getch(tchar& ch, CStyle& sty) | |||
435 | 235 | ||
436 | void PeanutFormatter::getch(tchar& ch, CStyle& sty) | 236 | void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
437 | { | 237 | { |
@@ -439,6 +239,6 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
439 | currentstyle.setColour(0,0,0); | 239 | currentstyle.setColour(0,0,0); |
440 | parent->getch(ch, dummy); | 240 | parent->getch(ch, dummy, pos); |
441 | while (ch == '\\') | 241 | while (ch == '\\') |
442 | { | 242 | { |
443 | parent->getch(ch, dummy); | 243 | parent->getch(ch, dummy, pos); |
444 | if (ch == '\\') break; | 244 | if (ch == '\\') break; |
@@ -451,3 +251,3 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
451 | { | 251 | { |
452 | parent->getch(ch, dummy); | 252 | parent->getch(ch, dummy, pos); |
453 | code = 10*code + ch - '0'; | 253 | code = 10*code + ch - '0'; |
@@ -461,9 +261,9 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
461 | { | 261 | { |
462 | parent->getch(ch, dummy); | 262 | parent->getch(ch, dummy, pos); |
463 | if (ch == '\\') | 263 | if (ch == '\\') |
464 | { | 264 | { |
465 | parent->getch(ch, dummy); | 265 | parent->getch(ch, dummy, pos); |
466 | if (ch == 'v') | 266 | if (ch == 'v') |
467 | { | 267 | { |
468 | parent->getch(ch, dummy); | 268 | parent->getch(ch, dummy, pos); |
469 | break; | 269 | break; |
@@ -477,3 +277,3 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
477 | currentstyle.setFontSize(0); | 277 | currentstyle.setFontSize(0); |
478 | parent->getch(ch,dummy); | 278 | parent->getch(ch,dummy, pos); |
479 | break; | 279 | break; |
@@ -493,3 +293,3 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
493 | } | 293 | } |
494 | parent->getch(ch, dummy); | 294 | parent->getch(ch, dummy, pos); |
495 | break; | 295 | break; |
@@ -518,3 +318,3 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
518 | } | 318 | } |
519 | parent->getch(ch, dummy); | 319 | parent->getch(ch, dummy, pos); |
520 | break; | 320 | break; |
@@ -530,3 +330,3 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
530 | } | 330 | } |
531 | parent->getch(ch, dummy); | 331 | parent->getch(ch, dummy, pos); |
532 | break; | 332 | break; |
@@ -541,3 +341,3 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
541 | } | 341 | } |
542 | parent->getch(ch, dummy); | 342 | parent->getch(ch, dummy, pos); |
543 | break; | 343 | break; |
@@ -552,3 +352,3 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
552 | } | 352 | } |
553 | parent->getch(ch, dummy); | 353 | parent->getch(ch, dummy, pos); |
554 | break; | 354 | break; |
@@ -561,8 +361,8 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty) | |||
561 | 361 | ||
562 | void OnePara::getch(tchar& ch, CStyle& sty) | 362 | void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
563 | { | 363 | { |
564 | parent->getch(ch, sty); | 364 | parent->getch(ch, sty, pos); |
565 | if (m_lastchar == 10) | 365 | if (m_lastchar == 10) |
566 | { | 366 | { |
567 | while (ch == 10) parent->getch(ch, sty); | 367 | while (ch == 10) parent->getch(ch, sty, pos); |
568 | } | 368 | } |
@@ -571,6 +371,5 @@ void OnePara::getch(tchar& ch, CStyle& sty) | |||
571 | 371 | ||
572 | #ifdef REPALM | 372 | void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
573 | void repalm::getch(tchar& ch, CStyle& sty) | ||
574 | { | 373 | { |
575 | parent->getch(ch, sty); | 374 | parent->getch(ch, sty, pos); |
576 | switch (ch) | 375 | switch (ch) |
@@ -682,3 +481,2 @@ void repalm::getch(tchar& ch, CStyle& sty) | |||
682 | } | 481 | } |
683 | #endif | ||
684 | 482 | ||
@@ -687,3 +485,3 @@ void repalm::getch(tchar& ch, CStyle& sty) | |||
687 | 485 | ||
688 | void DePluck::getch(tchar& ch, CStyle& sty) | 486 | void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
689 | { | 487 | { |
@@ -706,3 +504,3 @@ void DePluck::getch(tchar& ch, CStyle& sty) | |||
706 | } | 504 | } |
707 | unsigned long lnk; | 505 | unsigned long lnk, lnkoff; |
708 | do | 506 | do |
@@ -710,5 +508,9 @@ void DePluck::getch(tchar& ch, CStyle& sty) | |||
710 | if (nextpart[m_buffed] == 0) break; | 508 | if (nextpart[m_buffed] == 0) break; |
711 | parent->getch(ch, sty); | 509 | parent->getch(ch, sty, pos); |
712 | m_laststyle = sty; | 510 | m_laststyle = sty; |
713 | if (sty.getLink()) lnk = sty.getData(); | 511 | if (sty.getLink()) |
512 | { | ||
513 | lnk = sty.getData(); | ||
514 | lnkoff = sty.getOffset(); | ||
515 | } | ||
714 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); | 516 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); |
@@ -718,10 +520,10 @@ void DePluck::getch(tchar& ch, CStyle& sty) | |||
718 | m_buffed = 0; | 520 | m_buffed = 0; |
719 | QString dmy; | 521 | QString dmy, dmy2; |
720 | parent->hyperlink(lnk, dmy); | 522 | parent->hyperlink(lnk, lnkoff, dmy, dmy2); |
721 | do | 523 | do |
722 | { | 524 | { |
723 | parent->getch(ch, sty); | 525 | parent->getch(ch, sty, pos); |
724 | } | 526 | } |
725 | while (ch != 10); | 527 | while (ch != 10); |
726 | parent->getch(ch, sty); | 528 | parent->getch(ch, sty, pos); |
727 | } | 529 | } |
@@ -741 +543,273 @@ void DePluck::getch(tchar& ch, CStyle& sty) | |||
741 | } | 543 | } |
544 | |||
545 | HighlightFilter::HighlightFilter(QTReader* _p) : pReader(_p), lastpos(0), nextpos(0), red(255), green(255), blue(255) | ||
546 | { | ||
547 | } | ||
548 | |||
549 | #include "Bkmks.h" | ||
550 | #include "QTReader.h" | ||
551 | |||
552 | void HighlightFilter::refresh(unsigned long pos) | ||
553 | { | ||
554 | bkmks = pReader->Bkmklist(); | ||
555 | |||
556 | red = green = blue = 255; | ||
557 | |||
558 | if (bkmks == NULL) | ||
559 | { | ||
560 | lastpos = 0; | ||
561 | nextpos = 0xffffffff; | ||
562 | } | ||
563 | else | ||
564 | { | ||
565 | lastpos = 0; | ||
566 | nextpos = 0xffffffff; | ||
567 | for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++) | ||
568 | { | ||
569 | if ((*i).value() <= pos && pos < (*i).value2()) | ||
570 | { | ||
571 | red = i->red(); | ||
572 | green = i->green(); | ||
573 | blue = i->blue(); | ||
574 | lastpos = (*i).value(); | ||
575 | nextpos = (*i).value2(); | ||
576 | break; | ||
577 | } | ||
578 | if ((*i).value() > pos) | ||
579 | { | ||
580 | nextpos = (*i).value(); | ||
581 | break; | ||
582 | } | ||
583 | lastpos = (*i).value(); | ||
584 | } | ||
585 | } | ||
586 | } | ||
587 | |||
588 | void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
589 | { | ||
590 | parent->getch(ch, sty, pos); | ||
591 | if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) | ||
592 | { | ||
593 | // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); | ||
594 | refresh(pos); | ||
595 | // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); | ||
596 | } | ||
597 | int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); | ||
598 | if (r == 255 && g == 255 && b == 255) | ||
599 | { | ||
600 | sty.setBackground(red, green, blue); | ||
601 | } | ||
602 | } | ||
603 | |||
604 | void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
605 | { | ||
606 | if (uselast) | ||
607 | { | ||
608 | ch = lastchar; | ||
609 | sty = laststy; | ||
610 | uselast = false; | ||
611 | return; | ||
612 | } | ||
613 | else | ||
614 | { | ||
615 | parent->getch(ch, sty, pos); | ||
616 | } | ||
617 | switch (ch) | ||
618 | { | ||
619 | case 'f': | ||
620 | { | ||
621 | tchar savedchar = 'f'; | ||
622 | parent->getch(ch, sty, pos); | ||
623 | switch (ch) | ||
624 | { | ||
625 | case 'i': | ||
626 | ch = (251 << 8) + 1; | ||
627 | break; | ||
628 | case 'l': | ||
629 | ch = (251 << 8) + 2; | ||
630 | break; | ||
631 | default: | ||
632 | lastchar = ch; | ||
633 | uselast = true; | ||
634 | laststy = sty; | ||
635 | ch = savedchar; | ||
636 | } | ||
637 | } | ||
638 | break; | ||
639 | default: | ||
640 | break; | ||
641 | } | ||
642 | } | ||
643 | |||
644 | class ErrorFilter : public CFilter | ||
645 | { | ||
646 | QString error; | ||
647 | int currentpos; | ||
648 | public: | ||
649 | ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} | ||
650 | ~ErrorFilter() {} | ||
651 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
652 | { | ||
653 | if (currentpos == error.length()) | ||
654 | { | ||
655 | ch = UEOF; | ||
656 | currentpos = 0; | ||
657 | } | ||
658 | else | ||
659 | { | ||
660 | ch = error[currentpos++].unicode(); | ||
661 | } | ||
662 | } | ||
663 | QString about() { return parent->about(); } | ||
664 | }; | ||
665 | |||
666 | #ifndef __STATIC | ||
667 | ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) | ||
668 | { | ||
669 | QString filterpath(QTReaderUtil::getPluginPath("filters/lib")); | ||
670 | filterpath += nm; | ||
671 | filterpath += ".so"; | ||
672 | if (QFile::exists(filterpath)) | ||
673 | { | ||
674 | qDebug("Filter:%s", (const char*)filterpath); | ||
675 | handle = dlopen(filterpath, RTLD_LAZY); | ||
676 | if (handle == 0) | ||
677 | { | ||
678 | qDebug("Can't find filter:%s", dlerror()); | ||
679 | // status = -10; | ||
680 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); | ||
681 | return; | ||
682 | } | ||
683 | CFilter* (*newfilter)(const QString&); | ||
684 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); | ||
685 | if (newfilter == NULL) | ||
686 | { | ||
687 | qDebug("Can't find newfilter"); | ||
688 | filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); | ||
689 | return; | ||
690 | } | ||
691 | filt = (*newfilter)(optional); | ||
692 | } | ||
693 | else | ||
694 | { | ||
695 | qDebug("No filter path"); | ||
696 | filt = new ErrorFilter(QString("No filter plugins installed:")+nm); | ||
697 | } | ||
698 | if (filt == NULL) | ||
699 | { | ||
700 | qDebug("Can't do newfilter"); | ||
701 | filt = new ErrorFilter(QString("Filter creation failed:")+nm); | ||
702 | return; | ||
703 | } | ||
704 | } | ||
705 | #endif | ||
706 | |||
707 | void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
708 | { | ||
709 | parent->getch(ch, sty, pos); | ||
710 | int r,g,b; | ||
711 | r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); | ||
712 | sty.setColour(r,g,b); | ||
713 | r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); | ||
714 | sty.setBackground(r,g,b); | ||
715 | r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); | ||
716 | sty.setPaper(r,g,b); | ||
717 | } | ||
718 | /* | ||
719 | void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
720 | { | ||
721 | parent->getch(ch, sty, pos); | ||
722 | QColor fg(sty.Red(), sty.Green(), sty.Blue()); | ||
723 | int h,s,v; | ||
724 | fg.hsv(&h,&s,&v); | ||
725 | fg.setHsv(h,s,255-v); | ||
726 | int r,g,b; | ||
727 | fg.rgb(&r,&g,&b); | ||
728 | sty.setColour(r,g,b); | ||
729 | |||
730 | fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); | ||
731 | fg.hsv(&h,&s,&v); | ||
732 | fg.setHsv(h,s,255-v); | ||
733 | fg.rgb(&r,&g,&b); | ||
734 | sty.setBackground(r,g,b); | ||
735 | } | ||
736 | */ | ||
737 | void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
738 | { | ||
739 | parent->getch(ch, sty, pos); | ||
740 | int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); | ||
741 | if (r == 255 && g == 255 && b == 255) | ||
742 | { | ||
743 | sty.setPaper(m_r,m_g,m_b); | ||
744 | } | ||
745 | else | ||
746 | { | ||
747 | qDebug("We have background [%x%x%x]", r, g, b); | ||
748 | } | ||
749 | r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); | ||
750 | if (r == 255 && g == 255 && b == 255) | ||
751 | { | ||
752 | sty.setBackground(m_r,m_g,m_b); | ||
753 | } | ||
754 | else | ||
755 | { | ||
756 | qDebug("We have background [%x%x%x]", r, g, b); | ||
757 | } | ||
758 | } | ||
759 | |||
760 | void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
761 | { | ||
762 | parent->getch(ch, sty, pos); | ||
763 | int r = sty.Red(), g = sty.Green(), b = sty.Blue(); | ||
764 | if (r == 0 && g == 0 && b == 0) | ||
765 | { | ||
766 | sty.setColour(m_r,m_g,m_b); | ||
767 | } | ||
768 | } | ||
769 | |||
770 | #include "CRegExp.h" | ||
771 | |||
772 | repara::repara(const QString& pat) : tch(0) | ||
773 | { | ||
774 | // QString pat("{\\n[A-Z\"]}"); | ||
775 | flt = new CRegExpFilt(pat, false); | ||
776 | qDebug("Construction done"); | ||
777 | } | ||
778 | |||
779 | repara::~repara() | ||
780 | { | ||
781 | delete flt; | ||
782 | } | ||
783 | |||
784 | void repara::getch(tchar& ch, CStyle& sty, unsigned long& pos) | ||
785 | { | ||
786 | if (flt->empty()) | ||
787 | { | ||
788 | while (flt->empty()) | ||
789 | { | ||
790 | parent->getch(ch, sty, pos); | ||
791 | flt->addch(ch); | ||
792 | } | ||
793 | } | ||
794 | ch = flt->pop(); | ||
795 | /* | ||
796 | parent->getch(ch, sty, pos); | ||
797 | if (ch == 10 || ch == ' ') | ||
798 | { | ||
799 | if (tch == 10) | ||
800 | { | ||
801 | tch = ch; | ||
802 | ch = 10; | ||
803 | return; | ||
804 | } | ||
805 | else | ||
806 | { | ||
807 | tch = ch; | ||
808 | ch = ' '; | ||
809 | return; | ||
810 | } | ||
811 | } | ||
812 | tch = ch; | ||
813 | */ | ||
814 | return; | ||
815 | } | ||