KoFilter.h
1/* This file is part of the KOffice libraries
2 Copyright (C) 2001 Werner Trobin <trobin@kde.org>
3 2002 Werner Trobin <trobin@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
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 __koffice_filter_h__
21#define __koffice_filter_h__
22
23#include <tqobject.h>
24#include <tqmap.h>
25#include <tqptrstack.h>
26#include <koffice_export.h>
27class TQIODevice;
28class KoFilterChain;
29
49class KOFFICECORE_EXPORT KoFilter : public TQObject
50{
51 TQ_OBJECT
52
53
54 friend class KoFilterEntry; // needed for the filter chain pointer :(
55 friend class KoFilterChain;
56
57public:
64 enum ConversionStatus { OK, StupidError, UsageError, CreationError, FileNotFound,
65 StorageCreationError, BadMimeType, BadConversionGraph,
66 EmbeddedDocError, WrongFormat, NotImplemented,
67 ParsingError, InternalError, UnexpectedEOF,
68 UnexpectedOpcode, UserCancelled, OutOfMemory,
69 PasswordProtected,
70 JustInCaseSomeBrokenCompilerUsesLessThanAByte = 255 };
71
72 virtual ~KoFilter();
73
85 virtual ConversionStatus convert( const TQCString& from, const TQCString& to ) = 0;
86
87signals:
95 void sigProgress( int value );
96
97protected:
101 KoFilter();
102
109
110private:
111 KoFilter( const KoFilter& rhs );
112 KoFilter& operator=( const KoFilter& rhs );
113
114 class Private;
115 Private* d;
116};
117
118
147class KOFFICECORE_EXPORT KoEmbeddingFilter : public KoFilter
148{
149 TQ_OBJECT
150
151
152 friend class KoFilterChain;
153
154public:
155 virtual ~KoEmbeddingFilter();
156
165 int lruPartIndex() const;
166
173 static TQString mimeTypeByExtension( const TQString& extension );
174
175protected:
181
203 int embedPart( const TQCString& from, TQCString& to,
205 const TQString& key = TQString() );
206
217 void startInternalEmbedding( const TQString& key, const TQCString& mimeType );
218
225 void endInternalEmbedding();
226
236 int internalPartReference( const TQString& key ) const;
237
246 TQCString internalPartMimeType( const TQString& key ) const;
247
248private:
254 struct PartReference
255 {
256 PartReference( int index = -1, const TQCString& mimeType = "" );
257 bool isValid() const;
258
259 int m_index;
260 TQCString m_mimeType;
261 };
262
270 struct PartState
271 {
272 PartState();
273
274 int m_lruPartIndex;
275 TQMap<TQString, PartReference> m_partReferences;
276 };
277
281 KoEmbeddingFilter& operator=( const KoEmbeddingFilter& rhs );
282
293 virtual void savePartContents( TQIODevice* file );
294
300 void filterChainEnterDirectory( const TQString& directory ) const;
306 void filterChainLeaveDirectory() const;
307
312 TQPtrStack<PartState> m_partStack;
313
314 class Private;
315 Private* d;
316};
317
318#endif
The base class for all import filters embedding other filters.
Definition KoFilter.h:148
This class represents a chain of plain KoFilter instances.
Represents an available filter.
The base class for import and export filters.
Definition KoFilter.h:50
virtual ConversionStatus convert(const TQCString &from, const TQCString &to)=0
The filter chain calls this method to perform the actual conversion.
void sigProgress(int value)
Emit this signal with a value in the range of 1...100 to have some progress feedback for the user in ...
KoFilterChain * m_chain
Use this pointer to access all information about input/output during the conversion.
Definition KoFilter.h:108
ConversionStatus
This enum is used to signal the return state of your filter.
Definition KoFilter.h:64