summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-09-26 11:28:57 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-09-30 11:23:41 +0200
commit362a21d3a129b90149f6ef645c127f5e86e0ba61 (patch)
tree8583cb29b33de56e4489cb8950d2714a1fb2957e /fpicker
parent81ce629c9e8a4fc26ded9d49157e3f3263991e03 (diff)
Use explicit function names for fooA/fooW WinAPI; prefer fooW
We should only use generic foo function name when it takes params that are also dependent on UNICODE define, like LoadCursor( nullptr, IDC_ARROW ) where IDC_ARROW is defined in MSVC headers synchronised with LoadCursor definition. We should always use Unicode API for any file paths operations, because otherwise we will get "?" for any character in path that is not in current non-unicode codepage, which will result in failed file operations. Change-Id: I3a7f453ca0f893002d8a9764318919709fd8b633 Reviewed-on: https://gerrit.libreoffice.org/42935 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx4
-rw-r--r--fpicker/source/win32/folderpicker/MtaFop.cxx59
2 files changed, 31 insertions, 32 deletions
diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
index c3ce95a8054b..c615abd49afd 100644
--- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
+++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
@@ -929,8 +929,8 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest)
OUString aSystemPath;
osl_getSystemPathFromFileURL( aFileURL.pData, &aSystemPath.pData );
- WIN32_FIND_DATA aFindFileData;
- HANDLE hFind = FindFirstFile( reinterpret_cast<PCWSTR>(aSystemPath.getStr()), &aFindFileData );
+ WIN32_FIND_DATAW aFindFileData;
+ HANDLE hFind = FindFirstFileW( SAL_W(aSystemPath.getStr()), &aFindFileData );
if (hFind != INVALID_HANDLE_VALUE)
iDialog->SetFolder(pFolder);
else
diff --git a/fpicker/source/win32/folderpicker/MtaFop.cxx b/fpicker/source/win32/folderpicker/MtaFop.cxx
index 5e5de9f612c4..e98c20b6e732 100644
--- a/fpicker/source/win32/folderpicker/MtaFop.cxx
+++ b/fpicker/source/win32/folderpicker/MtaFop.cxx
@@ -42,9 +42,9 @@ const bool INIT_NONSIGNALED = false;
namespace
{
- const char* const FOLDERPICKER_SRV_DLL_NAME = "fps.dll";
- const char g_szWndClsName[] = "FopStaReqWnd###";
- const char* const CURRENT_INSTANCE = "CurrInst";
+ const wchar_t* const FOLDERPICKER_SRV_DLL_NAME = L"fps.dll";
+ const wchar_t g_szWndClsName[] = L"FopStaReqWnd###";
+ const wchar_t* const CURRENT_INSTANCE = L"CurrInst";
struct RequestContext
{
@@ -56,7 +56,7 @@ namespace
{
OSL_ASSERT( aRequestContext );
- aRequestContext->hEvent = CreateEventA(
+ aRequestContext->hEvent = CreateEventW(
nullptr, AUTO_RESET, INIT_NONSIGNALED, nullptr );
aRequestContext->bRet = false;
@@ -106,7 +106,7 @@ CMtaFolderPicker::CMtaFolderPicker( sal_uInt32 Flags ) :
m_hEvtThrdReady( nullptr ),
m_hwndStaRequestWnd( nullptr )
{
- m_hInstance = GetModuleHandleA( FOLDERPICKER_SRV_DLL_NAME );
+ m_hInstance = GetModuleHandleW( FOLDERPICKER_SRV_DLL_NAME );
OSL_ENSURE( m_hInstance, "The name of the FolderPicker service dll must have changed" );
ZeroMemory( &m_bi, sizeof( m_bi ) );
@@ -142,7 +142,7 @@ CMtaFolderPicker::CMtaFolderPicker( sal_uInt32 Flags ) :
m_Description = CResourceProvider::getResString(FOLDER_PICKER_DEF_DESCRIPTION);
// signals that the thread was successfully set up
- m_hEvtThrdReady = CreateEventA(
+ m_hEvtThrdReady = CreateEventW(
nullptr,
MANUAL_RESET,
INIT_NONSIGNALED,
@@ -187,7 +187,7 @@ CMtaFolderPicker::~CMtaFolderPicker( )
// the thread that created the window
if ( IsWindow( m_hwndStaRequestWnd ) )
{
- SendMessageA( m_hwndStaRequestWnd, MSG_SHUTDOWN, 0, 0 );
+ SendMessageW( m_hwndStaRequestWnd, MSG_SHUTDOWN, 0, 0 );
// we place unregister class here because
// if we have a valid window we must have
@@ -243,7 +243,7 @@ bool CMtaFolderPicker::browseForFolder( )
}
// marshall request into the sta thread
- BOOL const ret = PostMessageA(
+ BOOL const ret = PostMessageW(
m_hwndStaRequestWnd,
MSG_BROWSEFORFOLDER,
0,
@@ -278,8 +278,8 @@ bool CMtaFolderPicker::browseForFolder( )
// mouse messages are for the FolderPicker which
// is in the foreground and should not arrive here
MSG msg;
- while ( PeekMessageA( &msg, nullptr, 0, 0, PM_REMOVE ) )
- DispatchMessageA(&msg);
+ while ( PeekMessageW( &msg, nullptr, 0, 0, PM_REMOVE ) )
+ DispatchMessageW(&msg);
}
break;
@@ -346,7 +346,7 @@ void SAL_CALL CMtaFolderPicker::cancel( )
{
// simulate a mouse click to the
// cancel button
- BOOL const ret = PostMessageA(
+ BOOL const ret = PostMessageW(
m_hwnd,
WM_COMMAND,
MAKEWPARAM( IDCANCEL, BN_CLICKED ),
@@ -425,7 +425,7 @@ OUString SAL_CALL CMtaFolderPicker::getPathFromItemIdList( LPCITEMIDLIST lpItemI
if ( lpItemIdList )
{
- bool bRet = SHGetPathFromIDListW( lpItemIdList, reinterpret_cast<LPWSTR>(m_pathBuff) );
+ bool bRet = SHGetPathFromIDListW( lpItemIdList, SAL_W(m_pathBuff) );
if ( bRet )
path = m_pathBuff;
}
@@ -476,7 +476,7 @@ void SAL_CALL CMtaFolderPicker::onInitialized( )
if ( lpiidDisplayDir )
{
- SendMessageA(
+ SendMessageW(
m_hwnd,
BFFM_SETSELECTION,
(WPARAM)false,
@@ -506,7 +506,7 @@ int CALLBACK CMtaFolderPicker::FolderPickerCallback( HWND hwnd, UINT uMsg, LPARA
case BFFM_INITIALIZED:
pImpl->m_hwnd = hwnd;
pImpl->onInitialized( );
- SetWindowTextW( hwnd, reinterpret_cast<LPCWSTR>(pImpl->m_dialogTitle.getStr()) );
+ SetWindowTextW( hwnd, SAL_W(pImpl->m_dialogTitle.getStr()) );
break;
case BFFM_SELCHANGED:
@@ -547,20 +547,20 @@ LRESULT CALLBACK CMtaFolderPicker::StaWndProc( HWND hWnd, UINT uMsg, WPARAM wPar
{
case WM_CREATE:
{
- LPCREATESTRUCT lpcs =
- reinterpret_cast< LPCREATESTRUCT >( lParam );
+ LPCREATESTRUCTW lpcs =
+ reinterpret_cast< LPCREATESTRUCTW >( lParam );
OSL_ASSERT( lpcs->lpCreateParams );
// connect the instance handle to the window
- SetPropA( hWnd, CURRENT_INSTANCE, lpcs->lpCreateParams );
+ SetPropW( hWnd, CURRENT_INSTANCE, lpcs->lpCreateParams );
}
break;
case WM_NCDESTROY:
// RemoveProp returns the saved value on success
pImpl = static_cast< CMtaFolderPicker* >(
- RemovePropA( hWnd, CURRENT_INSTANCE ) );
+ RemovePropW( hWnd, CURRENT_INSTANCE ) );
OSL_ASSERT( pImpl && !IsBadReadPtr( pImpl, sizeof( CMtaFolderPicker ) ) );
break;
@@ -571,7 +571,7 @@ LRESULT CALLBACK CMtaFolderPicker::StaWndProc( HWND hWnd, UINT uMsg, WPARAM wPar
OSL_ASSERT( aReqCtx );
pImpl = static_cast< CMtaFolderPicker* >(
- GetPropA( hWnd, CURRENT_INSTANCE ) );
+ GetPropW( hWnd, CURRENT_INSTANCE ) );
OSL_ASSERT( pImpl && !IsBadReadPtr( pImpl, sizeof( CMtaFolderPicker ) ) );
@@ -582,7 +582,7 @@ LRESULT CALLBACK CMtaFolderPicker::StaWndProc( HWND hWnd, UINT uMsg, WPARAM wPar
case MSG_SHUTDOWN:
pImpl = static_cast< CMtaFolderPicker* >(
- GetPropA( hWnd, CURRENT_INSTANCE ) );
+ GetPropW( hWnd, CURRENT_INSTANCE ) );
OSL_ASSERT( pImpl && !IsBadReadPtr( pImpl, sizeof( CMtaFolderPicker ) ) );
@@ -594,7 +594,7 @@ LRESULT CALLBACK CMtaFolderPicker::StaWndProc( HWND hWnd, UINT uMsg, WPARAM wPar
break;
default:
- lResult = DefWindowProcA( hWnd, uMsg, wParam, lParam );
+ lResult = DefWindowProcW( hWnd, uMsg, wParam, lParam );
break;
}
@@ -608,7 +608,7 @@ bool SAL_CALL CMtaFolderPicker::createStaRequestWindow( )
if ( RegisterStaRequestWindowClass( ) )
{
- m_hwndStaRequestWnd = CreateWindowA(
+ m_hwndStaRequestWnd = CreateWindowW(
g_szWndClsName, nullptr,
0, 0, 0, 0, 0,
nullptr, nullptr, m_hInstance,
@@ -653,8 +653,8 @@ unsigned int CMtaFolderPicker::run( )
// pumping messages
MSG msg;
- while( GetMessageA( &msg, nullptr, 0, 0 ) )
- DispatchMessageA( &msg );
+ while( GetMessageW( &msg, nullptr, 0, 0 ) )
+ DispatchMessageW( &msg );
nRet = 0;
}
@@ -697,11 +697,11 @@ ATOM SAL_CALL CMtaFolderPicker::RegisterStaRequestWindowClass( )
if ( 0 == s_ClassAtom )
{
- WNDCLASSEXA wcex;
+ WNDCLASSEXW wcex;
- ZeroMemory( &wcex, sizeof( WNDCLASSEXA ) );
+ ZeroMemory( &wcex, sizeof( wcex ) );
- wcex.cbSize = sizeof(WNDCLASSEXA);
+ wcex.cbSize = sizeof(wcex);
wcex.style = 0;
wcex.lpfnWndProc = static_cast< WNDPROC >( CMtaFolderPicker::StaWndProc );
wcex.cbClsExtra = 0;
@@ -714,7 +714,7 @@ ATOM SAL_CALL CMtaFolderPicker::RegisterStaRequestWindowClass( )
wcex.lpszClassName = g_szWndClsName;
wcex.hIconSm = nullptr;
- s_ClassAtom = RegisterClassExA( &wcex );
+ s_ClassAtom = RegisterClassExW( &wcex );
OSL_ASSERT( s_ClassAtom );
}
@@ -745,8 +745,7 @@ void SAL_CALL CMtaFolderPicker::UnregisterStaRequestWindowClass( )
if ( 0 == s_StaRequestWndRegisterCount )
{
- UnregisterClassA(
- reinterpret_cast<PCSTR>((DWORD_PTR)MAKELONG( s_ClassAtom, 0 )), m_hInstance );
+ UnregisterClass( MAKEINTATOM(s_ClassAtom), m_hInstance );
s_ClassAtom = 0;
}