lib

KoOasisSettings.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Laurent Montel <montel@kde.org>
00003                       David Faure <faure@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 
00022 #ifndef KOOASISSETTINGS_H
00023 #define KOOASISSETTINGS_H
00024 
00025 #include <qdom.h>
00026 #include <koffice_export.h>
00027 
00070 class KOFFICECORE_EXPORT KoOasisSettings
00071 {
00072 public:
00076     explicit KoOasisSettings( const QDomDocument& doc );
00077 
00081     KoOasisSettings( const QDomDocument& doc, const char* officeNSURI, const char* configNSURI );
00082 
00083     class Items;
00084 
00089     Items itemSet( const QString& itemSetName ) const;
00090 
00091     class IndexedMap;
00092     class NamedMap;
00094     class KOFFICECORE_EXPORT Items
00095     {
00096         friend class KoOasisSettings;
00097         friend class IndexedMap;
00098         friend class NamedMap;
00099         Items( const QDomElement& elem, const KoOasisSettings* settings )
00100             : m_element( elem ), m_settings( settings ) {}
00101     public:
00102         bool isNull() const { return m_element.isNull(); }
00103 
00110         IndexedMap indexedMap( const QString& itemMapName ) const;
00111 
00118         NamedMap namedMap( const QString& itemMapName ) const;
00119 
00120         int parseConfigItemInt( const QString& configName, int defValue = 0 ) const;
00121         double parseConfigItemDouble( const QString& configName, double defValue = 0 ) const;
00122         QString parseConfigItemString( const QString& configName, const QString& defValue = QString::null ) const;
00123         bool parseConfigItemBool( const QString& configName, bool defValue = false ) const;
00124         short parseConfigItemShort( const QString& configName, short defValue = 0 ) const;
00125         long parseConfigItemLong( const QString& configName, long defValue = 0 ) const;
00126     private:
00128         QString findConfigItem( const QString& item, bool* ok ) const;
00130         QString findConfigItem( const QDomElement& element, const QString& item, bool* ok ) const;
00131 
00132         QDomElement m_element;
00133         const KoOasisSettings* m_settings;
00134     };
00135 
00137     class Map
00138     {
00139     public:
00140         bool isNull() const { return m_element.isNull(); }
00141     protected:
00142         Map( const QDomElement& elem, const KoOasisSettings* settings )
00143             : m_element( elem ), m_settings( settings ) {}
00144         const QDomElement m_element;
00145         const KoOasisSettings* m_settings;
00146     };
00147 
00148     class KOFFICECORE_EXPORT IndexedMap : public Map
00149     {
00150         friend class Items;
00151         IndexedMap( const QDomElement& elem, const KoOasisSettings* settings )
00152             : Map( elem, settings ) {}
00153     public:
00155         Items entry( int entryIndex ) const;
00156     };
00157 
00158     class KOFFICECORE_EXPORT NamedMap : public Map
00159     {
00160         friend class Items;
00161         NamedMap( const QDomElement& elem, const KoOasisSettings* settings )
00162             : Map( elem, settings ) {}
00163     public:
00165         Items entry( const QString& entryName ) const;
00166     };
00167 
00168 private:
00169     friend class Items;
00170     friend class IndexedMap;
00171     friend class NamedMap;
00172     const QDomElement m_settingsElement;
00173     const char* m_configNSURI;
00174 
00175     class Private;
00176     Private* d;
00177 };
00178 
00179 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys