koFilterChain.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __koffice_filter_chain_h__
00020 #define __koffice_filter_chain_h__
00021
00022 #include <qcstring.h>
00023 #include <qasciidict.h>
00024 #include <qptrlist.h>
00025 #include <qstringlist.h>
00026
00027 #include <koFilter.h>
00028 #include <koQueryTrader.h>
00029 #include <koStoreDevice.h>
00030 #include <koffice_export.h>
00031
00032 class KTempFile;
00033 class KoFilterManager;
00034 class KoDocument;
00035 class QStrList;
00036
00037 namespace KOffice {
00038 class Graph;
00039 }
00040
00050 class KOFFICECORE_EXPORT KoFilterChain : public KShared
00051 {
00052
00053
00054 friend class KOffice::Graph;
00055 friend class KoFilterManager;
00056
00057 public:
00058 typedef KSharedPtr<KoFilterChain> Ptr;
00059
00060 virtual ~KoFilterChain();
00061
00065 const KoFilterManager* manager() const { return m_manager; }
00066
00072 KoFilter::ConversionStatus invokeChain();
00073
00079 QString chainOutput() const;
00080
00085 QString inputFile();
00090 QString outputFile();
00091
00102 KoStoreDevice* storageFile( const QString& name = "root", KoStore::Mode mode = KoStore::Read );
00103
00110 KoDocument* inputDocument();
00117 KoDocument* outputDocument();
00118
00119
00120
00121 void dump() const;
00122
00123 private:
00124
00125
00126
00127 KoFilterChain( const KoFilterManager* manager );
00128
00129 void appendChainLink( KoFilterEntry::Ptr filterEntry, const QCString& from, const QCString& to );
00130 void prependChainLink( KoFilterEntry::Ptr filterEntry, const QCString& from, const QCString& to );
00131
00132
00133
00134
00135
00136
00137 friend void KoEmbeddingFilter::filterChainEnterDirectory( const QString& directory ) const;
00138 void enterDirectory( const QString& directory );
00139 friend void KoEmbeddingFilter::filterChainLeaveDirectory() const;
00140 void leaveDirectory();
00141
00142
00143
00144
00145 QString filterManagerImportFile() const;
00146 QString filterManagerExportFile() const;
00147 KoDocument* filterManagerKoDocument() const;
00148 int filterManagerDirection() const;
00149 KoFilterChain* const filterManagerParentChain() const;
00150
00151
00152
00153
00154
00155 void manageIO();
00156 void finalizeIO();
00157
00158 bool createTempFile( KTempFile** tempFile, bool autoDelete = true );
00159
00160 void inputFileHelper( KoDocument* document, const QString& alternativeFile );
00161 void outputFileHelper( bool autoDelete );
00162 KoStoreDevice* storageNewStreamHelper( KoStore** storage, KoStoreDevice** device, const QString& name );
00163 KoStoreDevice* storageHelper( const QString& file, const QString& streamName,
00164 KoStore::Mode mode, KoStore** storage, KoStoreDevice** device );
00165 void storageInit( const QString& file, KoStore::Mode mode, KoStore** storage );
00166 KoStoreDevice* storageInitEmbedding( const QString& name );
00167 KoStoreDevice* storageCreateFirstStream( const QString& streamName, KoStore** storage, KoStoreDevice** device );
00168 KoStoreDevice* storageCleanupHelper( KoStore** storage );
00169
00170 KoDocument* createDocument( const QString& file );
00171 KoDocument* createDocument( const QCString& mimeType );
00172
00178 class ChainLink
00179 {
00180
00181 public:
00182 ChainLink( KoFilterChain* chain, KoFilterEntry::Ptr filterEntry,
00183 const QCString& from, const QCString& to );
00184
00185 KoFilter::ConversionStatus invokeFilter( const ChainLink* const parentChainLink );
00186
00187 QCString from() const { return m_from; }
00188 QCString to() const { return m_to; }
00189
00190
00191 void dump() const;
00192
00193
00194
00195 int lruPartIndex() const;
00196
00197 private:
00198 ChainLink( const ChainLink& rhs );
00199 ChainLink& operator=( const ChainLink& rhs );
00200
00201 void setupCommunication( const KoFilter* const parentFilter ) const;
00202 void setupConnections( const KoFilter* sender, const QStrList& sigs,
00203 const KoFilter* receiver, const QStrList& sl0ts ) const;
00204
00205 KoFilterChain* m_chain;
00206 KoFilterEntry::Ptr m_filterEntry;
00207 QCString m_from, m_to;
00208
00209
00210
00211 KoFilter* m_filter;
00212
00213 class Private;
00214 Private* d;
00215 };
00216
00217
00218
00219 enum Whole { Beginning = 1, Middle = 2, End = 4, Done = 8 };
00220
00221
00222 KoFilterChain( const KoFilterChain& rhs );
00223 KoFilterChain& operator=( const KoFilterChain& rhs );
00224
00225 const KoFilterManager* const m_manager;
00226 QPtrList<ChainLink> m_chainLinks;
00227
00228
00229 int m_state;
00230
00231 QString m_inputFile;
00232 QString m_outputFile;
00233
00234 KoStore* m_inputStorage;
00235 KoStoreDevice* m_inputStorageDevice;
00236 KoStore* m_outputStorage;
00237 KoStoreDevice* m_outputStorageDevice;
00238
00239 KoDocument* m_inputDocument;
00240 KoDocument* m_outputDocument;
00241
00242 KTempFile* m_inputTempFile;
00243 KTempFile* m_outputTempFile;
00244
00245
00246
00247 enum IOState { Nil, File, Storage, Document };
00248 IOState m_inputQueried, m_outputQueried;
00249
00250
00251
00252
00253
00254
00255 QStringList m_internalEmbeddingDirectories;
00256
00257 class Private;
00258 Private* d;
00259 };
00260
00261
00262
00263 namespace KOffice
00264 {
00265 class Vertex;
00266 template<class T> class PriorityQueue;
00267
00272 class Edge
00273 {
00274
00275 public:
00276
00277 Edge( Vertex* vertex, KoFilterEntry::Ptr filterEntry );
00278 ~Edge() {}
00279
00280 unsigned int weight() const { return m_filterEntry ? m_filterEntry->weight : 0; }
00281 KoFilterEntry::Ptr filterEntry() const { return m_filterEntry; }
00282 const Vertex* vertex() const { return m_vertex; }
00283
00284
00285
00286
00287
00288
00289 void relax( const Vertex* predecessor, PriorityQueue<Vertex>& queue );
00290
00291
00292 void dump( const QCString& indent ) const;
00293
00294 private:
00295 Edge( const Edge& rhs );
00296 Edge& operator=( const Edge& rhs );
00297
00298 Vertex* m_vertex;
00299 KoFilterEntry::Ptr m_filterEntry;
00300
00301 class Private;
00302 Private* d;
00303 };
00304
00305
00310 class Vertex
00311 {
00312
00313 public:
00314 Vertex( const QCString& mimeType );
00315 ~Vertex() {}
00316
00317 QCString mimeType() const { return m_mimeType; }
00318
00319
00320
00321
00322 bool setKey( unsigned int key );
00323 unsigned int key() const { return m_weight; }
00324
00325
00326 void reset();
00327
00328
00329 void setIndex( int index ) { m_index=index; }
00330 int index() const { return m_index; }
00331
00332
00333
00334 void setPredecessor( const Vertex* predecessor ) { m_predecessor=predecessor; }
00335 const Vertex* predecessor() const { return m_predecessor; }
00336
00337
00338 void addEdge( const Edge* edge );
00339
00340
00341 const Edge* findEdge( const Vertex* vertex ) const;
00342
00343
00344
00345 void relaxVertices( PriorityQueue<Vertex>& queue );
00346
00347
00348 void dump( const QCString& indent ) const;
00349
00350 private:
00351 Vertex( const Vertex& rhs );
00352 Vertex& operator=( const Vertex& rhs );
00353
00354 QPtrList<Edge> m_edges;
00355 const Vertex* m_predecessor;
00356 QCString m_mimeType;
00357 unsigned int m_weight;
00358 int m_index;
00359
00360 class Private;
00361 Private* d;
00362 };
00363
00364
00370 class Graph
00371 {
00372
00373 public:
00374 Graph( const QCString& from );
00375 ~Graph() {}
00376
00377 bool isValid() const { return m_graphValid; }
00378
00379 QCString sourceMimeType() const { return m_from; }
00380 void setSourceMimeType( const QCString& from );
00381
00382
00383
00384
00385
00386
00387 KoFilterChain::Ptr chain( const KoFilterManager* manager, QCString& to ) const;
00388
00389
00390 void dump() const;
00391
00392 private:
00393 Graph( const Graph& rhs );
00394 Graph& operator=( const Graph& rhs );
00395
00396 void buildGraph();
00397 void shortestPaths();
00398 QCString findKOfficePart() const;
00399
00400 QAsciiDict<Vertex> m_vertices;
00401 QCString m_from;
00402 bool m_graphValid;
00403
00404 class Private;
00405 Private* d;
00406 };
00407
00408 }
00409
00410 #endif // __koffice_filter_chain_h__
This file is part of the documentation for lib Library Version 1.4.2.