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