1ed2f6d3bSAndrew Rist /************************************************************** 2*c8265279Smseidel * 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*c8265279Smseidel * 11ed2f6d3bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*c8265279Smseidel * 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*c8265279Smseidel * 20ed2f6d3bSAndrew Rist *************************************************************/ 21ed2f6d3bSAndrew Rist 22ed2f6d3bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "internal/types.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir //+------------------------------------------------------------------------- 27cdf0e10cSrcweir // 28*c8265279Smseidel // 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*c8265279Smseidel // Purpose: Implements interfaces of OpenOffice filter 59cdf0e10cSrcweir // 60cdf0e10cSrcweir //-------------------------------------------------------------------------- 61cdf0e10cSrcweir 62*c8265279Smseidel // OooFilter Class ID 63cdf0e10cSrcweir // {7BC0E710-5703-45be-A29D-5D46D8B39262} 64cdf0e10cSrcweir GUID const CLSID_COooFilter = 65cdf0e10cSrcweir { 66*c8265279Smseidel 0x7bc0e710, 67*c8265279Smseidel 0x5703, 68*c8265279Smseidel 0x45be, 69*c8265279Smseidel { 0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62 } 70cdf0e10cSrcweir }; 71cdf0e10cSrcweir 72*c8265279Smseidel // OpenOffice Persistent Handler Class ID 73cdf0e10cSrcweir // {7BC0E713-5703-45be-A29D-5D46D8B39262} 74*c8265279Smseidel const CLSID CLSID_PERSISTENT_HANDLER = 75cdf0e10cSrcweir {0x7bc0e713, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}}; 76cdf0e10cSrcweir 77*c8265279Smseidel // OpenOffice Persistent Handler Addin Registered Class ID 78cdf0e10cSrcweir // {89BCB740-6119-101A-BCB7-00DD010655AF} 79*c8265279Smseidel const CLSID CLSID_PERSISTENT_HANDLER_ADDIN = 80cdf0e10cSrcweir {0x89bcb740, 0x6119, 0x101a, {0xbc, 0xb7, 0x00, 0xdd, 0x01, 0x06, 0x55, 0xaf}}; 81cdf0e10cSrcweir 82*c8265279Smseidel // OpenOffice Filter Handler Class ID 83cdf0e10cSrcweir // {7BC0E710-5703-45be-A29D-5D46D8B39262} 84*c8265279Smseidel const CLSID CLSID_FILTER_HANDLER = 85cdf0e10cSrcweir {0x7bc0e710, 0x5703, 0x45be, {0xa2, 0x9d, 0x5d, 0x46, 0xd8, 0xb3, 0x92, 0x62}}; 86cdf0e10cSrcweir 87cdf0e10cSrcweir enum FilterState 88cdf0e10cSrcweir { 89*c8265279Smseidel FilteringContent, // Filtering the content property 90*c8265279Smseidel FilteringProperty // Filtering the pseudo property 91cdf0e10cSrcweir }; 92cdf0e10cSrcweir class COooFilter : public IFilter, public IPersistFile, public IPersistStream 93cdf0e10cSrcweir { 94cdf0e10cSrcweir public: 95*c8265279Smseidel // From IUnknown 96*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE QueryInterface( 97*c8265279Smseidel REFIID riid, 98*c8265279Smseidel void ** ppvObject); 99*c8265279Smseidel virtual ULONG STDMETHODCALLTYPE AddRef(); 100*c8265279Smseidel virtual ULONG STDMETHODCALLTYPE Release(); 101*c8265279Smseidel 102*c8265279Smseidel // From IFilter 103*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE Init( 104*c8265279Smseidel ULONG grfFlags, 105*c8265279Smseidel ULONG cAttributes, 106*c8265279Smseidel FULLPROPSPEC const * aAttributes, 107*c8265279Smseidel ULONG * pFlags); 108*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE GetChunk( 109*c8265279Smseidel STAT_CHUNK * pStat); 110*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE GetText( 111*c8265279Smseidel ULONG * pcwcBuffer, 112*c8265279Smseidel WCHAR * awcBuffer); 113*c8265279Smseidel 114*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE GetValue( 115*c8265279Smseidel PROPVARIANT ** ppPropValue); 116*c8265279Smseidel 117*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE BindRegion( 118*c8265279Smseidel FILTERREGION origPos, 119*c8265279Smseidel REFIID riid, 120*c8265279Smseidel void ** ppunk); 121*c8265279Smseidel 122*c8265279Smseidel // From IPersistFile 123*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE GetClassID( 124*c8265279Smseidel CLSID * pClassID); 125*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE IsDirty(); 126*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE Load( 127*c8265279Smseidel LPCWSTR pszFileName, 128*c8265279Smseidel DWORD dwMode); 129*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE Save( 130*c8265279Smseidel LPCWSTR pszFileName, 131*c8265279Smseidel BOOL fRemember); 132*c8265279Smseidel 133*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE SaveCompleted( 134*c8265279Smseidel LPCWSTR pszFileName); 135*c8265279Smseidel 136*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE GetCurFile( 137*c8265279Smseidel 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*c8265279Smseidel friend class COooFilterCF; 153cdf0e10cSrcweir 154*c8265279Smseidel COooFilter(); 155*c8265279Smseidel virtual ~COooFilter(); 156*c8265279Smseidel 157*c8265279Smseidel long m_lRefs; // Reference count 158657ff7dbSmseidel CContentReader * m_pContentReader; // A content reader that retrieves document content. 159657ff7dbSmseidel CMetaInfoReader * m_pMetaInfoReader; // A metainfo reader that retrieves document metainfo. 160*c8265279Smseidel FilterState m_eState; // State of filtering 161cdf0e10cSrcweir ::std::wstring m_pwszFileName; // Name of input file to filter 162*c8265279Smseidel ULONG m_ulUnicodeBufferLen; // UNICODE Characters read from file to chunk buffer 163*c8265279Smseidel 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*c8265279Smseidel ULONG m_ulChunkID; // Current chunk id 167*c8265279Smseidel BOOL m_fContents; // TRUE if contents requested 168*c8265279Smseidel BOOL m_fEof; // TRUE if end of file reached 169cdf0e10cSrcweir ::std::wstring m_pwsBuffer; // Buffer to save UNICODE content from ChunkBuffer. 170*c8265279Smseidel ULONG m_ChunkPosition; // Chunk pointer to specify the current Chunk; 171*c8265279Smseidel ULONG m_cAttributes; // Count of attributes 172*c8265279Smseidel CFullPropSpec * m_pAttributes; // Attributes to filter 173cdf0e10cSrcweir IStream * m_pStream; 174cdf0e10cSrcweir 175cdf0e10cSrcweir }; 176cdf0e10cSrcweir 177cdf0e10cSrcweir //C------------------------------------------------------------------------- 178cdf0e10cSrcweir // 179cdf0e10cSrcweir // Class: COooFilterCF 180cdf0e10cSrcweir // 181*c8265279Smseidel // Purpose: Implements class factory for OpenOffice filter 182cdf0e10cSrcweir // 183cdf0e10cSrcweir //-------------------------------------------------------------------------- 184cdf0e10cSrcweir 185cdf0e10cSrcweir class COooFilterCF : public IClassFactory 186cdf0e10cSrcweir { 187cdf0e10cSrcweir public: 188*c8265279Smseidel // From IUnknown 189*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE QueryInterface( 190*c8265279Smseidel REFIID riid, 191*c8265279Smseidel void ** ppvObject); 192cdf0e10cSrcweir 193*c8265279Smseidel virtual ULONG STDMETHODCALLTYPE AddRef(); 194*c8265279Smseidel virtual ULONG STDMETHODCALLTYPE Release(); 195cdf0e10cSrcweir 196*c8265279Smseidel // From IClassFactory 197*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE CreateInstance( 198*c8265279Smseidel IUnknown * pUnkOuter, 199*c8265279Smseidel REFIID riid, void ** ppvObject); 200cdf0e10cSrcweir 201*c8265279Smseidel virtual SCODE STDMETHODCALLTYPE LockServer( 202*c8265279Smseidel BOOL fLock); 203cdf0e10cSrcweir 204cdf0e10cSrcweir private: 205*c8265279Smseidel friend SCODE STDMETHODCALLTYPE DllGetClassObject( 206*c8265279Smseidel REFCLSID cid, 207*c8265279Smseidel REFIID iid, 208*c8265279Smseidel void ** ppvObj); 209*c8265279Smseidel 210*c8265279Smseidel COooFilterCF(); 211*c8265279Smseidel virtual ~COooFilterCF(); 212*c8265279Smseidel 213*c8265279Smseidel long m_lRefs; // Reference count 214cdf0e10cSrcweir }; 215*c8265279Smseidel 216*c8265279Smseidel /* vim: set noet sw=4 ts=4: */ 217