From 69adeb47391412ea0328055d3773d5b6ce0d00a6 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Tue, 26 Jan 2010 07:36:23 +0100 Subject: dv17: #i70994#: Moved property handler to own library to avoid problems with old Windows versions --- shell/inc/internal/propertyhdl.hxx | 36 +++++ shell/inc/internal/shlxthdl.hxx | 4 - shell/prj/d.lst | 1 + shell/source/win32/shlxthandler/classfactory.cxx | 4 - shell/source/win32/shlxthandler/makefile.mk | 10 +- .../source/win32/shlxthandler/prophdl/exports.dxp | 2 + .../source/win32/shlxthandler/prophdl/makefile.mk | 83 ++++++++++- .../win32/shlxthandler/prophdl/propertyhdl.cxx | 159 +++++++++++++++++++-- shell/source/win32/shlxthandler/shlxthdl.cxx | 5 +- 9 files changed, 268 insertions(+), 36 deletions(-) create mode 100755 shell/source/win32/shlxthandler/prophdl/exports.dxp (limited to 'shell') diff --git a/shell/inc/internal/propertyhdl.hxx b/shell/inc/internal/propertyhdl.hxx index 60ff10bc6958..6379fdf0137b 100755 --- a/shell/inc/internal/propertyhdl.hxx +++ b/shell/inc/internal/propertyhdl.hxx @@ -40,6 +40,10 @@ #pragma warning(pop) #endif +// {AE424E85-F6DF-4910-A6A9-438797986431} +const CLSID CLSID_PROPERTY_HANDLER = +{ 0xae424e85, 0xf6df, 0x4910, { 0xa6, 0xa9, 0x43, 0x87, 0x97, 0x98, 0x64, 0x31 } }; + class CMetaInfoReader; class CPropertyHdl : public IPropertyStore, @@ -87,4 +91,36 @@ private: IPropertyStoreCache* m_pCache; }; +class CClassFactory : public IClassFactory +{ +public: + CClassFactory( const CLSID& clsid ); + virtual ~CClassFactory(); + + //----------------------------- + // IUnknown methods + //----------------------------- + virtual HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void __RPC_FAR *__RPC_FAR *ppvObject); + virtual ULONG STDMETHODCALLTYPE AddRef( void ); + virtual ULONG STDMETHODCALLTYPE Release( void ); + + //----------------------------- + // IClassFactory methods + //----------------------------- + virtual HRESULT STDMETHODCALLTYPE CreateInstance( + IUnknown __RPC_FAR *pUnkOuter, + REFIID riid, + void __RPC_FAR *__RPC_FAR *ppvObject); + + virtual HRESULT STDMETHODCALLTYPE LockServer( BOOL fLock ); + static bool IsLocked(); + +private: + long m_RefCnt; + CLSID m_Clsid; + static long s_ServerLocks; +}; + #endif diff --git a/shell/inc/internal/shlxthdl.hxx b/shell/inc/internal/shlxthdl.hxx index 70830c9775ec..782212f6dc5b 100755 --- a/shell/inc/internal/shlxthdl.hxx +++ b/shell/inc/internal/shlxthdl.hxx @@ -55,8 +55,4 @@ 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/prj/d.lst b/shell/prj/d.lst index eee13ef34fe9..ea8be0bbaf04 100755 --- a/shell/prj/d.lst +++ b/shell/prj/d.lst @@ -7,6 +7,7 @@ ..\%__SRC%\bin\x64\shlxthdl.dll %_DEST%\bin%_EXT%\shlxthdl_x64.dll ..\%__SRC%\bin\x64\ooofiltproxy.dll %_DEST%\bin%_EXT%\ooofiltproxy_x64.dll ..\%__SRC%\bin\x64\ooofilt.dll %_DEST%\bin%_EXT%\ooofilt_x64.dll +..\%__SRC%\bin\x64\propertyhdl.dll %_DEST%\bin%_EXT%\propertyhdl_x64.dll ..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib ..\%__SRC%\lib\*.a %_DEST%\lib%_EXT%\*.a diff --git a/shell/source/win32/shlxthandler/classfactory.cxx b/shell/source/win32/shlxthandler/classfactory.cxx index 10dd3e82934d..ee60cb4f62b7 100755 --- a/shell/source/win32/shlxthandler/classfactory.cxx +++ b/shell/source/win32/shlxthandler/classfactory.cxx @@ -35,7 +35,6 @@ #include "internal/infotips.hxx" #include "internal/propsheets.hxx" #include "internal/columninfo.hxx" -#include "internal/propertyhdl.hxx" #ifdef __MINGW32__ #include using ::std::max; @@ -138,9 +137,6 @@ 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 index 7735a5947c80..83998a15e627 100755 --- a/shell/source/win32/shlxthandler/makefile.mk +++ b/shell/source/win32/shlxthandler/makefile.mk @@ -55,8 +55,6 @@ SLOFILES=$(SLO)$/classfactory.obj\ $(SLO)$/listviewbuilder.obj\ $(SLO)$/document_statistic.obj\ $(SLO)$/thumbviewer.obj\ - $(SLO)$/propertyhdl.obj\ - $(SLO)$/stream_helper.obj\ SHL1TARGET=$(TARGET) @@ -78,8 +76,7 @@ SHL1STDLIBS+=\ $(KERNEL32LIB)\ $(GDI32LIB)\ $(GDIPLUSLIB)\ - $(SHLWAPILIB)\ - $(PROPSYSLIB) + $(SHLWAPILIB) SHL1LIBS+=$(SLB)$/util.lib\ $(SLB)$/ooofilereader.lib @@ -109,8 +106,6 @@ SLOFILES_X64= \ $(SLO_X64)$/listviewbuilder.obj\ $(SLO_X64)$/document_statistic.obj\ $(SLO_X64)$/thumbviewer.obj\ - $(SLO_X64)$/propertyhdl.obj\ - $(SLO_X64)$/stream_helper.obj\ SHL1TARGET_X64=$(TARGET) SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/zlib.lib\ @@ -129,8 +124,7 @@ SHL1STDLIBS_X64+=\ $(GDIPLUSLIB_X64) \ $(MSVCRT_X64) \ $(MSVCPRT_X64) \ - $(OLDNAMESLIB_X64)\ - $(PROPSYSLIB_X64) + $(OLDNAMESLIB_X64) SHL1LIBS_X64+=$(SLB_X64)$/util.lib\ $(SLB_X64)$/ooofilereader.lib diff --git a/shell/source/win32/shlxthandler/prophdl/exports.dxp b/shell/source/win32/shlxthandler/prophdl/exports.dxp new file mode 100755 index 000000000000..2ada8255f8f7 --- /dev/null +++ b/shell/source/win32/shlxthandler/prophdl/exports.dxp @@ -0,0 +1,2 @@ +DllGetClassObject PRIVATE +DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/shell/source/win32/shlxthandler/prophdl/makefile.mk b/shell/source/win32/shlxthandler/prophdl/makefile.mk index 19f9d494b741..b9153bf014de 100755 --- a/shell/source/win32/shlxthandler/prophdl/makefile.mk +++ b/shell/source/win32/shlxthandler/prophdl/makefile.mk @@ -2,14 +2,10 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2008 by Sun Microsystems, Inc. +# Copyright 2010 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 @@ -34,25 +30,98 @@ PRJNAME=shell TARGET=propertyhdl LIBTARGET=NO ENABLE_EXCEPTIONS=TRUE - +USE_DEFFILE=TRUE +.IF "$(BUILD_X64)"!="" +USE_DEFFILE_X64=TRUE +.ENDIF # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +UWINAPILIB = +UWINAPILIB_X64 = + 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)$/$(TARGET).obj +SLOFILES=$(SLO)$/$(TARGET).obj\ + $(SLO)$/stream_helper.obj + +SHL1TARGET=$(TARGET) + +.IF "$(COM)"=="GCC" +SHL1STDLIBS=$(ZLIB3RDLIB) $(EXPAT3RDLIB) $(COMCTL32LIB) +SHL1LIBS= +.ELSE +SHL1STDLIBS= +SHL1LIBS=$(SOLARLIBDIR)$/zlib.lib\ + $(SOLARLIBDIR)$/expat_xmlparse.lib\ + $(SOLARLIBDIR)$/expat_xmltok.lib +.ENDIF +SHL1STDLIBS+=\ + $(OLEAUT32LIB)\ + $(ADVAPI32LIB)\ + $(OLE32LIB)\ + $(UUIDLIB)\ + $(SHELL32LIB)\ + $(KERNEL32LIB)\ + $(GDI32LIB)\ + $(GDIPLUSLIB)\ + $(SHLWAPILIB)\ + $(PROPSYSLIB) + +SHL1LIBS+=$(SLB)$/util.lib\ + $(SLB)$/ooofilereader.lib +SHL1DEPN= +SHL1OBJS=$(SLOFILES) +SHL1DEF=$(MISC)$/$(SHL1TARGET).def +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE=exports.dxp + +# -------------------- x64 ----------------------- .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 + +SLOFILES_X64= \ + $(SLO_X64)$/propertyhdl.obj\ + $(SLO_X64)$/stream_helper.obj\ + +SHL1TARGET_X64=$(TARGET) +SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/zlib.lib\ + $(SOLARLIBDIR_X64)$/expat_xmlparse.lib\ + $(SOLARLIBDIR_X64)$/expat_xmltok.lib + +SHL1STDLIBS_X64+=\ + $(OLEAUT32LIB_X64)\ + $(ADVAPI32LIB_X64)\ + $(OLE32LIB_X64)\ + $(UUIDLIB_X64)\ + $(SHELL32LIB_X64)\ + $(KERNEL32LIB_X64)\ + $(GDI32LIB_X64)\ + $(USER32LIB_X64) \ + $(GDIPLUSLIB_X64) \ + $(MSVCRT_X64) \ + $(MSVCPRT_X64) \ + $(OLDNAMESLIB_X64)\ + $(PROPSYSLIB_X64) + +SHL1LIBS_X64+=$(SLB_X64)$/util.lib\ + $(SLB_X64)$/ooofilereader.lib +SHL1OBJS_X64=$(SLOFILES_X64) +SHL1DEF_X64=$(MISC_X64)$/$(SHL1TARGET).def + +DEF1NAME_X64=$(SHL1TARGET_X64) +DEF1EXPORTFILE_X64=exports.dxp + .ENDIF # "$(BUILD_X64)"!="" # --- Targets ------------------------------------------------------ diff --git a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx index 97db20caaea5..3cece320ace4 100755 --- a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx +++ b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx @@ -42,9 +42,11 @@ #include "internal/stream_helper.hxx" -//---------------------------- -// -//---------------------------- +//--------------------------- +// Module global +//--------------------------- +long g_DllRefCnt = 0; +HINSTANCE g_hModule = NULL; // // Map of property keys to the locations of their value(s) in the .??? XML schema @@ -130,17 +132,17 @@ HRESULT STDMETHODCALLTYPE CPropertyHdl::QueryInterface(REFIID riid, void __RPC_F } //---------------------------- -ULONG STDMETHODCALLTYPE CPropertyHdl::AddRef(void) +ULONG STDMETHODCALLTYPE CPropertyHdl::AddRef( void ) { - return InterlockedIncrement(&m_RefCnt); + return InterlockedIncrement( &m_RefCnt ); } //---------------------------- -ULONG STDMETHODCALLTYPE CPropertyHdl::Release( void) +ULONG STDMETHODCALLTYPE CPropertyHdl::Release( void ) { - long refcnt = InterlockedDecrement(&m_RefCnt); + long refcnt = InterlockedDecrement( &m_RefCnt ); - if (0 == m_RefCnt) + if ( 0 == m_RefCnt ) delete this; return refcnt; @@ -315,4 +317,143 @@ HRESULT CPropertyHdl::GetItemData( CMetaInfoReader *pMetaInfoReader, UINT nIndex } return S_FALSE; -} \ No newline at end of file +} + +//----------------------------------------------------------------------------- +// CClassFactory +//----------------------------------------------------------------------------- + +long CClassFactory::s_ServerLocks = 0; + +//----------------------------------------------------------------------------- +CClassFactory::CClassFactory( const CLSID& clsid ) : + m_RefCnt(1), + m_Clsid(clsid) +{ + InterlockedIncrement( &g_DllRefCnt ); +} + +//----------------------------------------------------------------------------- +CClassFactory::~CClassFactory() +{ + InterlockedDecrement( &g_DllRefCnt ); +} + +//----------------------------------------------------------------------------- +// IUnknown methods +//----------------------------------------------------------------------------- +HRESULT STDMETHODCALLTYPE CClassFactory::QueryInterface( REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject ) +{ + *ppvObject = 0; + + if ( IID_IUnknown == riid || IID_IClassFactory == riid ) + { + IUnknown* pUnk = this; + pUnk->AddRef(); + *ppvObject = pUnk; + return S_OK; + } + + return E_NOINTERFACE; +} + +//----------------------------------------------------------------------------- +ULONG STDMETHODCALLTYPE CClassFactory::AddRef( void ) +{ + return InterlockedIncrement( &m_RefCnt ); +} + +//----------------------------------------------------------------------------- +ULONG STDMETHODCALLTYPE CClassFactory::Release( void ) +{ + long refcnt = InterlockedDecrement( &m_RefCnt ); + + if (0 == refcnt) + delete this; + + return refcnt; +} + +//----------------------------------------------------------------------------- +// IClassFactory methods +//----------------------------------------------------------------------------- +HRESULT STDMETHODCALLTYPE CClassFactory::CreateInstance( + IUnknown __RPC_FAR *pUnkOuter, + REFIID riid, + void __RPC_FAR *__RPC_FAR *ppvObject) +{ + if ( pUnkOuter != NULL ) + return CLASS_E_NOAGGREGATION; + + IUnknown* pUnk = 0; + + if ( CLSID_PROPERTY_HANDLER == m_Clsid ) + pUnk = static_cast( new CPropertyHdl() ); + + POST_CONDITION(pUnk != 0, "Could not create COM object"); + + if (0 == pUnk) + return E_OUTOFMEMORY; + + HRESULT hr = pUnk->QueryInterface( riid, ppvObject ); + + // if QueryInterface failed the component will destroy itself + pUnk->Release(); + + return hr; +} + +//----------------------------------------------------------------------------- +HRESULT STDMETHODCALLTYPE CClassFactory::LockServer( BOOL fLock ) +{ + if ( fLock ) + InterlockedIncrement( &s_ServerLocks ); + else + InterlockedDecrement( &s_ServerLocks ); + + return S_OK; +} + +//----------------------------------------------------------------------------- +bool CClassFactory::IsLocked() +{ + return ( s_ServerLocks > 0 ); +} + +//----------------------------------------------------------------------------- +extern "C" STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv) +{ + OutputDebugStringFormat( "DllGetClassObject.\n" ); + *ppv = 0; + + if ( rclsid != CLSID_PROPERTY_HANDLER ) + return CLASS_E_CLASSNOTAVAILABLE; + + if ( (riid != IID_IUnknown) && (riid != IID_IClassFactory) ) + return E_NOINTERFACE; + + IUnknown* pUnk = new CClassFactory( rclsid ); + if ( 0 == pUnk ) + return E_OUTOFMEMORY; + + *ppv = pUnk; + return S_OK; +} + +//----------------------------------------------------------------------------- +extern "C" STDAPI DllCanUnloadNow( void ) +{ + OutputDebugStringFormat( "DllCanUnloadNow.\n" ); + if (CClassFactory::IsLocked() || g_DllRefCnt > 0) + return S_FALSE; + + return S_OK; +} + +//----------------------------------------------------------------------------- +BOOL WINAPI DllMain( HINSTANCE hInst, ULONG /*ul_reason_for_call*/, LPVOID /*lpReserved*/ ) +{ + OutputDebugStringFormat( "DllMain.\n" ); + g_hModule = hInst; + return TRUE; +} diff --git a/shell/source/win32/shlxthandler/shlxthdl.cxx b/shell/source/win32/shlxthandler/shlxthdl.cxx index 80f17470c379..11bb23448cd0 100755 --- a/shell/source/win32/shlxthandler/shlxthdl.cxx +++ b/shell/source/win32/shlxthandler/shlxthdl.cxx @@ -392,8 +392,7 @@ 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_PROPERTY_HANDLER)) + (rclsid != CLSID_THUMBVIEWER_HANDLER)) return CLASS_E_CLASSNOTAVAILABLE; if ((riid != IID_IUnknown) && (riid != IID_IClassFactory)) @@ -407,8 +406,6 @@ extern "C" STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv) OutputDebugStringFormat( "DllGetClassObject: Create CLSID_PROPERTYSHEET_HANDLER\n" ); else if ( rclsid == CLSID_THUMBVIEWER_HANDLER ) OutputDebugStringFormat( "DllGetClassObject: Create CLSID_THUMBVIEWER_HANDLER\n" ); - else if ( rclsid == CLSID_PROPERTY_HANDLER ) - OutputDebugStringFormat( "DllGetClassObject: Create CLSID_PROPERTY_HANDLER\n" ); IUnknown* pUnk = new CClassFactory(rclsid); if (0 == pUnk) -- cgit