Scribus
Open source desktop publishing at your fingertips
htmlreader.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8  * Copyright (C) 2004 by Riku Leino *
9  * tsoots@gmail.com *
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  * This program is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19  * GNU General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU General Public License *
22  * along with this program; if not, write to the *
23  * Free Software Foundation, Inc., *
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25  ***************************************************************************/
26 #ifndef HTMLREADER_H
27 #define HTMLREADER_H
28 
29 #include "scconfig.h"
30 
31 #include <vector>
32 #include <libxml/HTMLparser.h>
33 
34 #include <QString>
35 #include <QXmlAttributes>
36 
37 #include <gtparagraphstyle.h>
38 #include <gtwriter.h>
39 
46 {
47 private:
48  QString currentDir;
49  QString currentFile;
50  QString defaultColor;
51  QString defaultWeight;
52  QString defaultSlant;
53  QString templateCategory;
54  QString href;
55  QString extLinks;
56  int extIndex;
57  int listLevel;
58  std::vector<gtParagraphStyle*> listStyles;
59  std::vector<int> nextItemNumbers;
60  gtWriter *writer;
61  gtParagraphStyle *pstyle;
62  gtParagraphStyle *pstylec;
63  gtParagraphStyle *pstyleh1;
64  gtParagraphStyle *pstyleh2;
65  gtParagraphStyle *pstyleh3;
66  gtParagraphStyle *pstyleh4;
67  gtParagraphStyle *pstyleh5;
68  gtParagraphStyle *pstyleh6;
69  gtParagraphStyle *pstylecode;
70  gtParagraphStyle *pstylep;
71  gtParagraphStyle *pstylepre;
72  bool inOL;
73  bool wasInOL;
74  bool inUL;
75  bool wasInUL;
76  bool inLI;
77  bool addedLI;
78  bool inH1;
79  bool inH2;
80  bool inH3;
81  bool inH4;
82  bool inH5;
83  bool inH6;
84  bool inA;
85  bool inCenter;
86  bool inCode;
87  bool inBody;
88  bool inPre;
89  bool inP;
90  static bool elemJustStarted;
91  static bool elemJustFinished;
92  bool lastCharWasSpace;
93  bool noFormatting;
94  void initPStyles();
95  void toggleEffect(FontEffect e);
96  void setItalicFont();
97  void unsetItalicFont();
98  void setBlueFont();
99  void setDefaultColor();
100  void setBoldFont();
101  void unSetBoldFont();
102  void createListStyle();
103  static HTMLReader* hreader;
104 public:
105  HTMLReader(gtParagraphStyle *ps, gtWriter *w, bool textOnly);
106  ~HTMLReader();
107  void parse(QString filename);
108  static void startElement(void *user_data, const xmlChar * fullname, const xmlChar ** atts);
109  static void endElement(void *user_data, const xmlChar * name);
110  static void characters(void *user_data, const xmlChar * ch, int len);
111  bool startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs);
112  bool endElement(const QString&, const QString&, const QString &name);
113  bool characters(const QString &ch);
114 };
115 
116 #endif
Definition: gtwriter.h:38
Parse and import a HTML file. Supported tags: P, CENTER, BR, A, UL, OL, LI, H1, H2, H3, H4, B, STRONG, I, EM, CODE, BODY, PRE, IMG, SUB, SUP, DEL, INS, U, DIV.
Definition: htmlreader.h:45
Definition: gtparagraphstyle.h:51