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