Qt 4.8
qsvghandler_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSvg module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QSVGHANDLER_P_H
43 #define QSVGHANDLER_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "QtXml/qxmlstream.h"
57 
58 #ifndef QT_NO_SVG
59 
60 #include "QtCore/qhash.h"
61 #include "QtCore/qstack.h"
62 #include "qsvgstyle_p.h"
63 #include "private/qcssparser_p.h"
64 #include "private/qsvggraphics_p.h"
65 
67 
68 class QSvgNode;
69 class QSvgTinyDocument;
70 class QSvgHandler;
71 class QColor;
72 class QSvgStyleSelector;
73 class QXmlStreamReader;
74 
76 {
79 };
80 
82 {
83 public:
84  enum LengthType {
92  LT_OTHER
93  };
94 
95 public:
96  QSvgHandler(QIODevice *device);
97  QSvgHandler(const QByteArray &data);
99  ~QSvgHandler();
100 
101  QSvgTinyDocument *document() const;
102 
103  inline bool ok() const {
104  return document() != 0 && !xml->hasError();
105  }
106 
107  inline QString errorString() const { return xml->errorString(); }
108  inline int lineNumber() const { return xml->lineNumber(); }
109 
110  void setDefaultCoordinateSystem(LengthType type);
111  LengthType defaultCoordinateSystem() const;
112 
113  void pushColor(const QColor &color);
114  void pushColorCopy();
115  void popColor();
116  QColor currentColor() const;
117 
118  void setInStyle(bool b);
119  bool inStyle() const;
120 
121  QSvgStyleSelector *selector() const;
122 
123  void setAnimPeriod(int start, int end);
124  int animationDuration() const;
125 
127 
128  inline QPen defaultPen() const
129  { return m_defaultPen; }
130 
131 public:
132  bool startElement(const QString &localName, const QXmlStreamAttributes &attributes);
133  bool endElement(const QStringRef &localName);
134  bool characters(const QStringRef &str);
135  bool processingInstruction(const QString &target, const QString &data);
136 
137 private:
138  void init();
139 
142 
144 
146  {
149  Style
150  };
152 
158 
160 
162 
165 
166  bool m_inStyle;
167 
169 
171 
174  void parse();
175  void resolveGradients(QSvgNode *node);
176 
182  const bool m_ownsReader;
183 };
184 
186 
187 #endif // QT_NO_SVG
188 #endif // QSVGHANDLER_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QStack< int > m_colorTagCount
QXmlStreamStringRef name
Definition: qsvghandler_p.h:77
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPen defaultPen() const
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QStack class is a template class that provides a stack.
Definition: qcontainerfwd.h:63
QCss::Parser m_cssParser
The QString class provides a Unicode character string.
Definition: qstring.h:83
const bool m_ownsReader
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
QXmlStreamReader *const xml
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool init
static const char * data(const QByteArray &arr)
QStack< QSvgNode * > m_nodes
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
static void parseCSStoXMLAttrs(const QVector< QCss::Declaration > &declarations, QXmlStreamAttributes &attributes)
int lineNumber() const
The QXmlStreamAttributes class represents a vector of QXmlStreamAttribute.
Definition: qxmlstream.h:169
QStack< CurrentNode > m_skipNodes
LengthType m_defaultCoords
QStack< QColor > m_colorStack
QString errorString() const
bool ok() const
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290
static const KeyPair *const end
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
QSvgRefCounter< QSvgStyleProperty > m_style
QList< QSvgNode * > m_resolveNodes
QSvgStyleSelector * m_selector
QStack< QSvgText::WhitespaceMode > m_whitespaceMode
Follows the depths of elements.
QXmlStreamStringRef value
Definition: qsvghandler_p.h:78
QSvgTinyDocument * m_doc
The QList class is a template class that provides lists.
Definition: qdatastream.h:62