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 | |
parent | bd579facad76db083ceab57bc8848f31c4a6d5e5 (diff) |
dv17: #i70994#: Use property handler instead of column info for Windows Vista
Diffstat (limited to 'shell/source/win32')
-rwxr-xr-x[-rw-r--r--] | shell/source/win32/shlxthandler/classfactory.cxx | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | shell/source/win32/shlxthandler/makefile.mk | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | shell/source/win32/shlxthandler/ooofilt/makefile.mk | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx | 294 | ||||
-rwxr-xr-x[-rw-r--r--] | shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx | 47 | ||||
-rwxr-xr-x | shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx | 181 | ||||
-rwxr-xr-x | shell/source/win32/shlxthandler/prophdl/makefile.mk | 61 | ||||
-rwxr-xr-x | shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx | 350 | ||||
-rwxr-xr-x[-rw-r--r--] | shell/source/win32/shlxthandler/propsheets/propsheets.cxx | 75 | ||||
-rwxr-xr-x[-rw-r--r--] | shell/source/win32/shlxthandler/shlxthdl.cxx | 3 |
10 files changed, 763 insertions, 263 deletions
diff --git a/shell/source/win32/shlxthandler/classfactory.cxx b/shell/source/win32/shlxthandler/classfactory.cxx index a7b729d03a..0ac4540c1b 100644..100755 --- 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 <algorithm> using ::std::max; @@ -137,6 +138,9 @@ HRESULT STDMETHODCALLTYPE CClassFactory::CreateInstance( else if (CLSID_THUMBVIEWER_HANDLER == m_Clsid) pUnk = static_cast<IExtractImage*>(new CThumbviewer()); + else if (CLSID_PROPERTY_HANDLER == m_Clsid) + pUnk = static_cast<IPropertyStore*>(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 index 07eea87f02..07a7539e9e 100644..100755 --- 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 index 22127bc8dd..221ec6ee99 100644..100755 --- 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 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;
- }
-}
- diff --git a/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx b/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx index f63a9942f5..1a094b90ce 100644..100755 --- 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 0000000000..dc5966ea28 --- /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 + * <http://www.openoffice.org/license.html> + * 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 <windows.h> +#if defined _MSC_VER +#pragma warning(pop) +#endif + +#include <stdio.h> +#include <objidl.h> + +/*#include <string.h> +#include <filter.h> +#include <filterr.h> +#include <ntquery.h> +#include "assert.h" +#include "propspec.hxx" +#ifdef __MINGW32__ +#include <algorithm> +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 0000000000..30efd7ceda --- /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 +# <http://www.openoffice.org/license.html> +# 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 0000000000..54acf521d0 --- /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 + * <http://www.openoffice.org/license.html> + * 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 <propkey.h> +#include <propvarutil.h> + +#include <malloc.h> +#include <strsafe.h> + +#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<IPropertyStore*>(this); + pUnk->AddRef(); + *ppvObject = pUnk; + return S_OK; + } + else if (IID_IPropertyStoreCapabilities == riid) + { + OutputDebugStringFormat( "CPropertyHdl: QueryInterface (IID_IPropertyStoreCapabilities)\n" ); + IUnknown* pUnk = static_cast<IPropertyStore*>(this); + pUnk->AddRef(); + *ppvObject = pUnk; + return S_OK; + } + else if (IID_IInitializeWithStream == riid) + { + OutputDebugStringFormat( "CPropertyHdl: QueryInterface (IID_IInitializeWithStream)\n" ); + IUnknown* pUnk = static_cast<IInitializeWithStream*>(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 index c901c7be42..e6a56a71dc 100644..100755 --- a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx +++ b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx @@ -51,6 +51,24 @@ #include <string> #include <vector> #include <utility> +#include <strsafe.h> + +//---------------------------------------------------------- +#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) { - - PROPSHEETPAGE psp; + // Get OS version (we don't need the summary page on Windows Vista or later) + OSVERSIONINFO sInfoOS; - // add the summary property page + ZeroMemory( &sInfoOS, sizeof(OSVERSIONINFO) ); + sInfoOS.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); + GetVersionEx( &sInfoOS ); + bool bIsVistaOrLater = (sInfoOS.dwMajorVersion >= 6); - ZeroMemory(&psp, sizeof(PROPSHEETPAGEA)); + std::wstring proppage_header; - std::wstring proppage_header = GetResString(IDS_PROPPAGE_SUMMARY_TITLE); + PROPSHEETPAGE psp; + ZeroMemory(&psp, sizeof(PROPSHEETPAGEA)); + // 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<DLGPROC>(CPropertySheet::PropPageSummaryProc); psp.lParam = reinterpret_cast<LPARAM>(this); psp.pfnCallback = reinterpret_cast<LPFNPSPCALLBACK>(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<DLGPROC>(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 + // 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 index 95d7f59d02..db27c21a32 100644..100755 --- 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)) |