1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ooofilt.hxx,v $
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 //--------------------------------------------------------------------------
43 //+-------------------------------------------------------------------------
45 // forward declaration
47 //--------------------------------------------------------------------------
49 class CMetaInfoReader
;
52 //+-------------------------------------------------------------------------
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-------------------------------------------------------------------------
65 // Purpose: Implements interfaces of OpenOffice.org filter
67 //--------------------------------------------------------------------------
70 // {7BC0E710-5703-45be-A29D-5D46D8B39262}
71 GUID
const CLSID_COooFilter
=
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}};
96 FilteringContent
, // Filtering the content property
97 FilteringProperty
// Filtering the pseudo property
99 class COooFilter
: public IFilter
, public IPersistFile
, public IPersistStream
103 virtual SCODE STDMETHODCALLTYPE
QueryInterface(
106 virtual ULONG STDMETHODCALLTYPE
AddRef();
107 virtual ULONG STDMETHODCALLTYPE
Release();
110 virtual SCODE STDMETHODCALLTYPE
Init(
113 FULLPROPSPEC
const * aAttributes
,
115 virtual SCODE STDMETHODCALLTYPE
GetChunk(
117 virtual SCODE STDMETHODCALLTYPE
GetText(
121 virtual SCODE STDMETHODCALLTYPE
GetValue(
122 PROPVARIANT
** ppPropValue
);
124 virtual SCODE STDMETHODCALLTYPE
BindRegion(
125 FILTERREGION origPos
,
130 virtual SCODE STDMETHODCALLTYPE
GetClassID(
132 virtual SCODE STDMETHODCALLTYPE
IsDirty();
133 virtual SCODE STDMETHODCALLTYPE
Load(
136 virtual SCODE STDMETHODCALLTYPE
Save(
140 virtual SCODE STDMETHODCALLTYPE
SaveCompleted(
141 LPCWSTR pszFileName
);
143 virtual SCODE STDMETHODCALLTYPE
GetCurFile(
144 LPWSTR
* ppszFileName
);
146 // From IPersistStream
147 virtual SCODE STDMETHODCALLTYPE
Load(
150 virtual SCODE STDMETHODCALLTYPE
Save(
154 virtual SCODE STDMETHODCALLTYPE
GetSizeMax(
155 ULARGE_INTEGER
*pcbSize
);
159 friend class COooFilterCF
;
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
184 //C-------------------------------------------------------------------------
186 // Class: COooFilterCF
188 // Purpose: Implements class factory for OpenOffice.org filter
190 //--------------------------------------------------------------------------
192 class COooFilterCF
: public IClassFactory
196 virtual SCODE STDMETHODCALLTYPE
QueryInterface(
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(
212 friend SCODE STDMETHODCALLTYPE
DllGetClassObject(
218 virtual ~COooFilterCF();
220 long m_lRefs
; // Reference count
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
);