Subversion Repositories Scribus

Rev

Rev 16941 | Rev 22635 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 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
*/
364 Franz 7
/***************************************************************************
403 Franz 8
 *   Copyright (C) 2004 by Riku Leino                                      *
1184 tsoots 9
 *   tsoots@gmail.com                                                      *
403 Franz 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.,                                       *
18122 mrdocs 24
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
364 Franz 25
 ***************************************************************************/
26
#ifndef HTMLREADER_H
27
#define HTMLREADER_H
28
 
2688 craig 29
#include "scconfig.h"
399 Franz 30
 
403 Franz 31
#include <vector>
399 Franz 32
#include <libxml/HTMLparser.h>
33
 
10223 cbradney 34
#include <QString>
35
#include <QXmlAttributes>
364 Franz 36
 
37
#include <gtparagraphstyle.h>
38
#include <gtwriter.h>
39
 
4140 subik 40
/*! \brief Parse and import a HTML file.
41
Supported tags: P, CENTER, BR, A, UL, OL, LI, H1, H2, H3, H4,
42
B, STRONG, I, EM, CODE, BODY, PRE, IMG, SUB, SUP, DEL, INS, U,
43
DIV.
44
*/
403 Franz 45
class HTMLReader
364 Franz 46
{
47
private:
48
        QString currentDir;
49
        QString currentFile;
50
        QString defaultColor;
399 Franz 51
        QString defaultWeight;
52
        QString defaultSlant;
364 Franz 53
        QString templateCategory;
54
        QString href;
403 Franz 55
        QString extLinks;
56
        int extIndex;
57
        int listLevel;
58
        std::vector<gtParagraphStyle*> listStyles;
59
        std::vector<int> nextItemNumbers;
364 Franz 60
        gtWriter *writer;
61
        gtParagraphStyle *pstyle;
62
        gtParagraphStyle *pstylec;
63
        gtParagraphStyle *pstyleh1;
64
        gtParagraphStyle *pstyleh2;
65
        gtParagraphStyle *pstyleh3;
399 Franz 66
        gtParagraphStyle *pstyleh4;
16941 jghali 67
        gtParagraphStyle *pstyleh5;
68
        gtParagraphStyle *pstyleh6;
399 Franz 69
        gtParagraphStyle *pstylecode;
70
        gtParagraphStyle *pstylep;
71
        gtParagraphStyle *pstylepre;
364 Franz 72
        bool inOL;
403 Franz 73
        bool wasInOL;
364 Franz 74
        bool inUL;
403 Franz 75
        bool wasInUL;
364 Franz 76
        bool inLI;
77
        bool addedLI;
78
        bool inH1;
79
        bool inH2;
80
        bool inH3;
399 Franz 81
        bool inH4;
16941 jghali 82
        bool inH5;
83
        bool inH6;
364 Franz 84
        bool inA;
85
        bool inCenter;
86
        bool inCode;
399 Franz 87
        bool inBody;
88
        bool inPre;
89
        bool inP;
8527 jghali 90
        static bool elemJustStarted;
91
        static bool elemJustFinished;
399 Franz 92
        bool lastCharWasSpace;
403 Franz 93
        bool noFormatting;
364 Franz 94
        void initPStyles();
399 Franz 95
        void toggleEffect(FontEffect e);
96
        void setItalicFont();
97
        void unsetItalicFont();
364 Franz 98
        void setBlueFont();
399 Franz 99
        void setDefaultColor();
364 Franz 100
        void setBoldFont();
101
        void unSetBoldFont();
403 Franz 102
        void createListStyle();
399 Franz 103
        static HTMLReader* hreader;
364 Franz 104
public:
403 Franz 105
        HTMLReader(gtParagraphStyle *ps, gtWriter *w, bool textOnly);
364 Franz 106
        ~HTMLReader();
399 Franz 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);
364 Franz 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