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