Kaydet (Commit) 515d2579 authored tarafından Mike Kaganski's avatar Mike Kaganski

Replace legacy dynamically-loaded functions with statically linked ones

We don't need the dynamic load complexity for these now with baseline
Windows version being Windows 7 SP1. Stuff used only for compatibility
with older versions was dumped.

Change-Id: I810f271796cfd875cfa18a3081c9ad444fe57b3e
Reviewed-on: https://gerrit.libreoffice.org/70321
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst edd163b5
......@@ -65,50 +65,6 @@ namespace dxcanvas
{
namespace
{
// monitorSupport
class monitorSupport
{
public:
monitorSupport() :
mhLibrary(LoadLibraryW(L"user32.dll")),
mpMonitorFromWindow(nullptr)
{
if(mhLibrary)
mpMonitorFromWindow = reinterpret_cast<fMonitorFromWindow>(
GetProcAddress(
mhLibrary,"MonitorFromWindow"));
}
~monitorSupport()
{
if(mhLibrary)
FreeLibrary(mhLibrary);
mhLibrary=nullptr;
}
HMONITOR MonitorFromWindow( HWND hwnd )
{
// return adapter_default in case something went wrong...
if(!mpMonitorFromWindow)
return HMONITOR(nullptr);
// MONITOR_DEFAULTTONEAREST
const DWORD dwFlags(0x00000002);
return mpMonitorFromWindow(hwnd,dwFlags);
}
private:
HINSTANCE mhLibrary;
typedef HMONITOR (WINAPI *fMonitorFromWindow )( HWND hwnd, DWORD dwFlags );
fMonitorFromWindow mpMonitorFromWindow;
};
monitorSupport aMonitorSupport;
class DXRenderModule;
......@@ -1100,7 +1056,7 @@ namespace dxcanvas
UINT DXRenderModule::getAdapterFromWindow()
{
HMONITOR hMonitor(aMonitorSupport.MonitorFromWindow(mhWnd));
HMONITOR hMonitor(MonitorFromWindow(mhWnd, MONITOR_DEFAULTTONEAREST));
UINT aAdapterCount(mpDirect3D9->GetAdapterCount());
for(UINT i=0; i<aAdapterCount; ++i)
if(hMonitor == mpDirect3D9->GetAdapterMonitor(i))
......
......@@ -15,6 +15,11 @@ $(eval $(call gb_Executable_use_libraries,odbcconfig,\
comphelper \
))
$(eval $(call gb_Executable_use_system_win32_libs,odbcconfig,\
legacy_stdio_definitions \
odbccp32 \
))
$(eval $(call gb_Library_use_sdk_api,odbcconfig))
$(eval $(call gb_Executable_add_exception_objects,odbcconfig,\
......
......@@ -22,14 +22,7 @@
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <sqlext.h>
#include <comphelper/scopeguard.hxx>
// the name of the library which contains the SQLManageDataSources function
#define ODBC_UI_LIB_NAME L"ODBCCP32.DLL"
// the signature of the SQLManageDataSources function
typedef SQLRETURN (SQL_API* TSQLManageDataSource) (SQLHWND hwndParent);
#include <odbcinst.h>
// displays the error text for the last error (GetLastError), and returns this error value
static int displayLastError()
......@@ -109,19 +102,7 @@ extern "C" int APIENTRY wWinMain( HINSTANCE _hAppInstance, HINSTANCE, LPWSTR, in
if ( !IsWindow( hAppWindow ) )
return displayLastError();
HMODULE hModule = LoadLibraryW( ODBC_UI_LIB_NAME );
if ( hModule == nullptr )
hModule = LoadLibraryExW( ODBC_UI_LIB_NAME, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
if ( hModule == nullptr )
return displayLastError();
comphelper::ScopeGuard hModuleReleaser([hModule]() { FreeLibrary(hModule); });
FARPROC pManageDSProc = GetProcAddress( hModule, "SQLManageDataSources" );
if ( pManageDSProc == nullptr )
return displayLastError();
TSQLManageDataSource pManageDS = reinterpret_cast<TSQLManageDataSource>(pManageDSProc);
if ( !( (*pManageDS)( hAppWindow ) ) )
if (!SQLManageDataSources(hAppWindow))
return displayLastError();
return 0;
......
......@@ -50,6 +50,8 @@ $(eval $(call gb_Library_use_system_win32_libs,sal,\
ole32 \
shell32 \
user32 \
userenv \
wer \
ws2_32 \
))
......
This diff is collapsed.
......@@ -33,24 +33,11 @@ extern "C" {
void sal_detail_initialize(int argc, char ** argv)
{
sal_initGlobalTimer();
HMODULE h = GetModuleHandleW(L"kernel32.dll");
if (h != nullptr) {
FARPROC p;
#ifndef _WIN64
p = GetProcAddress(h, "SetProcessDEPPolicy");
if (p != 0) {
reinterpret_cast< BOOL (WINAPI *)(DWORD) >(p)(0x00000001);
}
SetProcessDEPPolicy(PROCESS_DEP_ENABLE);
#endif
p = GetProcAddress(h, "SetDllDirectoryW");
if (p != nullptr) {
reinterpret_cast< BOOL (WINAPI *)(LPCWSTR) >(p)(L"");
}
p = GetProcAddress(h, "SetSearchPathMode");
if (p != nullptr) {
reinterpret_cast< BOOL (WINAPI *)(DWORD) >(p)(0x8001);
}
}
SetDllDirectoryW(L""); // remove the current directory from the default DLL search order
SetSearchPathMode(BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT);
WSADATA wsaData;
int error;
......
This diff is collapsed.
......@@ -27,6 +27,7 @@
#include <systools/win32/uwinapi.h>
#include <errorrep.h>
#include <werapi.h>
namespace
{
......@@ -39,14 +40,7 @@ bool onInitSignal()
{
pPreviousHandler = SetUnhandledExceptionFilter(signalHandlerFunction);
HMODULE hFaultRep = LoadLibraryW( L"faultrep.dll" );
if ( hFaultRep )
{
pfn_ADDEREXCLUDEDAPPLICATIONW pfn = reinterpret_cast<pfn_ADDEREXCLUDEDAPPLICATIONW>(GetProcAddress( hFaultRep, "AddERExcludedApplicationW" ));
if ( pfn )
pfn( L"SOFFICE.EXE" );
FreeLibrary( hFaultRep );
}
WerAddExcludedApplication(L"SOFFICE.EXE", FALSE);
return true;
}
......
......@@ -93,17 +93,14 @@ static bool IsValidHandle( HANDLE handle )
static DWORD WINAPI GetModuleFileNameExW_( HANDLE hProcess, HMODULE hModule, PWSTR lpFileName, DWORD nSize )
{
typedef DWORD (WINAPI *FN_PROC)( HANDLE hProcess, HMODULE hModule, LPWSTR lpFileName, DWORD nSize );
static FN_PROC lpProc = nullptr;
if ( !lpProc )
{
static auto lpProc = []() {
HMODULE hLibrary = LoadLibraryW(L"PSAPI.DLL");
if ( hLibrary )
lpProc = reinterpret_cast< FN_PROC >(GetProcAddress( hLibrary, "GetModuleFileNameExW" ));
}
decltype(GetModuleFileNameExW)* pRet = nullptr;
if (hLibrary)
pRet = reinterpret_cast<decltype(GetModuleFileNameExW)*>(
GetProcAddress(hLibrary, "GetModuleFileNameExW"));
return pRet;
}();
if ( lpProc )
return lpProc( hProcess, hModule, lpFileName, nSize );
......
......@@ -82,6 +82,8 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_win,\
))
$(eval $(call gb_Library_use_system_win32_libs,vclplug_win,\
d2d1 \
dwrite \
gdi32 \
gdiplus \
imm32 \
......
......@@ -36,19 +36,7 @@ enum class D2DTextAntiAliasMode
class D2DWriteTextOutRenderer : public TextOutRenderer
{
typedef HRESULT(WINAPI *pD2D1CreateFactory_t)(D2D1_FACTORY_TYPE,
REFIID, const D2D1_FACTORY_OPTIONS *, void **);
typedef HRESULT(WINAPI *pDWriteCreateFactory_t)(DWRITE_FACTORY_TYPE,
REFIID, IUnknown **);
static HINSTANCE mmD2d1, mmDWrite;
static pD2D1CreateFactory_t D2D1CreateFactory;
static pDWriteCreateFactory_t DWriteCreateFactory;
public:
static bool InitModules();
explicit D2DWriteTextOutRenderer();
virtual ~D2DWriteTextOutRenderer() override;
......@@ -74,8 +62,6 @@ public:
void changeTextAntiAliasMode(D2DTextAntiAliasMode eMode);
private:
static void CleanupModules();
// This is a singleton object disable copy ctor and assignment operator
D2DWriteTextOutRenderer(const D2DWriteTextOutRenderer &) = delete;
D2DWriteTextOutRenderer & operator = (const D2DWriteTextOutRenderer &) = delete;
......
......@@ -32,43 +32,6 @@
#include <comphelper/windowserrorstring.hxx>
#include <sal/log.hxx>
HINSTANCE D2DWriteTextOutRenderer::mmD2d1 = nullptr,
D2DWriteTextOutRenderer::mmDWrite = nullptr;
D2DWriteTextOutRenderer::pD2D1CreateFactory_t D2DWriteTextOutRenderer::D2D1CreateFactory = nullptr;
D2DWriteTextOutRenderer::pDWriteCreateFactory_t D2DWriteTextOutRenderer::DWriteCreateFactory = nullptr;
bool D2DWriteTextOutRenderer::InitModules()
{
mmD2d1 = LoadLibraryW(L"D2d1.dll");
mmDWrite = LoadLibraryW(L"dwrite.dll");
if (mmD2d1 && mmDWrite)
{
D2D1CreateFactory = pD2D1CreateFactory_t(GetProcAddress(mmD2d1, "D2D1CreateFactory"));
DWriteCreateFactory = pDWriteCreateFactory_t(GetProcAddress(mmDWrite, "DWriteCreateFactory"));
}
if (!D2D1CreateFactory || !DWriteCreateFactory)
{
CleanupModules();
return false;
}
return true;
}
void D2DWriteTextOutRenderer::CleanupModules()
{
if (mmD2d1)
FreeLibrary(mmD2d1);
if (mmDWrite)
FreeLibrary(mmDWrite);
mmD2d1 = nullptr;
mmDWrite = nullptr;
D2D1CreateFactory = nullptr;
DWriteCreateFactory = nullptr;
}
namespace
{
......@@ -167,8 +130,6 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer()
mpDWriteFactory->Release();
if (mpD2DFactory)
mpD2DFactory->Release();
CleanupModules();
}
void D2DWriteTextOutRenderer::applyTextAntiAliasMode()
......
......@@ -210,16 +210,11 @@ TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
if (bUseDWrite)
{
static bool const bSuccess(D2DWriteTextOutRenderer::InitModules());
if (bSuccess && !pSalData->m_pD2DWriteTextOutRenderer)
if (!pSalData->m_pD2DWriteTextOutRenderer)
{
pSalData->m_pD2DWriteTextOutRenderer.reset(new D2DWriteTextOutRenderer());
}
if (pSalData->m_pD2DWriteTextOutRenderer)
{
return *pSalData->m_pD2DWriteTextOutRenderer;
}
// else: fall back to GDI
return *pSalData->m_pD2DWriteTextOutRenderer;
}
if (!pSalData->m_pExTextOutRenderer)
{
......
......@@ -1794,34 +1794,26 @@ void WinSalFrame::SetApplicationID( const OUString &rApplicationID )
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd378430(v=vs.85).aspx
// A window's properties must be removed before the window is closed.
typedef HRESULT ( WINAPI *SHGETPROPERTYSTOREFORWINDOW )( HWND, REFIID, void ** );
SHGETPROPERTYSTOREFORWINDOW pSHGetPropertyStoreForWindow;
pSHGetPropertyStoreForWindow = reinterpret_cast<SHGETPROPERTYSTOREFORWINDOW>(GetProcAddress(
GetModuleHandleW (L"shell32.dll"), "SHGetPropertyStoreForWindow" ));
if( pSHGetPropertyStoreForWindow )
IPropertyStore *pps;
HRESULT hr = SHGetPropertyStoreForWindow(mhWnd, IID_PPV_ARGS(&pps));
if (SUCCEEDED(hr))
{
IPropertyStore *pps;
HRESULT hr = pSHGetPropertyStoreForWindow ( mhWnd, IID_PPV_ARGS(&pps) );
if ( SUCCEEDED(hr) )
PROPVARIANT pv;
if (!rApplicationID.isEmpty())
{
PROPVARIANT pv;
if ( !rApplicationID.isEmpty() )
{
hr = InitPropVariantFromString( o3tl::toW(rApplicationID.getStr()), &pv );
mbPropertiesStored = true;
}
else
// if rApplicationID we remove the property from the window, if present
PropVariantInit( &pv );
hr = InitPropVariantFromString(o3tl::toW(rApplicationID.getStr()), &pv);
mbPropertiesStored = true;
}
else
// if rApplicationID we remove the property from the window, if present
PropVariantInit(&pv);
if ( SUCCEEDED(hr) )
{
hr = pps->SetValue( PKEY_AppUserModel_ID, pv );
PropVariantClear( &pv );
}
pps->Release();
if (SUCCEEDED(hr))
{
hr = pps->SetValue(PKEY_AppUserModel_ID, pv);
PropVariantClear(&pv);
}
pps->Release();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment