update dev300-m58
[ooovba.git] / shell / source / win32 / shlxthandler / ooofilt / ooofilt.hxx
blobf63a9942f506596d6de1e15c4a48137d903ad149
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ooofilt.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "internal/types.hxx"
33 //+-------------------------------------------------------------------------
35 // Contents: OpenOffice.org filter declarations
37 // Platform: Windows 2000, Windows XP
39 //--------------------------------------------------------------------------
41 #pragma once
43 //+-------------------------------------------------------------------------
45 // forward declaration
47 //--------------------------------------------------------------------------
48 class CContentReader;
49 class CMetaInfoReader;
50 class CFullPropSpec;
52 //+-------------------------------------------------------------------------
54 // Global definitions
56 //--------------------------------------------------------------------------
58 long g_lInstances = 0; // Global count of COooFilter and COooFilterCF instances
59 GUID const guidStorage = PSGUID_STORAGE; // GUID for storage property set
61 //C-------------------------------------------------------------------------
63 // Class: COooFilter
65 // Purpose: Implements interfaces of OpenOffice.org filter
67 //--------------------------------------------------------------------------
69 // OooFilter Class ID
70 // {7BC0E710-5703-45be-A29D-5D46D8B39262}
71 GUID const CLSID_COooFilter =
73 0x7bc0e710,
74 0x5703,
75 0x45be,
76 { 0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62 }
79 // OpenOffice.org Persistent Handler Class ID
80 // {7BC0E713-5703-45be-A29D-5D46D8B39262}
81 const CLSID CLSID_PERSISTENT_HANDLER =
82 {0x7bc0e713, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}};
84 // OpenOffice.org Persistent Handler Addin Registered Class ID
85 // {89BCB740-6119-101A-BCB7-00DD010655AF}
86 const CLSID CLSID_PERSISTENT_HANDLER_ADDIN =
87 {0x89bcb740, 0x6119, 0x101a, {0xbc, 0xb7, 0x00, 0xdd, 0x01, 0x06, 0x55, 0xaf}};
89 // OpenOffice.org Filter Handler Class ID
90 // {7BC0E710-5703-45be-A29D-5D46D8B39262}
91 const CLSID CLSID_FILTER_HANDLER =
92 {0x7bc0e710, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}};
94 enum FilterState
96 FilteringContent, // Filtering the content property
97 FilteringProperty // Filtering the pseudo property
99 class COooFilter : public IFilter, public IPersistFile, public IPersistStream
101 public:
102 // From IUnknown
103 virtual SCODE STDMETHODCALLTYPE QueryInterface(
104 REFIID riid,
105 void ** ppvObject);
106 virtual ULONG STDMETHODCALLTYPE AddRef();
107 virtual ULONG STDMETHODCALLTYPE Release();
109 // From IFilter
110 virtual SCODE STDMETHODCALLTYPE Init(
111 ULONG grfFlags,
112 ULONG cAttributes,
113 FULLPROPSPEC const * aAttributes,
114 ULONG * pFlags);
115 virtual SCODE STDMETHODCALLTYPE GetChunk(
116 STAT_CHUNK * pStat);
117 virtual SCODE STDMETHODCALLTYPE GetText(
118 ULONG * pcwcBuffer,
119 WCHAR * awcBuffer);
121 virtual SCODE STDMETHODCALLTYPE GetValue(
122 PROPVARIANT ** ppPropValue);
124 virtual SCODE STDMETHODCALLTYPE BindRegion(
125 FILTERREGION origPos,
126 REFIID riid,
127 void ** ppunk);
129 // From IPersistFile
130 virtual SCODE STDMETHODCALLTYPE GetClassID(
131 CLSID * pClassID);
132 virtual SCODE STDMETHODCALLTYPE IsDirty();
133 virtual SCODE STDMETHODCALLTYPE Load(
134 LPCWSTR pszFileName,
135 DWORD dwMode);
136 virtual SCODE STDMETHODCALLTYPE Save(
137 LPCWSTR pszFileName,
138 BOOL fRemember);
140 virtual SCODE STDMETHODCALLTYPE SaveCompleted(
141 LPCWSTR pszFileName);
143 virtual SCODE STDMETHODCALLTYPE GetCurFile(
144 LPWSTR * ppszFileName);
146 // From IPersistStream
147 virtual SCODE STDMETHODCALLTYPE Load(
148 IStream *pStm);
150 virtual SCODE STDMETHODCALLTYPE Save(
151 IStream *pStm,
152 BOOL fClearDirty);
154 virtual SCODE STDMETHODCALLTYPE GetSizeMax(
155 ULARGE_INTEGER *pcbSize);
158 private:
159 friend class COooFilterCF;
161 COooFilter();
162 virtual ~COooFilter();
164 long m_lRefs; // Reference count
165 CContentReader * m_pContentReader; // A content reader that retrive document content.
166 CMetaInfoReader * m_pMetaInfoReader; // A metainfo reader that retrive document metainfo.
167 FilterState m_eState; // State of filtering
168 ::std::wstring m_pwszFileName; // Name of input file to filter
169 ULONG m_ulUnicodeBufferLen; // UNICODE Characters read from file to chunk buffer
170 ULONG m_ulUnicodeCharsRead; // UNICODE Characters read from chunk buffer
171 ULONG m_ulPropertyNum; // Number of properties that has been processed
172 ULONG m_ulCurrentPropertyNum; // Current Property that is processing;
173 ULONG m_ulChunkID; // Current chunk id
174 BOOL m_fContents; // TRUE if contents requested
175 BOOL m_fEof; // TRUE if end of file reached
176 ::std::wstring m_pwsBuffer; // Buffer to save UNICODE content from ChunkBuffer.
177 ULONG m_ChunkPosition; // Chunk pointer to specify the current Chunk;
178 ULONG m_cAttributes; // Count of attributes
179 CFullPropSpec * m_pAttributes; // Attributes to filter
180 IStream * m_pStream;
184 //C-------------------------------------------------------------------------
186 // Class: COooFilterCF
188 // Purpose: Implements class factory for OpenOffice.org filter
190 //--------------------------------------------------------------------------
192 class COooFilterCF : public IClassFactory
194 public:
195 // From IUnknown
196 virtual SCODE STDMETHODCALLTYPE QueryInterface(
197 REFIID riid,
198 void ** ppvObject);
200 virtual ULONG STDMETHODCALLTYPE AddRef();
201 virtual ULONG STDMETHODCALLTYPE Release();
203 // From IClassFactory
204 virtual SCODE STDMETHODCALLTYPE CreateInstance(
205 IUnknown * pUnkOuter,
206 REFIID riid, void ** ppvObject);
208 virtual SCODE STDMETHODCALLTYPE LockServer(
209 BOOL fLock);
211 private:
212 friend SCODE STDMETHODCALLTYPE DllGetClassObject(
213 REFCLSID cid,
214 REFIID iid,
215 void ** ppvObj);
217 COooFilterCF();
218 virtual ~COooFilterCF();
220 long m_lRefs; // Reference count
223 extern "C" {
225 voidpf ZCALLBACK cb_sopen OF((voidpf opaque, const char * filename, int mode));
226 uLong ZCALLBACK cb_sread OF((voidpf opaque, voidpf stream, void* vuf, uLong size));
227 uLong ZCALLBACK cb_swrite OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
228 long ZCALLBACK cb_stell OF((voidpf opaque, voidpf stream));
229 long ZCALLBACK cb_sseek OF((voidpf opaque, voidpf stream, uLong offset, int origin));
230 int ZCALLBACK cb_sclose OF((voidpf opaque, voidpf stream));
231 int ZCALLBACK cb_serror OF((voidpf opaque, voidpf stream));
233 void fill_stream_filefunc (zlib_filefunc_def* pzlib_filefunc_def);