Rev 2688 | Rev 4430 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
364 | Franz | 1 | /*************************************************************************** |
403 | Franz | 2 | * Copyright (C) 2004 by Riku Leino * |
1184 | tsoots | 3 | * tsoots@gmail.com * |
403 | Franz | 4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
||
6 | * it under the terms of the GNU General Public License as published by * |
||
7 | * the Free Software Foundation; either version 2 of the License, or * |
||
8 | * (at your option) any later version. * |
||
9 | * * |
||
10 | * This program is distributed in the hope that it will be useful, * |
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
13 | * GNU General Public License for more details. * |
||
14 | * * |
||
15 | * You should have received a copy of the GNU General Public License * |
||
16 | * along with this program; if not, write to the * |
||
17 | * Free Software Foundation, Inc., * |
||
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
364 | Franz | 19 | ***************************************************************************/ |
20 | #ifndef HTMLREADER_H |
||
21 | #define HTMLREADER_H |
||
22 | |||
2688 | craig | 23 | #include "scconfig.h" |
399 | Franz | 24 | |
25 | #ifdef HAVE_XML |
||
26 | |||
403 | Franz | 27 | #include <vector> |
28 | |||
399 | Franz | 29 | #include <libxml/HTMLparser.h> |
30 | |||
403 | Franz | 31 | #include <qstring.h> |
364 | Franz | 32 | #include <qxml.h> |
33 | |||
34 | #include <gtparagraphstyle.h> |
||
35 | #include <gtwriter.h> |
||
36 | |||
4140 | subik | 37 | /*! \brief Parse and import a HTML file. |
38 | Supported tags: P, CENTER, BR, A, UL, OL, LI, H1, H2, H3, H4, |
||
39 | B, STRONG, I, EM, CODE, BODY, PRE, IMG, SUB, SUP, DEL, INS, U, |
||
40 | DIV. |
||
41 | */ |
||
403 | Franz | 42 | class HTMLReader |
364 | Franz | 43 | { |
44 | private: |
||
45 | QString currentDir; |
||
46 | QString currentFile; |
||
47 | QString defaultColor; |
||
399 | Franz | 48 | QString defaultWeight; |
49 | QString defaultSlant; |
||
364 | Franz | 50 | QString templateCategory; |
51 | QString href; |
||
403 | Franz | 52 | QString extLinks; |
53 | int extIndex; |
||
54 | int listLevel; |
||
55 | std::vector<gtParagraphStyle*> listStyles; |
||
56 | std::vector<int> nextItemNumbers; |
||
364 | Franz | 57 | gtWriter *writer; |
58 | gtParagraphStyle *pstyle; |
||
59 | gtParagraphStyle *pstylec; |
||
60 | gtParagraphStyle *pstyleh1; |
||
61 | gtParagraphStyle *pstyleh2; |
||
62 | gtParagraphStyle *pstyleh3; |
||
399 | Franz | 63 | gtParagraphStyle *pstyleh4; |
64 | gtParagraphStyle *pstylecode; |
||
65 | gtParagraphStyle *pstylep; |
||
66 | gtParagraphStyle *pstylepre; |
||
364 | Franz | 67 | bool inOL; |
403 | Franz | 68 | bool wasInOL; |
364 | Franz | 69 | bool inUL; |
403 | Franz | 70 | bool wasInUL; |
364 | Franz | 71 | bool inLI; |
72 | bool addedLI; |
||
73 | bool inH1; |
||
74 | bool inH2; |
||
75 | bool inH3; |
||
399 | Franz | 76 | bool inH4; |
364 | Franz | 77 | bool inA; |
78 | bool inCenter; |
||
79 | bool inCode; |
||
399 | Franz | 80 | bool inBody; |
81 | bool inPre; |
||
82 | bool inP; |
||
83 | bool lastCharWasSpace; |
||
403 | Franz | 84 | bool noFormatting; |
364 | Franz | 85 | void initPStyles(); |
399 | Franz | 86 | void toggleEffect(FontEffect e); |
87 | void setItalicFont(); |
||
88 | void unsetItalicFont(); |
||
364 | Franz | 89 | void setBlueFont(); |
399 | Franz | 90 | void setDefaultColor(); |
364 | Franz | 91 | void setBoldFont(); |
92 | void unSetBoldFont(); |
||
403 | Franz | 93 | void createListStyle(); |
399 | Franz | 94 | static HTMLReader* hreader; |
364 | Franz | 95 | public: |
403 | Franz | 96 | HTMLReader(gtParagraphStyle *ps, gtWriter *w, bool textOnly); |
364 | Franz | 97 | ~HTMLReader(); |
399 | Franz | 98 | void parse(QString filename); |
99 | static void startElement(void *user_data, const xmlChar * fullname, const xmlChar ** atts); |
||
100 | static void endElement(void *user_data, const xmlChar * name); |
||
101 | static void characters(void *user_data, const xmlChar * ch, int len); |
||
364 | Franz | 102 | bool startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs); |
103 | bool endElement(const QString&, const QString&, const QString &name); |
||
104 | bool characters(const QString &ch); |
||
105 | }; |
||
106 | |||
399 | Franz | 107 | #endif // HAVE_XML |
108 | |||
364 | Franz | 109 | #endif |