Back to index

scribus-ng  1.3.4.dfsg+svn20071115
contentreader.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 
00027 #ifndef CONTENTREADER_H
00028 #define CONTENTREADER_H
00029 
00030 #include "scconfig.h"
00031 
00032 #ifdef HAVE_XML
00033 
00034 #include <utility>
00035 #include <vector>
00036 #ifdef HAVE_XML26
00037  #include <libxml/SAX2.h>
00038 #else
00039  #include <libxml/SAX.h>
00040 #endif
00041 #include <qxml.h>
00042 #include <qmap.h>
00043 #include <gtstyle.h>
00044 #include <gtwriter.h>
00045 #include "stylereader.h"
00046 
00047 typedef std::vector<std::pair<QString, QString> > Properties;
00048 typedef QMap<QString, Properties > TMap;
00049 
00050 class ContentReader
00051 {
00052 private:
00053        static ContentReader *creader;
00054        TMap tmap;
00055        QString docname;
00056        StyleReader* sreader;
00057        gtWriter *writer;
00058        gtStyle *defaultStyle;
00059        gtStyle *currentStyle;
00060        gtStyle *lastStyle;
00061        gtStyle *pstyle;
00062        bool importTextOnly;
00063        bool append;
00064        bool inList;
00065        bool isOrdered;
00066        bool inSpan;
00067        int listLevel;
00068        int listIndex;
00069        std::vector<int> listIndex2;
00070        std::vector<bool> isOrdered2;
00071        bool inT;
00072        std::vector<QString> styleNames;
00073        QString tName;
00074        QString currentList;
00075        void write(const QString& text);
00076        QString getName();
00077        void getStyle();
00078 public:
00079        ContentReader(QString documentName, StyleReader* s, gtWriter *w, bool textOnly);
00080        ~ContentReader();
00081        static void startElement(void *user_data, const xmlChar *fullname, const xmlChar ** atts);
00082        static void endElement(void *user_data, const xmlChar *name);
00083        static void characters(void *user_data, const xmlChar *ch, int len);
00084        bool startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs);
00085        bool endElement(const QString&, const QString&, const QString &name);
00086        bool characters(const QString &ch);
00087        void parse(QString fileName);
00088 };
00089 
00090 #endif // HAVE_XML
00091 
00092 #endif