summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/striphtml.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/striphtml.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/striphtml.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/striphtml.h b/noncore/apps/opie-reader/striphtml.h
new file mode 100644
index 0000000..42e2b7e
--- a/dev/null
+++ b/noncore/apps/opie-reader/striphtml.h
@@ -0,0 +1,93 @@
1#ifndef __STRIPHTML_H
2#define __STRIPHTML_H
3
4#include "CFilter.h"
5#include "Navigation.h"
6#include "CBuffer.h"
7#include "CExpander.h"
8#include "my_list.h"
9
10class striphtml : public CFilter
11{
12 bool ignorespace;
13 bool m_bchm;
14 CList<CStyle> stylestack;
15 static CNavigation_base<htmlmark> m_nav;
16 QMap<QString, tchar>* entmap;
17 CStyle currentstyle;
18 bool isPre;
19 unsigned short skip_ws();
20 unsigned short skip_ws_end();
21 unsigned short skip_ws_end(unsigned long&);
22 unsigned short parse_m();
23 QMap<QString, unsigned long>* href2filepos;
24 QMap<unsigned long, QString>* id2href;
25 unsigned long currentid;
26 tchar lastch;
27 QString currentfile;
28 QString q;
29 bool forcecentre, m_inblock;
30 QString text_q;
31 int indent;
32 int m_listtype[m_cmaxdepth];
33 int m_ctr[m_cmaxdepth];
34 void mygetch(tchar& ch, CStyle& sty, unsigned long& pos);
35 void initentmap();
36 QString getname(tchar& ch, const QString& nd);
37 void skipblock(const QString&);
38 QString getattr(tchar&);
39 QString dehtml(const QString& _info);
40 void parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long);
41 int getpara(CBuffer&, unsigned long&);
42 public:
43 QString about() { return QString("HTML filter (c) Tim Wentford\n")+parent->about(); }
44 striphtml(const QString&);
45 ~striphtml();
46 void getch(tchar& ch, CStyle& sty, unsigned long& pos);
47 virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm);
48 bool findanchor(const QString&);
49
50
51 void saveposn(const QString& f, size_t posn) { m_nav.saveposn(htmlmark(f, posn)); }
52 void writeposn(const QString& f, size_t posn) { m_nav.writeposn(htmlmark(f, posn)); }
53 linkType forward(QString& f, size_t& loc)
54 {
55 htmlmark m(f, loc);
56 linkType ret = (m_nav.forward(m)) ? eFile : eNone;
57 if (f == m.filename())
58 {
59 if (ret == eFile)
60 {
61 ret = eLink;
62 }
63 }
64 else
65 {
66 f = m.filename();
67 }
68 loc = m.posn();
69 return ret;
70 }
71 linkType back(QString& f, size_t& loc)
72 {
73 htmlmark m(f, loc);
74 linkType ret = (m_nav.back(m)) ? eFile : eNone;
75 if (f == m.filename())
76 {
77 if (ret == eFile)
78 {
79 ret = eLink;
80 }
81 }
82 else
83 {
84 f = m.filename();
85 }
86 loc = m.posn();
87 return ret;
88 }
89 bool hasnavigation() { return true; }
90 virtual void locate(unsigned int n);
91 void setchm(bool _b) { m_bchm = _b; }
92};
93#endif