summaryrefslogtreecommitdiffstats
path: root/filters/kword/html/import/tdehtmlreader.h
blob: bee84c606c5477148ff01a7c13f394c08b07707c (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
97
98
99
100
101
102
103
/***************************************************************************
                          tdehtmlreader.h  -  description
                             -------------------
    begin                : Sun Sep 9 2001
    copyright            : (C) 2001 by Frank Dekervel
    email                : Frank.Dekervel@student.kuleuven.ac.be
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Lesser General Public License as        *
 *   published by                                                          *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KHTMLREADER_H
#define KHTMLREADER_H

#include <tdehtml_part.h> // fixme speedup compile time by moving these into the cpp file.
#include <tqdom.h>
#include <tqptrstack.h>
#include <kwdwriter.h>

//#include <tqstack.h>

/**
  *@author Frank Dekervel
  */

namespace DOM {
 	class Node;
 	class Element;
}

struct HTMLReader_state {
  TQDomElement format;
  TQDomElement frameset;
  TQDomElement paragraph;
  TQDomElement layout;
  bool in_pre_mode; // keep formatting as is.
};

class KHTMLReader: public TQObject {

Q_OBJECT
  

public:
	KHTMLReader(KWDWriter *writer);
	~KHTMLReader();
	
	bool filter(KURL url);

private slots:
	void completed();

private:	
	void parseNode(DOM::Node n);
        bool parseTag(DOM::Element e);
        void parseStyle(DOM::Element e);
	void parse_head(DOM::Element e);
        HTMLReader_state *state();
        HTMLReader_state *pushNewState();
        void popState();


  /*      void stateSetFormat(TQDomElement f);
        void stateSetFrameset(TQDomElement f);
        void stateSetLayout(TQDomElement l);
        void stateSetParagraph(TQDomElement p);*/

        TQPtrStack<HTMLReader_state> _state;
        KHTMLPart *_html;
        KWDWriter *_writer;

	void startNewLayout(bool startNewFormat=false);
	void startNewLayout(bool startNewFormat, TQDomElement layout);
        void startNewParagraph(bool startnewformat=true, bool startnewlayout=true);
        bool _it_worked;
// -----------------------------------------------------
        int _list_depth;
// -----------------------------------------------------
	bool parse_CommonAttributes(DOM::Element e);
	bool parse_a(DOM::Element e);
	bool parse_p(DOM::Element e);
	bool parse_br(DOM::Element e);
	bool parse_table(DOM::Element e);
	bool parse_pre(DOM::Element e);
	bool parse_font(DOM::Element e);
	bool parse_ol(DOM::Element e);
	bool parse_ul(DOM::Element e);
	bool parse_hr(DOM::Element e);
	bool parse_img(DOM::Element e);


// -------------------------------------------------------

};

#endif