Subversion Repositories Scribus

Rev

Rev 1593 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1593 tsoots 1
/***************************************************************************
2
 *   Copyright (C) 2004 by Riku Leino                                      *
3
 *   tsoots@gmail.com                                                      *
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.             *
19
 ***************************************************************************/
20
 
21
#ifndef CONTENTREADER_H
22
#define CONTENTREADER_H
23
 
24
#include "config.h"
25
 
26
#ifdef HAVE_XML
27
 
28
#include <utility>
29
#include <vector>
30
#ifdef HAVE_XML26
31
 #include <libxml/SAX2.h>
32
#else
33
 #include <libxml/SAX.h>
34
#endif
35
#include <qxml.h>
36
#include <qmap.h>
37
#include <gtstyle.h>
38
#include <gtwriter.h>
39
#include "stylereader.h"
40
 
41
typedef std::vector<std::pair<QString, QString> > Properties;
42
typedef QMap<QString, Properties > TMap;
43
 
44
class ContentReader
45
{
46
private:
47
        static ContentReader *creader;
48
        TMap tmap;
49
        QString docname;
50
        StyleReader* sreader;
51
        gtWriter *writer;
52
        gtStyle *defaultStyle;
53
        gtStyle *currentStyle;
54
        gtStyle *lastStyle;
55
        gtStyle *pstyle;
56
        bool importTextOnly;
57
        bool append;
58
        bool inList;
59
        bool inSpan;
60
        int listLevel;
61
        int listIndex;
2211 tsoots 62
        ListStyle *currentListStyle;
1593 tsoots 63
        std::vector<int> listIndex2;
64
        bool inT;
65
        std::vector<QString> styleNames;
66
        QString tName;
67
        QString currentList;
68
        void write(const QString& text);
69
        QString getName();
70
        void getStyle();
71
public:
72
        ContentReader(QString documentName, StyleReader* s, gtWriter *w, bool textOnly);
73
        ~ContentReader();
74
        static void startElement(void *user_data, const xmlChar *fullname, const xmlChar ** atts);
75
        static void endElement(void *user_data, const xmlChar *name);
76
        static void characters(void *user_data, const xmlChar *ch, int len);
77
        bool startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs);
78
        bool endElement(const QString&, const QString&, const QString &name);
79
        bool characters(const QString &ch);
80
        void parse(QString fileName);
81
};
82
 
83
#endif // HAVE_XML
84
 
85
#endif