olefilter.h
1/* This file is part of the KDE project
2 Copyright (C) 1999 Werner Trobin <trobin@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// The OLEFilter class is the main filtering class. It manages the
21// correct handling of the input and output file and provides the
22// OLE 2 streams for the real filters (excel97, powerpoint97, winword97)
23
24#ifndef OLEFILTER_H
25#define OLEFILTER_H
26
27#include <filterbase.h>
28#include <KoFilter.h>
29#include <klaola.h>
30
31class KoStore;
32
33class OLEFilter : public KoEmbeddingFilter {
34
35 TQ_OBJECT
36
37
38public:
39 OLEFilter(KoFilter *parent, const char *name, const TQStringList&);
40 virtual ~OLEFilter();
41
42 virtual KoFilter::ConversionStatus convert( const TQCString& from, const TQCString& to );
43
44public slots:
45 void commSlotDelayStream( const char* delay );
46 void commSlotShapeID( unsigned int& shapeID );
47
48protected slots:
49 // This slot saves the document informations to the KOffice tar storage.
50 void slotSaveDocumentInformation(
51 const TQString &fullName,
52 const TQString &title,
53 const TQString &company,
54 const TQString &email,
55 const TQString &telephone,
56 const TQString &fax,
57 const TQString &postalCode,
58 const TQString &country,
59 const TQString &city,
60 const TQString &street,
61 const TQString &docTitle,
62 const TQString &docAbstract);
63
64 // This slot saves an embedded Picture to the KOffice tar storage.
65 void slotSavePic(
66 const TQString &nameIN,
67 TQString &storageId,
68 const TQString &extension,
69 unsigned int length,
70 const char *data);
71
72 // This slot saves an embedded object to the KOffice tar storage. Note that
73 // this only applies to objects within an OLE stream (like embedded WMFs)
74 // that we want to handle as parts rather than using slotSavePic() since OLE
75 // objects are handled by us, and a filter need only call slotPart().
76 void slotSavePart(
77 const TQString &nameIN,
78 TQString &storageId,
79 TQString &mimeType,
80 const TQString &extension,
81 unsigned int length,
82 const char *data);
83
84 // Generate a name for a new part to store it in the KOffice tar storage,
85 // or find the name and type of an existing one.
86 void slotPart(
87 const TQString &nameIN,
88 TQString &storageId,
89 TQString &mimeType);
90
91 // Get another OLE 2 stream for your filter.
92 // Attention: You'll have to delete [] the stream.data ptr!
93 void slotGetStream(const int &handle, myFile &stream);
94
95 // Like above. Note: This method might return the wrong stream
96 // as the stream names are NOT unique in the OLE 2 file!!!
97 // (Therefore it's searching only in the current dir)
98 // Attention: You'll have to delete [] the stream.data ptr!
99 void slotGetStream(const TQString &name, myFile &stream);
100
101signals:
102 // Forwarding signals for inter-filter communication
103 void internalCommShapeID( unsigned int& shapeID );
104 void internalCommDelayStream( const char* delay );
105
106private:
107 // Don't copy or assign me >:)
108 OLEFilter(const OLEFilter &);
109 const OLEFilter &operator=(const OLEFilter &);
110
111 // Template method, triggered by embedPart calls
112 virtual void savePartContents( TQIODevice* file );
113
114 void convert( const TQCString& mimeTypeHint );
115 void connectCommon(FilterBase **myFilter);
116 TQCString mimeTypeHelper();
117
118 TQMap<TQString, TQString> imageMap;
119
120 myFile olefile;
121 int numPic; // for the "unique name generation"
122 KLaola *docfile; // used to split up the OLE 2 file
123
124 // Needed for the template method callback savePartContents
125 const char* m_embeddeeData;
126 unsigned int m_embeddeeLength;
127
128 bool success;
129 static const int s_area;
130};
131
132#endif // OLEFILTER_H