1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ooofiltproxy.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_shell.hxx"
35 #pragma warning(push, 1)
48 The indexing filter library ooofilt.dll is linked against a couple
49 of libaries (e.g. stlport, uwinapi, ...) which are not standard on
50 a windows system. Unfortunately the library will be loaded by the
51 indexing service via LoadLibrary so that the libraries ooofilt.dll
52 depends on need to be in one of the standard search directories or
53 the <office installation> directory need to be added to the PATH
54 environment variable. In order to prevent failures while loading
55 the ooofilt.dll we're installing and registering this proxy library
56 which will load ooofilt.dll using LoadLibraryEx with the flag
57 LOAD_WITH_ALTERED_SEARCH_PATH (see MSDN for details). This approach
58 ensures that all libraries ooofilt.dll depends on will be found.
61 typedef HRESULT (__stdcall
* Forward_DllGetClassObject_t
)(REFCLSID cid
, REFIID iid
, void** ppvObj
);
62 typedef HRESULT (__stdcall
* Forward_DllCanUnloadNow_t
)();
63 typedef HRESULT (__stdcall
* Forward_DllRegisterServer_t
)();
64 typedef HRESULT (__stdcall
* Forward_DllUnregisterServer_t
)();
66 Forward_DllGetClassObject_t Forward_DllGetClassObject
= NULL
;
67 Forward_DllCanUnloadNow_t Forward_DllCanUnloadNow
= NULL
;
68 Forward_DllRegisterServer_t Forward_DllRegisterServer
= NULL
;
69 Forward_DllUnregisterServer_t Forward_DllUnregisterServer
= NULL
;
71 HMODULE hOoofilt
= NULL
;
72 HMODULE hThisLibrary
= NULL
;
74 /* Truncates the file name from an absolute path but
75 leaves the final '\' */
76 void PathTruncateFileName(TCHAR
* path
)
78 TCHAR
* p
= path
+ lstrlen(path
);
79 while (*p
!= _T('\\')) p
--;
86 if (Forward_DllGetClassObject
== NULL
)
89 GetModuleFileName(hThisLibrary
, buff
, (sizeof(buff
)/sizeof(TCHAR
)));
90 PathTruncateFileName(buff
);
91 lstrcat(buff
, TEXT("ooofilt.dll"));
93 hOoofilt
= LoadLibraryEx(buff
, NULL
, LOAD_WITH_ALTERED_SEARCH_PATH
);
97 Forward_DllGetClassObject
= reinterpret_cast<Forward_DllGetClassObject_t
>(
98 GetProcAddress(hOoofilt
, "DllGetClassObject"));
99 Forward_DllCanUnloadNow
= reinterpret_cast<Forward_DllCanUnloadNow_t
>(
100 GetProcAddress(hOoofilt
, "DllCanUnloadNow"));
101 Forward_DllRegisterServer
= reinterpret_cast<Forward_DllRegisterServer_t
>(
102 GetProcAddress(hOoofilt
, "DllRegisterServer"));
103 Forward_DllUnregisterServer
= reinterpret_cast<Forward_DllUnregisterServer_t
>(
104 GetProcAddress(hOoofilt
, "DllUnregisterServer"));
109 extern "C" BOOL WINAPI
DllMain(HMODULE hInstance
, DWORD fdwReason
, LPVOID
/*lpvReserved*/)
113 case DLL_PROCESS_ATTACH
:
114 DisableThreadLibraryCalls( hInstance
);
115 hThisLibrary
= hInstance
;
117 case DLL_PROCESS_DETACH
:
119 FreeLibrary(hOoofilt
);
127 extern "C" HRESULT __stdcall
DllGetClassObject(REFCLSID cid
, REFIID iid
, void** ppvObj
)
131 if (Forward_DllGetClassObject
)
132 return Forward_DllGetClassObject(cid
, iid
, ppvObj
);
137 extern "C" HRESULT __stdcall
DllCanUnloadNow()
141 if (Forward_DllCanUnloadNow
)
142 return Forward_DllCanUnloadNow();
147 extern "C" HRESULT __stdcall
DllRegisterServer()
150 if (Forward_DllRegisterServer
)
151 return Forward_DllRegisterServer();
156 extern "C" HRESULT __stdcall
DllUnregisterServer()
160 if (Forward_DllUnregisterServer
)
161 return Forward_DllUnregisterServer();