1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "internal/types.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir //+-------------------------------------------------------------------------
31*cdf0e10cSrcweir //
32*cdf0e10cSrcweir //  Contents:   OpenOffice.org filter declarations
33*cdf0e10cSrcweir //
34*cdf0e10cSrcweir //  Platform:   Windows 2000, Windows XP
35*cdf0e10cSrcweir //
36*cdf0e10cSrcweir //--------------------------------------------------------------------------
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #pragma once
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir //+-------------------------------------------------------------------------
41*cdf0e10cSrcweir //
42*cdf0e10cSrcweir //  forward declaration
43*cdf0e10cSrcweir //
44*cdf0e10cSrcweir //--------------------------------------------------------------------------
45*cdf0e10cSrcweir class CContentReader;
46*cdf0e10cSrcweir class CMetaInfoReader;
47*cdf0e10cSrcweir class CFullPropSpec;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir //+-------------------------------------------------------------------------
50*cdf0e10cSrcweir //
51*cdf0e10cSrcweir //  Global definitions
52*cdf0e10cSrcweir //
53*cdf0e10cSrcweir //--------------------------------------------------------------------------
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir long g_lInstances = 0;                        // Global count of COooFilter and COooFilterCF instances
56*cdf0e10cSrcweir GUID const guidStorage = PSGUID_STORAGE;      // GUID for storage property set
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir //C-------------------------------------------------------------------------
59*cdf0e10cSrcweir //
60*cdf0e10cSrcweir //  Class:      COooFilter
61*cdf0e10cSrcweir //
62*cdf0e10cSrcweir //  Purpose:    Implements interfaces of OpenOffice.org filter
63*cdf0e10cSrcweir //
64*cdf0e10cSrcweir //--------------------------------------------------------------------------
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir // OooFilter Class ID
67*cdf0e10cSrcweir // {7BC0E710-5703-45be-A29D-5D46D8B39262}
68*cdf0e10cSrcweir GUID const CLSID_COooFilter =
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir     0x7bc0e710,
71*cdf0e10cSrcweir     0x5703,
72*cdf0e10cSrcweir     0x45be,
73*cdf0e10cSrcweir     { 0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62 }
74*cdf0e10cSrcweir };
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir // OpenOffice.org Persistent Handler Class ID
77*cdf0e10cSrcweir // {7BC0E713-5703-45be-A29D-5D46D8B39262}
78*cdf0e10cSrcweir const CLSID CLSID_PERSISTENT_HANDLER =
79*cdf0e10cSrcweir {0x7bc0e713, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}};
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir // OpenOffice.org Persistent Handler Addin Registered Class ID
82*cdf0e10cSrcweir // {89BCB740-6119-101A-BCB7-00DD010655AF}
83*cdf0e10cSrcweir const CLSID CLSID_PERSISTENT_HANDLER_ADDIN =
84*cdf0e10cSrcweir {0x89bcb740, 0x6119, 0x101a, {0xbc, 0xb7, 0x00, 0xdd, 0x01, 0x06, 0x55, 0xaf}};
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir // OpenOffice.org Filter Handler Class ID
87*cdf0e10cSrcweir // {7BC0E710-5703-45be-A29D-5D46D8B39262}
88*cdf0e10cSrcweir const CLSID CLSID_FILTER_HANDLER =
89*cdf0e10cSrcweir {0x7bc0e710, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}};
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir enum FilterState
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir     FilteringContent,                           // Filtering the content property
94*cdf0e10cSrcweir     FilteringProperty                           // Filtering the pseudo property
95*cdf0e10cSrcweir };
96*cdf0e10cSrcweir class COooFilter : public IFilter, public IPersistFile, public IPersistStream
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir public:
99*cdf0e10cSrcweir     // From IUnknown
100*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  QueryInterface(
101*cdf0e10cSrcweir         REFIID riid,
102*cdf0e10cSrcweir         void  ** ppvObject);
103*cdf0e10cSrcweir     virtual  ULONG STDMETHODCALLTYPE  AddRef();
104*cdf0e10cSrcweir     virtual  ULONG STDMETHODCALLTYPE  Release();
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     // From IFilter
107*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  Init(
108*cdf0e10cSrcweir         ULONG grfFlags,
109*cdf0e10cSrcweir         ULONG cAttributes,
110*cdf0e10cSrcweir         FULLPROPSPEC const * aAttributes,
111*cdf0e10cSrcweir         ULONG * pFlags);
112*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  GetChunk(
113*cdf0e10cSrcweir         STAT_CHUNK * pStat);
114*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  GetText(
115*cdf0e10cSrcweir         ULONG * pcwcBuffer,
116*cdf0e10cSrcweir         WCHAR * awcBuffer);
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  GetValue(
119*cdf0e10cSrcweir         PROPVARIANT ** ppPropValue);
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  BindRegion(
122*cdf0e10cSrcweir         FILTERREGION origPos,
123*cdf0e10cSrcweir         REFIID riid,
124*cdf0e10cSrcweir         void ** ppunk);
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     // From IPersistFile
127*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  GetClassID(
128*cdf0e10cSrcweir         CLSID * pClassID);
129*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  IsDirty();
130*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  Load(
131*cdf0e10cSrcweir         LPCWSTR pszFileName,
132*cdf0e10cSrcweir         DWORD dwMode);
133*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  Save(
134*cdf0e10cSrcweir         LPCWSTR pszFileName,
135*cdf0e10cSrcweir         BOOL fRemember);
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  SaveCompleted(
138*cdf0e10cSrcweir         LPCWSTR pszFileName);
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  GetCurFile(
141*cdf0e10cSrcweir         LPWSTR  * ppszFileName);
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	// From IPersistStream
144*cdf0e10cSrcweir 	virtual SCODE STDMETHODCALLTYPE  Load(
145*cdf0e10cSrcweir 		IStream *pStm);
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	virtual SCODE STDMETHODCALLTYPE Save(
148*cdf0e10cSrcweir 		IStream *pStm,
149*cdf0e10cSrcweir 		BOOL fClearDirty);
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	virtual SCODE STDMETHODCALLTYPE  GetSizeMax(
152*cdf0e10cSrcweir 		ULARGE_INTEGER *pcbSize);
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir private:
156*cdf0e10cSrcweir     friend class COooFilterCF;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir     COooFilter();
159*cdf0e10cSrcweir     virtual ~COooFilter();
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     long                      m_lRefs;                  // Reference count
162*cdf0e10cSrcweir 	CContentReader *          m_pContentReader;         // A content reader that retrive document content.
163*cdf0e10cSrcweir 	CMetaInfoReader *         m_pMetaInfoReader;        // A metainfo reader that retrive document metainfo.
164*cdf0e10cSrcweir     FilterState               m_eState;                 // State of filtering
165*cdf0e10cSrcweir 	::std::wstring            m_pwszFileName;           // Name of input file to filter
166*cdf0e10cSrcweir     ULONG                     m_ulUnicodeBufferLen;     // UNICODE Characters read from file to chunk buffer
167*cdf0e10cSrcweir     ULONG                     m_ulUnicodeCharsRead;     // UNICODE Characters read from chunk buffer
168*cdf0e10cSrcweir 	ULONG                     m_ulPropertyNum;          // Number of properties that has been processed
169*cdf0e10cSrcweir 	ULONG                     m_ulCurrentPropertyNum;   // Current Property that is processing;
170*cdf0e10cSrcweir     ULONG                     m_ulChunkID;              // Current chunk id
171*cdf0e10cSrcweir     BOOL                      m_fContents;              // TRUE if contents requested
172*cdf0e10cSrcweir     BOOL                      m_fEof;                   // TRUE if end of file reached
173*cdf0e10cSrcweir 	::std::wstring            m_pwsBuffer;              // Buffer to save UNICODE content from ChunkBuffer.
174*cdf0e10cSrcweir     ULONG			          m_ChunkPosition;          // Chunk pointer to specify the current Chunk;
175*cdf0e10cSrcweir     ULONG                     m_cAttributes;            // Count of attributes
176*cdf0e10cSrcweir     CFullPropSpec *           m_pAttributes;            // Attributes to filter
177*cdf0e10cSrcweir 	IStream *                 m_pStream;
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir };
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir //C-------------------------------------------------------------------------
182*cdf0e10cSrcweir //
183*cdf0e10cSrcweir //  Class:      COooFilterCF
184*cdf0e10cSrcweir //
185*cdf0e10cSrcweir //  Purpose:    Implements class factory for OpenOffice.org filter
186*cdf0e10cSrcweir //
187*cdf0e10cSrcweir //--------------------------------------------------------------------------
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir class COooFilterCF : public IClassFactory
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir public:
192*cdf0e10cSrcweir     // From IUnknown
193*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  QueryInterface(
194*cdf0e10cSrcweir         REFIID riid,
195*cdf0e10cSrcweir         void  ** ppvObject);
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     virtual  ULONG STDMETHODCALLTYPE  AddRef();
198*cdf0e10cSrcweir     virtual  ULONG STDMETHODCALLTYPE  Release();
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     // From IClassFactory
201*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  CreateInstance(
202*cdf0e10cSrcweir         IUnknown * pUnkOuter,
203*cdf0e10cSrcweir         REFIID riid, void  ** ppvObject);
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir     virtual  SCODE STDMETHODCALLTYPE  LockServer(
206*cdf0e10cSrcweir         BOOL fLock);
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir private:
209*cdf0e10cSrcweir     friend SCODE STDMETHODCALLTYPE DllGetClassObject(
210*cdf0e10cSrcweir         REFCLSID   cid,
211*cdf0e10cSrcweir         REFIID     iid,
212*cdf0e10cSrcweir         void **    ppvObj);
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     COooFilterCF();
215*cdf0e10cSrcweir     virtual  ~COooFilterCF();
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     long m_lRefs;           // Reference count
218*cdf0e10cSrcweir };
219