diff options
Diffstat (limited to 'shell/source/win32')
21 files changed, 852 insertions, 420 deletions
diff --git a/shell/source/win32/makefile.mk b/shell/source/win32/makefile.mk index 065261cd8dad..9a9564ed76ca 100644 --- a/shell/source/win32/makefile.mk +++ b/shell/source/win32/makefile.mk @@ -64,4 +64,6 @@ DEF1EXPORTFILE= exports.dxp # --- Targets ------------------------------------------------------ .INCLUDE : target.mk +INCLUDE!:=$(subst,/stl, $(INCLUDE)) +.EXPORT : INCLUDE diff --git a/shell/source/win32/shlxthandler/classfactory.cxx b/shell/source/win32/shlxthandler/classfactory.cxx index e19dd68383b4..e19dd68383b4 100644..100755 --- a/shell/source/win32/shlxthandler/classfactory.cxx +++ b/shell/source/win32/shlxthandler/classfactory.cxx diff --git a/shell/source/win32/shlxthandler/columninfo/makefile.mk b/shell/source/win32/shlxthandler/columninfo/makefile.mk index 2e7bd47261c5..868a711e005c 100644 --- a/shell/source/win32/shlxthandler/columninfo/makefile.mk +++ b/shell/source/win32/shlxthandler/columninfo/makefile.mk @@ -54,4 +54,6 @@ SLOFILES_X64=$(SLO_X64)$/$(TARGET).obj # --- Targets ------------------------------------------------------ .INCLUDE : set_wntx64.mk .INCLUDE : target.mk +INCLUDE!:=$(subst,/stl, $(INCLUDE)) +.EXPORT : INCLUDE .INCLUDE : tg_wntx64.mk
\ No newline at end of file diff --git a/shell/source/win32/shlxthandler/infotips/makefile.mk b/shell/source/win32/shlxthandler/infotips/makefile.mk index 85d4099b20d3..f69f2cf2fd78 100644 --- a/shell/source/win32/shlxthandler/infotips/makefile.mk +++ b/shell/source/win32/shlxthandler/infotips/makefile.mk @@ -30,6 +30,7 @@ PRJNAME=shell TARGET=infotips LIBTARGET=NO ENABLE_EXCEPTIONS=TRUE +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE # --- Settings ----------------------------------------------------- @@ -54,4 +55,6 @@ SLOFILES_X64=$(SLO_X64)$/$(TARGET).obj .INCLUDE : set_wntx64.mk .INCLUDE : target.mk +INCLUDE!:=$(subst,/stl, $(INCLUDE)) +.EXPORT : INCLUDE .INCLUDE : tg_wntx64.mk
\ No newline at end of file diff --git a/shell/source/win32/shlxthandler/makefile.mk b/shell/source/win32/shlxthandler/makefile.mk index db3496687d6c..69d247cf51f0 100644..100755 --- a/shell/source/win32/shlxthandler/makefile.mk +++ b/shell/source/win32/shlxthandler/makefile.mk @@ -54,7 +54,7 @@ SLOFILES=$(SLO)$/classfactory.obj\ $(SLO)$/shlxthdl.obj\ $(SLO)$/listviewbuilder.obj\ $(SLO)$/document_statistic.obj\ - $(SLO)$/thumbviewer.obj + $(SLO)$/thumbviewer.obj\ SHL1TARGET=$(TARGET) @@ -75,7 +75,9 @@ SHL1STDLIBS+=\ $(SHELL32LIB)\ $(KERNEL32LIB)\ $(GDI32LIB)\ - $(GDIPLUSLIB) + $(GDIPLUSLIB)\ + msvcprt.lib + $(SHLWAPILIB) SHL1LIBS+=$(SLB)$/util.lib\ $(SLB)$/ooofilereader.lib @@ -104,7 +106,7 @@ SLOFILES_X64= \ $(SLO_X64)$/shlxthdl.obj\ $(SLO_X64)$/listviewbuilder.obj\ $(SLO_X64)$/document_statistic.obj\ - $(SLO_X64)$/thumbviewer.obj + $(SLO_X64)$/thumbviewer.obj\ SHL1TARGET_X64=$(TARGET) SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/zlib.lib\ @@ -139,5 +141,7 @@ DEF1EXPORTFILE_X64=exports.dxp .INCLUDE : set_wntx64.mk .INCLUDE : target.mk +INCLUDE!:=$(subst,/stl, $(INCLUDE)) +.EXPORT : INCLUDE .INCLUDE : tg_wntx64.mk diff --git a/shell/source/win32/shlxthandler/ooofilt/makefile.mk b/shell/source/win32/shlxthandler/ooofilt/makefile.mk index 2fa6a57ab756..afd51c1dd4d7 100644..100755 --- a/shell/source/win32/shlxthandler/ooofilt/makefile.mk +++ b/shell/source/win32/shlxthandler/ooofilt/makefile.mk @@ -33,7 +33,7 @@ ENABLE_EXCEPTIONS=TRUE USE_DEFFILE=TRUE # Do not use the dynamic STLport library. -# NO_DEFAULT_STL=YES +NO_DEFAULT_STL=YES # Do not use the uwinapi library UWINAPILIB= @@ -51,7 +51,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 @@ -72,7 +73,8 @@ SHL1STDLIBS+=$(OLE32LIB)\ $(UUIDLIB)\ $(SHELL32LIB)\ $(KERNEL32LIB)\ - $(OLDNAMESLIB) + $(OLDNAMESLIB)\ + msvcprt.lib # $(LIBSTLPORTST) @@ -94,7 +96,8 @@ CDEFS_X64+=-D_WIN32_IE=0x501 USE_DEFFILE_X64=TRUE SLOFILES_X64=$(SLO_X64)$/ooofilt.obj\ - $(SLO_X64)$/propspec.obj + $(SLO_X64)$/propspec.obj\ + $(SLO_X64)$/stream_helper.obj SHL1TARGET_X64=$(TARGET) @@ -125,4 +128,6 @@ DEF1EXPORTFILE_X64=exports.dxp .INCLUDE : set_wntx64.mk .INCLUDE : target.mk +INCLUDE!:=$(subst,/stl, $(INCLUDE)) +.EXPORT : INCLUDE .INCLUDE : tg_wntx64.mk
\ No newline at end of file diff --git a/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx index d04f98e537b6..adcf2b2f8ddf 100644..100755 --- a/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx +++ b/shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx @@ -83,6 +83,7 @@ using ::std::min; #endif +#include "internal/stream_helper.hxx" //C------------------------------------------------------------------------- // @@ -735,23 +736,9 @@ SCODE STDMETHODCALLTYPE COooFilter::SaveCompleted(LPCWSTR /*pszFileName*/) //-------------------------------------------------------------------------- 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; + m_pStream = PrepareIStream( pStm, z_filefunc ); try { @@ -1250,8 +1237,8 @@ namespace /* private */ GUID_PLACEHOLDER, ClsidToString(PersistentGuid)); - if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist_Entry.c_str(), "", ClsidToString(PersistentGuid).c_str())); - + if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist_Entry.c_str(), "", ClsidToString(PersistentGuid).c_str())) + return E_FAIL; std::string ClsidEntry_Persist_Addin = CLSID_GUID_PERSIST_ADDIN_ENTRY; SubstitutePlaceholder(ClsidEntry_Persist_Addin, @@ -1501,100 +1488,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 a661609eb803..b68863523b28 100644..100755 --- a/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx +++ b/shell/source/win32/shlxthandler/ooofilt/ooofilt.hxx @@ -216,26 +216,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/proxy/exports.dxp b/shell/source/win32/shlxthandler/ooofilt/proxy/exports.dxp deleted file mode 100644 index 953039ccc957..000000000000 --- a/shell/source/win32/shlxthandler/ooofilt/proxy/exports.dxp +++ /dev/null @@ -1,4 +0,0 @@ -DllRegisterServer PRIVATE -DllUnregisterServer PRIVATE -DllGetClassObject PRIVATE -DllCanUnloadNow PRIVATE
\ No newline at end of file diff --git a/shell/source/win32/shlxthandler/ooofilt/proxy/makefile.mk b/shell/source/win32/shlxthandler/ooofilt/proxy/makefile.mk deleted file mode 100644 index aab2285f980b..000000000000 --- a/shell/source/win32/shlxthandler/ooofilt/proxy/makefile.mk +++ /dev/null @@ -1,88 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# 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. -# -#************************************************************************* - -PRJ=..$/..$/..$/..$/.. -PRJNAME=shell -TARGET=ooofiltproxy -LIBTARGET=NO -ENABLE_EXCEPTIONS=TRUE -USE_DEFFILE=TRUE -DYNAMIC_CRT= -UWINAPILIB= - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -CFLAGS+=-DWIN32_LEAN_AND_MEAN -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501 -CDEFS+=-D_WIN32_IE=0x501 - -# --- Files -------------------------------------------------------- - -SLOFILES=$(SLO)$/ooofiltproxy.obj -SHL1TARGET=$(TARGET) -SHL1STDLIBS=$(OLE32LIB)\ - $(ADVAPO32LIB)\ - $(COMCTL32LIB)\ - $(UUIDLIB)\ - $(SHELL32LIB)\ - $(KERNEL32LIB) - -SHL1DEPN= -SHL1OBJS=$(SLOFILES) -SHL1DEF=$(MISC)$/$(SHL1TARGET).def -DEF1NAME=$(SHL1TARGET) -DEF1EXPORTFILE=exports.dxp - -.IF "$(BUILD_X64)"!="" -#------------- x64 stuff ---------------- -USE_DEFFILE_X64=TRUE -CFLAGS_X64+=-DWIN32_LEAN_AND_MEAN -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501 -CDEFS_X64+=-D_WIN32_IE=0x501 - -SLOFILES_X64=$(SLO_X64)$/ooofiltproxy.obj -SHL1TARGET_X64=$(TARGET) -SHL1STDLIBS_X64=$(OLE32LIB_X64)\ - $(ADVAPO32LIB_X64)\ - $(COMCTL32LIB_X64)\ - $(UUIDLIB_X64)\ - $(SHELL32LIB_X64)\ - $(KERNEL32LIB_X64)\ - $(MSVCRT_X64) - -SHL1DEPN_X64= -SHL1OBJS_X64=$(SLO_X64)$/ooofiltproxy.obj -SHL1DEF_X64=$(MISC_X64)$/$(TARGET).def -DEF1NAME_X64=$(TARGET) -DEF1EXPORTFILE_X64=exports.dxp -.ENDIF # "$(BUILD_X64)"!="" - -# --- Targets ------------------------------------------------------ - -.INCLUDE : set_wntx64.mk -.INCLUDE : target.mk -.INCLUDE : tg_wntx64.mk diff --git a/shell/source/win32/shlxthandler/ooofilt/proxy/ooofiltproxy.cxx b/shell/source/win32/shlxthandler/ooofilt/proxy/ooofiltproxy.cxx deleted file mode 100644 index bd11c4102f53..000000000000 --- a/shell/source/win32/shlxthandler/ooofilt/proxy/ooofiltproxy.cxx +++ /dev/null @@ -1,163 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * 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 <tchar.h> -#ifdef __MINGW32__ -#include <basetyps.h> -#endif -#include "internal/config.hxx" - - -/* - The indexing filter library ooofilt.dll is linked against a couple - of libaries (e.g. stlport, uwinapi, ...) which are not standard on - a windows system. Unfortunately the library will be loaded by the - indexing service via LoadLibrary so that the libraries ooofilt.dll - depends on need to be in one of the standard search directories or - the <office installation> directory need to be added to the PATH - environment variable. In order to prevent failures while loading - the ooofilt.dll we're installing and registering this proxy library - which will load ooofilt.dll using LoadLibraryEx with the flag - LOAD_WITH_ALTERED_SEARCH_PATH (see MSDN for details). This approach - ensures that all libraries ooofilt.dll depends on will be found. -*/ - -typedef HRESULT (__stdcall * Forward_DllGetClassObject_t)(REFCLSID cid, REFIID iid, void** ppvObj); -typedef HRESULT (__stdcall * Forward_DllCanUnloadNow_t)(); -typedef HRESULT (__stdcall * Forward_DllRegisterServer_t)(); -typedef HRESULT (__stdcall * Forward_DllUnregisterServer_t)(); - -Forward_DllGetClassObject_t Forward_DllGetClassObject = NULL; -Forward_DllCanUnloadNow_t Forward_DllCanUnloadNow = NULL; -Forward_DllRegisterServer_t Forward_DllRegisterServer = NULL; -Forward_DllUnregisterServer_t Forward_DllUnregisterServer = NULL; - -HMODULE hOoofilt = NULL; -HMODULE hThisLibrary = NULL; - -/* Truncates the file name from an absolute path but - leaves the final '\' */ -void PathTruncateFileName(TCHAR* path) -{ - TCHAR* p = path + lstrlen(path); - while (*p != _T('\\')) p--; - p++; - *p = 0; -} - -void Init() -{ - if (Forward_DllGetClassObject == NULL) - { - TCHAR buff[MAX_PATH]; - GetModuleFileName(hThisLibrary, buff, (sizeof(buff)/sizeof(TCHAR))); - PathTruncateFileName(buff); - - lstrcat(buff, MODULE_NAME_FILTER); - - hOoofilt = LoadLibraryEx(buff, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - - if (hOoofilt) - { - Forward_DllGetClassObject = reinterpret_cast<Forward_DllGetClassObject_t>( - GetProcAddress(hOoofilt, "DllGetClassObject")); - Forward_DllCanUnloadNow = reinterpret_cast<Forward_DllCanUnloadNow_t>( - GetProcAddress(hOoofilt, "DllCanUnloadNow")); - Forward_DllRegisterServer = reinterpret_cast<Forward_DllRegisterServer_t>( - GetProcAddress(hOoofilt, "DllRegisterServer")); - Forward_DllUnregisterServer = reinterpret_cast<Forward_DllUnregisterServer_t>( - GetProcAddress(hOoofilt, "DllUnregisterServer")); - } - } -} - -extern "C" BOOL WINAPI DllMain(HMODULE hInstance, DWORD fdwReason, LPVOID /*lpvReserved*/) -{ - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - DisableThreadLibraryCalls( hInstance ); - hThisLibrary = hInstance; - break; - case DLL_PROCESS_DETACH: - if (hOoofilt) - FreeLibrary(hOoofilt); - break; - default: - break; - } - return TRUE; -} - -extern "C" HRESULT __stdcall DllGetClassObject(REFCLSID cid, REFIID iid, void** ppvObj) -{ - Init(); - - if (Forward_DllGetClassObject) - return Forward_DllGetClassObject(cid, iid, ppvObj); - else - return E_FAIL; -} - -extern "C" HRESULT __stdcall DllCanUnloadNow() -{ - Init(); - - if (Forward_DllCanUnloadNow) - return Forward_DllCanUnloadNow(); - else - return E_FAIL; -} - -extern "C" HRESULT __stdcall DllRegisterServer() -{ - Init(); - if (Forward_DllRegisterServer) - return Forward_DllRegisterServer(); - else - return E_FAIL; -} - -extern "C" HRESULT __stdcall DllUnregisterServer() -{ - Init(); - - if (Forward_DllUnregisterServer) - return Forward_DllUnregisterServer(); - else - return E_FAIL; -} 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 + * <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/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 new file mode 100755 index 000000000000..b9153bf014de --- /dev/null +++ b/shell/source/win32/shlxthandler/prophdl/makefile.mk @@ -0,0 +1,130 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +PRJ=..$/..$/..$/.. +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\ + $(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 ------------------------------------------------------ +.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..3cece320ace4 --- /dev/null +++ b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx @@ -0,0 +1,459 @@ +/************************************************************************* + * + * 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" + +//--------------------------- +// 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 +// +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; +} + +//----------------------------------------------------------------------------- +// 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<IPropertyStore*>( 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/propsheets/makefile.mk b/shell/source/win32/shlxthandler/propsheets/makefile.mk index 81bab609a8e5..fd83f33b9960 100644 --- a/shell/source/win32/shlxthandler/propsheets/makefile.mk +++ b/shell/source/win32/shlxthandler/propsheets/makefile.mk @@ -59,4 +59,6 @@ SLOFILES_X64=$(SLO_X64)$/propsheets.obj\ .INCLUDE : set_wntx64.mk .INCLUDE : target.mk +INCLUDE!:=$(subst,/stl, $(INCLUDE)) +.EXPORT : INCLUDE .INCLUDE : tg_wntx64.mk
\ 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 b57a21c1cf82..a45c7967f233 100644..100755 --- a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx +++ b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx @@ -48,6 +48,7 @@ #include <string> #include <vector> #include <utility> +#include <strsafe.h> /*--------------------------------------------- @@ -67,6 +68,7 @@ CPropertySheet::CPropertySheet(long RefCnt) : m_RefCnt(RefCnt) { + OutputDebugStringFormat("CPropertySheet::CTor [%d], [%d]", m_RefCnt, g_DllRefCnt ); InterlockedIncrement(&g_DllRefCnt); } @@ -76,6 +78,7 @@ CPropertySheet::CPropertySheet(long RefCnt) : CPropertySheet::~CPropertySheet() { + OutputDebugStringFormat("CPropertySheet::DTor [%d], [%d]", m_RefCnt, g_DllRefCnt ); InterlockedDecrement(&g_DllRefCnt); } @@ -113,6 +116,7 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::QueryInterface( ULONG STDMETHODCALLTYPE CPropertySheet::AddRef(void) { + OutputDebugStringFormat("CPropertySheet::AddRef [%d]", m_RefCnt ); return InterlockedIncrement(&m_RefCnt); } @@ -122,6 +126,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) @@ -174,41 +179,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); - - // keep this instance alive - // will be released when the - // the page is about to be - // destroyed in the callback - // function + HPROPSHEETPAGE hPage = NULL; - 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 - 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 21fd4e3438ab..6263c98ea749 100644..100755 --- a/shell/source/win32/shlxthandler/shlxthdl.cxx +++ b/shell/source/win32/shlxthandler/shlxthdl.cxx @@ -395,6 +395,15 @@ extern "C" STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv) if ((riid != IID_IUnknown) && (riid != IID_IClassFactory)) return E_NOINTERFACE; + if ( rclsid == CLSID_INFOTIP_HANDLER ) + OutputDebugStringFormat( "DllGetClassObject: Create CLSID_INFOTIP_HANDLER\n" ); + else if ( rclsid == CLSID_COLUMN_HANDLER ) + OutputDebugStringFormat( "DllGetClassObject: Create CLSID_COLUMN_HANDLER\n" ); + else if ( rclsid == CLSID_PROPERTYSHEET_HANDLER ) + OutputDebugStringFormat( "DllGetClassObject: Create CLSID_PROPERTYSHEET_HANDLER\n" ); + else if ( rclsid == CLSID_THUMBVIEWER_HANDLER ) + OutputDebugStringFormat( "DllGetClassObject: Create CLSID_THUMBVIEWER_HANDLER\n" ); + IUnknown* pUnk = new CClassFactory(rclsid); if (0 == pUnk) return E_OUTOFMEMORY; diff --git a/shell/source/win32/shlxthandler/thumbviewer/makefile.mk b/shell/source/win32/shlxthandler/thumbviewer/makefile.mk index eaa6beb3e2a4..1b7dd103026e 100644 --- a/shell/source/win32/shlxthandler/thumbviewer/makefile.mk +++ b/shell/source/win32/shlxthandler/thumbviewer/makefile.mk @@ -56,5 +56,7 @@ SLOFILES_X64=$(SLO_X64)$/$(TARGET).obj .INCLUDE : set_wntx64.mk .INCLUDE : target.mk +INCLUDE!:=$(subst,/stl, $(INCLUDE)) +.EXPORT : INCLUDE .INCLUDE : tg_wntx64.mk diff --git a/shell/source/win32/shlxthandler/util/iso8601_converter.cxx b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx index c55b7be0017e..dcd779098865 100644 --- a/shell/source/win32/shlxthandler/util/iso8601_converter.cxx +++ b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx @@ -146,7 +146,7 @@ std::wstring iso8601_duration_to_local_duration(const std::wstring& iso8601durat hours = buff; } -#if defined(_MSC_VER) && defined(_M_X64) +#if defined(_MSC_VER) //&& defined(_M_X64) std::wostringstream oss; oss << std::setw(2) << std::setfill(wchar_t('0')) << hours << L":" << std::setw(2) << std::setfill(wchar_t('0')) << minutes << L":" << @@ -169,12 +169,14 @@ std::wstring iso8601_duration_to_local_duration(const std::wstring& iso8601durat return result; #undef ADD_AS_PREFILLED +/* #else std::wostringstream oss; oss << std::setw(2) << std::setfill('0') << hours << L":" << std::setw(2) << std::setfill('0') << minutes << L":" << std::setw(2) << std::setfill('0') << seconds; return oss.str(); +*/ #endif } diff --git a/shell/source/win32/shlxthandler/util/makefile.mk b/shell/source/win32/shlxthandler/util/makefile.mk index f49ee1389b49..8ccf50602f93 100644 --- a/shell/source/win32/shlxthandler/util/makefile.mk +++ b/shell/source/win32/shlxthandler/util/makefile.mk @@ -62,5 +62,7 @@ SLOFILES_X64=$(SLO_X64)$/dbgmacros.obj\ .INCLUDE : set_wntx64.mk .INCLUDE : target.mk +INCLUDE!:=$(subst,/stl, $(INCLUDE)) +.EXPORT : INCLUDE .INCLUDE : tg_wntx64.mk |