diff options
author | Dirk Voelzke <dv@openoffice.org> | 2010-01-20 11:33:12 +0100 |
---|---|---|
committer | Dirk Voelzke <dv@openoffice.org> | 2010-01-20 11:33:12 +0100 |
commit | 2eae126053ac8607d90263dc9c1bd48a0c411904 (patch) | |
tree | e2e52723a50b4f47f24fe83fb312b3a6c60e896c /shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx | |
parent | bd579facad76db083ceab57bc8848f31c4a6d5e5 (diff) |
dv17: #i70994#: Use property handler instead of column info for Windows Vista
Diffstat (limited to 'shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx')
-rwxr-xr-x[-rw-r--r--] | shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx | 294 |
1 files changed, 92 insertions, 202 deletions
diff --git a/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx index f907306e99..7a738ba20b 100644..100755 --- a/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx +++ b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx @@ -78,14 +78,15 @@ #include <ntquery.h> #include "assert.h" #include "ooofilt.hxx" -#include <objidl.h>
-#include <stdio.h>
+#include <objidl.h> +#include <stdio.h> #include "propspec.hxx" #ifdef __MINGW32__ #include <algorithm> using ::std::min; #endif +#include "internal/stream_helper.hxx" //C------------------------------------------------------------------------- // @@ -120,7 +121,7 @@ COooFilter::COooFilter() : m_ChunkPosition(0), m_cAttributes(0), m_pAttributes(0), - m_pStream(NULL)
+ m_pStream(NULL) { InterlockedIncrement( &g_lInstances ); @@ -176,8 +177,8 @@ SCODE STDMETHODCALLTYPE COooFilter::QueryInterface( pUnkTemp = (IUnknown *)(IPersistFile *)this; else if ( IID_IPersist == riid ) pUnkTemp = (IUnknown *)(IPersist *)(IPersistFile *)this; - else if (IID_IPersistStream == riid)
- pUnkTemp = (IUnknown *)(IPersistStream *)this;
+ else if (IID_IPersistStream == riid) + pUnkTemp = (IUnknown *)(IPersistStream *)this; else if ( IID_IUnknown == riid ) pUnkTemp = (IUnknown *)(IPersist *)(IPersistFile *)this; else @@ -720,99 +721,85 @@ SCODE STDMETHODCALLTYPE COooFilter::SaveCompleted(LPCWSTR /*pszFileName*/) return S_OK; } -//M-------------------------------------------------------------------------
-//
-// Method: COooFilter::Load (IPersistStream::Load)
-//
-// Summary: Initializes an object from the stream where it was previously saved
-//
-// Arguments: pStm
-// [in] Pointer to stream from which object should be loaded
-//
-//
-// Returns: S_OK
-// E_OUTOFMEMORY
-// E_FAIL
-//
-//
-//--------------------------------------------------------------------------
-SCODE STDMETHODCALLTYPE COooFilter::Load(IStream *pStm)
-{
-
- // These next few lines work around the "Seek pointer" bug found on Vista.
-
- char buf[20];
- unsigned long count;
- HRESULT hr;
- ULARGE_INTEGER NewPosition;
- LARGE_INTEGER Move;
- Move.QuadPart = 0;
- hr = pStm->Seek (Move, STREAM_SEEK_SET, &NewPosition);
- hr = pStm->Read (buf, 20, &count);
-
- zlib_filefunc_def z_filefunc;
- fill_stream_filefunc (&z_filefunc);
- z_filefunc.opaque = (void*)pStm;
-
- m_pStream = pStm;
-
- try
- {
- if (m_pMetaInfoReader)
- delete m_pMetaInfoReader;
- m_pMetaInfoReader = new CMetaInfoReader((void*)m_pStream, &z_filefunc);
-
- if (m_pContentReader)
- delete m_pContentReader;
- m_pContentReader = new CContentReader((void*)m_pStream, m_pMetaInfoReader->getDefaultLocale(), &z_filefunc);
- }
- catch (const std::exception&)
- {
- return E_FAIL;
- }
- return S_OK;
-}
-
-//M-------------------------------------------------------------------------
-//
-// Method: COooFilter::GetSizeMax (IPersistStream::GetSizeMax)
-//
-// Summary: Returns the size in bytes of the stream neede to save the object.
-//
-// Arguments: pcbSize
-// [out] Pointer to a 64 bit unsigned int indicating the size needed
-//
-// Returns: E_NOTIMPL
-//
-//
-//--------------------------------------------------------------------------
-SCODE STDMETHODCALLTYPE COooFilter::GetSizeMax(ULARGE_INTEGER * /*pcbSize*/)
-{
- //
- return E_NOTIMPL;
-}
-
-//M-------------------------------------------------------------------------
-//
-// Method: COooFilter::Save (IPersistStream::Save)
-//
-// Summary: Save object to specified stream
-//
-// Arguments: pStm
-// [in] Pointer to stream
-//
-// fClearDirty
-// [in] Indicates whether to clear dirty flag
-//
-// Returns: E_NOTIMPL
-//
-//
-//--------------------------------------------------------------------------
-SCODE STDMETHODCALLTYPE COooFilter::Save(IStream * /*pStm*/, BOOL )
-{
- //
- return E_NOTIMPL;
-}
+//M------------------------------------------------------------------------- +// +// Method: COooFilter::Load (IPersistStream::Load) +// +// Summary: Initializes an object from the stream where it was previously saved +// +// Arguments: pStm +// [in] Pointer to stream from which object should be loaded +// +// +// Returns: S_OK +// E_OUTOFMEMORY +// E_FAIL +// +// +//-------------------------------------------------------------------------- +SCODE STDMETHODCALLTYPE COooFilter::Load(IStream *pStm) +{ + zlib_filefunc_def z_filefunc; + + m_pStream = PrepareIStream( pStm, z_filefunc ); + + try + { + if (m_pMetaInfoReader) + delete m_pMetaInfoReader; + m_pMetaInfoReader = new CMetaInfoReader((void*)m_pStream, &z_filefunc); + + if (m_pContentReader) + delete m_pContentReader; + m_pContentReader = new CContentReader((void*)m_pStream, m_pMetaInfoReader->getDefaultLocale(), &z_filefunc); + } + catch (const std::exception&) + { + return E_FAIL; + } + return S_OK; +} + +//M------------------------------------------------------------------------- +// +// Method: COooFilter::GetSizeMax (IPersistStream::GetSizeMax) +// +// Summary: Returns the size in bytes of the stream neede to save the object. +// +// Arguments: pcbSize +// [out] Pointer to a 64 bit unsigned int indicating the size needed +// +// Returns: E_NOTIMPL +// +// +//-------------------------------------------------------------------------- +SCODE STDMETHODCALLTYPE COooFilter::GetSizeMax(ULARGE_INTEGER * /*pcbSize*/) +{ + // + return E_NOTIMPL; +} + +//M------------------------------------------------------------------------- +// +// Method: COooFilter::Save (IPersistStream::Save) +// +// Summary: Save object to specified stream +// +// Arguments: pStm +// [in] Pointer to stream +// +// fClearDirty +// [in] Indicates whether to clear dirty flag +// +// Returns: E_NOTIMPL +// +// +//-------------------------------------------------------------------------- +SCODE STDMETHODCALLTYPE COooFilter::Save(IStream * /*pStm*/, BOOL ) +{ + // + return E_NOTIMPL; +} //M------------------------------------------------------------------------- // @@ -1247,13 +1234,13 @@ namespace /* private */ if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist.c_str(), "", "OpenOffice.org Persistent Handler")) return E_FAIL; - // Add missing entry
- std::string ClsidEntry_Persist_Entry = CLSID_PERSIST_ENTRY;
- SubstitutePlaceholder(ClsidEntry_Persist_Entry,
- GUID_PLACEHOLDER,
- ClsidToString(PersistentGuid));
-
- if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist_Entry.c_str(), "", ClsidToString(PersistentGuid).c_str()));
+ // Add missing entry + std::string ClsidEntry_Persist_Entry = CLSID_PERSIST_ENTRY; + SubstitutePlaceholder(ClsidEntry_Persist_Entry, + GUID_PLACEHOLDER, + ClsidToString(PersistentGuid)); + + if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist_Entry.c_str(), "", ClsidToString(PersistentGuid).c_str())); std::string ClsidEntry_Persist_Addin = CLSID_GUID_PERSIST_ADDIN_ENTRY; @@ -1504,100 +1491,3 @@ STDAPI DllUnregisterServer() */ return S_OK; } - -extern "C" {
-
- // IStream callback
- voidpf ZCALLBACK cb_sopen (voidpf opaque, const char* filename, int mode) {
- return opaque;
- }
-
- uLong ZCALLBACK cb_sread (voidpf opaque, voidpf stream, void* buf, uLong size) {
- unsigned long newsize;
- HRESULT hr;
-
- hr = ((IStream *)stream)->Read (buf, size, &newsize);
- if (hr == S_OK){
- return (unsigned long)newsize;
- }
- else {
- return (uLong)0;
- }
- }
-
- long ZCALLBACK cb_sseek (voidpf opaque, voidpf stream, uLong offset, int origin) {
- // IStream::Seek parameters
- HRESULT hr;
- LARGE_INTEGER Move;
- DWORD dwOrigin;
- Move.QuadPart = (__int64)offset;
-
- switch (origin) {
- case SEEK_CUR:
- dwOrigin = STREAM_SEEK_CUR;
- break;
- case SEEK_END:
- dwOrigin = STREAM_SEEK_END;
- break;
- case SEEK_SET:
- dwOrigin = STREAM_SEEK_SET;
- break;
- default:
- return -1;
- }
-
- hr = ((IStream*)stream)->Seek (Move, dwOrigin, NULL);
- if (hr == S_OK){
- return 0;
- }
- else {
- return -1;
- }
- }
-
- long ZCALLBACK cb_stell (voidpf opaque, voidpf stream) {
- // IStream::Seek parameters
- HRESULT hr;
- LARGE_INTEGER Move;
- ULARGE_INTEGER NewPosition;
- Move.QuadPart = 0;
- NewPosition.QuadPart = 0;
-
- hr = ((IStream*)stream)->Seek (Move, STREAM_SEEK_CUR, &NewPosition);
- if (hr == S_OK){
- return (long) NewPosition.QuadPart;
- }
- else {
- return -1;
- }
- }
-
- int ZCALLBACK cb_sclose (voidpf opaque, voidpf stream) {
- return 0;
- }
-
- int ZCALLBACK cb_serror (voidpf opaque, voidpf stream) {
- return 0; //RJK - for now
- }
-
- uLong ZCALLBACK cb_swrite (voidpf opaque, voidpf stream, const void* buf, uLong size) {
- HRESULT hr;
- unsigned long writecount;
- hr = ((IStream*)stream)->Write (buf, size, &writecount);
- if (hr == S_OK)
- return (unsigned int)writecount;
- else
- return (uLong)0;
- }
-
- void fill_stream_filefunc (zlib_filefunc_def* pzlib_filefunc_def) {
- pzlib_filefunc_def->zopen_file = cb_sopen;
- pzlib_filefunc_def->zread_file = cb_sread;
- pzlib_filefunc_def->zwrite_file = cb_swrite;
- pzlib_filefunc_def->ztell_file = cb_stell;
- pzlib_filefunc_def->zseek_file = cb_sseek;
- pzlib_filefunc_def->zclose_file = cb_sclose;
- pzlib_filefunc_def->zerror_file = cb_serror;
- }
-}
- |