Back to index

scribus-ng  1.3.4.dfsg+svn20071115
stylestack.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 /* This file is part of the KDE project
00008    Copyright (c) 2003 Lukas Tinkl <lukas@kde.org>
00009    Copyright (c) 2003 David Faure <faure@kde.org>
00010 
00011    This library is free software; you can redistribute it and/or
00012    modify it under the terms of the GNU Library General Public
00013    License as published by the Free Software Foundation; either
00014    version 2 of the License, or (at your option) any later version.
00015 
00016    This library 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 GNU
00019    Library General Public License for more details.
00020 
00021    You should have received a copy of the GNU Library General Public License
00022    along with this library; see the file COPYING.LIB.  If not, write to
00023    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00024    Boston, MA 02111-1307, USA.
00025 */
00026 
00027 #ifndef STYLESTACK_H
00028 #define STYLESTACK_H
00029 
00030 #include <qvaluelist.h>
00031 #include <qdom.h>
00032 #include <qvaluestack.h>
00033 #include <qstringlist.h>
00034 
00057 class StyleStack
00058 {
00059 public:
00060     StyleStack();
00061     virtual ~StyleStack();
00062 
00063        enum Mode
00064        {
00065               OODraw1x = 1,
00066               OODraw2x = 2
00067        };
00068 
00072        void setMode( const StyleStack::Mode mode );
00073 
00077     void clear();
00078 
00083     void save();
00084 
00088     void restore();
00089 
00093     void pop();
00094 
00098     void push( const QDomElement& style );
00099 
00103        bool hasAttribute( const QString& name ) const;
00104 
00109     QString attribute( const QString& name ) const;
00110 
00116     bool hasAttribute( const QString& name, const QString& detail ) const;
00117 
00122        QString attribute( const QString& name, const QString& detail ) const;
00123 
00127     bool hasChildNode(const QString & name) const;
00128 
00133     QDomNode childNode(const QString & name) const;
00134 
00138     double fontSize() const;
00139 
00144     QString userStyleName() const;
00145 
00146 private:
00147 
00148        // Node names to look for style properties
00149        QStringList m_nodeNames;
00150 
00151     // For save/restore: stack of "marks". Each mark is an index in m_stack.
00152     QValueStack<int> m_marks;
00153 
00154     // We use QValueList instead of QValueStack because we need access to all styles
00155     // not only the top one.
00156     QValueList<QDomElement> m_stack;
00157 
00158        // Get node name to look for according to property type
00159        void fillNodeNameList( QStringList& names, const StyleStack::Mode mode );
00160 
00161        // Search a specific attribute amongst childs of an element
00162        QDomElement searchAttribute( const QDomElement& element, const QStringList& names,const QString& name ) const;
00163 
00164        // Search a specific attribute amongst childs of an element
00165        QDomElement searchAttribute( const QDomElement& element, const QStringList& names, const QString& name, const QString& fullName ) const;
00166 };
00167 
00168 
00169 #endif /* STYLESTACK_H */