From 74185b8edf7f046a3372319da86a1d8ca0024c87 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 25 Feb 2024 19:28:24 +0600 Subject: Link to oledlg, and use OleUIInsertObjectW directly ... instead of manually loading and using OleUIInsertObjectA. Change-Id: I597dd44e13edf8c94d83f434b57142c88e5aca6f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163922 Tested-by: Mike Kaganski Reviewed-by: Mike Kaganski --- embeddedobj/Library_emboleobj.mk | 1 + embeddedobj/source/msole/xdialogcreator.cxx | 25 ++++++------------------- 2 files changed, 7 insertions(+), 19 deletions(-) (limited to 'embeddedobj') diff --git a/embeddedobj/Library_emboleobj.mk b/embeddedobj/Library_emboleobj.mk index d92f86f2c7d3..661bd655358b 100644 --- a/embeddedobj/Library_emboleobj.mk +++ b/embeddedobj/Library_emboleobj.mk @@ -55,6 +55,7 @@ $(eval $(call gb_Library_use_system_win32_libs,emboleobj,\ gdi32 \ ole32 \ oleaut32 \ + oledlg \ uuid \ )) diff --git a/embeddedobj/source/msole/xdialogcreator.cxx b/embeddedobj/source/msole/xdialogcreator.cxx index 7e4e99156291..74b267eca22f 100644 --- a/embeddedobj/source/msole/xdialogcreator.cxx +++ b/embeddedobj/source/msole/xdialogcreator.cxx @@ -51,6 +51,7 @@ #ifdef _WIN32 #include +#include #include namespace { @@ -140,34 +141,21 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia InitializedOleGuard aGuard; - OLEUIINSERTOBJECT io = {}; - char szFile[MAX_PATH]; - UINT uTemp; - - io.cbStruct = sizeof(io); + OLEUIINSERTOBJECTW io{ sizeof(io) }; io.hWndOwner = GetActiveWindow(); + wchar_t szFile[MAX_PATH]; szFile[0] = 0; io.lpszFile = szFile; - io.cchFile = MAX_PATH; + io.cchFile = std::size(szFile); io.dwFlags = IOF_SELECTCREATENEW | IOF_DISABLELINK; - - ::osl::Module aOleDlgLib; - if( !aOleDlgLib.load( "oledlg" )) - throw uno::RuntimeException(); - - OleUIInsertObjectA_Type * pInsertFct = reinterpret_cast( - aOleDlgLib.getSymbol( "OleUIInsertObjectA" )); - if( !pInsertFct ) - throw uno::RuntimeException(); - // Disable any event loop shortcuts by enabling a real timer. // This way the native windows dialog won't block our own processing. WinScheduler::SetForceRealTimer(); - uTemp=pInsertFct(&io); + UINT uTemp = OleUIInsertObjectW(&io); if ( OLEUI_OK != uTemp ) throw ucb::CommandAbortedException(); @@ -196,8 +184,7 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia } else { - OUString aFileName - = OStringToOUString( std::string_view( szFile ), osl_getThreadTextEncoding() ); + OUString aFileName(o3tl::toU(szFile)); OUString aFileURL; if ( osl::FileBase::getFileURLFromSystemPath( aFileName, aFileURL ) != osl::FileBase::E_None ) throw uno::RuntimeException(); -- cgit