lib

KoOasisContext.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004-2006 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 as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KOOASISCONTEXT_H
00021 #define KOOASISCONTEXT_H
00022 
00023 #include <KoOasisLoadingContext.h>
00024 
00025 class KoVariableSettings;
00026 class KoTextParag;
00027 class KoParagStyle;
00028 class KoGenStyles;
00029 class KoVariableCollection;
00030 
00031 #include "KoListStyleStack.h"
00032 #include "KoTextBookmark.h"
00033 
00034 // ####### TODO rename to KoTextOasisLoadingContext (wow that's long).
00035 // ####### maybe KoTextLoadingContext?
00036 
00045 class KOTEXT_EXPORT KoOasisContext : public KoOasisLoadingContext
00046 {
00047 public:
00057     KoOasisContext( KoDocument* doc, KoVariableCollection& varColl,
00058                     KoOasisStyles& styles, KoStore* store );
00059     ~KoOasisContext();
00060 
00061     KoVariableCollection& variableCollection() { return m_varColl; }
00062 
00064 
00065     KoListStyleStack& listStyleStack() { return m_listStyleStack; }
00066     QString currentListStyleName() const { return m_currentListStyleName; }
00067     void setCurrentListStyleName( const QString& s ) { m_currentListStyleName = s; }
00068 
00071     bool pushListLevelStyle( const QString& listStyleName, int level );
00073     bool pushOutlineListLevelStyle( int level );
00074 
00076     void setCursorPosition( KoTextParag* cursorTextParagraph,
00077                             int cursorTextIndex );
00078 
00079     KoTextParag* cursorTextParagraph() const { return m_cursorTextParagraph; }
00080     int cursorTextIndex() const { return m_cursorTextIndex; }
00081 
00082 private:
00084     bool pushListLevelStyle( const QString& listStyleName, const QDomElement& fullListStyle, int level );
00085 
00086 private:
00087     KoListStyleStack m_listStyleStack;
00088     QString m_currentListStyleName;
00089     KoVariableCollection& m_varColl;
00090 
00091     KoTextParag* m_cursorTextParagraph;
00092     int m_cursorTextIndex;
00093 
00094     class Private;
00095     Private *d;
00096 };
00097 
00098 // TODO extract non-text base class for kofficecore, see KoOasisLoadingContext
00099 
00100 // ####### TODO rename to KoTextOasisSavingContext (wow that's long).
00101 // ####### maybe KoTextSavingContext?
00102 
00111 class KOTEXT_EXPORT KoSavingContext
00112 {
00113 public:
00114     enum SavingMode { Store, Flat };
00115 
00121     KoSavingContext( KoGenStyles& mainStyles, KoVariableSettings* settings = 0, bool hasColumns = false, SavingMode savingMode = Store );
00122 
00123     ~KoSavingContext();
00124 
00125 
00126     KoGenStyles& mainStyles() { return m_mainStyles; }
00127 
00129     SavingMode savingMode() const { return m_savingMode; }
00130 
00132     void setCursorPosition( KoTextParag* cursorTextParagraph,
00133                             int cursorTextIndex );
00134 
00135     KoTextParag* cursorTextParagraph() const { return m_cursorTextParagraph; }
00136     int cursorTextIndex() const { return m_cursorTextIndex; }
00137 
00140     struct BookmarkPosition {
00141         BookmarkPosition() : name(), pos( -1 ), startEqualsEnd( false ) {} // for QValueList
00142         BookmarkPosition( const QString& nm, int p, bool simple )
00143             : name( nm ), pos( p ), startEqualsEnd( simple ) {}
00144         QString name;
00145         int pos;
00146         bool startEqualsEnd;
00147         bool operator<( BookmarkPosition& rhs ) const {
00148             return pos < rhs.pos;
00149         }
00150     };
00151     typedef QValueList<BookmarkPosition> BookmarkPositions;
00152     void setBookmarkPositions( const BookmarkPositions& bkStarts,
00153                                const BookmarkPositions& bkEnds ) {
00154         m_bookmarkStarts = bkStarts;
00155         m_bookmarkEnds = bkEnds;
00156     }
00157     const BookmarkPositions& bookmarkStarts() const { return m_bookmarkStarts; }
00158     const BookmarkPositions& bookmarkEnds() const { return m_bookmarkEnds; }
00159 
00160     void addFontFace( const QString& fontName );
00161     typedef QMap<QString, bool> FontFaces;
00162     void writeFontFaces( KoXmlWriter& writer );
00163 
00164     // See KoParagLayout::saveOasis
00165     bool hasColumns() const { return m_hasColumns; }
00166 
00167     // See KoTextParag::saveOasis
00168     KoVariableSettings* variableSettings() const { return m_variableSettings; }
00169 
00170 private:
00171     KoGenStyles& m_mainStyles;
00172     SavingMode m_savingMode;
00173 
00174     BookmarkPositions m_bookmarkStarts, m_bookmarkEnds;
00175 
00176     KoTextParag* m_cursorTextParagraph;
00177     int m_cursorTextIndex;
00178     FontFaces m_fontFaces;
00179     KoVariableSettings* m_variableSettings;
00180     bool m_hasColumns;
00181 
00182     class Private;
00183     Private *d;
00184 };
00185 
00186 #endif /* KOOASISCONTEXT_H */
KDE Home | KDE Accessibility Home | Description of Access Keys