summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/striphtml.h
blob: b1f7c0a3f923c95ded619929e5b359b8fb3b76b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef __STRIPHTML_H
#define __STRIPHTML_H

#include "CFilter.h"
#include "Navigation.h"
#include "CBuffer.h"
#include "CExpander.h"
#include "my_list.h"

class striphtml : public CFilter
{
  void reset();
  bool ignorespace;
  bool m_bchm;
  int tablenesteddepth;
   CList<CStyle> stylestack;
  static CNavigation_base<htmlmark> m_nav;
  QMap<QString, tchar>* entmap;
    CStyle currentstyle;
    bool isPre;
    unsigned short skip_ws();
    unsigned short skip_ws_end();
    unsigned short skip_ws_end(unsigned long&);
    unsigned short parse_m();
    QMap<QString, unsigned long>* href2filepos;
    QMap<unsigned long, QString>* id2href;
    unsigned long currentid;
    tchar lastch;
    QString currentfile;
    QString q;
    bool forcecentre, m_inblock;
    QString text_q;
    int indent;
    int m_listtype[m_cmaxdepth];
    int m_ctr[m_cmaxdepth];
    void mygetch(tchar& ch, CStyle& sty, unsigned long& pos);
    void initentmap();
    QString getname(tchar& ch, const QString& nd);
    void skipblock(const QString&);
    QString getattr(tchar&);
    QString dehtml(const QString& _info);
    void parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long);
    int getpara(CBuffer&, unsigned long&);
 public:
    QString about() { return QString("HTML filter (c) Tim Wentford\n")+parent->about(); }
    striphtml(const QString&);
    ~striphtml();
    void getch(tchar& ch, CStyle& sty, unsigned long& pos);
    virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm);
    bool findanchor(const QString&);


    void saveposn(const QString& f, size_t posn) { m_nav.saveposn(htmlmark(f, posn)); }
    void writeposn(const QString& f, size_t posn) { m_nav.writeposn(htmlmark(f, posn)); }
    linkType forward(QString& f, size_t& loc)
      {
	htmlmark m(f, loc);
	linkType ret =  (m_nav.forward(m)) ? eFile : eNone;
	if (f == m.filename())
	  {
	    if (ret == eFile)
	      {
		ret = eLink;
	      }
	  }
	else
	  {
	    f = m.filename();
	  }
	loc = m.posn();
	return ret;
      }
    linkType back(QString& f, size_t& loc)
      {
	htmlmark m(f, loc);
	linkType ret =  (m_nav.back(m)) ? eFile : eNone;
	if (f == m.filename())
	  {
	    if (ret == eFile)
	      {
		ret = eLink;
	      }
	  }
	else
	  {
	    f = m.filename();
	  }
	loc = m.posn();
	return ret;
      }
    bool hasnavigation() { return true; }
    virtual void locate(unsigned int n);
    void setchm(bool _b) { m_bchm = _b; }
    QString getTableAsHtml(unsigned long loc);
};
#endif