filters

khtmlreader.h

00001 /***************************************************************************
00002                           khtmlreader.h  -  description
00003                              -------------------
00004     begin                : Sun Sep 9 2001
00005     copyright            : (C) 2001 by Frank Dekervel
00006     email                : Frank.Dekervel@student.kuleuven.ac.be
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU Lesser General Public License as        *
00013  *   published by                                                          *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #ifndef KHTMLREADER_H
00020 #define KHTMLREADER_H
00021 
00022 #include <khtml_part.h> // fixme speedup compile time by moving these into the cpp file.
00023 #include <qdom.h>
00024 #include <qptrstack.h>
00025 #include <kwdwriter.h>
00026 
00027 //#include <qstack.h>
00028 
00033 namespace DOM {
00034     class Node;
00035     class Element;
00036 }
00037 
00038 struct HTMLReader_state {
00039   QDomElement format;
00040   QDomElement frameset;
00041   QDomElement paragraph;
00042   QDomElement layout;
00043   bool in_pre_mode; // keep formatting as is.
00044 };
00045 
00046 class KHTMLReader: public QObject {
00047 
00048 Q_OBJECT
00049 
00050 public:
00051     KHTMLReader(KWDWriter *writer);
00052     ~KHTMLReader();
00053     
00054     bool filter(KURL url);
00055 
00056 private slots:
00057     void completed();
00058 
00059 private:    
00060     void parseNode(DOM::Node n);
00061         bool parseTag(DOM::Element e);
00062         void parseStyle(DOM::Element e);
00063     void parse_head(DOM::Element e);
00064         HTMLReader_state *state();
00065         HTMLReader_state *pushNewState();
00066         void popState();
00067 
00068 
00069   /*      void stateSetFormat(QDomElement f);
00070         void stateSetFrameset(QDomElement f);
00071         void stateSetLayout(QDomElement l);
00072         void stateSetParagraph(QDomElement p);*/
00073 
00074         QPtrStack<HTMLReader_state> _state;
00075         KHTMLPart *_html;
00076         KWDWriter *_writer;
00077 
00078     void startNewLayout(bool startNewFormat=false);
00079     void startNewLayout(bool startNewFormat, QDomElement layout);
00080         void startNewParagraph(bool startnewformat=true, bool startnewlayout=true);
00081         bool _it_worked;
00082 // -----------------------------------------------------
00083         int _list_depth;
00084 // -----------------------------------------------------
00085     bool parse_CommonAttributes(DOM::Element e);
00086     bool parse_a(DOM::Element e);
00087     bool parse_p(DOM::Element e);
00088     bool parse_br(DOM::Element e);
00089     bool parse_table(DOM::Element e);
00090     bool parse_pre(DOM::Element e);
00091     bool parse_font(DOM::Element e);
00092     bool parse_ol(DOM::Element e);
00093     bool parse_ul(DOM::Element e);
00094     bool parse_hr(DOM::Element e);
00095     bool parse_img(DOM::Element e);
00096 
00097 
00098 // -------------------------------------------------------
00099 
00100 };
00101 
00102 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys