lib Library API Documentation

koFilter.h

00001 /* This file is part of the KOffice libraries
00002    Copyright (C) 2001 Werner Trobin <trobin@kde.org>
00003                  2002 Werner Trobin <trobin@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 version 2 as published by the Free Software Foundation.
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., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #ifndef __koffice_filter_h__
00021 #define __koffice_filter_h__
00022 
00023 #include <qobject.h>
00024 #include <qmap.h>
00025 #include <qptrstack.h>
00026 #include <koffice_export.h>
00027 class QIODevice;
00028 class KoFilterChain;
00029 
00048 class KOFFICECORE_EXPORT KoFilter : public QObject
00049 {
00050     Q_OBJECT
00051 
00052     friend class KoFilterEntry;  // needed for the filter chain pointer :(
00053     friend class KoFilterChain;
00054 
00055 public:
00062     enum ConversionStatus { OK, StupidError, UsageError, CreationError, FileNotFound,
00063                             StorageCreationError, BadMimeType, BadConversionGraph,
00064                             EmbeddedDocError, WrongFormat, NotImplemented,
00065                             ParsingError, InternalError, UnexpectedEOF,
00066                             UnexpectedOpcode, UserCancelled, OutOfMemory,
00067                             JustInCaseSomeBrokenCompilerUsesLessThanAByte = 255 };
00068 
00069     virtual ~KoFilter();
00070 
00082     virtual ConversionStatus convert( const QCString& from, const QCString& to ) = 0;
00083 
00084 signals:
00092     void sigProgress( int value );
00093 
00094 protected:
00098     KoFilter();
00099 
00105     KoFilterChain* m_chain;
00106 
00107 private:
00108     KoFilter( const KoFilter& rhs );
00109     KoFilter& operator=( const KoFilter& rhs );
00110 
00111     class Private;
00112     Private* d;
00113 };
00114 
00115 
00144 class KOFFICECORE_EXPORT KoEmbeddingFilter : public KoFilter
00145 {
00146     Q_OBJECT
00147 
00148     friend class KoFilterChain;
00149 
00150 public:
00151     virtual ~KoEmbeddingFilter();
00152 
00161     int lruPartIndex() const;
00162 
00169     static QString mimeTypeByExtension( const QString& extension );
00170 
00171 protected:
00176     KoEmbeddingFilter();
00177 
00199     int embedPart( const QCString& from, QCString& to,
00200                    KoFilter::ConversionStatus& status,
00201                    const QString& key = QString::null );
00202 
00213     void startInternalEmbedding( const QString& key, const QCString& mimeType );
00214 
00221     void endInternalEmbedding();
00222 
00232     int internalPartReference( const QString& key ) const;
00233 
00242     QCString internalPartMimeType( const QString& key ) const;
00243 
00244 private:
00250     struct PartReference
00251     {
00252         PartReference( int index = -1, const QCString& mimeType = "" );
00253         bool isValid() const;
00254 
00255         int m_index;
00256         QCString m_mimeType;
00257     };
00258 
00266     struct PartState
00267     {
00268         PartState();
00269 
00270         int m_lruPartIndex;
00271         QMap<QString, PartReference> m_partReferences;
00272     };
00273 
00275     KoEmbeddingFilter( const KoEmbeddingFilter& rhs );
00277     KoEmbeddingFilter& operator=( const KoEmbeddingFilter& rhs );
00278 
00289     virtual void savePartContents( QIODevice* file );
00290 
00296     void filterChainEnterDirectory( const QString& directory ) const;
00302     void filterChainLeaveDirectory() const;
00303 
00308     QPtrStack<PartState> m_partStack;
00309 
00310     class Private;
00311     Private* d;
00312 };
00313 
00314 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:00 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003