diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-20 20:20:44 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-22 20:53:30 +0200 |
commit | eef4c133e9649ebd690918bd7b83c2d5dc0dfcff (patch) | |
tree | 1a8d084c5b16056a15258770a05b9cd2d53a40bc /dtrans | |
parent | bb406680cebd6fa1e1bdb9e2de430cd9a1f44da0 (diff) |
Windows: avoid dependence on UNICODE define; prefer W functions
Change-Id: I95b90128e93f0d88ed73601bcc5a7ca9279d4cf1
Reviewed-on: https://gerrit.libreoffice.org/42560
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'dtrans')
-rw-r--r-- | dtrans/source/win32/clipb/MtaOleClipb.cxx | 47 | ||||
-rw-r--r-- | dtrans/source/win32/workbench/XTDo.cxx | 1 | ||||
-rw-r--r-- | dtrans/test/win32/dnd/dndTest.cxx | 29 |
3 files changed, 39 insertions, 38 deletions
diff --git a/dtrans/source/win32/clipb/MtaOleClipb.cxx b/dtrans/source/win32/clipb/MtaOleClipb.cxx index e80b048d7101..91585935c5b9 100644 --- a/dtrans/source/win32/clipb/MtaOleClipb.cxx +++ b/dtrans/source/win32/clipb/MtaOleClipb.cxx @@ -35,7 +35,10 @@ // characters in the debug information #endif -//#define UNICODE +#if !defined WINVER +#define WINVER 0x0400 +#endif + #include <osl/diagnose.h> #include <sal/log.hxx> @@ -54,8 +57,8 @@ using osl::ClearableMutexGuard; namespace /* private */ { - char CLIPSRV_DLL_NAME[] = "sysdtrans.dll"; - char g_szWndClsName[] = "MtaOleReqWnd###"; + wchar_t CLIPSRV_DLL_NAME[] = L"sysdtrans.dll"; + wchar_t g_szWndClsName[] = L"MtaOleReqWnd###"; // messages constants @@ -86,7 +89,7 @@ namespace /* private */ // ctor Win32Condition() { - m_hEvent = CreateEvent( + m_hEvent = CreateEventW( nullptr, /* no security */ true, /* manual reset */ false, /* initial state not signaled */ @@ -119,7 +122,7 @@ namespace /* private */ queue that's what we want, messages from the PostMessage queue stay untouched */ MSG msg; - PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE); + PeekMessageW(&msg, nullptr, 0, 0, PM_NOREMOVE); break; } @@ -248,7 +251,7 @@ CMtaOleClipboard::CMtaOleClipboard( ) : m_ClipboardChangedEventCount( 0 ) { // signals that the thread was successfully setup - m_hEvtThrdReady = CreateEventA( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr ); + m_hEvtThrdReady = CreateEventW( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr ); OSL_ASSERT( nullptr != m_hEvtThrdReady ); @@ -260,10 +263,10 @@ CMtaOleClipboard::CMtaOleClipboard( ) : // setup the clipboard changed notifier thread - m_hClipboardChangedNotifierEvents[0] = CreateEventA( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr ); + m_hClipboardChangedNotifierEvents[0] = CreateEventW( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr ); OSL_ASSERT( nullptr != m_hClipboardChangedNotifierEvents[0] ); - m_hClipboardChangedNotifierEvents[1] = CreateEventA( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr ); + m_hClipboardChangedNotifierEvents[1] = CreateEventW( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr ); OSL_ASSERT( nullptr != m_hClipboardChangedNotifierEvents[1] ); unsigned uThreadId; @@ -315,7 +318,7 @@ CMtaOleClipboard::~CMtaOleClipboard( ) CloseHandle( m_hEvtThrdReady ); if ( m_MtaOleReqWndClassAtom ) - UnregisterClassA( g_szWndClsName, nullptr ); + UnregisterClassW( g_szWndClsName, nullptr ); OSL_ENSURE( ( nullptr == m_pfncClipViewerCallback ) && !IsWindow( m_hwndNextClipViewer ), @@ -516,7 +519,7 @@ LRESULT CMtaOleClipboard::onChangeCBChain( HWND hWndRemove, HWND hWndNext ) { // forward the message to the next one DWORD_PTR dwpResult; - SendMessageTimeoutA( + SendMessageTimeoutW( m_hwndNextClipViewer, WM_CHANGECBCHAIN, reinterpret_cast<WPARAM>(hWndRemove), @@ -549,7 +552,7 @@ LRESULT CMtaOleClipboard::onDrawClipboard( ) if ( IsWindow( m_hwndNextClipViewer ) ) { DWORD_PTR dwpResult; - SendMessageTimeoutA( + SendMessageTimeoutW( m_hwndNextClipViewer, WM_DRAWCLIPBOARD, static_cast< WPARAM >( 0 ), @@ -567,7 +570,7 @@ LRESULT CMtaOleClipboard::onDrawClipboard( ) LRESULT CMtaOleClipboard::sendMessage( UINT msg, WPARAM wParam, LPARAM lParam ) { - return ::SendMessageA( m_hwndMtaOleReqWnd, msg, wParam, lParam ); + return ::SendMessageW( m_hwndMtaOleReqWnd, msg, wParam, lParam ); } // PostMessage so we don't need to supply the HWND if we send @@ -575,7 +578,7 @@ LRESULT CMtaOleClipboard::sendMessage( UINT msg, WPARAM wParam, LPARAM lParam ) bool CMtaOleClipboard::postMessage( UINT msg, WPARAM wParam, LPARAM lParam ) { - BOOL const ret = PostMessageA(m_hwndMtaOleReqWnd, msg, wParam, lParam); + BOOL const ret = PostMessageW(m_hwndMtaOleReqWnd, msg, wParam, lParam); SAL_WARN_IF(0 == ret, "dtrans", "ERROR: PostMessage() failed!"); return ret; } @@ -658,7 +661,7 @@ LRESULT CALLBACK CMtaOleClipboard::mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARA break; default: - lResult = DefWindowProcA( hWnd, uMsg, wParam, lParam ); + lResult = DefWindowProcW( hWnd, uMsg, wParam, lParam ); break; } @@ -667,14 +670,14 @@ LRESULT CALLBACK CMtaOleClipboard::mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARA void CMtaOleClipboard::createMtaOleReqWnd( ) { - WNDCLASSEXA wcex; + WNDCLASSEXW wcex; - HINSTANCE hInst = GetModuleHandleA( CLIPSRV_DLL_NAME ); + HINSTANCE hInst = GetModuleHandleW( CLIPSRV_DLL_NAME ); OSL_ENSURE( nullptr != hInst, "The name of the clipboard service dll must have changed" ); - ZeroMemory( &wcex, sizeof( WNDCLASSEXA ) ); + ZeroMemory( &wcex, sizeof(wcex) ); - wcex.cbSize = sizeof(WNDCLASSEXA); + wcex.cbSize = sizeof(wcex); wcex.style = 0; wcex.lpfnWndProc = static_cast< WNDPROC >( CMtaOleClipboard::mtaOleReqWndProc ); wcex.cbClsExtra = 0; @@ -687,10 +690,10 @@ void CMtaOleClipboard::createMtaOleReqWnd( ) wcex.lpszClassName = g_szWndClsName; wcex.hIconSm = nullptr; - m_MtaOleReqWndClassAtom = RegisterClassExA( &wcex ); + m_MtaOleReqWndClassAtom = RegisterClassExW( &wcex ); if ( 0 != m_MtaOleReqWndClassAtom ) - m_hwndMtaOleReqWnd = CreateWindowA( + m_hwndMtaOleReqWnd = CreateWindowW( g_szWndClsName, nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, hInst, nullptr ); } @@ -710,8 +713,8 @@ unsigned int CMtaOleClipboard::run( ) // pumping messages MSG msg; - while( GetMessageA( &msg, nullptr, 0, 0 ) ) - DispatchMessageA( &msg ); + while( GetMessageW( &msg, nullptr, 0, 0 ) ) + DispatchMessageW( &msg ); nRet = 0; } diff --git a/dtrans/source/win32/workbench/XTDo.cxx b/dtrans/source/win32/workbench/XTDo.cxx index 2aecc0c5bf22..f8da707d92e3 100644 --- a/dtrans/source/win32/workbench/XTDo.cxx +++ b/dtrans/source/win32/workbench/XTDo.cxx @@ -32,7 +32,6 @@ #pragma warning(pop) #endif #include <memory> -#include <tchar.h> using namespace ::std; diff --git a/dtrans/test/win32/dnd/dndTest.cxx b/dtrans/test/win32/dnd/dndTest.cxx index 16d16f74f891..b9f1d841e1c5 100644 --- a/dtrans/test/win32/dnd/dndTest.cxx +++ b/dtrans/test/win32/dnd/dndTest.cxx @@ -22,7 +22,6 @@ #endif #include <windows.h> #include <comdef.h> -#include <tchar.h> #include <atlbase.h> CComModule _Module; #include <atlcom.h> @@ -59,11 +58,11 @@ int main( int argc, char *argv[ ], char *envp[ ] ) HRESULT hr; if( FAILED( hr=CoInitialize(NULL ))) { - _tprintf(_T("CoInitialize failed \n")); + printf("CoInitialize failed \n"); return -1; } - _Module.Init( ObjectMap, GetModuleHandle( NULL)); + _Module.Init( ObjectMap, GetModuleHandleA( NULL)); if( FAILED(hr=doTest())) { @@ -82,7 +81,7 @@ HRESULT doTest() // create the MTA thread that is used to realize MTA calls to the services // We create the thread and wait until the thread has created its message queue - HANDLE evt= CreateEvent(NULL, FALSE, FALSE, NULL); + HANDLE evt= CreateEventA(NULL, FALSE, FALSE, NULL); DWORD threadIdMTA=0; HANDLE hMTAThread= CreateThread( NULL, 0, MTAFunc, &evt, 0, &threadIdMTA); WaitForSingleObject( evt, INFINITE); @@ -90,27 +89,27 @@ HRESULT doTest() HRESULT hr= S_OK; RECT pos1={0,0,300,200}; - AWindow win(_T("DnD starting in Ole STA"), threadIdMTA, pos1); + AWindow win("DnD starting in Ole STA", threadIdMTA, pos1); RECT pos2={ 0, 205, 300, 405}; - AWindow win2( _T("DnD starting in MTA"), threadIdMTA, pos2, true); + AWindow win2("DnD starting in MTA", threadIdMTA, pos2, true); // win3 and win4 call initialize from an MTA but they are created in an STA RECT pos3={300,0,600,200}; - AWindow win3(_T("DnD starting in OLE STA"), threadIdMTA, pos3, false, true); + AWindow win3("DnD starting in OLE STA", threadIdMTA, pos3, false, true); RECT pos4={ 300, 205, 600, 405}; - AWindow win24( _T("DnD starting in Ole MTA"), threadIdMTA, pos4, true, true); + AWindow win24("DnD starting in Ole MTA", threadIdMTA, pos4, true, true); MSG msg; - while( GetMessage(&msg, (HWND)NULL, 0, 0) ) + while( GetMessageA(&msg, (HWND)NULL, 0, 0) ) { TranslateMessage( &msg); - DispatchMessage( &msg); + DispatchMessageA( &msg); } // Shut down the MTA thread - PostThreadMessage( threadIdMTA, WM_QUIT, 0, 0); + PostThreadMessageA( threadIdMTA, WM_QUIT, 0, 0); WaitForSingleObject(hMTAThread, INFINITE); CloseHandle(hMTAThread); @@ -124,13 +123,13 @@ DWORD WINAPI MTAFunc( void* threadData) ATLASSERT( FAILED(hr) ); MSG msg; // force the creation of a message queue - PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); + PeekMessageA(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); SetEvent( *(HANDLE*)threadData ); RECT pos={0, 406, 300, 605}; - AWindow win(_T("DnD, full MTA"), GetCurrentThreadId(), pos, false, true); + AWindow win("DnD, full MTA", GetCurrentThreadId(), pos, false, true); - while( GetMessage(&msg, (HWND)NULL, 0, 0) ) + while( GetMessageA(&msg, (HWND)NULL, 0, 0) ) { switch( msg.message) { @@ -168,7 +167,7 @@ DWORD WINAPI MTAFunc( void* threadData) } // end switch TranslateMessage( &msg); - DispatchMessage( &msg); + DispatchMessageA( &msg); } CoUninitialize(); |