00001 /* This file is part of the KDE project 00002 Copyright (C) 2001-2005 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef kostyle_h 00020 #define kostyle_h 00021 00022 #include <qdom.h> 00023 #include <q3valuevector.h> 00024 #include "KoParagStyle.h" 00025 #include "KoUserStyleCollection.h" 00026 00027 class KoGenStyles; 00028 class KoParagStyle; 00029 class KoOasisContext; 00030 class KoSavingContext; 00031 class KoXmlWriter; 00032 00033 struct KoStyleChangeDef { 00034 KoStyleChangeDef() { 00035 paragLayoutChanged = -1; 00036 formatChanged = -1; 00037 } 00038 KoStyleChangeDef( int parag, int format) { 00039 paragLayoutChanged = parag; 00040 formatChanged = format; 00041 }; 00042 int paragLayoutChanged; 00043 int formatChanged; 00044 }; 00045 typedef QMap<KoParagStyle *, KoStyleChangeDef> KoStyleChangeDefMap; 00046 00048 class KOTEXT_EXPORT KoStyleCollection : public KoUserStyleCollection 00049 { 00050 public: 00051 KoStyleCollection(); 00052 ~KoStyleCollection(); 00053 00054 //const QPtrList<KoParagStyle> & styleList() const { return m_styleList; } 00055 00056 // compat method, TODO: remove 00057 QStringList translatedStyleNames() const { return displayNameList(); } 00058 00063 KoParagStyle* addStyle( KoParagStyle* sty ) { 00064 return static_cast<KoParagStyle*>( KoUserStyleCollection::addStyle( sty ) ); 00065 } 00066 00071 KoParagStyle* findStyle( const QString & name ) const { 00072 return static_cast<KoParagStyle*>( KoUserStyleCollection::findStyle( name, QString::fromLatin1( "Standard" ) ) ); 00073 } 00074 00079 KoParagStyle* findStyleByDisplayName( const QString & name ) const { 00080 return static_cast<KoParagStyle*>( KoUserStyleCollection::findStyleByDisplayName( name ) ); 00081 } 00082 00086 KoParagStyle* styleAt( int i ) { return static_cast<KoParagStyle*>( m_styleList[i] ); } 00087 00088 00090 void importStyles( const KoStyleCollection& styleList ); 00091 00094 int loadOasisStyles( KoOasisContext& context ); 00095 00098 void saveOasis( KoGenStyles& styles, int styleType, KoSavingContext& context ) const; 00099 00101 void saveOasisOutlineStyles( KoXmlWriter& writer ) const; 00102 00104 Q3ValueVector<KoParagStyle *> outlineStyles() const; 00105 00107 KoParagStyle* outlineStyleForLevel( int level ) const; 00108 00110 KoParagStyle* numberedStyleForLevel( int level ) const; 00111 00116 KoParagStyle* defaultStyle() const; 00117 00118 #ifndef NDEBUG 00119 void printDebug() const; 00120 #endif 00121 }; 00122 00123 #endif