From 85e0cc246d4350122b17fbe2bfd15635a190ad77 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 20 Jan 2010 11:33:12 +0100 Subject: dv17: #i70994#: Use property handler instead of column info for Windows Vista --- shell/inc/internal/metainforeader.hxx | 2 +- shell/inc/internal/propertyhdl.hxx | 90 ++++++ shell/inc/internal/shlxthdl.hxx | 4 + shell/inc/internal/stream_helper.hxx | 35 +++ shell/inc/internal/utilities.hxx | 0 shell/prj/build.lst | 7 +- shell/source/win32/shlxthandler/classfactory.cxx | 4 + shell/source/win32/shlxthandler/makefile.mk | 8 +- .../source/win32/shlxthandler/ooofilt/makefile.mk | 3 +- .../source/win32/shlxthandler/ooofilt/ooofilt.cxx | 294 ++++++----------- .../source/win32/shlxthandler/ooofilt/ooofilt.hxx | 47 +-- .../win32/shlxthandler/ooofilt/stream_helper.cxx | 181 +++++++++++ .../source/win32/shlxthandler/prophdl/makefile.mk | 61 ++++ .../win32/shlxthandler/prophdl/propertyhdl.cxx | 350 +++++++++++++++++++++ .../win32/shlxthandler/propsheets/propsheets.cxx | 71 +++-- shell/source/win32/shlxthandler/shlxthdl.cxx | 3 +- 16 files changed, 895 insertions(+), 265 deletions(-) mode change 100644 => 100755 shell/inc/internal/metainforeader.hxx create mode 100755 shell/inc/internal/propertyhdl.hxx mode change 100644 => 100755 shell/inc/internal/shlxthdl.hxx create mode 100755 shell/inc/internal/stream_helper.hxx mode change 100644 => 100755 shell/inc/internal/utilities.hxx mode change 100644 => 100755 shell/prj/build.lst mode change 100644 => 100755 shell/source/win32/shlxthandler/classfactory.cxx mode change 100644 => 100755 shell/source/win32/shlxthandler/makefile.mk mode change 100644 => 100755 shell/source/win32/shlxthandler/ooofilt/makefile.mk mode change 100644 => 100755 shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx mode change 100644 => 100755 shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx create mode 100755 shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx create mode 100755 shell/source/win32/shlxthandler/prophdl/makefile.mk create mode 100755 shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx mode change 100644 => 100755 shell/source/win32/shlxthandler/propsheets/propsheets.cxx mode change 100644 => 100755 shell/source/win32/shlxthandler/shlxthdl.cxx diff --git a/shell/inc/internal/metainforeader.hxx b/shell/inc/internal/metainforeader.hxx old mode 100644 new mode 100755 index 1e004b5a3727..478365811da3 --- a/shell/inc/internal/metainforeader.hxx +++ b/shell/inc/internal/metainforeader.hxx @@ -46,7 +46,7 @@ public: CMetaInfoReader( const std::string& DocumentName ); - CMetaInfoReader( void* stream, zlib_filefunc_def* fa); + CMetaInfoReader( void* stream, zlib_filefunc_def* fa); /** check if the Tag is in the target meta.xml file. diff --git a/shell/inc/internal/propertyhdl.hxx b/shell/inc/internal/propertyhdl.hxx new file mode 100755 index 000000000000..60ff10bc6958 --- /dev/null +++ b/shell/inc/internal/propertyhdl.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PropertyHdl.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef PROPERTYHDL_HXX_INCLUDED +#define PROPERTYHDL_HXX_INCLUDED + +#if defined _MSC_VER +#pragma warning(push, 1) +#pragma warning(disable:4917) +#endif +#include +#if defined _MSC_VER +#pragma warning(pop) +#endif + +class CMetaInfoReader; + +class CPropertyHdl : public IPropertyStore, + public IPropertyStoreCapabilities, + public IInitializeWithStream +{ +public: + CPropertyHdl(long RefCnt = 1); + virtual ~CPropertyHdl(); + + //----------------------------- + // IUnknown methods + //----------------------------- + virtual HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void __RPC_FAR *__RPC_FAR *ppvObject ); + virtual ULONG STDMETHODCALLTYPE AddRef( void ); + virtual ULONG STDMETHODCALLTYPE Release( void ); + + //----------------------------- + // IPropertyStore + //----------------------------- + virtual HRESULT STDMETHODCALLTYPE GetCount( DWORD *pcProps ); + virtual HRESULT STDMETHODCALLTYPE GetAt( DWORD iProp, PROPERTYKEY *pkey ); + virtual HRESULT STDMETHODCALLTYPE GetValue( REFPROPERTYKEY key, PROPVARIANT *pPropVar ); + virtual HRESULT STDMETHODCALLTYPE SetValue( REFPROPERTYKEY key, REFPROPVARIANT propVar ); + virtual HRESULT STDMETHODCALLTYPE Commit(); + + //----------------------------- + // IPropertyStoreCapabilities + //----------------------------- + virtual HRESULT STDMETHODCALLTYPE IsPropertyWritable( REFPROPERTYKEY key ); + + //----------------------------- + // IInitializeWithStream + //----------------------------- + virtual HRESULT STDMETHODCALLTYPE Initialize(IStream *pStream, DWORD grfMode); + +private: + void LoadProperties( CMetaInfoReader *pMetaInfoReader ); + HRESULT GetItemData( CMetaInfoReader *pMetaInfoReader, UINT nIndex, PROPVARIANT *pVarData ); + +private: + long m_RefCnt; + IPropertyStoreCache* m_pCache; +}; + +#endif diff --git a/shell/inc/internal/shlxthdl.hxx b/shell/inc/internal/shlxthdl.hxx old mode 100644 new mode 100755 index 782212f6dc5b..70830c9775ec --- a/shell/inc/internal/shlxthdl.hxx +++ b/shell/inc/internal/shlxthdl.hxx @@ -55,4 +55,8 @@ const CLSID CLSID_PROPERTYSHEET_HANDLER = const CLSID CLSID_THUMBVIEWER_HANDLER = { 0x3b092f0c, 0x7696, 0x40e3, { 0xa8, 0xf, 0x68, 0xd7, 0x4d, 0xa8, 0x42, 0x10 } }; +// {AE424E85-F6DF-4910-A6A9-438797986431} +const CLSID CLSID_PROPERTY_HANDLER = +{ 0xae424e85, 0xf6df, 0x4910, { 0xa6, 0xa9, 0x43, 0x87, 0x97, 0x98, 0x64, 0x31 } }; + #endif diff --git a/shell/inc/internal/stream_helper.hxx b/shell/inc/internal/stream_helper.hxx new file mode 100755 index 000000000000..2ef4529b54ce --- /dev/null +++ b/shell/inc/internal/stream_helper.hxx @@ -0,0 +1,35 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2010 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef STREAM_HELPER_HXX_INCLUDED +#define STREAM_HELPER_HXX_INCLUDED + +#include "internal/types.hxx" + +IStream* PrepareIStream( IStream* pStream, zlib_filefunc_def &zFileFunc ); + +#endif diff --git a/shell/inc/internal/utilities.hxx b/shell/inc/internal/utilities.hxx old mode 100644 new mode 100755 diff --git a/shell/prj/build.lst b/shell/prj/build.lst old mode 100644 new mode 100755 index ed4fbca7e3f5..5499014e2a41 --- a/shell/prj/build.lst +++ b/shell/prj/build.lst @@ -16,13 +16,16 @@ sl shell\source\all\zipfile nmake - w sl_all_zipfil sl shell\source\all\zipfile nmake - p sl_all_zipfile sl_inc NULL sl shell\source\all\ooofilereader nmake - w sl_all_ooofilereader sl_all_zipfile.w sl_all sl_inc NULL sl shell\source\all\ooofilereader nmake - p sl_all_ooofilereader sl_all_zipfile.w sl_all sl_inc NULL +sl shell\source\win32\shlxthandler\ooofilt\proxy nmake - w sl_win32_ooofiltproxy sl_inc NULL sl shell\source\win32\shlxthandler\res nmake - w sl_win32_shlxthandler_res sl_win32_lngconv.w sl_inc NULL sl shell\source\win32\shlxthandler\util nmake - w sl_win32_shlxthandler_util sl_inc NULL sl shell\source\win32\shlxthandler\propsheets nmake - w sl_win32_shlxthandler_propsheets sl_inc NULL sl shell\source\win32\shlxthandler\infotips nmake - w sl_win32_shlxthandler_infotips sl_inc NULL sl shell\source\win32\shlxthandler\columninfo nmake - w sl_win32_shlxthandler_columninfo sl_inc NULL sl shell\source\win32\shlxthandler\thumbviewer nmake - w sl_win32_shlxthandler_thumbviewer sl_inc NULL -sl shell\source\win32\shlxthandler nmake - w sl_win32_shlxthandler sl_win32_lngconv.w sl_win32_shlxthandler_res.w sl_win32_shlxthandler_util.w sl_all_zipfile.w sl_all_ooofilereader.w sl_win32_shlxthandler_propsheets.w sl_win32_shlxthandler_infotips.w sl_win32_shlxthandler_columninfo.w sl_win32_shlxthandler_thumbviewer.w sl_inc NULL +sl shell\source\win32\shlxthandler\prophdl nmake - w sl_win32_shlxthandler_prophdl sl_inc NULL +sl shell\source\win32\shlxthandler\ooofilt nmake - w sl_win32_shlxthandler_ooofilt sl_all_zipfile.w sl_all_ooofilereader.w sl_win32_shlxthandler_util.w sl_all sl_inc NULL +sl shell\source\win32\shlxthandler nmake - w sl_win32_shlxthandler sl_win32_lngconv.w sl_win32_shlxthandler_res.w sl_win32_shlxthandler_util.w sl_all_zipfile.w sl_all_ooofilereader.w sl_win32_shlxthandler_propsheets.w sl_win32_shlxthandler_infotips.w sl_win32_shlxthandler_columninfo.w sl_win32_shlxthandler_thumbviewer.w sl_win32_shlxthandler_prophdl.w sl_inc sl_win32_shlxthandler_ooofilt.w NULL sl shell\source\backends\localebe nmake - all sl_backends_localebe sl_inc NULL sl shell\source\backends\wininetbe nmake - w sl_backends_wininetbe sl_inc NULL sl shell\source\backends\macbe nmake - u sl_backends_macbe sl_inc NULL @@ -30,5 +33,3 @@ sl shell\source\backends\gconfbe nmake - u sl_backends_g sl shell\source\backends\kdebe nmake - u sl_backends_kdebe sl_inc NULL sl shell\source\backends\kde4be nmake - u sl_backends_kde4be sl_inc NULL sl shell\source\backends\desktopbe nmake - u sl_backends_desktopbe sl_inc NULL -sl shell\source\win32\shlxthandler\ooofilt nmake - w sl_win32_shlxthandler_ooofilt sl_all_zipfile.w sl_all_ooofilereader.w sl_win32_shlxthandler_util.w sl_all sl_inc NULL -sl shell\source\win32\shlxthandler\ooofilt\proxy nmake - w sl_win32_ooofiltproxy sl_inc NULL diff --git a/shell/source/win32/shlxthandler/classfactory.cxx b/shell/source/win32/shlxthandler/classfactory.cxx old mode 100644 new mode 100755 index ee60cb4f62b7..10dd3e82934d --- a/shell/source/win32/shlxthandler/classfactory.cxx +++ b/shell/source/win32/shlxthandler/classfactory.cxx @@ -35,6 +35,7 @@ #include "internal/infotips.hxx" #include "internal/propsheets.hxx" #include "internal/columninfo.hxx" +#include "internal/propertyhdl.hxx" #ifdef __MINGW32__ #include using ::std::max; @@ -137,6 +138,9 @@ HRESULT STDMETHODCALLTYPE CClassFactory::CreateInstance( else if (CLSID_THUMBVIEWER_HANDLER == m_Clsid) pUnk = static_cast(new CThumbviewer()); + else if (CLSID_PROPERTY_HANDLER == m_Clsid) + pUnk = static_cast(new CPropertyHdl()); + POST_CONDITION(pUnk != 0, "Could not create COM object"); if (0 == pUnk) diff --git a/shell/source/win32/shlxthandler/makefile.mk b/shell/source/win32/shlxthandler/makefile.mk old mode 100644 new mode 100755 index 07eea87f0263..07a7539e9e11 --- a/shell/source/win32/shlxthandler/makefile.mk +++ b/shell/source/win32/shlxthandler/makefile.mk @@ -58,7 +58,9 @@ SLOFILES=$(SLO)$/classfactory.obj\ $(SLO)$/shlxthdl.obj\ $(SLO)$/listviewbuilder.obj\ $(SLO)$/document_statistic.obj\ - $(SLO)$/thumbviewer.obj + $(SLO)$/thumbviewer.obj\ + $(SLO)$/propertyhdl.obj\ + $(SLO)$/stream_helper.obj\ SHL1TARGET=$(TARGET) @@ -79,7 +81,9 @@ SHL1STDLIBS+=\ $(SHELL32LIB)\ $(KERNEL32LIB)\ $(GDI32LIB)\ - $(GDIPLUSLIB) + $(GDIPLUSLIB)\ + $(SHLWAPILIB)\ + propsys.lib SHL1LIBS+=$(SLB)$/util.lib\ $(SLB)$/ooofilereader.lib diff --git a/shell/source/win32/shlxthandler/ooofilt/makefile.mk b/shell/source/win32/shlxthandler/ooofilt/makefile.mk old mode 100644 new mode 100755 index 22127bc8ddac..221ec6ee99c5 --- a/shell/source/win32/shlxthandler/ooofilt/makefile.mk +++ b/shell/source/win32/shlxthandler/ooofilt/makefile.mk @@ -55,7 +55,8 @@ CDEFS+=-D_WIN32_IE=0x501 # --- Files -------------------------------------------------------- SLOFILES=$(SLO)$/ooofilt.obj\ - $(SLO)$/propspec.obj + $(SLO)$/propspec.obj\ + $(SLO)$/stream_helper.obj # $(SLO)$/utilities.obj # $(SLO)$/dbgmacros.obj diff --git a/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx old mode 100644 new mode 100755 index ac8dd676c3b1..e7460e899e82 --- a/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx +++ b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx @@ -78,14 +78,15 @@ #include #include "assert.h" #include "ooofilt.hxx" -#include -#include +#include +#include #include "propspec.hxx" #ifdef __MINGW32__ #include 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; - } -} - diff --git a/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx b/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx old mode 100644 new mode 100755 index 9f1566b406bd..a3bf364ccaf1 --- a/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx +++ b/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx @@ -96,7 +96,7 @@ enum FilterState FilteringContent, // Filtering the content property FilteringProperty // Filtering the pseudo property }; -class COooFilter : public IFilter, public IPersistFile, public IPersistStream +class COooFilter : public IFilter, public IPersistFile, public IPersistStream { public: // From IUnknown @@ -143,16 +143,16 @@ public: virtual SCODE STDMETHODCALLTYPE GetCurFile( LPWSTR * ppszFileName); - // From IPersistStream - virtual SCODE STDMETHODCALLTYPE Load( - IStream *pStm); - - virtual SCODE STDMETHODCALLTYPE Save( - IStream *pStm, - BOOL fClearDirty); - - virtual SCODE STDMETHODCALLTYPE GetSizeMax( - ULARGE_INTEGER *pcbSize); + // From IPersistStream + virtual SCODE STDMETHODCALLTYPE Load( + IStream *pStm); + + virtual SCODE STDMETHODCALLTYPE Save( + IStream *pStm, + BOOL fClearDirty); + + virtual SCODE STDMETHODCALLTYPE GetSizeMax( + ULARGE_INTEGER *pcbSize); private: @@ -177,7 +177,7 @@ private: ULONG m_ChunkPosition; // Chunk pointer to specify the current Chunk; ULONG m_cAttributes; // Count of attributes CFullPropSpec * m_pAttributes; // Attributes to filter - IStream * m_pStream; + IStream * m_pStream; }; @@ -219,26 +219,3 @@ private: long m_lRefs; // Reference count }; - -extern "C" { - - voidpf ZCALLBACK cb_sopen OF((voidpf opaque, const char * filename, int mode)); - uLong ZCALLBACK cb_sread OF((voidpf opaque, voidpf stream, void* vuf, uLong size)); - uLong ZCALLBACK cb_swrite OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); - long ZCALLBACK cb_stell OF((voidpf opaque, voidpf stream)); - long ZCALLBACK cb_sseek OF((voidpf opaque, voidpf stream, uLong offset, int origin)); - int ZCALLBACK cb_sclose OF((voidpf opaque, voidpf stream)); - int ZCALLBACK cb_serror OF((voidpf opaque, voidpf stream)); - - void fill_stream_filefunc (zlib_filefunc_def* pzlib_filefunc_def); - -} - - - - - - - - - diff --git a/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx new file mode 100755 index 000000000000..e12f95a88e50 --- /dev/null +++ b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx @@ -0,0 +1,181 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2010 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_shell.hxx" + +#if defined _MSC_VER +#pragma warning(push, 1) +#endif +#include +#if defined _MSC_VER +#pragma warning(pop) +#endif + +#include +#include + +/*#include +#include +#include +#include +#include "assert.h" +#include "propspec.hxx" +#ifdef __MINGW32__ +#include +using ::std::min; +#endif +*/ + +#include "internal/stream_helper.hxx" + +extern "C" { + voidpf ZCALLBACK cb_sopen OF((voidpf opaque, const char * filename, int mode)); + uLong ZCALLBACK cb_sread OF((voidpf opaque, voidpf stream, void* vuf, uLong size)); + uLong ZCALLBACK cb_swrite OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); + long ZCALLBACK cb_stell OF((voidpf opaque, voidpf stream)); + long ZCALLBACK cb_sseek OF((voidpf opaque, voidpf stream, uLong offset, int origin)); + int ZCALLBACK cb_sclose OF((voidpf opaque, voidpf stream)); + int ZCALLBACK cb_serror OF((voidpf opaque, voidpf stream)); + + void fill_stream_filefunc (zlib_filefunc_def* pzlib_filefunc_def); +} + +//----------------------------- +IStream* PrepareIStream( IStream* pStream, zlib_filefunc_def &zFileFunc ) +{ + // These next few lines work around the "Seek pointer" bug found on Vista. + char cBuf[20]; + unsigned long nCount; + HRESULT hr; + ULARGE_INTEGER nNewPosition; + LARGE_INTEGER nMove; + nMove.QuadPart = 0; + hr = pStream->Seek( nMove, STREAM_SEEK_SET, &nNewPosition ); + hr = pStream->Read( cBuf, 20, &nCount ); + + fill_stream_filefunc( &zFileFunc ); + zFileFunc.opaque = (void*)pStream; + + return pStream; +} + +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; + } +} diff --git a/shell/source/win32/shlxthandler/prophdl/makefile.mk b/shell/source/win32/shlxthandler/prophdl/makefile.mk new file mode 100755 index 000000000000..30efd7cedaa8 --- /dev/null +++ b/shell/source/win32/shlxthandler/prophdl/makefile.mk @@ -0,0 +1,61 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.6 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/..$/.. +PRJNAME=shell +TARGET=propertyhdl +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE + + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501 +CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820 +CDEFS+=-D_WIN32_IE=0x501 + +# --- Files -------------------------------------------------------- + +SLOFILES=$(SLO)$/propertyhdl.obj + +.IF "$(BUILD_X64)"!="" +CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501 +CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820 +CDEFS_X64+=-D_WIN32_IE=0x501 +SLOFILES_X64=$(SLO_X64)$/$(TARGET).obj +.ENDIF # "$(BUILD_X64)"!="" + +# --- Targets ------------------------------------------------------ +.INCLUDE : set_wntx64.mk +.INCLUDE : target.mk +.INCLUDE : tg_wntx64.mk \ No newline at end of file diff --git a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx new file mode 100755 index 000000000000..06d619de6f8d --- /dev/null +++ b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx @@ -0,0 +1,350 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2010 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_shell.hxx" +#include "internal/global.hxx" +#include "internal/PropertyHdl.hxx" +#include "internal/fileextensions.hxx" +#include "internal/metainforeader.hxx" +#include "internal/utilities.hxx" +#include "internal/config.hxx" + +#include +#include + +#include +#include + +#include "internal/stream_helper.hxx" + +//---------------------------------------------------------- +#ifdef DEBUG +inline void OutputDebugStringFormat( LPCSTR pFormat, ... ) +{ + CHAR buffer[1024]; + va_list args; + + va_start( args, pFormat ); + StringCchVPrintfA( buffer, sizeof(buffer), pFormat, args ); + OutputDebugStringA( buffer ); +} +#else +static inline void OutputDebugStringFormat( LPCSTR, ... ) +{ +} +#endif + +//---------------------------- +// +//---------------------------- + +//namespace /* private */ +/*{ + SHPropertyHdl PropertyHdlTable[] = + { + {{PSGUID_SUMMARYINFORMATION, PIDSI_TITLE}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Title", L"Title"}, + {{PSGUID_SUMMARYINFORMATION, PIDSI_AUTHOR}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Author", L"Author"}, + {{PSGUID_SUMMARYINFORMATION, PIDSI_SUBJECT}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Subject", L"Subject"}, + {{PSGUID_SUMMARYINFORMATION, PIDSI_KEYWORDS}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Keywords", L"Keywords"}, + {{PSGUID_SUMMARYINFORMATION, PIDSI_COMMENTS}, VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Comments", L"Comments"}, + {{PSGUID_SUMMARYINFORMATION, PIDSI_PAGECOUNT},VT_BSTR, LVCFMT_LEFT, 30, SHCOLSTATE_TYPE_STR, L"Pagecount", L"Pagecount"} + }; + + size_t PropertyHdlTableSize = sizeof(PropertyHdlTable)/sizeof(PropertyHdlTable[0]); +}*/ + +// +// Map of property keys to the locations of their value(s) in the .??? XML schema +// +struct PROPERTYMAP +{ + PROPERTYKEY key; + PCWSTR pszXPathParent; + PCWSTR pszValueNodeName; +}; + +PROPERTYMAP g_rgPROPERTYMAP[] = +{ + { PKEY_Title, L"OpenOffice.org", L"Title" }, + { PKEY_Author, L"OpenOffice.org", L"Author" }, + { PKEY_Subject, L"OpenOffice.org", L"Subject" }, + { PKEY_Keywords, L"OpenOffice.org", L"Keyword" }, + { PKEY_Comment, L"OpenOffice.org", L"Comments" }, +}; + +size_t gPropertyMapTableSize = sizeof(g_rgPROPERTYMAP)/sizeof(g_rgPROPERTYMAP[0]); + +//---------------------------- +// +//---------------------------- + +CPropertyHdl::CPropertyHdl( long nRefCnt ) : + m_RefCnt( nRefCnt ), + m_pCache( NULL ) +{ + OutputDebugStringFormat( "CPropertyHdl: CTOR\n" ); + InterlockedIncrement( &g_DllRefCnt ); +} + +//---------------------------- +// +//---------------------------- + +CPropertyHdl::~CPropertyHdl() +{ + if ( m_pCache ) + { + m_pCache->Release(); + m_pCache = NULL; + } + InterlockedDecrement( &g_DllRefCnt ); +} + +//----------------------------- +// IUnknown methods +//----------------------------- +HRESULT STDMETHODCALLTYPE CPropertyHdl::QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject) +{ + *ppvObject = 0; + + if (IID_IUnknown == riid || IID_IPropertyStore == riid) + { + OutputDebugStringFormat( "CPropertyHdl: QueryInterface (IID_IPropertyStore)\n" ); + IUnknown* pUnk = static_cast(this); + pUnk->AddRef(); + *ppvObject = pUnk; + return S_OK; + } + else if (IID_IPropertyStoreCapabilities == riid) + { + OutputDebugStringFormat( "CPropertyHdl: QueryInterface (IID_IPropertyStoreCapabilities)\n" ); + IUnknown* pUnk = static_cast(this); + pUnk->AddRef(); + *ppvObject = pUnk; + return S_OK; + } + else if (IID_IInitializeWithStream == riid) + { + OutputDebugStringFormat( "CPropertyHdl: QueryInterface (IID_IInitializeWithStream)\n" ); + IUnknown* pUnk = static_cast(this); + pUnk->AddRef(); + *ppvObject = pUnk; + return S_OK; + } + OutputDebugStringFormat( "CPropertyHdl: QueryInterface (something different)\n" ); + + return E_NOINTERFACE; +} + +//---------------------------- +ULONG STDMETHODCALLTYPE CPropertyHdl::AddRef(void) +{ + return InterlockedIncrement(&m_RefCnt); +} + +//---------------------------- +ULONG STDMETHODCALLTYPE CPropertyHdl::Release( void) +{ + long refcnt = InterlockedDecrement(&m_RefCnt); + + if (0 == m_RefCnt) + delete this; + + return refcnt; +} + +//----------------------------- +// IPropertyStore +//----------------------------- +HRESULT STDMETHODCALLTYPE CPropertyHdl::GetCount( DWORD *pcProps ) +{ + HRESULT hr = E_UNEXPECTED; + if ( m_pCache && pcProps ) + { + hr = m_pCache->GetCount( pcProps ); + } + + return hr; +} + +//----------------------------- +HRESULT STDMETHODCALLTYPE CPropertyHdl::GetAt( DWORD iProp, PROPERTYKEY *pKey ) +{ + HRESULT hr = E_UNEXPECTED; + if ( m_pCache ) + { + hr = m_pCache->GetAt( iProp, pKey ); + } + + return hr; +} + +//----------------------------- +HRESULT STDMETHODCALLTYPE CPropertyHdl::GetValue( REFPROPERTYKEY key, PROPVARIANT *pPropVar ) +{ + HRESULT hr = E_UNEXPECTED; + if ( m_pCache ) + { + hr = m_pCache->GetValue( key, pPropVar ); + } + + return hr; +} + +//----------------------------- +HRESULT STDMETHODCALLTYPE CPropertyHdl::SetValue( REFPROPERTYKEY key, REFPROPVARIANT propVar ) +{ + HRESULT hr = E_UNEXPECTED; + if ( m_pCache ) + { + hr = STG_E_ACCESSDENIED; + } + return hr; +} + +//----------------------------- +HRESULT STDMETHODCALLTYPE CPropertyHdl::Commit() +{ + return S_OK; +} + +//----------------------------- +// IPropertyStore +//----------------------------- +HRESULT STDMETHODCALLTYPE CPropertyHdl::IsPropertyWritable( REFPROPERTYKEY key ) +{ + // We start with read only properties only + return S_FALSE; +} + +//----------------------------- +// IInitializeWithStream +//----------------------------- +HRESULT STDMETHODCALLTYPE CPropertyHdl::Initialize( IStream *pStream, DWORD grfMode ) +{ + if ( grfMode & STGM_READWRITE ) + return STG_E_ACCESSDENIED; + + if ( !m_pCache ) + { + if ( FAILED( PSCreateMemoryPropertyStore( IID_PPV_ARGS( &m_pCache ) ) ) ) + OutputDebugStringFormat( "CPropertyHdl::Initialize: PSCreateMemoryPropertyStore failed" ); + + zlib_filefunc_def z_filefunc; + pStream = PrepareIStream( pStream, z_filefunc ); + + CMetaInfoReader *pMetaInfoReader = NULL; + + try + { + pMetaInfoReader = new CMetaInfoReader( (void*)pStream, &z_filefunc ); + } + catch (const std::exception& e) + { + OutputDebugStringFormat( "CPropertyHdl::Initialize: Caught exception [%s]", e.what() ); + return E_FAIL; + } + + LoadProperties( pMetaInfoReader ); +/* + // load extended properties and search content + _LoadExtendedProperties(); + _LoadSearchContent(); +*/ + } + + return S_OK; +} + +//----------------------------- +void CPropertyHdl::LoadProperties( CMetaInfoReader *pMetaInfoReader ) +{ + OutputDebugStringFormat( "CPropertyHdl: LoadProperties\n" ); + PROPVARIANT propvarValues; + + for ( UINT i = 0; i < (UINT)gPropertyMapTableSize; ++i ) + { + PropVariantClear( &propvarValues ); + HRESULT hr = GetItemData( pMetaInfoReader, i, &propvarValues); + if (hr == S_OK) + { + // coerce the value(s) to the appropriate type for the property key + hr = PSCoerceToCanonicalValue( g_rgPROPERTYMAP[i].key, &propvarValues ); + if (SUCCEEDED(hr)) + { + // cache the value(s) loaded + hr = m_pCache->SetValueAndState( g_rgPROPERTYMAP[i].key, &propvarValues, PSC_NORMAL ); + } + } + } +} + +//----------------------------- +HRESULT CPropertyHdl::GetItemData( CMetaInfoReader *pMetaInfoReader, UINT nIndex, PROPVARIANT *pVarData ) +{ + switch (nIndex) { + case 0: { + pVarData->vt = VT_BSTR; + pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_TITLE ).c_str() ); + OutputDebugStringFormat( "CPropertyHdl::GetItemData: Title=%S.\n", pMetaInfoReader->getTagData( META_INFO_TITLE ).c_str() ); + return S_OK; + } + case 1: { + pVarData->vt = VT_BSTR; + pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_AUTHOR ).c_str() ); + OutputDebugStringFormat( "CPropertyHdl::GetItemData: Author=%S.\n", pMetaInfoReader->getTagData( META_INFO_AUTHOR ).c_str() ); + return S_OK; + } + case 2: { + pVarData->vt = VT_BSTR; + pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_SUBJECT ).c_str() ); + OutputDebugStringFormat( "CPropertyHdl::GetItemData: Subject=%S.\n", pMetaInfoReader->getTagData( META_INFO_SUBJECT ).c_str() ); + return S_OK; + } + case 3: { + pVarData->vt = VT_BSTR; + pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_KEYWORDS ).c_str() ); + OutputDebugStringFormat( "CPropertyHdl::GetItemData: Keywords=%S.\n", pMetaInfoReader->getTagData( META_INFO_KEYWORDS ).c_str() ); + return S_OK; + } + case 4: { + pVarData->vt = VT_BSTR; + pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagData( META_INFO_DESCRIPTION ).c_str() ); + OutputDebugStringFormat( "CPropertyHdl::GetItemData: Description=%S.\n", pMetaInfoReader->getTagData( META_INFO_DESCRIPTION ).c_str() ); + return S_OK; + } + case 5: { + pVarData->vt = VT_BSTR; + pVarData->bstrVal = SysAllocString( pMetaInfoReader->getTagAttribute( META_INFO_DOCUMENT_STATISTIC, META_INFO_PAGES ).c_str() ); + OutputDebugStringFormat( "CPropertyHdl::GetItemData: Pages=%S.\n", pMetaInfoReader->getTagAttribute( META_INFO_DOCUMENT_STATISTIC, META_INFO_PAGES ).c_str() ); + return S_OK; + } + } + + return S_FALSE; +} \ No newline at end of file diff --git a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx old mode 100644 new mode 100755 index 171bc287715f..51eb2d251f71 --- a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx +++ b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx @@ -51,6 +51,24 @@ #include #include #include +#include + +//---------------------------------------------------------- +#ifdef DEBUG +inline void OutputDebugStringFormat( LPCSTR pFormat, ... ) +{ + CHAR buffer[1024]; + va_list args; + + va_start( args, pFormat ); + StringCchVPrintfA( buffer, sizeof(buffer), pFormat, args ); + OutputDebugStringA( buffer ); +} +#else +static inline void OutputDebugStringFormat( LPCSTR, ... ) +{ +} +#endif /*--------------------------------------------- @@ -70,6 +88,7 @@ CPropertySheet::CPropertySheet(long RefCnt) : m_RefCnt(RefCnt) { + OutputDebugStringFormat("CPropertySheet::CTor [%d], [%d]", m_RefCnt, g_DllRefCnt ); InterlockedIncrement(&g_DllRefCnt); } @@ -79,6 +98,7 @@ CPropertySheet::CPropertySheet(long RefCnt) : CPropertySheet::~CPropertySheet() { + OutputDebugStringFormat("CPropertySheet::DTor [%d], [%d]", m_RefCnt, g_DllRefCnt ); InterlockedDecrement(&g_DllRefCnt); } @@ -116,6 +136,7 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::QueryInterface( ULONG STDMETHODCALLTYPE CPropertySheet::AddRef(void) { + OutputDebugStringFormat("CPropertySheet::AddRef [%d]", m_RefCnt ); return InterlockedIncrement(&m_RefCnt); } @@ -125,6 +146,7 @@ ULONG STDMETHODCALLTYPE CPropertySheet::AddRef(void) ULONG STDMETHODCALLTYPE CPropertySheet::Release(void) { + OutputDebugStringFormat("CPropertySheet::Release [%d]", m_RefCnt ); long refcnt = InterlockedDecrement(&m_RefCnt); if (0 == refcnt) @@ -177,42 +199,51 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::Initialize( HRESULT STDMETHODCALLTYPE CPropertySheet::AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam) { + // Get OS version (we don't need the summary page on Windows Vista or later) + OSVERSIONINFO sInfoOS; - PROPSHEETPAGE psp; + ZeroMemory( &sInfoOS, sizeof(OSVERSIONINFO) ); + sInfoOS.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); + GetVersionEx( &sInfoOS ); + bool bIsVistaOrLater = (sInfoOS.dwMajorVersion >= 6); - // add the summary property page + std::wstring proppage_header; + PROPSHEETPAGE psp; ZeroMemory(&psp, sizeof(PROPSHEETPAGEA)); - std::wstring proppage_header = GetResString(IDS_PROPPAGE_SUMMARY_TITLE); - + // add the summary property page psp.dwSize = sizeof(PROPSHEETPAGE); psp.dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USECALLBACK; psp.hInstance = GetModuleHandle(MODULE_NAME); - psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_SUMMARY); - psp.pszTitle = proppage_header.c_str(); - psp.pfnDlgProc = reinterpret_cast(CPropertySheet::PropPageSummaryProc); psp.lParam = reinterpret_cast(this); psp.pfnCallback = reinterpret_cast(CPropertySheet::PropPageSummaryCallback); - HPROPSHEETPAGE hPage = CreatePropertySheetPage(&psp); + HPROPSHEETPAGE hPage = NULL; - // keep this instance alive - // will be released when the - // the page is about to be - // destroyed in the callback - // function - - if (hPage) + if ( !bIsVistaOrLater ) { - if (lpfnAddPage(hPage, lParam)) - AddRef(); - else - DestroyPropertySheetPage(hPage); + proppage_header = GetResString(IDS_PROPPAGE_SUMMARY_TITLE); + + psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_SUMMARY); + psp.pszTitle = proppage_header.c_str(); + psp.pfnDlgProc = reinterpret_cast(CPropertySheet::PropPageSummaryProc); + + hPage = CreatePropertySheetPage(&psp); + + // keep this instance alive, will be released when the + // the page is about to be destroyed in the callback function + + if (hPage) + { + if (lpfnAddPage(hPage, lParam)) + AddRef(); + else + DestroyPropertySheetPage(hPage); + } } // add the statistics property page - proppage_header = GetResString(IDS_PROPPAGE_STATISTICS_TITLE); psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_STATISTICS); diff --git a/shell/source/win32/shlxthandler/shlxthdl.cxx b/shell/source/win32/shlxthandler/shlxthdl.cxx old mode 100644 new mode 100755 index 1249d3cde6e7..9af1f6314ae0 --- a/shell/source/win32/shlxthandler/shlxthdl.cxx +++ b/shell/source/win32/shlxthandler/shlxthdl.cxx @@ -392,7 +392,8 @@ extern "C" STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv) if ((rclsid != CLSID_INFOTIP_HANDLER) && (rclsid != CLSID_COLUMN_HANDLER) && (rclsid != CLSID_PROPERTYSHEET_HANDLER) && - (rclsid != CLSID_THUMBVIEWER_HANDLER)) + (rclsid != CLSID_THUMBVIEWER_HANDLER) && + (rclsid != CLSID_PROPERTY_HANDLER)) return CLASS_E_CLASSNOTAVAILABLE; if ((riid != IID_IUnknown) && (riid != IID_IClassFactory)) -- cgit