lib

KoOasisContext.h
1/* This file is part of the KDE project
2 Copyright (C) 2004-2006 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KOOASISCONTEXT_H
21#define KOOASISCONTEXT_H
22
23#include <KoOasisLoadingContext.h>
24
25class KoVariableSettings;
26class KoTextParag;
27class KoParagStyle;
28class KoGenStyles;
29class KoVariableCollection;
30
31#include "KoListStyleStack.h"
32#include "KoTextBookmark.h"
33
34// ####### TODO rename to KoTextOasisLoadingContext (wow that's long).
35// ####### maybe KoTextLoadingContext?
36
45class KOTEXT_EXPORT KoOasisContext : public KoOasisLoadingContext
46{
47public:
57 KoOasisContext( KoDocument* doc, KoVariableCollection& varColl,
58 KoOasisStyles& styles, KoStore* store );
60
61 KoVariableCollection& variableCollection() { return m_varColl; }
62
64
65 KoListStyleStack& listStyleStack() { return m_listStyleStack; }
66 TQString currentListStyleName() const { return m_currentListStyleName; }
67 void setCurrentListStyleName( const TQString& s ) { m_currentListStyleName = s; }
68
71 bool pushListLevelStyle( const TQString& listStyleName, int level );
73 bool pushOutlineListLevelStyle( int level );
74
76 void setCursorPosition( KoTextParag* cursorTextParagraph,
77 int cursorTextIndex );
78
79 KoTextParag* cursorTextParagraph() const { return m_cursorTextParagraph; }
80 int cursorTextIndex() const { return m_cursorTextIndex; }
81
82private:
84 bool pushListLevelStyle( const TQString& listStyleName, const TQDomElement& fullListStyle, int level );
85
86private:
87 KoListStyleStack m_listStyleStack;
88 TQString m_currentListStyleName;
89 KoVariableCollection& m_varColl;
90
91 KoTextParag* m_cursorTextParagraph;
92 int m_cursorTextIndex;
93
94 class Private;
95 Private *d;
96};
97
98// TODO extract non-text base class for kofficecore, see KoOasisLoadingContext
99
100// ####### TODO rename to KoTextOasisSavingContext (wow that's long).
101// ####### maybe KoTextSavingContext?
102
111class KOTEXT_EXPORT KoSavingContext
112{
113public:
114 enum SavingMode { Store, Flat };
115
121 KoSavingContext( KoGenStyles& mainStyles, KoVariableSettings* settings = 0, bool hasColumns = false, SavingMode savingMode = Store );
122
124
125
126 KoGenStyles& mainStyles() { return m_mainStyles; }
127
129 SavingMode savingMode() const { return m_savingMode; }
130
132 void setCursorPosition( KoTextParag* cursorTextParagraph,
133 int cursorTextIndex );
134
135 KoTextParag* cursorTextParagraph() const { return m_cursorTextParagraph; }
136 int cursorTextIndex() const { return m_cursorTextIndex; }
137
140 struct BookmarkPosition {
141 BookmarkPosition() : name(), pos( -1 ), startEqualsEnd( false ) {} // for TQValueList
142 BookmarkPosition( const TQString& nm, int p, bool simple )
143 : name( nm ), pos( p ), startEqualsEnd( simple ) {}
144 TQString name;
145 int pos;
146 bool startEqualsEnd;
147 bool operator<( BookmarkPosition& rhs ) const {
148 return pos < rhs.pos;
149 }
150 };
151 typedef TQValueList<BookmarkPosition> BookmarkPositions;
152 void setBookmarkPositions( const BookmarkPositions& bkStarts,
153 const BookmarkPositions& bkEnds ) {
154 m_bookmarkStarts = bkStarts;
155 m_bookmarkEnds = bkEnds;
156 }
157 const BookmarkPositions& bookmarkStarts() const { return m_bookmarkStarts; }
158 const BookmarkPositions& bookmarkEnds() const { return m_bookmarkEnds; }
159
160 void addFontFace( const TQString& fontName );
161 typedef TQMap<TQString, bool> FontFaces;
162 void writeFontFaces( KoXmlWriter& writer );
163
164 // See KoParagLayout::saveOasis
165 bool hasColumns() const { return m_hasColumns; }
166
167 // See KoTextParag::saveOasis
168 KoVariableSettings* variableSettings() const { return m_variableSettings; }
169
170private:
171 KoGenStyles& m_mainStyles;
172 SavingMode m_savingMode;
173
174 BookmarkPositions m_bookmarkStarts, m_bookmarkEnds;
175
176 KoTextParag* m_cursorTextParagraph;
177 int m_cursorTextIndex;
178 FontFaces m_fontFaces;
179 KoVariableSettings* m_variableSettings;
180 bool m_hasColumns;
181
182 class Private;
183 Private *d;
184};
185
186#endif /* KOOASISCONTEXT_H */
The KOffice document class.
Definition KoDocument.h:61
Repository of styles used during saving of OASIS/OOo file.
Definition KoGenStyles.h:60
This class implements the list styles currently active at a given point.
bool pushListLevelStyle(const TQString &listStyleName, int level)
Used for lists (numbered paragraphs).
bool pushOutlineListLevelStyle(int level)
Used for outline levels.
KoOasisContext(KoDocument *doc, KoVariableCollection &varColl, KoOasisStyles &styles, KoStore *store)
Stores reference to the KoOasisStyles parsed by KoDocument.
void setCursorPosition(KoTextParag *cursorTextParagraph, int cursorTextIndex)
Set cursor position (set by KoTextParag upon finding the processing instruction).
KoOasisLoadingContext(KoDocument *doc, KoOasisStyles &styles, KoStore *store)
Stores reference to the KoOasisStyles and stored passed by KoDocument.
Repository of styles used during loading of OASIS/OOo file.
A paragraph style is a combination of a character style and paragraph-layout attributes,...
SavingMode savingMode() const
KoSavingContext(KoGenStyles &mainStyles, KoVariableSettings *settings=0, bool hasColumns=false, SavingMode savingMode=Store)
Constructor.
Saves and loads KOffice documents using various backends.
Definition KoStore.h:40