1ed2f6d3bSAndrew Rist /**************************************************************
2*fff73a02Smseidel  *
3ed2f6d3bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ed2f6d3bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ed2f6d3bSAndrew Rist  * distributed with this work for additional information
6ed2f6d3bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ed2f6d3bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ed2f6d3bSAndrew Rist  * "License"); you may not use this file except in compliance
9ed2f6d3bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*fff73a02Smseidel  *
11ed2f6d3bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*fff73a02Smseidel  *
13ed2f6d3bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ed2f6d3bSAndrew Rist  * software distributed under the License is distributed on an
15ed2f6d3bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ed2f6d3bSAndrew Rist  * KIND, either express or implied.  See the License for the
17ed2f6d3bSAndrew Rist  * specific language governing permissions and limitations
18ed2f6d3bSAndrew Rist  * under the License.
19*fff73a02Smseidel  *
20ed2f6d3bSAndrew Rist  *************************************************************/
21ed2f6d3bSAndrew Rist 
22ed2f6d3bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "internal/types.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir //+-------------------------------------------------------------------------
27cdf0e10cSrcweir //
28*fff73a02Smseidel //  Contents:   OpenOffice filter declarations
29cdf0e10cSrcweir //
30cdf0e10cSrcweir //  Platform:   Windows 2000, Windows XP
31cdf0e10cSrcweir //
32cdf0e10cSrcweir //--------------------------------------------------------------------------
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #pragma once
35cdf0e10cSrcweir 
36cdf0e10cSrcweir //+-------------------------------------------------------------------------
37cdf0e10cSrcweir //
38cdf0e10cSrcweir //  forward declaration
39cdf0e10cSrcweir //
40cdf0e10cSrcweir //--------------------------------------------------------------------------
41cdf0e10cSrcweir class CContentReader;
42cdf0e10cSrcweir class CMetaInfoReader;
43cdf0e10cSrcweir class CFullPropSpec;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //+-------------------------------------------------------------------------
46cdf0e10cSrcweir //
47cdf0e10cSrcweir //  Global definitions
48cdf0e10cSrcweir //
49cdf0e10cSrcweir //--------------------------------------------------------------------------
50cdf0e10cSrcweir 
51cdf0e10cSrcweir long g_lInstances = 0;                        // Global count of COooFilter and COooFilterCF instances
52cdf0e10cSrcweir GUID const guidStorage = PSGUID_STORAGE;      // GUID for storage property set
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //C-------------------------------------------------------------------------
55cdf0e10cSrcweir //
56cdf0e10cSrcweir //  Class:      COooFilter
57cdf0e10cSrcweir //
58*fff73a02Smseidel //  Purpose:    Implements interfaces of OpenOffice filter
59cdf0e10cSrcweir //
60cdf0e10cSrcweir //--------------------------------------------------------------------------
61cdf0e10cSrcweir 
62*fff73a02Smseidel // OooFilter Class ID
63cdf0e10cSrcweir // {7BC0E710-5703-45be-A29D-5D46D8B39262}
64cdf0e10cSrcweir GUID const CLSID_COooFilter =
65cdf0e10cSrcweir {
66*fff73a02Smseidel 	0x7bc0e710,
67*fff73a02Smseidel 	0x5703,
68*fff73a02Smseidel 	0x45be,
69*fff73a02Smseidel 	{ 0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62 }
70cdf0e10cSrcweir };
71cdf0e10cSrcweir 
72*fff73a02Smseidel // OpenOffice Persistent Handler Class ID
73cdf0e10cSrcweir // {7BC0E713-5703-45be-A29D-5D46D8B39262}
74*fff73a02Smseidel const CLSID CLSID_PERSISTENT_HANDLER =
75cdf0e10cSrcweir {0x7bc0e713, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}};
76cdf0e10cSrcweir 
77*fff73a02Smseidel // OpenOffice Persistent Handler Addin Registered Class ID
78cdf0e10cSrcweir // {89BCB740-6119-101A-BCB7-00DD010655AF}
79*fff73a02Smseidel const CLSID CLSID_PERSISTENT_HANDLER_ADDIN =
80cdf0e10cSrcweir {0x89bcb740, 0x6119, 0x101a, {0xbc, 0xb7, 0x00, 0xdd, 0x01, 0x06, 0x55, 0xaf}};
81cdf0e10cSrcweir 
82*fff73a02Smseidel // OpenOffice Filter Handler Class ID
83cdf0e10cSrcweir // {7BC0E710-5703-45be-A29D-5D46D8B39262}
84*fff73a02Smseidel const CLSID CLSID_FILTER_HANDLER =
85cdf0e10cSrcweir {0x7bc0e710, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}};
86cdf0e10cSrcweir 
87cdf0e10cSrcweir enum FilterState
88cdf0e10cSrcweir {
89*fff73a02Smseidel 	FilteringContent,                           // Filtering the content property
90*fff73a02Smseidel 	FilteringProperty                           // Filtering the pseudo property
91cdf0e10cSrcweir };
92cdf0e10cSrcweir class COooFilter : public IFilter, public IPersistFile, public IPersistStream
93cdf0e10cSrcweir {
94cdf0e10cSrcweir public:
95*fff73a02Smseidel 	// From IUnknown
96*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  QueryInterface(
97*fff73a02Smseidel 		REFIID riid,
98*fff73a02Smseidel 		void  ** ppvObject);
99*fff73a02Smseidel 	virtual  ULONG STDMETHODCALLTYPE  AddRef();
100*fff73a02Smseidel 	virtual  ULONG STDMETHODCALLTYPE  Release();
101*fff73a02Smseidel 
102*fff73a02Smseidel 	// From IFilter
103*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  Init(
104*fff73a02Smseidel 		ULONG grfFlags,
105*fff73a02Smseidel 		ULONG cAttributes,
106*fff73a02Smseidel 		FULLPROPSPEC const * aAttributes,
107*fff73a02Smseidel 		ULONG * pFlags);
108*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  GetChunk(
109*fff73a02Smseidel 		STAT_CHUNK * pStat);
110*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  GetText(
111*fff73a02Smseidel 		ULONG * pcwcBuffer,
112*fff73a02Smseidel 		WCHAR * awcBuffer);
113*fff73a02Smseidel 
114*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  GetValue(
115*fff73a02Smseidel 		PROPVARIANT ** ppPropValue);
116*fff73a02Smseidel 
117*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  BindRegion(
118*fff73a02Smseidel 		FILTERREGION origPos,
119*fff73a02Smseidel 		REFIID riid,
120*fff73a02Smseidel 		void ** ppunk);
121*fff73a02Smseidel 
122*fff73a02Smseidel 	// From IPersistFile
123*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  GetClassID(
124*fff73a02Smseidel 		CLSID * pClassID);
125*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  IsDirty();
126*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  Load(
127*fff73a02Smseidel 		LPCWSTR pszFileName,
128*fff73a02Smseidel 		DWORD dwMode);
129*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  Save(
130*fff73a02Smseidel 		LPCWSTR pszFileName,
131*fff73a02Smseidel 		BOOL fRemember);
132*fff73a02Smseidel 
133*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  SaveCompleted(
134*fff73a02Smseidel 		LPCWSTR pszFileName);
135*fff73a02Smseidel 
136*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  GetCurFile(
137*fff73a02Smseidel 		LPWSTR  * ppszFileName);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	// From IPersistStream
140cdf0e10cSrcweir 	virtual SCODE STDMETHODCALLTYPE  Load(
141cdf0e10cSrcweir 		IStream *pStm);
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	virtual SCODE STDMETHODCALLTYPE Save(
144cdf0e10cSrcweir 		IStream *pStm,
145cdf0e10cSrcweir 		BOOL fClearDirty);
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	virtual SCODE STDMETHODCALLTYPE  GetSizeMax(
148cdf0e10cSrcweir 		ULARGE_INTEGER *pcbSize);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 
151cdf0e10cSrcweir private:
152*fff73a02Smseidel 	friend class COooFilterCF;
153cdf0e10cSrcweir 
154*fff73a02Smseidel 	COooFilter();
155*fff73a02Smseidel 	virtual ~COooFilter();
156*fff73a02Smseidel 
157*fff73a02Smseidel 	long                      m_lRefs;                  // Reference count
1588cc42d09Smseidel 	CContentReader *          m_pContentReader;         // A content reader that retrieves document content.
1598cc42d09Smseidel 	CMetaInfoReader *         m_pMetaInfoReader;        // A metainfo reader that retrieves document metainfo.
160*fff73a02Smseidel 	FilterState               m_eState;                 // State of filtering
161cdf0e10cSrcweir 	::std::wstring            m_pwszFileName;           // Name of input file to filter
162*fff73a02Smseidel 	ULONG                     m_ulUnicodeBufferLen;     // UNICODE Characters read from file to chunk buffer
163*fff73a02Smseidel 	ULONG                     m_ulUnicodeCharsRead;     // UNICODE Characters read from chunk buffer
164cdf0e10cSrcweir 	ULONG                     m_ulPropertyNum;          // Number of properties that has been processed
165cdf0e10cSrcweir 	ULONG                     m_ulCurrentPropertyNum;   // Current Property that is processing;
166*fff73a02Smseidel 	ULONG                     m_ulChunkID;              // Current chunk id
167*fff73a02Smseidel 	BOOL                      m_fContents;              // TRUE if contents requested
168*fff73a02Smseidel 	BOOL                      m_fEof;                   // TRUE if end of file reached
169cdf0e10cSrcweir 	::std::wstring            m_pwsBuffer;              // Buffer to save UNICODE content from ChunkBuffer.
170*fff73a02Smseidel 	ULONG			          m_ChunkPosition;          // Chunk pointer to specify the current Chunk;
171*fff73a02Smseidel 	ULONG                     m_cAttributes;            // Count of attributes
172*fff73a02Smseidel 	CFullPropSpec *           m_pAttributes;            // Attributes to filter
173cdf0e10cSrcweir 	IStream *                 m_pStream;
174cdf0e10cSrcweir 
175cdf0e10cSrcweir };
176cdf0e10cSrcweir 
177cdf0e10cSrcweir //C-------------------------------------------------------------------------
178cdf0e10cSrcweir //
179cdf0e10cSrcweir //  Class:      COooFilterCF
180cdf0e10cSrcweir //
181*fff73a02Smseidel //  Purpose:    Implements class factory for OpenOffice filter
182cdf0e10cSrcweir //
183cdf0e10cSrcweir //--------------------------------------------------------------------------
184cdf0e10cSrcweir 
185cdf0e10cSrcweir class COooFilterCF : public IClassFactory
186cdf0e10cSrcweir {
187cdf0e10cSrcweir public:
188*fff73a02Smseidel 	// From IUnknown
189*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  QueryInterface(
190*fff73a02Smseidel 		REFIID riid,
191*fff73a02Smseidel 		void  ** ppvObject);
192cdf0e10cSrcweir 
193*fff73a02Smseidel 	virtual  ULONG STDMETHODCALLTYPE  AddRef();
194*fff73a02Smseidel 	virtual  ULONG STDMETHODCALLTYPE  Release();
195cdf0e10cSrcweir 
196*fff73a02Smseidel 	// From IClassFactory
197*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  CreateInstance(
198*fff73a02Smseidel 		IUnknown * pUnkOuter,
199*fff73a02Smseidel 		REFIID riid, void  ** ppvObject);
200cdf0e10cSrcweir 
201*fff73a02Smseidel 	virtual  SCODE STDMETHODCALLTYPE  LockServer(
202*fff73a02Smseidel 		BOOL fLock);
203cdf0e10cSrcweir 
204cdf0e10cSrcweir private:
205*fff73a02Smseidel 	friend SCODE STDMETHODCALLTYPE DllGetClassObject(
206*fff73a02Smseidel 		REFCLSID   cid,
207*fff73a02Smseidel 		REFIID     iid,
208*fff73a02Smseidel 		void **    ppvObj);
209*fff73a02Smseidel 
210*fff73a02Smseidel 	COooFilterCF();
211*fff73a02Smseidel 	virtual  ~COooFilterCF();
212*fff73a02Smseidel 
213*fff73a02Smseidel 	long m_lRefs;           // Reference count
214cdf0e10cSrcweir };
215*fff73a02Smseidel 
216*fff73a02Smseidel /* vim: set noet sw=4 ts=4: */
217