Scribus
Open source desktop publishing at your fingertips
stylereader.h
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 */
7 /***************************************************************************
8  * Copyright (C) 2004 by Riku Leino *
9  * tsoots@gmail.com *
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., *
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25  ***************************************************************************/
26 
27 #ifndef STYLEREADER_H
28 #define STYLEREADER_H
29 
30 #include "scconfig.h"
31 
32 #ifdef HAVE_XML26
33  #include <libxml/SAX2.h>
34 #else
35  #include <libxml/SAX.h>
36 #endif
37 #include <QMap>
38 #include <QXmlAttributes>
39 #include <gtstyle.h>
40 #include <gtwriter.h>
41 
42 typedef QMap<QString, gtStyle*> StyleMap;
43 typedef QMap<QString, QString> FontMap;
44 typedef QMap<QString, int> CounterMap;
45 
46 class StyleReader
47 {
48 private:
49  static StyleReader *sreader;
50  gtWriter *writer;
51  bool importTextOnly;
52  bool usePrefix;
53  bool packStyles;
54  bool readProperties;
55  QString docname;
56  StyleMap styles;
57  StyleMap listParents;
58  StyleMap attrsStyles;
59  CounterMap pstyleCounts;
60  FontMap fonts;
61  gtStyle* currentStyle;
62  gtStyle* parentStyle;
63  bool inList;
64  QString currentList;
65  bool defaultStyleCreated;
66  double getSize(QString s, double parentSize = -1);
67  void styleProperties(const QXmlAttributes& attrs);
68  void defaultStyle(const QXmlAttributes& attrs);
69  void styleStyle(const QXmlAttributes& attrs);
70  void tabStop(const QXmlAttributes& attrs);
71  void setupFrameStyle();
72 public:
73  StyleReader(QString documentName, gtWriter *wr, bool textOnly, bool prefix, bool combineStyles = true);
74  ~StyleReader();
75  bool updateStyle(gtStyle* style, gtStyle* parent2Style, const QString& key, const QString& value);
76  static void startElement(void *user_data, const xmlChar * fullname, const xmlChar ** atts);
77  static void endElement(void *user_data, const xmlChar * name);
78  bool startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs);
79  bool endElement(const QString&, const QString&, const QString &name);
80  void parse(QString fileName);
81  gtStyle* getDefaultStyle(void);
82  gtStyle* getStyle(const QString& name);
83  void setStyle(const QString& name, gtStyle* style);
84  QString getFont(const QString& key);
85 };
86 
87 #endif
Definition: gtwriter.h:38
Definition: gtstyle.h:34
Definition: stylereader.h:119