Back to index

scribus-ng  1.3.4.dfsg+svn20071115
htmlreader.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008  *   Copyright (C) 2004 by Riku Leino                                      *
00009  *   tsoots@gmail.com                                                      *
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  *   This program is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00019  *   GNU General Public License for more details.                          *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU General Public License     *
00022  *   along with this program; if not, write to the                         *
00023  *   Free Software Foundation, Inc.,                                       *
00024  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00025  ***************************************************************************/
00026 #ifndef HTMLREADER_H
00027 #define HTMLREADER_H
00028 
00029 #include "scconfig.h"
00030 
00031 #ifdef HAVE_XML
00032 
00033 #include <vector>
00034 
00035 #include <libxml/HTMLparser.h>
00036 
00037 #include <qstring.h>
00038 #include <qxml.h>
00039 
00040 #include <gtparagraphstyle.h>
00041 #include <gtwriter.h>
00042 
00048 class HTMLReader
00049 {
00050 private:
00051        QString currentDir;
00052        QString currentFile;
00053        QString defaultColor;
00054        QString defaultWeight;
00055        QString defaultSlant;
00056        QString templateCategory;
00057        QString href;
00058        QString extLinks;
00059        int extIndex;
00060        int listLevel;
00061        std::vector<gtParagraphStyle*> listStyles;
00062        std::vector<int> nextItemNumbers;
00063        gtWriter *writer;
00064        gtParagraphStyle *pstyle;
00065        gtParagraphStyle *pstylec;
00066        gtParagraphStyle *pstyleh1;
00067        gtParagraphStyle *pstyleh2;
00068        gtParagraphStyle *pstyleh3;
00069        gtParagraphStyle *pstyleh4;
00070        gtParagraphStyle *pstylecode;
00071        gtParagraphStyle *pstylep;
00072        gtParagraphStyle *pstylepre;
00073        bool inOL;
00074        bool wasInOL;
00075        bool inUL;
00076        bool wasInUL;
00077        bool inLI;
00078        bool addedLI;
00079        bool inH1;
00080        bool inH2;
00081        bool inH3;
00082        bool inH4;
00083        bool inA;
00084        bool inCenter;
00085        bool inCode;
00086        bool inBody;
00087        bool inPre;
00088        bool inP;
00089        static bool elemJustStarted;
00090        static bool elemJustFinished;
00091        bool lastCharWasSpace;
00092        bool noFormatting;
00093        void initPStyles();
00094        void toggleEffect(FontEffect e);
00095        void setItalicFont();
00096        void unsetItalicFont();
00097        void setBlueFont();
00098        void setDefaultColor();
00099        void setBoldFont();
00100        void unSetBoldFont();
00101        void createListStyle();
00102        static HTMLReader* hreader;
00103 public:
00104        HTMLReader(gtParagraphStyle *ps, gtWriter *w, bool textOnly);
00105        ~HTMLReader();
00106        void parse(QString filename);
00107        static void startElement(void *user_data, const xmlChar * fullname, const xmlChar ** atts);
00108        static void endElement(void *user_data, const xmlChar * name);
00109        static void characters(void *user_data, const xmlChar * ch, int len);
00110        bool startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs);
00111        bool endElement(const QString&, const QString&, const QString &name);
00112        bool characters(const QString &ch);
00113 };
00114 
00115 #endif // HAVE_XML
00116 
00117 #endif