Scribus
Open source desktop publishing at your fingertips
stylestack.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 /* This file is part of the KDE project
8  Copyright (c) 2003 Lukas Tinkl <lukas@kde.org>
9  Copyright (c) 2003 David Faure <faure@kde.org>
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Library General Public
13  License as published by the Free Software Foundation; either
14  version 2 of the License, or (at your option) any later version.
15 
16  This library 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 GNU
19  Library General Public License for more details.
20 
21  You should have received a copy of the GNU Library General Public License
22  along with this library; see the file COPYING.LIB. If not, write to
23  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24  Boston, MA 02110-1301, USA.
25 */
26 
27 #ifndef STYLESTACK_H
28 #define STYLESTACK_H
29 
30 #include <QDomElement>
31 #include <QStringList>
32 #include <QList>
33 #include <QStack>
34 
35 
59 {
60 public:
61  StyleStack();
62  virtual ~StyleStack();
63 
64  enum Mode
65  {
66  OODraw1x = 1,
67  OODraw2x = 2
68  };
69 
73  void setMode( const StyleStack::Mode mode );
74 
78  void clear();
79 
84  void save();
85 
89  void restore();
90 
94  void pop();
95 
99  void push( const QDomElement& style );
100 
104  bool hasAttribute( const QString& name ) const;
105 
110  QString attribute( const QString& name ) const;
111 
117  bool hasAttribute( const QString& name, const QString& detail ) const;
118 
123  QString attribute( const QString& name, const QString& detail ) const;
124 
128  bool hasChildNode(const QString & name) const;
129 
134  QDomNode childNode(const QString & name) const;
135 
139  double fontSize() const;
140 
145  QString userStyleName() const;
146 
147 private:
148 
149  // Node names to look for style properties
150  QStringList m_nodeNames;
151 
152  // For save/restore: stack of "marks". Each mark is an index in m_stack.
153  QStack<int> m_marks;
154 
155  // We use QValueList instead of QValueStack because we need access to all styles
156  // not only the top one.
157  QList<QDomElement> m_stack;
158 
159  // Get node name to look for according to property type
160  void fillNodeNameList( QStringList& names, const StyleStack::Mode mode );
161 
162  // Search a specific attribute amongst childs of an element
163  QDomElement searchAttribute( const QDomElement& element, const QStringList& names,const QString& name ) const;
164 
165  // Search a specific attribute amongst childs of an element
166  QDomElement searchAttribute( const QDomElement& element, const QStringList& names, const QString& name, const QString& fullName ) const;
167 };
168 
169 
170 #endif /* STYLESTACK_H */
void clear()
Definition: stylestack.cpp:48
void save()
Definition: stylestack.cpp:53
void setMode(const StyleStack::Mode mode)
Definition: stylestack.cpp:42
void restore()
Definition: stylestack.cpp:58
bool hasChildNode(const QString &name) const
Definition: stylestack.cpp:167
void push(const QDomElement &style)
Definition: stylestack.cpp:73
void pop()
Definition: stylestack.cpp:68
QString userStyleName() const
Definition: stylestack.cpp:201
bool hasAttribute(const QString &name) const
Definition: stylestack.cpp:78
double fontSize() const
Definition: stylestack.cpp:147
QDomNode childNode(const QString &name) const
Definition: stylestack.cpp:181
Definition: stylestack.h:58
QString attribute(const QString &name) const
Definition: stylestack.cpp:93