Back to index

scribus-ng  1.3.4.dfsg+svn20071115
stylereader.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 STYLEREADER_H
00028 #define STYLEREADER_H
00029 
00030 #include "scconfig.h"
00031 
00032 #ifdef HAVE_XML
00033 
00034 #ifdef HAVE_XML26
00035  #include <libxml/SAX2.h>
00036 #else
00037  #include <libxml/SAX.h>
00038 #endif
00039 #include <qmap.h>
00040 #include <qxml.h>
00041 #include <gtstyle.h>
00042 #include <gtwriter.h>
00043 
00044 typedef QMap<QString, gtStyle*> StyleMap;
00045 typedef QMap<QString, QString> FontMap;
00046 typedef QMap<QString, int> CounterMap;
00047 
00048 class StyleReader
00049 {
00050 private:
00051        static StyleReader *sreader;
00052        gtWriter *writer;
00053        bool importTextOnly;
00054        bool usePrefix;
00055        bool packStyles;
00056        bool readProperties;
00057        QString docname;
00058        StyleMap styles;
00059        StyleMap listParents;
00060        StyleMap attrsStyles;
00061        CounterMap pstyleCounts;
00062        FontMap fonts;
00063        gtStyle* currentStyle;
00064        gtStyle* parentStyle;
00065        bool inList;
00066        QString currentList;
00067        bool defaultStyleCreated;
00068        double getSize(QString s, double parentSize = -1);
00069        void styleProperties(const QXmlAttributes& attrs);
00070        void defaultStyle(const QXmlAttributes& attrs);
00071        void styleStyle(const QXmlAttributes& attrs);
00072        void tabStop(const QXmlAttributes& attrs);
00073        void setupFrameStyle();
00074 public:
00075        StyleReader(QString documentName, gtWriter *wr, bool textOnly, bool prefix, bool combineStyles = true);
00076        ~StyleReader();
00077        bool updateStyle(gtStyle* style, gtStyle* parent2Style, const QString& key, const QString& value);
00078        static void startElement(void *user_data, const xmlChar * fullname, const xmlChar ** atts);
00079        static void endElement(void *user_data, const xmlChar * name);
00080        bool startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs);
00081        bool endElement(const QString&, const QString&, const QString &name);
00082        void parse(QString fileName);
00083        gtStyle* getStyle(const QString& name);
00084        void setStyle(const QString& name, gtStyle* style);
00085        QString getFont(const QString& key);
00086 };
00087 
00088 #endif // HAVE_XML
00089 
00090 #endif