diff options
59 files changed, 479 insertions, 499 deletions
diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx index 4ba72ca9a368..268babd1b17c 100644 --- a/avmedia/source/win/player.cxx +++ b/avmedia/source/win/player.cxx @@ -44,7 +44,7 @@ namespace avmedia { namespace win { LRESULT CALLBACK MediaPlayerWndProc_2( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) { - Player* pPlayer = reinterpret_cast<Player*>(::GetWindowLongPtr( hWnd, 0 )); + Player* pPlayer = reinterpret_cast<Player*>(::GetWindowLongPtrW( hWnd, 0 )); bool bProcessed = true; if( pPlayer ) @@ -62,7 +62,7 @@ LRESULT CALLBACK MediaPlayerWndProc_2( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM else bProcessed = false; - return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) ); + return( bProcessed ? 0 : DefWindowProcW( hWnd, nMsg, nPar1, nPar2 ) ); } @@ -226,31 +226,31 @@ void SAL_CALL Player::start( ) { if ( mbAddWindow ) { - static WNDCLASS* mpWndClass = nullptr; + static WNDCLASSW* mpWndClass = nullptr; if ( !mpWndClass ) { - mpWndClass = new WNDCLASS; + mpWndClass = new WNDCLASSW; memset( mpWndClass, 0, sizeof( *mpWndClass ) ); - mpWndClass->hInstance = GetModuleHandle( nullptr ); + mpWndClass->hInstance = GetModuleHandleW( nullptr ); mpWndClass->cbWndExtra = sizeof( DWORD ); mpWndClass->lpfnWndProc = MediaPlayerWndProc_2; - mpWndClass->lpszClassName = "com_sun_star_media_Sound_Player"; + mpWndClass->lpszClassName = L"com_sun_star_media_Sound_Player"; mpWndClass->hbrBackground = static_cast<HBRUSH>(::GetStockObject( BLACK_BRUSH )); mpWndClass->hCursor = ::LoadCursor( nullptr, IDC_ARROW ); - ::RegisterClass( mpWndClass ); + RegisterClassW( mpWndClass ); } if ( !mnFrameWnd ) { - mnFrameWnd = ::CreateWindow( mpWndClass->lpszClassName, nullptr, - 0, - 0, 0, 0, 0, - nullptr, nullptr, mpWndClass->hInstance, nullptr ); + mnFrameWnd = CreateWindowW( mpWndClass->lpszClassName, nullptr, + 0, + 0, 0, 0, 0, + nullptr, nullptr, mpWndClass->hInstance, nullptr ); if ( mnFrameWnd ) { ::ShowWindow(mnFrameWnd, SW_HIDE); - ::SetWindowLongPtr( mnFrameWnd, 0, reinterpret_cast<LONG_PTR>(this) ); + SetWindowLongPtrW( mnFrameWnd, 0, reinterpret_cast<LONG_PTR>(this) ); // mpVW->put_Owner( (OAHWND) mnFrameWnd ); setNotifyWnd( mnFrameWnd ); } diff --git a/avmedia/source/win/window.cxx b/avmedia/source/win/window.cxx index 8b31cbb2fa61..16deeee09a1e 100644 --- a/avmedia/source/win/window.cxx +++ b/avmedia/source/win/window.cxx @@ -43,7 +43,7 @@ namespace avmedia { namespace win { LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) { - Window* pWindow = reinterpret_cast<Window*>(::GetWindowLongPtr( hWnd, 0 )); + Window* pWindow = reinterpret_cast<Window*>(GetWindowLongPtrW( hWnd, 0 )); bool bProcessed = true; if( pWindow ) @@ -136,22 +136,22 @@ LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM n else bProcessed = false; - return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) ); + return( bProcessed ? 0 : DefWindowProcW( hWnd, nMsg, nPar1, nPar2 ) ); } -WNDCLASS* lcl_getWndClass() +WNDCLASSW* lcl_getWndClass() { - WNDCLASS* s_pWndClass = new WNDCLASS; + WNDCLASSW* s_pWndClass = new WNDCLASSW; memset( s_pWndClass, 0, sizeof( *s_pWndClass ) ); - s_pWndClass->hInstance = GetModuleHandle( nullptr ); + s_pWndClass->hInstance = GetModuleHandleW( nullptr ); s_pWndClass->cbWndExtra = sizeof( DWORD ); s_pWndClass->lpfnWndProc = MediaPlayerWndProc; - s_pWndClass->lpszClassName = "com_sun_star_media_PlayerWnd"; + s_pWndClass->lpszClassName = L"com_sun_star_media_PlayerWnd"; s_pWndClass->hbrBackground = static_cast<HBRUSH>(::GetStockObject( BLACK_BRUSH )); s_pWndClass->hCursor = ::LoadCursor( nullptr, IDC_ARROW ); - ::RegisterClass( s_pWndClass ); + RegisterClassW( s_pWndClass ); return s_pWndClass; } @@ -261,7 +261,7 @@ void Window::ImplLayoutVideoWindow() bool Window::create( const uno::Sequence< uno::Any >& rArguments ) { IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() ); - static WNDCLASS* mpWndClass = lcl_getWndClass(); + static WNDCLASSW* mpWndClass = lcl_getWndClass(); if( !mnFrameWnd && pVideoWindow && mpWndClass ) { @@ -273,23 +273,23 @@ bool Window::create( const uno::Sequence< uno::Any >& rArguments ) mnParentWnd = reinterpret_cast<HWND>(nWnd); - mnFrameWnd = ::CreateWindow( mpWndClass->lpszClassName, nullptr, - WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - aRect.X, aRect.Y, aRect.Width, aRect.Height, - mnParentWnd, nullptr, mpWndClass->hInstance, nullptr ); + mnFrameWnd = CreateWindowW( mpWndClass->lpszClassName, nullptr, + WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + aRect.X, aRect.Y, aRect.Width, aRect.Height, + mnParentWnd, nullptr, mpWndClass->hInstance, nullptr ); if( mnFrameWnd ) { - ::SetWindowLongPtr( mnFrameWnd, 0, reinterpret_cast<LONG_PTR>(this) ); + SetWindowLongPtrW( mnFrameWnd, 0, reinterpret_cast<LONG_PTR>(this) ); - pVideoWindow->put_Owner( reinterpret_cast<OAHWND>(mnFrameWnd) ); - pVideoWindow->put_MessageDrain( reinterpret_cast<OAHWND>(mnFrameWnd) ); - pVideoWindow->put_WindowStyle( WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN ); + pVideoWindow->put_Owner( reinterpret_cast<OAHWND>(mnFrameWnd) ); + pVideoWindow->put_MessageDrain( reinterpret_cast<OAHWND>(mnFrameWnd) ); + pVideoWindow->put_WindowStyle( WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN ); - mrPlayer.setNotifyWnd( mnFrameWnd ); + mrPlayer.setNotifyWnd( mnFrameWnd ); - meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW; - ImplLayoutVideoWindow(); + meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW; + ImplLayoutVideoWindow(); } } @@ -303,7 +303,7 @@ void Window::processGraphEvent() void Window::updatePointer() { - char* pCursorName; + LPCTSTR pCursorName; switch( mnPointerType ) { @@ -316,7 +316,7 @@ void Window::updatePointer() break; } - ::SetCursor( ::LoadCursor( nullptr, pCursorName ) ); + SetCursor( LoadCursor( nullptr, pCursorName ) ); } void SAL_CALL Window::update( ) diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 8a0ae5d2ff36..cef5dd269a3a 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -2958,8 +2958,7 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite) OUString aPathURL = getFullPath( rPar.Get(1)->GetOUString() ); OUString aPath; FileBase::getSystemPathFromFileURL( aPathURL, aPath ); - OString aSystemPath(OUStringToOString(aPath, osl_getThreadTextEncoding())); - DWORD nRealFlags = GetFileAttributes (aSystemPath.getStr()); + DWORD nRealFlags = GetFileAttributesW (SAL_W(aPath.getStr())); if (nRealFlags != 0xffffffff) { if (nRealFlags == FILE_ATTRIBUTE_NORMAL) diff --git a/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c b/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c index dc3ee5b4bb35..b1b476356fd5 100644 --- a/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c +++ b/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c @@ -38,7 +38,7 @@ #define SYSTEM_WIN32 1 -#define OLD_PROC_KEY "oldwindowproc" +#define OLD_PROC_KEY L"oldwindowproc" static LRESULT APIENTRY OpenOfficeWndProc( HWND , UINT , WPARAM , LPARAM ); @@ -131,10 +131,10 @@ JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNative and calls on such construct produce a stack overflow. */ - if (GetProp( hWnd, OLD_PROC_KEY )==NULL) + if (GetPropW( hWnd, OLD_PROC_KEY )==NULL) { - hFuncPtr = SetWindowLongPtr( hWnd, GWLP_WNDPROC, (LONG_PTR)OpenOfficeWndProc ); - SetProp( hWnd, OLD_PROC_KEY, (HANDLE)hFuncPtr ); + hFuncPtr = SetWindowLongPtrW( hWnd, GWLP_WNDPROC, (LONG_PTR)OpenOfficeWndProc ); + SetPropW( hWnd, OLD_PROC_KEY, (HANDLE)hFuncPtr ); } return (jlong)hWnd; @@ -182,7 +182,7 @@ static LRESULT APIENTRY OpenOfficeWndProc( #pragma warning(push) #pragma warning(disable: 4152) /* function/data pointer conversion: */ #endif - return CallWindowProc(GetProp(hWnd, OLD_PROC_KEY), + return CallWindowProcW(GetPropW(hWnd, OLD_PROC_KEY), hWnd, uMsg, wParam, lParam); #if defined _MSC_VER #pragma warning(pop) diff --git a/canvas/source/directx/dx_9rm.cxx b/canvas/source/directx/dx_9rm.cxx index ce1d7d03b6d2..3cc7fd5437a3 100644 --- a/canvas/source/directx/dx_9rm.cxx +++ b/canvas/source/directx/dx_9rm.cxx @@ -73,7 +73,7 @@ namespace dxcanvas public: monitorSupport() : - mhLibrary(LoadLibrary("user32.dll")), + mhLibrary(LoadLibraryW(L"user32.dll")), mpMonitorFromWindow(nullptr) { if(mhLibrary) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index b08e928dd32c..7c194f890db9 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -2633,12 +2633,12 @@ void Desktop::CheckFirstRun( ) #ifdef _WIN32 // Check if Quickstarter should be started (on Windows only) - TCHAR szValue[8192]; + WCHAR szValue[8192]; DWORD nValueSize = sizeof(szValue); HKEY hKey; - if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, "Software\\LibreOffice", &hKey ) ) + if ( ERROR_SUCCESS == RegOpenKeyW( HKEY_LOCAL_MACHINE, L"Software\\LibreOffice", &hKey ) ) { - if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("RunQuickstartAtFirstStart"), nullptr, nullptr, reinterpret_cast<LPBYTE>(szValue), &nValueSize ) ) + if ( ERROR_SUCCESS == RegQueryValueExW( hKey, L"RunQuickstartAtFirstStart", nullptr, nullptr, reinterpret_cast<LPBYTE>(szValue), &nValueSize ) ) { css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); css::office::Quickstart::createAutoStart(xContext, true/*Quickstart*/, true/*bAutostart*/); diff --git a/desktop/source/app/cmdlinehelp.cxx b/desktop/source/app/cmdlinehelp.cxx index a4b3114cf3bb..43028a72fd10 100644 --- a/desktop/source/app/cmdlinehelp.cxx +++ b/desktop/source/app/cmdlinehelp.cxx @@ -187,9 +187,9 @@ namespace desktop { if (GetStdHandle(STD_OUTPUT_HANDLE) == nullptr) // application does not have associated standard handles { - STARTUPINFOA aStartupInfo; + STARTUPINFOW aStartupInfo; aStartupInfo.cb = sizeof(aStartupInfo); - GetStartupInfoA(&aStartupInfo); + GetStartupInfoW(&aStartupInfo); if ((aStartupInfo.dwFlags & STARTF_USESTDHANDLES) == STARTF_USESTDHANDLES) { // If standard handles had been passed to this process, use them @@ -247,11 +247,11 @@ namespace desktop ke.bKeyDown = TRUE; ke.wRepeatCount = 1; ke.wVirtualKeyCode = VK_RETURN; - ke.wVirtualScanCode = MapVirtualKeyA(VK_RETURN, MAPVK_VK_TO_VSC); - ke.uChar.AsciiChar = '\r'; + ke.wVirtualScanCode = MapVirtualKeyW(VK_RETURN, MAPVK_VK_TO_VSC); + ke.uChar.UnicodeChar = L'\r'; ke.dwControlKeyState = 0; DWORD nEvents; - WriteConsoleInputA(GetStdHandle(STD_INPUT_HANDLE), &ir, 1, &nEvents); + WriteConsoleInputW(GetStdHandle(STD_INPUT_HANDLE), &ir, 1, &nEvents); break; } case allocated: diff --git a/desktop/source/deployment/misc/lockfile.cxx b/desktop/source/deployment/misc/lockfile.cxx index 11530d0be892..0544f434bd14 100644 --- a/desktop/source/deployment/misc/lockfile.cxx +++ b/desktop/source/deployment/misc/lockfile.cxx @@ -55,7 +55,7 @@ static OString impl_getHostname() */ DWORD sz = MAX_COMPUTERNAME_LENGTH + 1; auto szHost = std::unique_ptr<char[]>(new char[sz]); - if (GetComputerName(szHost.get(), &sz)) + if (GetComputerNameA(szHost.get(), &sz)) aHost = OString(szHost.get()); else aHost = OString("UNKNOWN"); diff --git a/dtrans/source/win32/dnd/source.cxx b/dtrans/source/win32/dnd/source.cxx index b6d1d9a628bd..06c8e4977def 100644 --- a/dtrans/source/win32/dnd/source.cxx +++ b/dtrans/source/win32/dnd/source.cxx @@ -314,7 +314,7 @@ unsigned __stdcall DndOleSTAFunc(LPVOID pParams) // We force the creation of a thread message queue. This is necessary // for a later call to AttachThreadInput MSG msgtemp; - PeekMessage( &msgtemp, nullptr, WM_USER, WM_USER, PM_NOREMOVE); + PeekMessageW( &msgtemp, nullptr, WM_USER, WM_USER, PM_NOREMOVE); DWORD threadId= GetCurrentThreadId(); diff --git a/dtrans/source/win32/dnd/target.cxx b/dtrans/source/win32/dnd/target.cxx index b797d4e769d8..ab3c554ea5bc 100644 --- a/dtrans/source/win32/dnd/target.cxx +++ b/dtrans/source/win32/dnd/target.cxx @@ -76,7 +76,7 @@ void SAL_CALL DropTarget::disposing() if( m_threadIdTarget) { // Call RevokeDragDrop and wait for the OLE thread to die; - PostThreadMessage( m_threadIdTarget, WM_REVOKEDRAGDROP, reinterpret_cast<WPARAM>(this), 0); + PostThreadMessageW( m_threadIdTarget, WM_REVOKEDRAGDROP, reinterpret_cast<WPARAM>(this), 0); WaitForSingleObject( m_hOleThread, INFINITE); CloseHandle( m_hOleThread); //OSL_ENSURE( SUCCEEDED( hr), "HWND not valid!" ); @@ -142,13 +142,13 @@ void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments ) m_threadIdWindow= GetWindowThreadProcessId( m_hWnd, nullptr); // The event is set by the thread that we will create momentarily. // It indicates that the thread is ready to receive messages. - HANDLE m_evtThreadReady= CreateEvent( nullptr, FALSE, FALSE, nullptr); + HANDLE m_evtThreadReady= CreateEventW( nullptr, FALSE, FALSE, nullptr); m_hOleThread= CreateThread( nullptr, 0, DndTargetOleSTAFunc, &m_evtThreadReady, 0, &m_threadIdTarget); WaitForSingleObject( m_evtThreadReady, INFINITE); CloseHandle( m_evtThreadReady); - PostThreadMessage( m_threadIdTarget, WM_REGISTERDRAGDROP, reinterpret_cast<WPARAM>(this), 0); + PostThreadMessageW( m_threadIdTarget, WM_REGISTERDRAGDROP, reinterpret_cast<WPARAM>(this), 0); } else if( hr == S_OK || hr == S_FALSE) { @@ -197,7 +197,7 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams) { MSG msg; // force the creation of a message queue - PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE); + PeekMessageW( &msg, nullptr, 0, 0, PM_NOREMOVE); // Signal the creator ( DropTarget::initialize) that the thread is // ready to receive messages. SetEvent( *static_cast<HANDLE*>(pParams)); @@ -206,7 +206,7 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams) DWORD threadId= GetCurrentThreadId(); // We force the creation of a thread message queue. This is necessary // for a later call to AttachThreadInput - while( GetMessage(&msg, nullptr, 0, 0) ) + while( GetMessageW(&msg, nullptr, 0, 0) ) { if( msg.message == WM_REGISTERDRAGDROP) { @@ -238,7 +238,7 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams) break; } TranslateMessage( &msg); - DispatchMessage( &msg); + DispatchMessageW( &msg); } OleUninitialize(); } diff --git a/dtrans/source/win32/dtobj/DTransHelper.cxx b/dtrans/source/win32/dtobj/DTransHelper.cxx index 49151f4d4fd1..552ec1368f1a 100644 --- a/dtrans/source/win32/dtobj/DTransHelper.cxx +++ b/dtrans/source/win32/dtobj/DTransHelper.cxx @@ -177,7 +177,7 @@ sal_uInt32 SAL_CALL CStgTransferHelper::memSize( CLIPFORMAT cf ) const HGLOBAL hGlob; GetHGlobalFromStream( m_lpStream, &hGlob ); - if ( CF_TEXT == cf || RegisterClipboardFormat( "HTML Format" ) == cf ) + if ( CF_TEXT == cf || RegisterClipboardFormatW( L"HTML Format" ) == cf ) { sal_Char* pText = static_cast< sal_Char* >( GlobalLock( hGlob ) ); if ( pText ) diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.cxx b/dtrans/source/win32/dtobj/DataFmtTransl.cxx index 9c6f40047967..c72f2646563b 100644 --- a/dtrans/source/win32/dtobj/DataFmtTransl.cxx +++ b/dtrans/source/win32/dtobj/DataFmtTransl.cxx @@ -87,7 +87,7 @@ CFormatEtc CDataFormatTranslator::getFormatEtcFromDataFlavor( const DataFlavor& aFormat >>= aClipFmtName; OSL_ASSERT( aClipFmtName.getLength( ) ); - cf = RegisterClipboardFormatW( reinterpret_cast<LPCWSTR>(aClipFmtName.getStr( )) ); + cf = RegisterClipboardFormatW( SAL_W(aClipFmtName.getStr( )) ); OSL_ENSURE( CF_INVALID != cf, "RegisterClipboardFormat failed" ); } @@ -163,7 +163,7 @@ CFormatEtc SAL_CALL CDataFormatTranslator::getFormatEtcForClipformatName( const if ( !aClipFmtName.getLength( ) ) return CFormatEtc( CF_INVALID ); - CLIPFORMAT cf = sal::static_int_cast<CLIPFORMAT>(RegisterClipboardFormatW( reinterpret_cast<LPCWSTR>(aClipFmtName.getStr( )) )); + CLIPFORMAT cf = sal::static_int_cast<CLIPFORMAT>(RegisterClipboardFormatW( SAL_W(aClipFmtName.getStr( )) )); return getFormatEtcForClipformat( cf ); } @@ -172,7 +172,7 @@ OUString CDataFormatTranslator::getClipboardFormatName( CLIPFORMAT aClipformat ) OSL_PRECOND( CF_INVALID != aClipformat, "Invalid clipboard format" ); sal_Unicode wBuff[ MAX_CLIPFORMAT_NAME + 1 ]; // Null terminator isn't counted, apparently. - sal_Int32 nLen = GetClipboardFormatNameW( aClipformat, reinterpret_cast<LPWSTR>(wBuff), MAX_CLIPFORMAT_NAME ); + sal_Int32 nLen = GetClipboardFormatNameW( aClipformat, SAL_W(wBuff), MAX_CLIPFORMAT_NAME ); return OUString( wBuff, nLen ); } @@ -204,7 +204,7 @@ CFormatEtc SAL_CALL CDataFormatTranslator::getFormatEtcForClipformat( CLIPFORMAT of which FileContents it wants to paste see MSDN: "Handling Shell Data Transfer Scenarios" */ - if ( cf == RegisterClipboardFormatA( CFSTR_FILECONTENTS ) ) + if ( cf == RegisterClipboardFormat( CFSTR_FILECONTENTS ) ) fetc.setLindex( 0 ); return fetc; diff --git a/dtrans/source/win32/misc/ImplHelper.cxx b/dtrans/source/win32/misc/ImplHelper.cxx index 8047ffc9a424..f9d5a07a7f28 100644 --- a/dtrans/source/win32/misc/ImplHelper.cxx +++ b/dtrans/source/win32/misc/ImplHelper.cxx @@ -92,27 +92,23 @@ OUString SAL_CALL getWinCPFromLocaleId( LCID lcid, LCTYPE lctype ) else OSL_ASSERT( false ); - // we use the GetLocaleInfoA because don't want to provide - // a unicode wrapper function for Win9x in sal/systools - char buff[6]; - sal_Int32 nResult = GetLocaleInfoA( - lcid, lctype | LOCALE_USE_CP_ACP, buff, sizeof( buff ) ); + // First, get required buffer size, in characters + int nResult = GetLocaleInfoW( + lcid, lctype, nullptr, 0 ); OSL_ASSERT( nResult ); if ( nResult ) { - sal_Int32 len = MultiByteToWideChar( - CP_ACP, 0, buff, -1, nullptr, 0 ); + std::unique_ptr<wchar_t> buff( new wchar_t[nResult] ); + // Now get the actual data + nResult = GetLocaleInfoW( lcid, lctype, buff.get(), nResult ); - OSL_ASSERT( len > 0 ); + OSL_ASSERT(nResult); - std::vector< sal_Unicode > lpwchBuff(len); + if (nResult) + winCP = SAL_U( buff.get() ); - len = MultiByteToWideChar( - CP_ACP, 0, buff, -1, reinterpret_cast<LPWSTR>(&lpwchBuff[0]), len ); - - winCP = OUString( &lpwchBuff[0], (len - 1) ); } return winCP; diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx index 929e8d252350..c596af732f93 100644 --- a/embedserv/source/embed/docholder.cxx +++ b/embedserv/source/embed/docholder.cxx @@ -505,12 +505,12 @@ void DocumentHolder::UIDeactivate() void CopyToOLEMenu(HMENU hOrig,WORD origPos,HMENU hDest,WORD destPos) { HMENU subMenu(nullptr); - char buffer[256]; + wchar_t buffer[256]; subMenu = GetSubMenu(hOrig,origPos); - GetMenuString(hOrig,origPos,buffer,256,MF_BYPOSITION); - InsertMenu(hDest,destPos,MF_BYPOSITION | MF_POPUP, - reinterpret_cast<UINT_PTR>(subMenu),LPCTSTR(buffer)); + GetMenuStringW(hOrig,origPos,buffer,256,MF_BYPOSITION); + InsertMenuW(hDest,destPos,MF_BYPOSITION | MF_POPUP, + reinterpret_cast<UINT_PTR>(subMenu),buffer); MENUITEMINFOW mi; memset(&mi,0,sizeof(mi)); diff --git a/embedserv/source/embed/ed_idataobj.cxx b/embedserv/source/embed/ed_idataobj.cxx index f682254e1f9d..fe37ad43ddd6 100644 --- a/embedserv/source/embed/ed_idataobj.cxx +++ b/embedserv/source/embed/ed_idataobj.cxx @@ -118,8 +118,8 @@ STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pM } else { - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); + CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj ) { if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) ) @@ -157,8 +157,8 @@ STDMETHODIMP EmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGMEDIUM || pFormatetc->dwAspect == DVASPECT_DOCPRINT ) return DV_E_DVASPECT; - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); + CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj ) { @@ -204,8 +204,8 @@ STDMETHODIMP EmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc ) } else { - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); + CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj ) { if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) ) @@ -241,8 +241,8 @@ STDMETHODIMP EmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pFormatetcIn } else { - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); + CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); if ( pFormatetcIn->cfFormat == cf_embSource || pFormatetcIn->cfFormat == cf_embObj ) { pFormatetcOut->tymed = TYMED_ISTORAGE; diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx index 0de9ab79fd09..70c8b226a4df 100644 --- a/embedserv/source/embed/ed_ipersiststr.cxx +++ b/embedserv/source/embed/ed_ipersiststr.cxx @@ -422,7 +422,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg ) if ( hr == S_OK ) { wchar_t const * aCurType = getStorageTypeFromGUID_Impl( &m_guid ); // ??? - CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( pStg, cf, // ??? const_cast<wchar_t *>(aCurType) ); @@ -750,7 +750,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) if ( FAILED( hr ) || !m_pMasterStorage ) return E_FAIL; o3tl::u16string_view aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ??? - CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) ); @@ -801,7 +801,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) if ( hr == S_OK ) { aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ??? - cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" ); + cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) ); diff --git a/embedserv/source/embed/syswinwrapper.cxx b/embedserv/source/embed/syswinwrapper.cxx index 64eefc17af38..ef92307b0d53 100644 --- a/embedserv/source/embed/syswinwrapper.cxx +++ b/embedserv/source/embed/syswinwrapper.cxx @@ -40,7 +40,7 @@ using namespace winwrap; //Notification codes for WM_COMMAND messages #define HWN_BORDERDOUBLECLICKED 1 #define CBHATCHWNDEXTRA (sizeof(LONG)) -#define SZCLASSHATCHWIN TEXT("hatchwin") +#define SZCLASSHATCHWIN L"hatchwin" typedef CHatchWin *PCHatchWin; @@ -106,7 +106,7 @@ HINSTANCE winwrap::CWindow::Instance() BOOL winwrap::HatchWindowRegister(HINSTANCE hInst) { - WNDCLASS wc; + WNDCLASSW wc; //Must have CS_DBLCLKS for border! wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; @@ -120,7 +120,7 @@ BOOL winwrap::HatchWindowRegister(HINSTANCE hInst) wc.lpszMenuName = nullptr; wc.lpszClassName = SZCLASSHATCHWIN; - return RegisterClass(&wc); + return RegisterClassW(&wc); } @@ -141,8 +141,8 @@ CHatchWin::CHatchWin(HINSTANCE hInst,const DocumentHolder* pDocHolder) m_hWndAssociate=nullptr; m_uID=0; - m_dBorderOrg=GetProfileInt(TEXT("windows") - , TEXT("OleInPlaceBorderWidth") + m_dBorderOrg=GetProfileIntW(L"windows" + , L"OleInPlaceBorderWidth" , HATCHWIN_BORDERWIDTHDEFAULT); m_dBorder=m_dBorderOrg; @@ -187,7 +187,7 @@ CHatchWin::~CHatchWin() BOOL CHatchWin::Init(HWND hWndParent, WORD uID, HWND hWndAssoc) { m_hWndParent = hWndParent; - m_hWnd=CreateWindowEx( + m_hWnd=CreateWindowExW( WS_EX_NOPARENTNOTIFY, SZCLASSHATCHWIN , SZCLASSHATCHWIN, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 100, 100, hWndParent @@ -370,14 +370,14 @@ LRESULT APIENTRY winwrap::HatchWndProc( HDC hDC; PAINTSTRUCT ps; - phw=reinterpret_cast<PCHatchWin>(GetWindowLongPtr(hWnd, HWWL_STRUCTURE)); + phw=reinterpret_cast<PCHatchWin>(GetWindowLongPtrW(hWnd, HWWL_STRUCTURE)); POINT ptMouse; switch (iMsg) { case WM_CREATE: phw=static_cast<PCHatchWin>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams); - SetWindowLongPtr(hWnd, HWWL_STRUCTURE, reinterpret_cast<LONG_PTR>(phw)); + SetWindowLongPtrW(hWnd, HWWL_STRUCTURE, reinterpret_cast<LONG_PTR>(phw)); break; case WM_PAINT: hDC=BeginPaint(hWnd,&ps); @@ -421,7 +421,7 @@ LRESULT APIENTRY winwrap::HatchWndProc( */ if (nullptr!=phw->m_hWndAssociate) { - SendMessage( + SendMessageW( phw->m_hWndAssociate, WM_COMMAND, MAKEWPARAM(phw->m_uID, HWN_BORDERDOUBLECLICKED), reinterpret_cast<LPARAM>(hWnd)); @@ -429,7 +429,7 @@ LRESULT APIENTRY winwrap::HatchWndProc( break; default: - return DefWindowProc(hWnd, iMsg, wParam, lParam); + return DefWindowProcW(hWnd, iMsg, wParam, lParam); } return 0; diff --git a/embedserv/source/embed/tracker.cxx b/embedserv/source/embed/tracker.cxx index b39f5499d53f..ae30e630f709 100644 --- a/embedserv/source/embed/tracker.cxx +++ b/embedserv/source/embed/tracker.cxx @@ -255,10 +255,9 @@ void Tracker::Construct() } // get default handle size from Windows profile setting - static const TCHAR szWindows[] = TEXT("windows"); - static const TCHAR szInplaceBorderWidth[] = - TEXT("oleinplaceborderwidth"); - afxHandleSize = GetProfileInt(szWindows, szInplaceBorderWidth, 4); + static const WCHAR szWindows[] = L"windows"; + static const WCHAR szInplaceBorderWidth[] = L"oleinplaceborderwidth"; + afxHandleSize = GetProfileIntW(szWindows, szInplaceBorderWidth, 4); bInitialized = TRUE; afxCursors[0] = afxCursors[2] = LoadCursor(nullptr,IDC_SIZENWSE); @@ -396,7 +395,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) for (;;) { MSG msg; - GetMessage(&msg, nullptr, 0, 0); + GetMessageW(&msg, nullptr, 0, 0); if (GetCapture() != hWnd) break; @@ -461,7 +460,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) // just dispatch rest of the messages default: - DispatchMessage(&msg); + DispatchMessageW(&msg); break; } } diff --git a/embedserv/source/inprocserv/dllentry.cxx b/embedserv/source/inprocserv/dllentry.cxx index a4346eab84c2..f6f3b21d01df 100644 --- a/embedserv/source/inprocserv/dllentry.cxx +++ b/embedserv/source/inprocserv/dllentry.cxx @@ -42,47 +42,47 @@ static ULONG g_nLock = 0; namespace { - void FillCharFromInt( int nValue, char* pBuf, int nLen ) + void FillCharFromInt( int nValue, wchar_t* pBuf, int nLen ) { int nInd = 0; while( nInd < nLen ) { char nSign = ( nValue / ( 1 << ( ( nLen - nInd - 1 ) * 4 ) ) ) % 16; if ( nSign >= 0 && nSign <= 9 ) - pBuf[nInd] = nSign + '0'; + pBuf[nInd] = nSign + L'0'; else if ( nSign >= 10 && nSign <= 15 ) - pBuf[nInd] = nSign - 10 + 'a'; + pBuf[nInd] = nSign - 10 + L'a'; nInd++; } } - int GetStringFromClassID( const GUID& guid, char* pBuf, int nLen ) + int GetStringFromClassID( const GUID& guid, wchar_t* pBuf, int nLen ) { // is not allowed to insert if ( nLen < 38 ) return 0; - pBuf[0] = '{'; + pBuf[0] = L'{'; FillCharFromInt( guid.Data1, &pBuf[1], 8 ); - pBuf[9] = '-'; + pBuf[9] = L'-'; FillCharFromInt( guid.Data2, &pBuf[10], 4 ); - pBuf[14] = '-'; + pBuf[14] = L'-'; FillCharFromInt( guid.Data3, &pBuf[15], 4 ); - pBuf[19] = '-'; + pBuf[19] = L'-'; int nInd = 0; for ( nInd = 0; nInd < 2 ; nInd++ ) FillCharFromInt( guid.Data4[nInd], &pBuf[20 + 2*nInd], 2 ); - pBuf[24] = '-'; + pBuf[24] = L'-'; for ( nInd = 2; nInd < 8 ; nInd++ ) FillCharFromInt( guid.Data4[nInd], &pBuf[20 + 1 + 2*nInd], 2 ); - pBuf[37] = '}'; + pBuf[37] = L'}'; return 38; } - HRESULT WriteLibraryToRegistry( const char* pLibrary, DWORD nLen ) + HRESULT WriteLibraryToRegistry( const wchar_t* pLibrary, DWORD nLen ) { HRESULT hRes = E_FAIL; if ( pLibrary && nLen ) @@ -92,18 +92,18 @@ namespace { hRes = S_OK; for ( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ ) { - const char pSubKeyTemplate[] = "Software\\Classes\\CLSID\\.....................................\\InprocHandler32"; - char pSubKey[SAL_N_ELEMENTS(pSubKeyTemplate)]; - strncpy(pSubKey, pSubKeyTemplate, SAL_N_ELEMENTS(pSubKeyTemplate)); + const wchar_t pSubKeyTemplate[] = L"Software\\Classes\\CLSID\\.....................................\\InprocHandler32"; + wchar_t pSubKey[SAL_N_ELEMENTS(pSubKeyTemplate)]; + wcsncpy(pSubKey, pSubKeyTemplate, SAL_N_ELEMENTS(pSubKeyTemplate)); int nGuidLen = GetStringFromClassID( *guidList[nInd], &pSubKey[23], 38 ); BOOL bLocalSuccess = FALSE; if ( nGuidLen == 38 ) { - if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, pSubKey, &hKey ) ) + if ( ERROR_SUCCESS == RegOpenKeyW( HKEY_LOCAL_MACHINE, pSubKey, &hKey ) ) { - if ( ERROR_SUCCESS == RegSetValueEx( hKey, "", 0, REG_SZ, reinterpret_cast<const BYTE*>(pLibrary), nLen ) ) + if ( ERROR_SUCCESS == RegSetValueExW( hKey, L"", 0, REG_SZ, reinterpret_cast<const BYTE*>(pLibrary), nLen*sizeof(wchar_t) ) ) bLocalSuccess = TRUE; } @@ -199,11 +199,11 @@ STDAPI DllCanUnloadNow() STDAPI DllRegisterServer() { - HMODULE aCurModule = GetModuleHandleA( "inprocserv.dll" ); + HMODULE aCurModule = GetModuleHandleW( L"inprocserv.dll" ); if( aCurModule ) { - char aLibPath[1024]; - DWORD nLen = GetModuleFileNameA( aCurModule, aLibPath, 1019 ); + wchar_t aLibPath[1024]; + DWORD nLen = GetModuleFileNameW( aCurModule, aLibPath, 1019 ); if ( nLen && nLen < 1019 ) { aLibPath[nLen++] = 0; @@ -217,7 +217,7 @@ STDAPI DllRegisterServer() STDAPI DllUnregisterServer() { - return WriteLibraryToRegistry( "ole32.dll", 10 ); + return WriteLibraryToRegistry( L"ole32.dll", 10 ); } diff --git a/extensions/source/activex/SOActiveX.cxx b/extensions/source/activex/SOActiveX.cxx index 436700851200..304b74812756 100644 --- a/extensions/source/activex/SOActiveX.cxx +++ b/extensions/source/activex/SOActiveX.cxx @@ -39,23 +39,23 @@ #pragma warning (pop) -#define STAROFFICE_WINDOWCLASS "SOParentWindow" +#define STAROFFICE_WINDOWCLASS L"SOParentWindow" void OutputError_Impl( HWND hw, HRESULT ErrorCode ) { - LPTSTR sMessage; - FormatMessageA( + LPWSTR sMessage; + FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, ErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - reinterpret_cast<LPTSTR>(&sMessage), + reinterpret_cast<LPWSTR>(&sMessage), 0, nullptr ); - ::MessageBoxA( hw, sMessage, nullptr, MB_OK | MB_ICONINFORMATION ); + MessageBoxW( hw, sMessage, nullptr, MB_OK | MB_ICONINFORMATION ); LocalFree( sMessage ); } @@ -164,17 +164,17 @@ CSOActiveX::CSOActiveX() OutputError_Impl( nullptr, hr ); mPWinClass.style = CS_HREDRAW|CS_VREDRAW; - mPWinClass.lpfnWndProc = ::DefWindowProc; + mPWinClass.lpfnWndProc = DefWindowProcW; mPWinClass.cbClsExtra = 0; mPWinClass.cbWndExtra = 0; - mPWinClass.hInstance = GetModuleHandle(nullptr); //myInstance; + mPWinClass.hInstance = GetModuleHandleW(nullptr); //myInstance; mPWinClass.hIcon = nullptr; mPWinClass.hCursor = nullptr; mPWinClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BACKGROUND); mPWinClass.lpszMenuName = nullptr; mPWinClass.lpszClassName = STAROFFICE_WINDOWCLASS; - RegisterClass(&mPWinClass); + RegisterClassW(&mPWinClass); } CSOActiveX::~CSOActiveX() @@ -991,9 +991,9 @@ HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di ) } mParentWin = hwnd; - mOffWin = CreateWindow( + mOffWin = CreateWindowW( STAROFFICE_WINDOWCLASS, - "OfficeContainer", + L"OfficeContainer", WS_CHILD | WS_CLIPCHILDREN | WS_BORDER, di.prcBounds->left, di.prcBounds->top, diff --git a/extensions/source/activex/SOActiveX.h b/extensions/source/activex/SOActiveX.h index 14451fcdbf51..5f652e6b6752 100644 --- a/extensions/source/activex/SOActiveX.h +++ b/extensions/source/activex/SOActiveX.h @@ -90,7 +90,7 @@ protected: OLECHAR const * mCurFileUrl; BOOL mbLoad; BOOL mbViewOnly; - WNDCLASS mPWinClass; + WNDCLASSW mPWinClass; HWND mParentWin; HWND mOffWin; diff --git a/extensions/source/scanner/scanwin.cxx b/extensions/source/scanner/scanwin.cxx index 117e8d55f80e..437b408a6918 100644 --- a/extensions/source/scanner/scanwin.cxx +++ b/extensions/source/scanner/scanwin.cxx @@ -127,7 +127,7 @@ static ImpTwain* pImpTwainInstance = nullptr; LRESULT CALLBACK TwainWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) { - return DefWindowProc( hWnd, nMsg, nPar1, nPar2 ); + return DefWindowProcW( hWnd, nMsg, nPar1, nPar2 ); } LRESULT CALLBACK TwainMsgProc( int nCode, WPARAM wParam, LPARAM lParam ) @@ -235,11 +235,11 @@ ImpTwain::ImpTwain( ScannerManager& rMgr, const Link<unsigned long,void>& rNotif strncpy( aAppIdent.ProductName, "Office", 32 ); aAppIdent.ProductName[32] = aAppIdent.ProductName[33] = 0; - WNDCLASS aWc = { 0, &TwainWndProc, 0, sizeof( WNDCLASS ), GetModuleHandle( nullptr ), nullptr, nullptr, nullptr, nullptr, "TwainClass" }; - RegisterClass( &aWc ); + WNDCLASSW aWc = { 0, &TwainWndProc, 0, sizeof( WNDCLASSW ), GetModuleHandleW( nullptr ), nullptr, nullptr, nullptr, nullptr, L"TwainClass" }; + RegisterClassW( &aWc ); - hTwainWnd = CreateWindowEx( WS_EX_TOPMOST, aWc.lpszClassName, "TWAIN", 0, 0, 0, 0, 0, HWND_DESKTOP, nullptr, aWc.hInstance, nullptr ); - hTwainHook = SetWindowsHookEx( WH_GETMESSAGE, &TwainMsgProc, nullptr, GetCurrentThreadId() ); + hTwainWnd = CreateWindowExW( WS_EX_TOPMOST, aWc.lpszClassName, L"TWAIN", 0, 0, 0, 0, 0, HWND_DESKTOP, nullptr, aWc.hInstance, nullptr ); + hTwainHook = SetWindowsHookExW( WH_GETMESSAGE, &TwainMsgProc, nullptr, GetCurrentThreadId() ); // block destruction until ImplDestroyHdl is called mxSelfRef = static_cast< ::cppu::OWeakObject* >( this ); 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; } diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index 8ac074eff35c..47869520de23 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -532,11 +532,11 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) char dirname[128]; int fd; #ifdef _WIN32 - GetTempPath(sizeof(dirname), dirname); + GetTempPathA(sizeof(dirname), dirname); sprintf(filename, "%s%s",dirname, emp->name); if( (fd = open( filename , _O_CREAT | _O_WRONLY | _O_BINARY , 0666)) >= 0 ) #else - strcpy(dirname, "/tmp/"); + strcpy(dirname, "/tmp/"); sprintf(filename, "%s%s", dirname, emp->name); if( (fd = open( filename , O_CREAT | O_WRONLY , 0666)) >= 0 ) #endif diff --git a/hwpfilter/source/mzstring.cxx b/hwpfilter/source/mzstring.cxx index 6b579e47b8f6..dae04be2169b 100644 --- a/hwpfilter/source/mzstring.cxx +++ b/hwpfilter/source/mzstring.cxx @@ -34,7 +34,7 @@ #include <string.h> #ifndef _WIN32 -# define wsprintf sprintf +# define wsprintfA sprintf #endif const int AllocSize = 8; @@ -181,7 +181,7 @@ MzString &MzString::operator << (int i) { char str[80]; - wsprintf(str, "%d", i); + wsprintfA(str, "%d", i); append(str); return *this; } @@ -191,7 +191,7 @@ MzString &MzString::operator << (long l) { char str[80]; - wsprintf(str, "%ld", l); + wsprintfA(str, "%ld", l); append(str); return *this; } diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx index cbbd55b895a8..1ae892471ac3 100644 --- a/idlc/source/options.cxx +++ b/idlc/source/options.cxx @@ -192,7 +192,7 @@ OString convertIncPathtoShortWindowsPath(const OString& incPath) { std::vector<sal_Unicode> vec(path.getLength() + 1); //GetShortPathNameW only works if the file can be found! const DWORD len = GetShortPathNameW( - reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1); + SAL_W(path.getStr()), SAL_W(&vec[0]), path.getLength() + 1); if (len > 0) { diff --git a/include/comphelper/windowserrorstring.hxx b/include/comphelper/windowserrorstring.hxx index 805c491c37e1..59f27711a5f8 100644 --- a/include/comphelper/windowserrorstring.hxx +++ b/include/comphelper/windowserrorstring.hxx @@ -29,7 +29,7 @@ inline OUString WindowsErrorString(DWORD nErrorCode) nullptr) == 0) return OUString::number(nErrorCode, 16); - OUString result(reinterpret_cast<sal_Unicode const *>(pMsgBuf)); + OUString result(SAL_U(pMsgBuf)); result.endsWith("\r\n", &result); LocalFree(pMsgBuf); diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 5d28e0240b58..7a9cefd78f34 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -485,8 +485,7 @@ static void load_msvcr(OUString const & jvm_dll, OUStringLiteral msvcr) } if (LoadLibraryW( - reinterpret_cast<wchar_t const *>( - OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr()))) + SAL_W(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr()))) return; // Then check if msvcr71.dll is in the parent folder of where @@ -498,8 +497,7 @@ static void load_msvcr(OUString const & jvm_dll, OUStringLiteral msvcr) return; LoadLibraryW( - reinterpret_cast<wchar_t const *>( - OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr())); + SAL_W(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr())); } // Check if the jvm DLL imports msvcr71.dll, and in that case try diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index f1bf45816af6..7513716d4f90 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -631,7 +631,11 @@ bool getJavaInfoFromRegistry(const wchar_t* szRegKey, // Find out how long the string for JavaHome is and allocate memory to hold the path if( RegQueryValueExW(hKey, L"JavaHome", nullptr, &dwType, nullptr, &dwTmpPathLen)== ERROR_SUCCESS) { - unsigned char* szTmpPath= static_cast<unsigned char *>(malloc( dwTmpPathLen)); + unsigned char* szTmpPath= static_cast<unsigned char *>(malloc(dwTmpPathLen+sizeof(sal_Unicode))); + // According to https://msdn.microsoft.com/en-us/ms724911, the application should ensure + // that the string is properly terminated before using it + for (DWORD i = 0; i < sizeof(sal_Unicode); ++i) + szTmpPath[dwTmpPathLen + i] = 0; // Get the path for the runtime lib if(RegQueryValueExW(hKey, L"JavaHome", nullptr, &dwType, szTmpPath, &dwTmpPathLen) == ERROR_SUCCESS) { diff --git a/jvmfwk/source/fwkutil.cxx b/jvmfwk/source/fwkutil.cxx index fbb885b1d0c2..95fa21503bc0 100644 --- a/jvmfwk/source/fwkutil.cxx +++ b/jvmfwk/source/fwkutil.cxx @@ -66,18 +66,19 @@ bool isAccessibilitySupportDesired() #ifdef _WIN32 bool retVal = false; HKEY hKey = nullptr; - if (RegOpenKeyEx(HKEY_CURRENT_USER, - "Software\\LibreOffice\\Accessibility\\AtToolSupport", - 0, KEY_READ, &hKey) == ERROR_SUCCESS) + if (RegOpenKeyExA(HKEY_CURRENT_USER, + "Software\\LibreOffice\\Accessibility\\AtToolSupport", + 0, KEY_READ, &hKey) == ERROR_SUCCESS) { DWORD dwType = 0; DWORD dwLen = 16; unsigned char arData[16]; - if( RegQueryValueEx(hKey, "SupportAssistiveTechnology", nullptr, &dwType, arData, - & dwLen)== ERROR_SUCCESS) + if( RegQueryValueExA(hKey, "SupportAssistiveTechnology", nullptr, &dwType, arData, + &dwLen)== ERROR_SUCCESS) { if (dwType == REG_SZ) { + arData[std::min(dwLen, DWORD(15))] = 0; if (strcmp(reinterpret_cast<char*>(arData), "true") == 0 || strcmp(reinterpret_cast<char*>(arData), "1") == 0) retVal = true; @@ -98,9 +99,8 @@ bool isAccessibilitySupportDesired() "jfw", "bad registry value " << unsigned(arData[0])); } } + RegCloseKey(hKey); } - RegCloseKey(hKey); - #elif defined UNX // Java is no longer required for a11y - we use atk directly. bool retVal = ::rtl::Bootstrap::get( "JFW_PLUGIN_FORCE_ACCESSIBILITY", sValue) && sValue == "1"; diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx index 73412e9fff58..71e6722f83dc 100644 --- a/opencl/source/openclwrapper.cxx +++ b/opencl/source/openclwrapper.cxx @@ -502,10 +502,10 @@ bool initOpenCLRunEnv( GPUEnv *gpuInfo ) const bool bIsNotWinOrIsWin8OrGreater = IsWindows8OrGreater(); # else bool bIsNotWinOrIsWin8OrGreater = true; - OSVERSIONINFO aVersionInfo; + OSVERSIONINFOW aVersionInfo; memset( &aVersionInfo, 0, sizeof(aVersionInfo) ); aVersionInfo.dwOSVersionInfoSize = sizeof( aVersionInfo ); - if (GetVersionEx( &aVersionInfo )) + if (GetVersionExW( &aVersionInfo )) { // Windows 7 or lower? if (aVersionInfo.dwMajorVersion < 6 || diff --git a/sal/osl/w32/security.cxx b/sal/osl/w32/security.cxx index 02f9c02e82b6..b25e3076af70 100644 --- a/sal/osl/w32/security.cxx +++ b/sal/osl/w32/security.cxx @@ -66,7 +66,9 @@ typedef BOOL (STDMETHODCALLTYPE FAR * LPFNGETUSERPROFILEDIR) ( #define TOKEN_DUP_QUERY (TOKEN_QUERY|TOKEN_DUPLICATE) static bool GetSpecialFolder(rtl_uString **strPath,int nFolder); -static BOOL Privilege(LPCWSTR pszPrivilege, BOOL bEnable); +// We use LPCTSTR here, because we use it with SE_foo_NAME constants +// which are defined in winnt.h as UNICODE-dependent TEXT("PrivilegeName") +static BOOL Privilege(LPCTSTR pszPrivilege, BOOL bEnable); static bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **strName, bool bIncludeDomain); oslSecurity SAL_CALL osl_getCurrentSecurity(void) @@ -99,7 +101,7 @@ oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString * } // this process must have the right: 'act as a part of operatingsystem' - OSL_ASSERT(LookupPrivilegeValueW(nullptr, L"SeTcbPrivilege", &luid)); + OSL_ASSERT(LookupPrivilegeValue(nullptr, SE_TCB_NAME, &luid)); (void) luid; if (LogonUserW(SAL_W(strUser), strDomain ? SAL_W(strDomain) : L"", SAL_W(rtl_uString_getStr(strPasswd)), @@ -510,7 +512,7 @@ sal_Bool SAL_CALL osl_loadUserProfile(oslSecurity Security) RegCloseKey(HKEY_CURRENT_USER); - if (Privilege(L"SeRestorePrivilege", TRUE)) + if (Privilege(SE_RESTORE_NAME, TRUE)) { HMODULE hUserEnvLib = nullptr; LPFNLOADUSERPROFILE fLoadUserProfile = nullptr; @@ -712,7 +714,9 @@ static bool GetSpecialFolder(rtl_uString **strPath, int nFolder) return bRet; } -static BOOL Privilege(LPCWSTR strPrivilege, BOOL bEnable) +// We use LPCTSTR here, because we use it with SE_foo_NAME constants +// which are defined in winnt.h as UNICODE-dependent TEXT("PrivilegeName") +static BOOL Privilege(LPCTSTR strPrivilege, BOOL bEnable) { HANDLE hToken; TOKEN_PRIVILEGES tp; @@ -722,7 +726,7 @@ static BOOL Privilege(LPCWSTR strPrivilege, BOOL bEnable) return FALSE; // get the luid - if (!LookupPrivilegeValueW(nullptr, strPrivilege, &tp.Privileges[0].Luid)) + if (!LookupPrivilegeValue(nullptr, strPrivilege, &tp.Privileges[0].Luid)) return FALSE; tp.PrivilegeCount = 1; diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index f384339f25f2..e670d62e4d7e 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -96,9 +96,9 @@ typedef struct tagMYITEM static void addMenuItem( HMENU hMenu, UINT id, UINT iconId, const OUString& text, int& pos, bool bOwnerdraw, const OUString& module ) { MENUITEMINFOW mi; - memset( &mi, 0, sizeof( MENUITEMINFOW ) ); + memset( &mi, 0, sizeof( mi ) ); - mi.cbSize = sizeof( MENUITEMINFOW ); + mi.cbSize = sizeof( mi ); if( id == static_cast<UINT>( -1 ) ) { mi.fMask=MIIM_TYPE; @@ -326,7 +326,7 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP EnableMenuItem( popupMenu, IDM_TEMPLATE, MF_BYCOMMAND | (ShutdownIcon::bModalMode ? MF_GRAYED : MF_ENABLED) ); int m = TrackPopupMenuEx( popupMenu, TPM_RETURNCMD|TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, hWnd, nullptr ); - BOOL const ret = PostMessage( hWnd, 0, 0, 0 ); + BOOL const ret = PostMessageW( hWnd, 0, 0, 0 ); SAL_WARN_IF(0 == ret, "sfx.appl", "ERROR: PostMessage() failed!"); switch( m ) { @@ -344,11 +344,11 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP break; case IDM_EXIT: // delete taskbar icon - NOTIFYICONDATAA nid; - nid.cbSize=sizeof(NOTIFYICONDATA); + NOTIFYICONDATAW nid; + nid.cbSize=sizeof(nid); nid.hWnd = hWnd; nid.uID = ID_QUICKSTART; - Shell_NotifyIconA(NIM_DELETE, &nid); + Shell_NotifyIconW(NIM_DELETE, &nid); break; } @@ -372,11 +372,11 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP else if ( uMsg == s_uMsgKillTray ) { // delete taskbar icon - NOTIFYICONDATAA nid; - nid.cbSize=sizeof(NOTIFYICONDATA); + NOTIFYICONDATAW nid; + nid.cbSize=sizeof(nid); nid.hWnd = hWnd; nid.uID = ID_QUICKSTART; - Shell_NotifyIconA(NIM_DELETE, &nid); + Shell_NotifyIconW(NIM_DELETE, &nid); BOOL const ret = PostMessageW(aExecuterWindow, WM_COMMAND, IDM_EXIT, reinterpret_cast<LPARAM>(hWnd)); SAL_WARN_IF(0 == ret, "sfx.appl", "ERROR: PostMessage() failed!"); @@ -628,7 +628,7 @@ void OnDrawItem(HWND /*hwnd*/, LPDRAWITEMSTRUCT lpdis) } } - hIcon = static_cast<HICON>(LoadImageA( hModule, MAKEINTRESOURCE( pMyItem->iconId ), + hIcon = static_cast<HICON>(LoadImageW( hModule, MAKEINTRESOURCEW( pMyItem->iconId ), IMAGE_ICON, cx, cy, LR_DEFAULTCOLOR | LR_SHARED )); @@ -719,7 +719,7 @@ static HRESULT WINAPI SHCoCreateInstance( LPVOID lpszReserved, REFCLSID clsid, L { typedef HRESULT (WINAPI *SHCoCreateInstance_PROC)( LPVOID lpszReserved, REFCLSID clsid, LPUNKNOWN pUnkUnknwon, REFIID iid, LPVOID *ppv ); - SHCoCreateInstance_PROC lpfnSHCoCreateInstance = reinterpret_cast<SHCoCreateInstance_PROC>(GetProcAddress( hModShell, MAKEINTRESOURCE(102) )); + SHCoCreateInstance_PROC lpfnSHCoCreateInstance = reinterpret_cast<SHCoCreateInstance_PROC>(GetProcAddress( hModShell, MAKEINTRESOURCEA(102) )); if ( lpfnSHCoCreateInstance ) hResult = lpfnSHCoCreateInstance( lpszReserved, clsid, pUnkUnknown, iid, ppv ); diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index eb8ad7ffe736..02664519ee8a 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -88,7 +88,6 @@ void* GraphicHelper::getEnhMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta ) OUString aMetaFile = aTempFile.GetFileName(); OUString aMetaURL = aTempFile.GetURL(); - OString aWinFile = OUStringToOString( aMetaFile, osl_getThreadTextEncoding() ); SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aMetaURL, StreamMode::STD_READWRITE ); if ( pStream ) @@ -99,7 +98,7 @@ void* GraphicHelper::getEnhMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta ) delete pStream; if ( !nFailed ) - pResult = GetEnhMetaFileA( aWinFile.getStr() ); + pResult = GetEnhMetaFileW( SAL_W(aMetaFile.getStr()) ); } } #else diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 548ccd30d161..86a02dc5dd8f 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -1195,7 +1195,7 @@ OUString ModelData_Impl::GetRecommendedDir( const OUString& aSuggestedDir ) if( SUCCEEDED(hRes) ) { OUString sTempINetFiles; - if( osl::FileBase::getFileURLFromSystemPath(reinterpret_cast<sal_Unicode*>(sPath), sTempINetFiles) == osl::FileBase::E_None ) + if( osl::FileBase::getFileURLFromSystemPath(SAL_U(sPath), sTempINetFiles) == osl::FileBase::E_None ) bIsInTempPath = !sTempINetFiles.isEmpty() && sLocationURL.startsWith( sTempINetFiles ); } } diff --git a/sfx2/source/doc/syspathw32.cxx b/sfx2/source/doc/syspathw32.cxx index c190a7e159bd..ea6e13c078ba 100644 --- a/sfx2/source/doc/syspathw32.cxx +++ b/sfx2/source/doc/syspathw32.cxx @@ -61,7 +61,7 @@ static bool SHGetSpecialFolderW32( int nFolderID, WCHAR* pszFolder, int nSize ) bool GetUserTemplateLocation(sal_Unicode* pFolder, int nSize) { #ifdef _WIN32 - return SHGetSpecialFolderW32( CSIDL_TEMPLATES, reinterpret_cast<LPWSTR>(pFolder), nSize ); + return SHGetSpecialFolderW32( CSIDL_TEMPLATES, SAL_W(pFolder), nSize ); #else (void)pFolder; (void)nSize; diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx index 8c2d18e0ac87..83840fb8de5a 100644 --- a/svl/source/crypto/cryptosign.cxx +++ b/svl/source/crypto/cryptosign.cxx @@ -762,7 +762,7 @@ bool CreateSigningCertificateAttribute(void const * pDerEncoded, int nDerEncoded std::vector<unsigned char> aSHA256{0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01}; HCRYPTPROV hProv = 0; - if (!CryptAcquireContext(&hProv, nullptr, nullptr, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) + if (!CryptAcquireContextW(&hProv, nullptr, nullptr, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) { SAL_WARN("svl.crypto", "CryptAcquireContext() failed"); return false; @@ -1867,7 +1867,7 @@ bad_data: bool VerifyNonDetachedSignature(const std::vector<unsigned char>& aData, const std::vector<BYTE>& rExpectedHash) { HCRYPTPROV hProv = 0; - if (!CryptAcquireContext(&hProv, nullptr, nullptr, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) + if (!CryptAcquireContextW(&hProv, nullptr, nullptr, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) { SAL_WARN("svl.crypto", "CryptAcquireContext() failed"); return false; @@ -1941,14 +1941,13 @@ OUString GetSubjectName(PCCERT_CONTEXT pCertContext) szName, dwData)) { + LocalFree(szName); SAL_WARN("svl.crypto", "ValidateSignature: CertGetNameString failed"); return subjectName; } - subjectName = OUString(reinterpret_cast<sal_Unicode*>(szName)); - - if (szName != nullptr) - LocalFree(szName); + subjectName = SAL_U(szName); + LocalFree(szName); return subjectName; } diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx index 3c629b1b9cba..c0c5373573e2 100644 --- a/tools/source/stream/strmwnt.cxx +++ b/tools/source/stream/strmwnt.cxx @@ -276,7 +276,6 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode ) m_eStreamMode &= ~StreamMode::TRUNC; // don't truncate on reopen aFilename = aParsedFilename; - OString aFileNameA(OUStringToOString(aFilename, osl_getThreadTextEncoding())); SetLastError( ERROR_SUCCESS ); // might be changed by Redirector DWORD nOpenAction; @@ -317,8 +316,8 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode ) nOpenAction = OPEN_EXISTING; } - pInstanceData->hFile = CreateFile( - aFileNameA.getStr(), + pInstanceData->hFile = CreateFileW( + SAL_W(aFilename.getStr()), nAccessMode, nShareMode, nullptr, @@ -351,8 +350,8 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode ) // if Openaction is CREATE_ALWAYS nOpenAction = OPEN_EXISTING; SetLastError( ERROR_SUCCESS ); - pInstanceData->hFile = CreateFile( - aFileNameA.getStr(), + pInstanceData->hFile = CreateFileW( + SAL_W(aFilename.getStr()), GENERIC_READ, nShareMode, nullptr, diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx index 5b0e638c3c00..0f3e05b8f31a 100644 --- a/vcl/inc/win/saldata.hxx +++ b/vcl/inc/win/saldata.hxx @@ -196,8 +196,8 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 ); #define SAL_TMPSUBFRAME_CLASSNAMEW L"SALTMPSUBFRAME" #define SAL_OBJECT_WNDEXTRA sizeof( DWORD ) #define SAL_OBJECT_THIS GWLP_USERDATA -#define SAL_OBJECT_CLASSNAMEA "SALOBJECT" -#define SAL_OBJECT_CHILDCLASSNAMEA "SALOBJECTCHILD" +#define SAL_OBJECT_CLASSNAMEW L"SALOBJECT" +#define SAL_OBJECT_CHILDCLASSNAMEW L"SALOBJECTCHILD" #define SAL_COM_CLASSNAMEW L"SALCOMWND" #define SAL_MOUSELEAVE_TIMEOUT 300 @@ -273,7 +273,7 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 ); inline void SetWindowPtr( HWND hWnd, WinSalFrame* pThis ) { - SetWindowLongPtr( hWnd, SAL_FRAME_THIS, reinterpret_cast<LONG_PTR>(pThis) ); + SetWindowLongPtrW( hWnd, SAL_FRAME_THIS, reinterpret_cast<LONG_PTR>(pThis) ); } inline WinSalFrame* GetWindowPtr( HWND hWnd ) @@ -283,12 +283,12 @@ inline WinSalFrame* GetWindowPtr( HWND hWnd ) inline void SetSalObjWindowPtr( HWND hWnd, WinSalObject* pThis ) { - SetWindowLongPtr( hWnd, SAL_OBJECT_THIS, reinterpret_cast<LONG_PTR>(pThis) ); + SetWindowLongPtrW( hWnd, SAL_OBJECT_THIS, reinterpret_cast<LONG_PTR>(pThis) ); } inline WinSalObject* GetSalObjWindowPtr( HWND hWnd ) { - return reinterpret_cast<WinSalObject*>(GetWindowLongPtr( hWnd, SAL_OBJECT_THIS )); + return reinterpret_cast<WinSalObject*>(GetWindowLongPtrW( hWnd, SAL_OBJECT_THIS )); } #endif // INCLUDED_VCL_INC_WIN_SALDATA_HXX diff --git a/vcl/inc/win/wincomp.hxx b/vcl/inc/win/wincomp.hxx index 8fd774fc6eb1..4a436fbd309d 100644 --- a/vcl/inc/win/wincomp.hxx +++ b/vcl/inc/win/wincomp.hxx @@ -97,22 +97,22 @@ inline void DeletePalette( HPALETTE hPalette ) inline void SetWindowStyle( HWND hWnd, DWORD nStyle ) { - SetWindowLong( hWnd, GWL_STYLE, nStyle ); + SetWindowLongPtrW( hWnd, GWL_STYLE, nStyle ); } inline DWORD GetWindowStyle( HWND hWnd ) { - return GetWindowLong( hWnd, GWL_STYLE ); + return GetWindowLongPtrW( hWnd, GWL_STYLE ); } inline void SetWindowExStyle( HWND hWnd, DWORD nStyle ) { - SetWindowLong( hWnd, GWL_EXSTYLE, nStyle ); + SetWindowLongPtrW( hWnd, GWL_EXSTYLE, nStyle ); } inline DWORD GetWindowExStyle( HWND hWnd ) { - return GetWindowLong( hWnd, GWL_EXSTYLE ); + return GetWindowLongPtrW( hWnd, GWL_EXSTYLE ); } inline BOOL IsMinimized( HWND hWnd ) @@ -127,12 +127,12 @@ inline BOOL IsMaximized( HWND hWnd ) inline void SetWindowFont( HWND hWnd, HFONT hFont, BOOL bRedraw ) { - SendMessage( hWnd, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), MAKELPARAM((UINT)bRedraw,0) ); + SendMessageW( hWnd, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), MAKELPARAM((UINT)bRedraw,0) ); } inline HFONT GetWindowFont( HWND hWnd ) { - return reinterpret_cast<HFONT>(SendMessage( hWnd, WM_GETFONT, 0, 0 )); + return reinterpret_cast<HFONT>(SendMessageW( hWnd, WM_GETFONT, 0, 0 )); } inline void SetClassCursor( HWND hWnd, HCURSOR hCursor ) @@ -167,17 +167,17 @@ inline HBRUSH GetClassBrush( HWND hWnd ) inline HINSTANCE GetWindowInstance( HWND hWnd ) { - return reinterpret_cast<HINSTANCE>(GetWindowLongPtr( hWnd, GWLP_HINSTANCE )); + return reinterpret_cast<HINSTANCE>(GetWindowLongPtrW( hWnd, GWLP_HINSTANCE )); } -#define MOUSEZ_CLASSNAME "MouseZ" // wheel window class -#define MOUSEZ_TITLE "Magellan MSWHEEL" // wheel window title +#define MOUSEZ_CLASSNAME L"MouseZ" // wheel window class +#define MOUSEZ_TITLE L"Magellan MSWHEEL" // wheel window title #define MSH_WHEELMODULE_CLASS (MOUSEZ_CLASSNAME) #define MSH_WHEELMODULE_TITLE (MOUSEZ_TITLE) -#define MSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG" +#define MSH_SCROLL_LINES L"MSH_SCROLL_LINES_MSG" #ifndef WHEEL_DELTA #define WHEEL_DELTA 120 diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx index d81c37283983..0d2a0c0a8f0c 100644 --- a/vcl/opengl/win/gdiimpl.cxx +++ b/vcl/opengl/win/gdiimpl.cxx @@ -183,7 +183,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l case WM_DESTROY: return 0; default: - return DefWindowProc(hwnd, message, wParam, lParam); + return DefWindowProcW(hwnd, message, wParam, lParam); } } @@ -193,7 +193,7 @@ bool InitTempWindow(HWND& hwnd, int width, int height, const PIXELFORMATDESCRIPT PIXELFORMATDESCRIPTOR pfd = inPfd; int ret; - WNDCLASS wc; + WNDCLASSW wc; wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = wc.cbWndExtra = 0; @@ -202,9 +202,9 @@ bool InitTempWindow(HWND& hwnd, int width, int height, const PIXELFORMATDESCRIPT wc.hCursor = nullptr; wc.hbrBackground = nullptr; wc.lpszMenuName = nullptr; - wc.lpszClassName = "GLRenderer"; - RegisterClass(&wc); - hwnd = CreateWindow(wc.lpszClassName, nullptr, WS_DISABLED, 0, 0, width, height, nullptr, nullptr, wc.hInstance, nullptr); + wc.lpszClassName = L"GLRenderer"; + RegisterClassW(&wc); + hwnd = CreateWindowW(wc.lpszClassName, nullptr, WS_DISABLED, 0, 0, width, height, nullptr, nullptr, wc.hInstance, nullptr); glWin.hDC = GetDC(hwnd); int nPixelFormat = ChoosePixelFormat(glWin.hDC, &pfd); diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 95b3a2a2de22..ebf5cb50104c 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -2445,21 +2445,21 @@ bool MiscSettings::GetEnableATToolSupport() const // be activated .. HKEY hkey; - if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, - "Software\\LibreOffice\\Accessibility\\AtToolSupport", + if( ERROR_SUCCESS == RegOpenKeyW(HKEY_CURRENT_USER, + L"Software\\LibreOffice\\Accessibility\\AtToolSupport", &hkey) ) { DWORD dwType; - sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD + wchar_t Data[6]; // possible values: "true", "false", "1", "0", DWORD DWORD cbData = sizeof(Data); - if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology", - nullptr, &dwType, Data, &cbData) ) + if( ERROR_SUCCESS == RegQueryValueExW(hkey, L"SupportAssistiveTechnology", + nullptr, &dwType, reinterpret_cast<LPBYTE>(Data), &cbData) ) { switch (dwType) { case REG_SZ: - mxData->mnEnableATT = ((0 == stricmp(reinterpret_cast<const char *>(Data), "1")) || (0 == stricmp(reinterpret_cast<const char *>(Data), "true"))) ? TRISTATE_TRUE : TRISTATE_FALSE; + mxData->mnEnableATT = ((0 == wcsicmp(Data, L"1")) || (0 == wcsicmp(Data, L"true"))) ? TRISTATE_TRUE : TRISTATE_FALSE; break; case REG_DWORD: switch (reinterpret_cast<DWORD *>(Data)[0]) { @@ -2517,29 +2517,29 @@ void MiscSettings::SetEnableATToolSupport( bool bEnable ) HKEY hkey; // If the accessibility key in the Windows registry exists, change it synchronously - if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, - "Software\\LibreOffice\\Accessibility\\AtToolSupport", + if( ERROR_SUCCESS == RegOpenKeyW(HKEY_CURRENT_USER, + L"Software\\LibreOffice\\Accessibility\\AtToolSupport", &hkey) ) { DWORD dwType; - sal_uInt8 Data[6]; // possible values: "true", "false", 1, 0 + wchar_t Data[6]; // possible values: "true", "false", 1, 0 DWORD cbData = sizeof(Data); - if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology", - nullptr, &dwType, Data, &cbData) ) + if( ERROR_SUCCESS == RegQueryValueExW(hkey, L"SupportAssistiveTechnology", + nullptr, &dwType, reinterpret_cast<LPBYTE>(Data), &cbData) ) { switch (dwType) { case REG_SZ: - RegSetValueEx(hkey, "SupportAssistiveTechnology", + RegSetValueExW(hkey, L"SupportAssistiveTechnology", 0, dwType, - reinterpret_cast<sal_uInt8 const *>(bEnable ? "true" : "false"), - bEnable ? sizeof("true") : sizeof("false")); + reinterpret_cast<const BYTE*>(bEnable ? L"true" : L"false"), + bEnable ? sizeof(L"true") : sizeof(L"false")); break; case REG_DWORD: reinterpret_cast<DWORD *>(Data)[0] = bEnable ? 1 : 0; - RegSetValueEx(hkey, "SupportAssistiveTechnology", - 0, dwType, Data, sizeof(DWORD)); + RegSetValueExW(hkey, L"SupportAssistiveTechnology", + 0, dwType, reinterpret_cast<const BYTE*>(Data), sizeof(DWORD)); break; default: // Unsupported registry type diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 70d031d4ee69..45099edbefe0 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -5130,19 +5130,19 @@ void ToolBox::ImplDisableFlatButtons() bInit = true; HKEY hkey; - if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, "Software\\LibreOffice\\Accessibility\\AtToolSupport", &hkey) ) + if( ERROR_SUCCESS == RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\LibreOffice\\Accessibility\\AtToolSupport", &hkey) ) { DWORD dwType = 0; - sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD + wchar_t Data[6]; // possible values: "true", "false", "1", "0", DWORD DWORD cbData = sizeof(Data); - if( ERROR_SUCCESS == RegQueryValueEx(hkey, "DisableFlatToolboxButtons", - nullptr, &dwType, Data, &cbData) ) + if( ERROR_SUCCESS == RegQueryValueExW(hkey, L"DisableFlatToolboxButtons", + nullptr, &dwType, reinterpret_cast<LPBYTE>(Data), &cbData) ) { switch (dwType) { case REG_SZ: - bValue = ((0 == stricmp(reinterpret_cast<const char *>(Data), "1")) || (0 == stricmp(reinterpret_cast<const char *>(Data), "true"))); + bValue = ((0 == wcsicmp(Data, L"1")) || (0 == wcsicmp(Data, L"true"))); break; case REG_DWORD: bValue = (bool)(reinterpret_cast<DWORD *>(Data)[0]); diff --git a/vcl/win/app/salinfo.cxx b/vcl/win/app/salinfo.cxx index 815582c8e2a5..c96f80862b53 100644 --- a/vcl/win/app/salinfo.cxx +++ b/vcl/win/app/salinfo.cxx @@ -59,7 +59,7 @@ bool WinSalSystem::handleMonitorCallback( sal_IntPtr hMonitor, sal_IntPtr, sal_I if( GetMonitorInfoW( reinterpret_cast<HMONITOR>(hMonitor), &aInfo ) ) { aInfo.szDevice[CCHDEVICENAME-1] = 0; - OUString aDeviceName( reinterpret_cast<const sal_Unicode *>(aInfo.szDevice) ); + OUString aDeviceName( SAL_U(aInfo.szDevice) ); std::map< OUString, unsigned int >::const_iterator it = m_aDeviceNameToMonitor.find( aDeviceName ); if( it != m_aDeviceNameToMonitor.end() ) @@ -110,8 +110,8 @@ bool WinSalSystem::initMonitors() { aDev.DeviceName[31] = 0; aDev.DeviceString[127] = 0; - OUString aDeviceName( reinterpret_cast<const sal_Unicode *>(aDev.DeviceName) ); - OUString aDeviceString( reinterpret_cast<const sal_Unicode *>(aDev.DeviceString) ); + OUString aDeviceName( SAL_U(aDev.DeviceName) ); + OUString aDeviceString( SAL_U(aDev.DeviceString) ); if( aDeviceStringCount.find( aDeviceString ) == aDeviceStringCount.end() ) aDeviceStringCount[ aDeviceString ] = 1; else @@ -169,8 +169,8 @@ int WinSalSystem::ShowNativeMessageBox(const OUString& rTitle, const OUString& r ImplHideSplash(); return MessageBoxW( nullptr, - reinterpret_cast<LPCWSTR>(rMessage.getStr()), - reinterpret_cast<LPCWSTR>(rTitle.getStr()), + SAL_W(rMessage.getStr()), + SAL_W(rTitle.getStr()), MB_TASKMODAL | MB_SETFOREGROUND | MB_ICONWARNING | MB_DEFBUTTON1); } diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index 437e8b594c65..faa5bd3776e4 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -88,7 +88,7 @@ void SalAbort( const OUString& rErrorText, bool ) CrashReporter::AddKeyValue("AbortMessage", rErrorText); // make sure crash reporter is triggered RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0, nullptr ); - FatalAppExitW( 0, reinterpret_cast<LPCWSTR>(rErrorText.getStr()) ); + FatalAppExitW( 0, SAL_W(rErrorText.getStr()) ); } } @@ -228,27 +228,27 @@ void SalData::initKeyCodeMap() { UINT nKey; #define initKey( a, b )\ - nKey = LOWORD( VkKeyScan( a ) );\ + nKey = LOWORD( VkKeyScanW( a ) );\ if( nKey < 0xffff )\ maVKMap[ nKey ] = b; maVKMap.clear(); - initKey( '+', KEY_ADD ); - initKey( '-', KEY_SUBTRACT ); - initKey( '*', KEY_MULTIPLY ); - initKey( '/', KEY_DIVIDE ); - initKey( '.', KEY_POINT ); - initKey( ',', KEY_COMMA ); - initKey( '<', KEY_LESS ); - initKey( '>', KEY_GREATER ); - initKey( '=', KEY_EQUAL ); - initKey( '~', KEY_TILDE ); - initKey( '`', KEY_QUOTELEFT ); - initKey( '[', KEY_BRACKETLEFT ); - initKey( ']', KEY_BRACKETRIGHT ); - initKey( ';', KEY_SEMICOLON ); - initKey( '\'', KEY_QUOTERIGHT ); + initKey( L'+', KEY_ADD ); + initKey( L'-', KEY_SUBTRACT ); + initKey( L'*', KEY_MULTIPLY ); + initKey( L'/', KEY_DIVIDE ); + initKey( L'.', KEY_POINT ); + initKey( L',', KEY_COMMA ); + initKey( L'<', KEY_LESS ); + initKey( L'>', KEY_GREATER ); + initKey( L'=', KEY_EQUAL ); + initKey( L'~', KEY_TILDE ); + initKey( L'`', KEY_QUOTELEFT ); + initKey( L'[', KEY_BRACKETLEFT ); + initKey( L']', KEY_BRACKETRIGHT ); + initKey( L';', KEY_SEMICOLON ); + initKey( L'\'', KEY_QUOTERIGHT ); } // SalData @@ -344,11 +344,11 @@ void InitSalMain() SalData* pData = GetSalData(); if ( pData ) // Im AppServer NULL { - STARTUPINFO aSI; + STARTUPINFOW aSI; aSI.cb = sizeof( aSI ); - GetStartupInfo( &aSI ); - pData->mhInst = GetModuleHandle( nullptr ); - pData->mnCmdShow = aSI.wShowWindow; + GetStartupInfoW( &aSI ); + pData->mhInst = GetModuleHandleW( nullptr ); + pData->mnCmdShow = aSI.wShowWindow; } } diff --git a/vcl/win/app/salshl.cxx b/vcl/win/app/salshl.cxx index 5fd1959b228d..1cd38e05abeb 100644 --- a/vcl/win/app/salshl.cxx +++ b/vcl/win/app/salshl.cxx @@ -33,7 +33,7 @@ HCURSOR ImplLoadSalCursor( int nId ) { SAL_WARN_IF( !aSalShlData.mhInst, "vcl", "no DLL instance handle" ); - HCURSOR hCursor = LoadCursor( aSalShlData.mhInst, MAKEINTRESOURCE( nId ) ); + HCURSOR hCursor = LoadCursorW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ) ); SAL_WARN_IF( !hCursor, "vcl", "cursor not found in sal resource" ); @@ -44,7 +44,7 @@ HBITMAP ImplLoadSalBitmap( int nId ) { SAL_WARN_IF( !aSalShlData.mhInst, "vcl", "no DLL instance handle" ); - HBITMAP hBitmap = LoadBitmap( aSalShlData.mhInst, MAKEINTRESOURCE( nId ) ); + HBITMAP hBitmap = LoadBitmapW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ) ); SAL_WARN_IF( !hBitmap, "vcl", "bitmap not found in sal resource" ); @@ -72,19 +72,19 @@ bool ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon ) } // Try at first to load the icons from the application exe file - rIcon = static_cast<HICON>(LoadImage( pSalData->mhInst, MAKEINTRESOURCE( nId ), + rIcon = static_cast<HICON>(LoadImageW( pSalData->mhInst, MAKEINTRESOURCEW( nId ), IMAGE_ICON, GetSystemMetrics( SM_CXICON ), GetSystemMetrics( SM_CYICON ), LR_DEFAULTCOLOR )); if ( !rIcon ) { // If the application don't provide these icons, then we try // to load the icon from the VCL resource - rIcon = static_cast<HICON>(LoadImage( aSalShlData.mhInst, MAKEINTRESOURCE( nId ), + rIcon = static_cast<HICON>(LoadImageW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ), IMAGE_ICON, GetSystemMetrics( SM_CXICON ), GetSystemMetrics( SM_CYICON ), LR_DEFAULTCOLOR )); if ( rIcon ) { - rSmallIcon = static_cast<HICON>(LoadImage( aSalShlData.mhInst, MAKEINTRESOURCE( nId ), + rSmallIcon = static_cast<HICON>(LoadImageW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), LR_DEFAULTCOLOR )); } @@ -93,7 +93,7 @@ bool ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon ) } else { - rSmallIcon = static_cast<HICON>(LoadImage( pSalData->mhInst, MAKEINTRESOURCE( nId ), + rSmallIcon = static_cast<HICON>(LoadImageW( pSalData->mhInst, MAKEINTRESOURCEW( nId ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), LR_DEFAULTCOLOR )); } diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index e16381040e4a..bd9c012d55fc 100755 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -37,8 +37,8 @@ D2DWriteTextOutRenderer::pDWriteCreateFactory_t D2DWriteTextOutRenderer::DWriteC bool D2DWriteTextOutRenderer::InitModules() { - mmD2d1 = LoadLibrary("D2d1.dll"); - mmDWrite = LoadLibrary("dwrite.dll"); + mmD2d1 = LoadLibraryW(L"D2d1.dll"); + mmDWrite = LoadLibraryW(L"dwrite.dll"); if (mmD2d1 && mmDWrite) { D2D1CreateFactory = pD2D1CreateFactory_t(GetProcAddress(mmD2d1, "D2D1CreateFactory")); @@ -75,7 +75,7 @@ D2DTextAntiAliasMode lclGetSystemTextAntiAliasMode() D2DTextAntiAliasMode eMode = D2DTextAntiAliasMode::Default; BOOL bFontSmoothing; - if (!SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &bFontSmoothing, 0)) + if (!SystemParametersInfoW(SPI_GETFONTSMOOTHING, 0, &bFontSmoothing, 0)) return eMode; if (bFontSmoothing) @@ -83,7 +83,7 @@ D2DTextAntiAliasMode lclGetSystemTextAntiAliasMode() eMode = D2DTextAntiAliasMode::AntiAliased; UINT nType; - if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &nType, 0) && nType == FE_FONTSMOOTHINGCLEARTYPE) + if (SystemParametersInfoW(SPI_GETFONTSMOOTHINGTYPE, 0, &nType, 0) && nType == FE_FONTSMOOTHINGCLEARTYPE) eMode = D2DTextAntiAliasMode::ClearType; } else diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx index fb8fb10d8055..f4d2a578ae64 100644 --- a/vcl/win/gdi/salbmp.cxx +++ b/vcl/win/gdi/salbmp.cxx @@ -515,7 +515,7 @@ bool WinSalBitmap::Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle ) { BITMAP aDDBInfo; - if( GetObjectA( mhDDB, sizeof( BITMAP ), &aDDBInfo ) ) + if( GetObjectW( mhDDB, sizeof( aDDBInfo ), &aDDBInfo ) ) { maSize = Size( aDDBInfo.bmWidth, aDDBInfo.bmHeight ); mnBitCount = aDDBInfo.bmPlanes * aDDBInfo.bmBitsPixel; @@ -610,7 +610,7 @@ bool WinSalBitmap::Create( const SalBitmap& rSSalBmp, SalGraphics* pSGraphics ) GlobalUnlock( rSalBmp.mhDIB ); - if( hNewDDB && GetObjectA( hNewDDB, sizeof( BITMAP ), &aDDBInfo ) ) + if( hNewDDB && GetObjectW( hNewDDB, sizeof( aDDBInfo ), &aDDBInfo ) ) { mhDDB = hNewDDB; maSize = Size( aDDBInfo.bmWidth, aDDBInfo.bmHeight ); @@ -797,7 +797,7 @@ HANDLE WinSalBitmap::ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB ) BITMAP aBmp; // find out size of source bitmap - GetObjectA( hHdl, sizeof( BITMAP ), &aBmp ); + GetObjectW( hHdl, sizeof( aBmp ), &aBmp ); // create destination bitmap if ( (hCopy = CreateBitmapIndirect( &aBmp )) != nullptr ) diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index f46ace4070a5..70ad1e908152 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -527,7 +527,7 @@ static FontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXW& rEnumFont aDFA.SetSymbolFlag(rLogFont.lfCharSet == SYMBOL_CHARSET); // get the font face name - aDFA.SetFamilyName(OUString(reinterpret_cast<const sal_Unicode*>(rLogFont.lfFaceName))); + aDFA.SetFamilyName(SAL_U(rLogFont.lfFaceName)); // use the face's style name only if it looks reasonable const wchar_t* pStyleName = rEnumFont.elfStyle; @@ -537,7 +537,7 @@ static FontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXW& rEnumFont if( *p < 0x0020 ) break; if( p < pEnd ) - aDFA.SetStyleName(OUString(reinterpret_cast<const sal_Unicode*>(pStyleName))); + aDFA.SetStyleName(SAL_U(pStyleName)); // heuristics for font quality // - opentypeTT > truetype @@ -571,7 +571,7 @@ static WinFontFace* ImplLogMetricToDevFontDataW( const ENUMLOGFONTEXW* pLogFont, void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, Font& rFont ) { - OUString aFontName( reinterpret_cast<const sal_Unicode*>(rLogFont.lfFaceName) ); + OUString aFontName( SAL_U(rLogFont.lfFaceName) ); if (!aFontName.isEmpty()) { rFont.SetFamilyName( aFontName ); @@ -944,8 +944,8 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa HFONT hOldFont = SelectFont( getHDC(), mhFonts[nFallbackLevel] ); wchar_t aFaceName[LF_FACESIZE+60]; - if( ::GetTextFaceW( getHDC(), sizeof(aFaceName)/sizeof(wchar_t), aFaceName ) ) - rxFontMetric->SetFamilyName(OUString(reinterpret_cast<const sal_Unicode*>(aFaceName))); + if( GetTextFaceW( getHDC(), SAL_N_ELEMENTS(aFaceName), aFaceName ) ) + rxFontMetric->SetFamilyName(SAL_U(aFaceName)); const DWORD nHheaTag = CalcTag("hhea"); const DWORD nOS2Tag = CalcTag("OS/2"); @@ -964,7 +964,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa // get the font metric OUTLINETEXTMETRICW aOutlineMetric; - const bool bOK = GetOutlineTextMetricsW(getHDC(), sizeof(OUTLINETEXTMETRICW), &aOutlineMetric); + const bool bOK = GetOutlineTextMetricsW(getHDC(), sizeof(aOutlineMetric), &aOutlineMetric); // restore the HDC to the font in the base level SelectFont( getHDC(), hOldFont ); if( !bOK ) @@ -1019,7 +1019,7 @@ int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe, // Ignore vertical fonts if ( pLogFont->elfLogFont.lfFaceName[0] != '@' ) { - OUString aName = OUString(reinterpret_cast<const sal_Unicode*>(pLogFont->elfLogFont.lfFaceName)); + OUString aName = SAL_U(pLogFont->elfLogFont.lfFaceName); pInfo->mpName = &aName; memcpy(pInfo->mpLogFont->lfFaceName, pLogFont->elfLogFont.lfFaceName, (aName.getLength()+1)*sizeof(wchar_t)); pInfo->mpLogFont->lfCharSet = pLogFont->elfLogFont.lfCharSet; @@ -1062,7 +1062,7 @@ int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe, struct TempFontItem { OUString maFontFilePath; - OString maResourcePath; + OUString maResourcePath; TempFontItem* mpNextItem; }; @@ -1072,35 +1072,33 @@ bool ImplAddTempFont( SalData& rSalData, const OUString& rFontFileURL ) OUString aUSytemPath; OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, aUSytemPath ) ); - nRet = AddFontResourceExW( reinterpret_cast<LPCWSTR>(aUSytemPath.getStr()), FR_PRIVATE, nullptr ); + nRet = AddFontResourceExW( SAL_W(aUSytemPath.getStr()), FR_PRIVATE, nullptr ); if ( !nRet ) { static int nCounter = 0; - char aFileName[] = "soAA.fot"; - aFileName[2] = sal::static_int_cast<char>('A' + (15 & (nCounter>>4))); - aFileName[3] = sal::static_int_cast<char>('A' + (15 & nCounter)); - char aResourceName[512]; - int const nMaxLen = sizeof(aResourceName)/sizeof(*aResourceName) - 16; - int nLen = ::GetTempPathA( nMaxLen, aResourceName ); - ::strncpy( aResourceName + nLen, aFileName, sizeof( aResourceName )- nLen ); + wchar_t aFileName[] = L"soAA.fot"; + aFileName[2] = sal::static_int_cast<wchar_t>(L'A' + (15 & (nCounter>>4))); + aFileName[3] = sal::static_int_cast<wchar_t>(L'A' + (15 & nCounter)); + wchar_t aResourceName[512]; + int const nMaxLen = SAL_N_ELEMENTS(aResourceName) - 16; + int nLen = GetTempPathW( nMaxLen, aResourceName ); + wcsncpy( aResourceName + nLen, aFileName, SAL_N_ELEMENTS( aResourceName ) - nLen ); // security: end buffer in any case - aResourceName[ (sizeof(aResourceName)/sizeof(*aResourceName))-1 ] = 0; - ::DeleteFileA( aResourceName ); + aResourceName[ SAL_N_ELEMENTS(aResourceName)-1 ] = 0; + DeleteFileW( aResourceName ); - rtl_TextEncoding theEncoding = osl_getThreadTextEncoding(); - OString aCFileName = OUStringToOString( aUSytemPath, theEncoding ); // TODO: font should be private => need to investigate why it doesn't work then - if( !::CreateScalableFontResourceA( 0, aResourceName, aCFileName.getStr(), nullptr ) ) + if( !CreateScalableFontResourceW( 0, aResourceName, SAL_W(aUSytemPath.getStr()), nullptr ) ) return false; ++nCounter; - nRet = ::AddFontResourceA( aResourceName ); + nRet = AddFontResourceW( aResourceName ); if( nRet > 0 ) { TempFontItem* pNewItem = new TempFontItem; - pNewItem->maResourcePath = OString( aResourceName ); - pNewItem->maFontFilePath = aUSytemPath.getStr(); + pNewItem->maResourcePath = SAL_U( aResourceName ); + pNewItem->maFontFilePath = aUSytemPath; pNewItem->mpNextItem = rSalData.mpTempFontItem; rSalData.mpTempFontItem = pNewItem; } @@ -1117,13 +1115,13 @@ void ImplReleaseTempFonts( SalData& rSalData ) ++nCount; if( p->maResourcePath.getLength() ) { - const char* pResourcePath = p->maResourcePath.getStr(); - ::RemoveFontResourceA( pResourcePath ); - ::DeleteFileA( pResourcePath ); + const wchar_t* pResourcePath = SAL_W(p->maResourcePath.getStr()); + RemoveFontResourceW( pResourcePath ); + DeleteFileW( pResourcePath ); } else { - ::RemoveFontResourceW( reinterpret_cast<LPCWSTR>(p->maFontFilePath.getStr()) ); + RemoveFontResourceW( SAL_W(p->maFontFilePath.getStr()) ); } rSalData.mpTempFontItem = p->mpNextItem; @@ -1147,19 +1145,17 @@ static bool ImplGetFontAttrFromFile( const OUString& rFontFileURL, rDFA.SetPitch(PITCH_DONTKNOW); // Create temporary file name - char aResourceName[512]; - int nMaxLen = sizeof(aResourceName)/sizeof(*aResourceName) - 16; - int nLen = ::GetTempPathA( nMaxLen, aResourceName ); - ::strncpy( aResourceName + nLen, "soAAT.fot", std::max( 0, nMaxLen - nLen )); - ::DeleteFileA( aResourceName ); + wchar_t aResourceName[512]; + int nMaxLen = SAL_N_ELEMENTS(aResourceName) - 16; + int nLen = GetTempPathW( nMaxLen, aResourceName ); + wcsncpy( aResourceName + nLen, L"soAAT.fot", std::max( 0, nMaxLen - nLen )); + DeleteFileW( aResourceName ); // Create font resource file (typically with a .fot file name extension). - rtl_TextEncoding theEncoding = osl_getThreadTextEncoding(); - OString aCFileName = OUStringToOString( aUSytemPath, theEncoding ); - ::CreateScalableFontResourceA( 0, aResourceName, aCFileName.getStr(), nullptr ); + CreateScalableFontResourceW( 0, aResourceName, SAL_W(aUSytemPath.getStr()), nullptr ); // Open and read the font resource file - OUString aFotFileName = OStringToOUString( aResourceName, osl_getThreadTextEncoding() ); + OUString aFotFileName = SAL_U( aResourceName ); osl::FileBase::getFileURLFromSystemPath( aFotFileName, aFotFileName ); osl::File aFotFile( aFotFileName ); osl::FileBase::RC aError = aFotFile.open( osl_File_OpenFlag_Read ); @@ -1171,7 +1167,7 @@ static bool ImplGetFontAttrFromFile( const OUString& rFontFileURL, aFotFile.read( aBuffer, sizeof( aBuffer ), nBytesRead ); // clean up temporary resource file aFotFile.close(); - ::DeleteFileA( aResourceName ); + DeleteFileW( aResourceName ); // retrieve font family name from byte offset 0x4F6 sal_uInt64 i = 0x4F6; @@ -1608,8 +1604,8 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, #if OSL_DEBUG_LEVEL > 1 // get font metrics - TEXTMETRICA aWinMetric; - if( !::GetTextMetricsA( getHDC(), &aWinMetric ) ) + TEXTMETRICW aWinMetric; + if( !::GetTextMetricsW( getHDC(), &aWinMetric ) ) return FALSE; SAL_WARN_IF( (aWinMetric.tmPitchAndFamily & TMPF_DEVICE), "vcl", "cannot subset device font" ); diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx index 3cb1b341f418..22ed3bf1262a 100644 --- a/vcl/win/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/gdi/salnativewidgets-luna.cxx @@ -351,7 +351,7 @@ bool ImplDrawTheme( HTHEME hTheme, HDC hDC, int iPart, int iState, RECT rc, cons RECT rcContent; hr = vsAPI.GetThemeBackgroundContentRect( hTheme, hDC, iPart, iState, &rc, &rcContent); hr = vsAPI.DrawThemeText( hTheme, hDC, iPart, iState, - reinterpret_cast<LPCWSTR>(aStr.getStr()), -1, + SAL_W(aStr.getStr()), -1, DT_CENTER | DT_VCENTER | DT_SINGLELINE, 0, &rcContent); } diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx index 211a524705d2..008f9a9e5817 100644 --- a/vcl/win/gdi/salprn.cxx +++ b/vcl/win/gdi/salprn.cxx @@ -79,8 +79,8 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::ui::dialogs; -static char aImplWindows[] = "windows"; -static char aImplDevice[] = "device"; +static const wchar_t aImplWindows[] = L"windows"; +static const wchar_t aImplDevice[] = L"device"; static DEVMODEW const * SAL_DEVMODE_W( const ImplJobSetup* pSetupData ) { @@ -162,7 +162,7 @@ void WinSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) for ( i = 0; i < nInfoPrn4; i++ ) { SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo; - pInfo->maPrinterName = OUString( reinterpret_cast< const sal_Unicode* >(pWinInfo4[i].pPrinterName) ); + pInfo->maPrinterName = SAL_U(pWinInfo4[i].pPrinterName); pInfo->mnStatus = PrintQueueFlags::NONE; pInfo->mnJobs = 0; pInfo->mpSysData = nullptr; @@ -176,7 +176,7 @@ void WinSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) void WinSalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) { HANDLE hPrinter = nullptr; - LPWSTR pPrnName = reinterpret_cast<LPWSTR>(const_cast<sal_Unicode*>(pInfo->maPrinterName.getStr())); + LPWSTR pPrnName = const_cast<LPWSTR>(SAL_W(pInfo->maPrinterName.getStr())); if( OpenPrinterW( pPrnName, &hPrinter, nullptr ) ) { DWORD nBytes = 0; @@ -187,18 +187,18 @@ void WinSalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) if( GetPrinterW( hPrinter, 2, reinterpret_cast<LPBYTE>(pWinInfo2), nBytes, &nBytes ) ) { if( pWinInfo2->pDriverName ) - pInfo->maDriver = OUString( reinterpret_cast< const sal_Unicode* >(pWinInfo2->pDriverName) ); + pInfo->maDriver = SAL_U(pWinInfo2->pDriverName); OUString aPortName; if ( pWinInfo2->pPortName ) - aPortName = OUString( reinterpret_cast< const sal_Unicode* >(pWinInfo2->pPortName) ); + aPortName = SAL_U(pWinInfo2->pPortName); // pLocation can be 0 (the Windows docu doesn't describe this) if ( pWinInfo2->pLocation && *pWinInfo2->pLocation ) - pInfo->maLocation = OUString( reinterpret_cast< const sal_Unicode* >(pWinInfo2->pLocation) ); + pInfo->maLocation = SAL_U(pWinInfo2->pLocation); else pInfo->maLocation = aPortName; // pComment can be 0 (the Windows docu doesn't describe this) if ( pWinInfo2->pComment ) - pInfo->maComment = OUString( reinterpret_cast< const sal_Unicode* >(pWinInfo2->pComment) ); + pInfo->maComment = SAL_U(pWinInfo2->pComment); pInfo->mnStatus = ImplWinQueueStatusToSal( pWinInfo2->Status ); pInfo->mnJobs = pWinInfo2->cJobs; if( ! pInfo->mpSysData ) @@ -226,7 +226,7 @@ OUString WinSalInstance::GetDefaultPrinter() OUString aDefPrt; if( GetDefaultPrinterW( pStr, &nChars ) ) { - aDefPrt = OUString(reinterpret_cast<sal_Unicode* >(pStr)); + aDefPrt = SAL_U(pStr); } rtl_freeMemory( pStr ); if( !aDefPrt.isEmpty() ) @@ -234,16 +234,16 @@ OUString WinSalInstance::GetDefaultPrinter() } // get default printer from win.ini - char szBuffer[256]; - GetProfileStringA( aImplWindows, aImplDevice, "", szBuffer, sizeof( szBuffer ) ); + wchar_t szBuffer[256]; + GetProfileStringW( aImplWindows, aImplDevice, L"", szBuffer, SAL_N_ELEMENTS( szBuffer ) ); if ( szBuffer[0] ) { // search for printer name - char* pBuf = szBuffer; - char* pTmp = pBuf; + wchar_t* pBuf = szBuffer; + wchar_t* pTmp = pBuf; while ( *pTmp && (*pTmp != ',') ) pTmp++; - return ImplSalGetUniString( pBuf, static_cast<sal_Int32>(pTmp-pBuf) ); + return OUString( SAL_U(pBuf), static_cast<sal_Int32>(pTmp-pBuf) ); } else return OUString(); @@ -258,8 +258,8 @@ static DWORD ImplDeviceCaps( WinSalInfoPrinter const * pPrinter, WORD nCaps, else pDevMode = SAL_DEVMODE_W( pSetupData ); - return DeviceCapabilitiesW( reinterpret_cast<LPCWSTR>(pPrinter->maDeviceName.getStr()), - reinterpret_cast<LPCWSTR>(pPrinter->maPortName.getStr()), + return DeviceCapabilitiesW( SAL_W(pPrinter->maDeviceName.getStr()), + SAL_W(pPrinter->maPortName.getStr()), nCaps, reinterpret_cast<LPWSTR>(pOutput), pDevMode ); } @@ -288,7 +288,7 @@ static bool ImplTestSalJobSetup( WinSalInfoPrinter const * pPrinter, // can avoid potential driver crashes as their jobsetups are often not compatible // #110800#, #111151#, #112381#, #i16580#, #i14173# and perhaps #112375# HANDLE hPrn; - LPWSTR pPrinterNameW = reinterpret_cast<LPWSTR>(const_cast<sal_Unicode*>(pPrinter->maDeviceName.getStr())); + LPWSTR pPrinterNameW = const_cast<LPWSTR>(SAL_W(pPrinter->maDeviceName.getStr())); if ( !OpenPrinterW( pPrinterNameW, &hPrn, nullptr ) ) return FALSE; @@ -350,7 +350,7 @@ static bool ImplUpdateSalJobSetup( WinSalInfoPrinter const * pPrinter, ImplJobSe bool bIn, WinSalFrame* pVisibleDlgParent ) { HANDLE hPrn; - LPWSTR pPrinterNameW = reinterpret_cast<LPWSTR>(const_cast<sal_Unicode*>(pPrinter->maDeviceName.getStr())); + LPWSTR pPrinterNameW = const_cast<LPWSTR>(SAL_W(pPrinter->maDeviceName.getStr())); if ( !OpenPrinterW( pPrinterNameW, &hPrn, nullptr ) ) return FALSE; // #131642# hPrn==HGDI_ERROR even though OpenPrinter() succeeded! @@ -1023,8 +1023,8 @@ static HDC ImplCreateSalPrnIC( WinSalInfoPrinter const * pPrinter, const ImplJob memset( pDriverName+pPrinter->maDriverName.getLength(), 0, 32 ); memcpy( pDeviceName, pPrinter->maDeviceName.getStr(), pPrinter->maDeviceName.getLength()*sizeof(sal_Unicode)); memset( pDeviceName+pPrinter->maDeviceName.getLength(), 0, 32 ); - hDC = ImplCreateICW_WithCatch( reinterpret_cast< LPWSTR >(pDriverName), - reinterpret_cast< LPCWSTR >(pDeviceName), + hDC = ImplCreateICW_WithCatch( SAL_W(pDriverName), + SAL_W(pDeviceName), pDevMode ); return hDC; } @@ -1438,8 +1438,8 @@ bool WinSalPrinter::StartJob( const OUString* pFileName, sal_Unicode aDevBuf[4096]; memcpy( aDrvBuf, mpInfoPrinter->maDriverName.getStr(), (mpInfoPrinter->maDriverName.getLength()+1)*sizeof(sal_Unicode)); memcpy( aDevBuf, mpInfoPrinter->maDeviceName.getStr(), (mpInfoPrinter->maDeviceName.getLength()+1)*sizeof(sal_Unicode)); - hDC = CreateDCW( reinterpret_cast<LPCWSTR>(aDrvBuf), - reinterpret_cast<LPCWSTR>(aDevBuf), + hDC = CreateDCW( SAL_W(aDrvBuf), + SAL_W(aDevBuf), nullptr, pDevModeW ); @@ -1481,7 +1481,6 @@ bool WinSalPrinter::StartJob( const OUString* pFileName, { Sequence< OUString > aPathSeq( xFilePicker->getSelectedFiles() ); INetURLObject aObj( aPathSeq[0] ); - // we're using ansi calls (StartDocA) so convert the string aOutFileName = aObj.PathToFileName(); } else diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index dd32c80ae695..3521bea0796d 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -253,7 +253,7 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout, if (rLayout.getFontSelData().mbVertical) { LOGFONTW aLogFont; - GetObjectW(hFont, sizeof(LOGFONTW), &aLogFont); + GetObjectW(hFont, sizeof(aLogFont), &aLogFont); if (aLogFont.lfFaceName[0] == '@') { memmove(&aLogFont.lfFaceName[0], &aLogFont.lfFaceName[1], diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 411bb644bfd5..e8a7c5090172 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -116,7 +116,7 @@ using namespace ::com::sun::star::beans; # define IDC_PEN MAKEINTRESOURCE(32631) #endif -const unsigned int WM_USER_SYSTEM_WINDOW_ACTIVATED = RegisterWindowMessageA("SYSTEM_WINDOW_ACTIVATED"); +const unsigned int WM_USER_SYSTEM_WINDOW_ACTIVATED = RegisterWindowMessageW(L"SYSTEM_WINDOW_ACTIVATED"); bool WinSalFrame::mbInReparent = FALSE; @@ -227,7 +227,7 @@ void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect ) pRect->bottom = GetSystemMetrics( SM_CYSCREEN ); } else - SystemParametersInfo( SPI_GETWORKAREA, 0, pRect, 0 ); + SystemParametersInfoW( SPI_GETWORKAREA, 0, pRect, 0 ); } else { @@ -262,7 +262,7 @@ void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect ) if( !bIgnoreTaskbar ) { RECT wRect, scrRect; - SystemParametersInfo( SPI_GETWORKAREA, 0, &wRect, 0 ); + SystemParametersInfoW( SPI_GETWORKAREA, 0, &wRect, 0 ); scrRect.left = 0; scrRect.top = 0; scrRect.right = GetSystemMetrics( SM_CXSCREEN ); @@ -503,8 +503,8 @@ SalFrame* ImplSalCreateFrame( WinSalInstance* pInst, HWND ImplSalReCreateHWND( HWND hWndParent, HWND oldhWnd, bool bAsChild ) { HINSTANCE hInstance = GetSalData()->mhInst; - sal_uLong nSysStyle = GetWindowLong( oldhWnd, GWL_STYLE ); - sal_uLong nExSysStyle = GetWindowLong( oldhWnd, GWL_EXSTYLE ); + sal_uLong nSysStyle = GetWindowLongW( oldhWnd, GWL_STYLE ); + sal_uLong nExSysStyle = GetWindowLongW( oldhWnd, GWL_EXSTYLE ); if( bAsChild ) { @@ -675,15 +675,15 @@ static const sal_uInt16 aImplTranslateKeyTab[KEY_TAB_SIZE] = static UINT ImplSalGetWheelScrollLines() { UINT nScrLines = 0; - HWND hWndMsWheel = FindWindowA( MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE ); + HWND hWndMsWheel = FindWindowW( MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE ); if ( hWndMsWheel ) { - UINT nGetScrollLinesMsgId = RegisterWindowMessage( MSH_SCROLL_LINES ); + UINT nGetScrollLinesMsgId = RegisterWindowMessageW( MSH_SCROLL_LINES ); nScrLines = (UINT)SendMessageW( hWndMsWheel, nGetScrollLinesMsgId, 0, 0 ); } if ( !nScrLines ) - if( !SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &nScrLines, 0 ) ) + if( !SystemParametersInfoW( SPI_GETWHEELSCROLLLINES, 0, &nScrLines, 0 ) ) nScrLines = 0 ; if ( !nScrLines ) @@ -695,7 +695,7 @@ static UINT ImplSalGetWheelScrollLines() static UINT ImplSalGetWheelScrollChars() { UINT nScrChars = 0; - if( !SystemParametersInfo( SPI_GETWHEELSCROLLCHARS, 0, &nScrChars, 0 ) ) + if( !SystemParametersInfoW( SPI_GETWHEELSCROLLCHARS, 0, &nScrChars, 0 ) ) { return 3; } @@ -1070,7 +1070,7 @@ void WinSalFrame::SetTitle( const OUString& rTitle ) { static_assert( sizeof( WCHAR ) == sizeof( sal_Unicode ), "must be the same size" ); - SetWindowTextW( mhWnd, reinterpret_cast<LPCWSTR>(rTitle.getStr()) ); + SetWindowTextW( mhWnd, SAL_W(rTitle.getStr()) ); } void WinSalFrame::SetIcon( sal_uInt16 nIcon ) @@ -1935,16 +1935,16 @@ void WinSalFrame::StartPresentation( bool bStart ) if ( bStart ) { // turn off screen-saver when in Presentation mode - SystemParametersInfo( SPI_GETSCREENSAVEACTIVE, 0, + SystemParametersInfoW( SPI_GETSCREENSAVEACTIVE, 0, &(pSalData->mbScrSvrEnabled), 0 ); if ( pSalData->mbScrSvrEnabled ) - SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, FALSE, nullptr, 0 ); + SystemParametersInfoW( SPI_SETSCREENSAVEACTIVE, FALSE, nullptr, 0 ); } else { // turn on screen-saver if ( pSalData->mbScrSvrEnabled ) - SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, pSalData->mbScrSvrEnabled, nullptr, 0 ); + SystemParametersInfoW( SPI_SETSCREENSAVEACTIVE, pSalData->mbScrSvrEnabled, nullptr, 0 ); } } @@ -2031,7 +2031,7 @@ void WinSalFrame::SetPointer( PointerStyle ePointerStyle ) struct ImplPtrData { HCURSOR mhCursor; - LPCSTR mnSysId; + LPCTSTR mnSysId; UINT mnOwnId; }; @@ -2303,7 +2303,7 @@ static void ImplGetKeyNameText( LONG lParam, sal_Unicode* pBuf, else { nKeyLen = aRet.getLength(); - wcscpy( aKeyBuf, reinterpret_cast< const wchar_t* >( aRet.getStr() )); + wcscpy( aKeyBuf, SAL_W( aRet.getStr() )); } } @@ -2344,21 +2344,21 @@ OUString WinSalFrame::GetKeyName( sal_uInt16 nKeyCode ) if ( nKeyCode & KEY_MOD1 ) { - nSysCode = MapVirtualKey( VK_CONTROL, 0 ); + nSysCode = MapVirtualKeyW( VK_CONTROL, 0 ); nSysCode = (nSysCode << 16) | (((sal_uLong)1) << 25); ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, "Ctrl" ); } if ( nKeyCode & KEY_MOD2 ) { - nSysCode = MapVirtualKey( VK_MENU, 0 ); + nSysCode = MapVirtualKeyW( VK_MENU, 0 ); nSysCode = (nSysCode << 16) | (((sal_uLong)1) << 25); ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, "Alt" ); } if ( nKeyCode & KEY_SHIFT ) { - nSysCode = MapVirtualKey( VK_SHIFT, 0 ); + nSysCode = MapVirtualKeyW( VK_SHIFT, 0 ); nSysCode = (nSysCode << 16) | (((sal_uLong)1) << 25); ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, "Shift" ); } @@ -2516,7 +2516,7 @@ OUString WinSalFrame::GetKeyName( sal_uInt16 nKeyCode ) if ( nSysCode ) { - nSysCode = MapVirtualKey( nSysCode, 0 ); + nSysCode = MapVirtualKeyW( nSysCode, 0 ); if ( nSysCode ) nSysCode = (nSysCode << 16) | nSysCode2; ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, pReplace ); @@ -2554,14 +2554,14 @@ static void ImplSalUpdateStyleFontW( HDC hDC, const LOGFONTW& rLogFont, vcl::Fon // 6 Point is the smallest one if ( rFont.GetFontHeight() < 8 ) { - if ( rtl_ustr_compareIgnoreAsciiCase( reinterpret_cast<const sal_Unicode*>(rLogFont.lfFaceName), reinterpret_cast<const sal_Unicode*>(L"MS Sans Serif") ) == 0 ) + if ( rtl_ustr_compareIgnoreAsciiCase( SAL_U(rLogFont.lfFaceName), SAL_U(L"MS Sans Serif") ) == 0 ) rFont.SetFontHeight( 8 ); else if ( rFont.GetFontHeight() < 6 ) rFont.SetFontHeight( 6 ); } } -static long ImplA2I( const BYTE* pStr ) +static long ImplW2I( const wchar_t* pStr ) { long n = 0; int nSign = 1; @@ -2597,18 +2597,18 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) if ( nDragHeight ) aMouseSettings.SetStartDragHeight( nDragHeight ); HKEY hRegKey; - if ( RegOpenKey( HKEY_CURRENT_USER, - "Control Panel\\Desktop", - &hRegKey ) == ERROR_SUCCESS ) + if ( RegOpenKeyW( HKEY_CURRENT_USER, + L"Control Panel\\Desktop", + &hRegKey ) == ERROR_SUCCESS ) { - BYTE aValueBuf[10]; + wchar_t aValueBuf[10]; DWORD nValueSize = sizeof( aValueBuf ); DWORD nType; - if ( RegQueryValueEx( hRegKey, "MenuShowDelay", nullptr, - &nType, aValueBuf, &nValueSize ) == ERROR_SUCCESS ) + if ( RegQueryValueExW( hRegKey, L"MenuShowDelay", nullptr, + &nType, reinterpret_cast<LPBYTE>(aValueBuf), &nValueSize ) == ERROR_SUCCESS ) { if ( nType == REG_SZ ) - aMouseSettings.SetMenuDelay( (sal_uLong)ImplA2I( aValueBuf ) ); + aMouseSettings.SetMenuDelay( (sal_uLong)ImplW2I( aValueBuf ) ); } RegCloseKey( hRegKey ); @@ -2689,8 +2689,8 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetActiveTextColor( ImplWinColorToSal( GetSysColor( COLOR_CAPTIONTEXT ) ) ); aStyleSettings.SetDeactiveColor( ImplWinColorToSal( GetSysColor( COLOR_INACTIVECAPTION ) ) ); aStyleSettings.SetDeactiveTextColor( ImplWinColorToSal( GetSysColor( COLOR_INACTIVECAPTIONTEXT ) ) ); - long bFlatMenus = 0; - SystemParametersInfo( SPI_GETFLATMENU, 0, &bFlatMenus, 0); + BOOL bFlatMenus = FALSE; + SystemParametersInfoW( SPI_GETFLATMENU, 0, &bFlatMenus, 0); if( bFlatMenus ) { aStyleSettings.SetUseFlatMenus( TRUE ); @@ -2707,13 +2707,13 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) // caret width DWORD nCaretWidth = 2; - if( SystemParametersInfo( SPI_GETCARETWIDTH, 0, &nCaretWidth, 0 ) ) + if( SystemParametersInfoW( SPI_GETCARETWIDTH, 0, &nCaretWidth, 0 ) ) aStyleSettings.SetCursorSize( nCaretWidth ); // High contrast HIGHCONTRAST hc; hc.cbSize = sizeof( HIGHCONTRAST ); - if( SystemParametersInfo( SPI_GETHIGHCONTRAST, hc.cbSize, &hc, 0 ) + if( SystemParametersInfoW( SPI_GETHIGHCONTRAST, hc.cbSize, &hc, 0 ) && (hc.dwFlags & HCF_HIGHCONTRASTON) ) aStyleSettings.SetHighContrastMode( true ); else @@ -2775,7 +2775,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetTabFont( aAppFont ); BOOL bDragFull; - if ( SystemParametersInfo( SPI_GETDRAGFULLWINDOWS, 0, &bDragFull, 0 ) ) + if ( SystemParametersInfoW( SPI_GETDRAGFULLWINDOWS, 0, &bDragFull, 0 ) ) { DragFullOptions nDragFullOptions = aStyleSettings.GetDragFullOptions(); if ( bDragFull ) @@ -2785,20 +2785,20 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetDragFullOptions( nDragFullOptions ); } - if ( RegOpenKey( HKEY_CURRENT_USER, - "Control Panel\\International\\Calendars\\TwoDigitYearMax", - &hRegKey ) == ERROR_SUCCESS ) + if ( RegOpenKeyW( HKEY_CURRENT_USER, + L"Control Panel\\International\\Calendars\\TwoDigitYearMax", + &hRegKey ) == ERROR_SUCCESS ) { - BYTE aValueBuf[10]; + wchar_t aValueBuf[10]; DWORD nValue; DWORD nValueSize = sizeof( aValueBuf ); DWORD nType; - if ( RegQueryValueEx( hRegKey, "1", nullptr, - &nType, aValueBuf, &nValueSize ) == ERROR_SUCCESS ) + if ( RegQueryValueExW( hRegKey, L"1", nullptr, + &nType, reinterpret_cast<LPBYTE>(aValueBuf), &nValueSize ) == ERROR_SUCCESS ) { if ( nType == REG_SZ ) { - nValue = (sal_uLong)ImplA2I( aValueBuf ); + nValue = (sal_uLong)ImplW2I( aValueBuf ); if ( (nValue > 1000) && (nValue < 10000) ) { MiscSettings aMiscSettings = rSettings.GetMiscSettings(); @@ -4436,15 +4436,15 @@ static int ImplMeasureItem( HWND hWnd, WPARAM wParam, LPARAM lParam ) HDC hdc = GetDC( hWnd ); SIZE strSize; - NONCLIENTMETRICS ncm; + NONCLIENTMETRICSW ncm; memset( &ncm, 0, sizeof(ncm) ); ncm.cbSize = sizeof( ncm ); - SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); + SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); // Assume every menu item can be default and printed bold //ncm.lfMenuFont.lfWeight = FW_BOLD; - HFONT hfntOld = static_cast<HFONT>(SelectObject(hdc, CreateFontIndirect( &ncm.lfMenuFont ))); + HFONT hfntOld = static_cast<HFONT>(SelectObject(hdc, CreateFontIndirectW( &ncm.lfMenuFont ))); // menu text and accelerator OUString aStr(pSalMenuItem->mText); @@ -4577,16 +4577,16 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) x += bmpSize.Width() + 3; aRect.left = x; - NONCLIENTMETRICS ncm; + NONCLIENTMETRICSW ncm; memset( &ncm, 0, sizeof(ncm) ); ncm.cbSize = sizeof( ncm ); - SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); + SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); // Print default menu entry with bold font //if ( pDI->itemState & ODS_DEFAULT ) // ncm.lfMenuFont.lfWeight = FW_BOLD; - hfntOld = static_cast<HFONT>(SelectObject(pDI->hDC, CreateFontIndirect( &ncm.lfMenuFont ))); + hfntOld = static_cast<HFONT>(SelectObject(pDI->hDC, CreateFontIndirectW( &ncm.lfMenuFont ))); SIZE strSize; OUString aStr( pSalMenuItem->mText ); @@ -4605,8 +4605,8 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) aStr = pSalMenuItem->mAccelText; GetTextExtentPoint32W( pDI->hDC, SAL_W(aStr.getStr()), aStr.getLength(), &strSizeA ); - TEXTMETRIC tm; - GetTextMetrics( pDI->hDC, &tm ); + TEXTMETRICW tm; + GetTextMetricsW( pDI->hDC, &tm ); // position the accelerator string to the right but leave space for the // (potential) submenu arrow (tm.tmMaxCharWidth) @@ -4969,7 +4969,7 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, { auto pTextBuf = std::unique_ptr<WCHAR[]>(new WCHAR[nTextLen]); ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, pTextBuf.get(), nTextLen*sizeof( WCHAR ) ); - aEvt.maText = OUString( reinterpret_cast<const sal_Unicode*>(pTextBuf.get()), (sal_Int32)nTextLen ); + aEvt.maText = OUString( SAL_U(pTextBuf.get()), (sal_Int32)nTextLen ); } aEvt.mnCursorPos = aEvt.maText.getLength(); @@ -4992,17 +4992,18 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, LONG nTextLen = ImmGetCompositionStringW( hIMC, GCS_COMPSTR, nullptr, 0 ) / sizeof( WCHAR ); if ( nTextLen > 0 ) { - WCHAR* pTextBuf = new WCHAR[nTextLen]; - ImmGetCompositionStringW( hIMC, GCS_COMPSTR, pTextBuf, nTextLen*sizeof( WCHAR ) ); - aEvt.maText = OUString( reinterpret_cast<const sal_Unicode*>(pTextBuf), (sal_Int32)nTextLen ); - delete [] pTextBuf; + { + auto pTextBuf = std::unique_ptr<WCHAR>(new WCHAR[nTextLen]); + ImmGetCompositionStringW( hIMC, GCS_COMPSTR, pTextBuf.get(), nTextLen*sizeof( WCHAR ) ); + aEvt.maText = OUString( SAL_U(pTextBuf.get()), (sal_Int32)nTextLen ); + } - BYTE* pAttrBuf = nullptr; + std::unique_ptr<BYTE> pAttrBuf; LONG nAttrLen = ImmGetCompositionStringW( hIMC, GCS_COMPATTR, nullptr, 0 ); if ( nAttrLen > 0 ) { - pAttrBuf = new BYTE[nAttrLen]; - ImmGetCompositionStringW( hIMC, GCS_COMPATTR, pAttrBuf, nAttrLen ); + pAttrBuf.reset(new BYTE[nAttrLen]); + ImmGetCompositionStringW( hIMC, GCS_COMPATTR, pAttrBuf.get(), nAttrLen ); } if ( pAttrBuf ) @@ -5012,7 +5013,7 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, memset( pSalAttrAry, 0, nTextLen2*sizeof( sal_uInt16 ) ); for( sal_Int32 i = 0; (i < nTextLen2) && (i < nAttrLen); i++ ) { - BYTE nWinAttr = pAttrBuf[i]; + BYTE nWinAttr = pAttrBuf.get()[i]; ExtTextInputAttr nSalAttr; if ( nWinAttr == ATTR_TARGET_CONVERTED ) { @@ -5031,7 +5032,6 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, } aEvt.mpTextAttr = pSalAttrAry; - delete [] pAttrBuf; } } @@ -5443,9 +5443,9 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lP if ( nMsg == WM_CREATE ) { // Save Window-Instance in Windowhandle - // Can also be used for the W-Version, because the struct + // Can also be used for the A-Version, because the struct // to access lpCreateParams is the same structure - CREATESTRUCTA* pStruct = reinterpret_cast<CREATESTRUCTA*>(lParam); + CREATESTRUCTW* pStruct = reinterpret_cast<CREATESTRUCTW*>(lParam); WinSalFrame* pFrame = static_cast<WinSalFrame*>(pStruct->lpCreateParams); if ( pFrame != nullptr ) { @@ -5870,7 +5870,7 @@ bool HasAtHook() { BOOL bIsRunning = FALSE; // pvParam must be BOOL - return SystemParametersInfo(SPI_GETSCREENREADER, 0, &bIsRunning, 0) + return SystemParametersInfoW(SPI_GETSCREENREADER, 0, &bIsRunning, 0) && bIsRunning; } #endif diff --git a/vcl/win/window/salobj.cxx b/vcl/win/window/salobj.cxx index dfbcf8c54648..744d260c0d48 100644 --- a/vcl/win/window/salobj.cxx +++ b/vcl/win/window/salobj.cxx @@ -356,9 +356,9 @@ LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM l case WM_CREATE: { // Window-Instanz am Windowhandle speichern - // Can also be used for the W-Version, because the struct + // Can also be used for the A-Version, because the struct // to access lpCreateParams is the same structure - CREATESTRUCTA* pStruct = reinterpret_cast<CREATESTRUCTA*>(lParam); + CREATESTRUCTW* pStruct = reinterpret_cast<CREATESTRUCTW*>(lParam); pSysObj = static_cast<WinSalObject*>(pStruct->lpCreateParams); SetSalObjWindowPtr( hWnd, pSysObj ); // set HWND already here, @@ -372,12 +372,12 @@ LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM l return nRet; } -LRESULT CALLBACK SalSysObjWndProcA( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) +LRESULT CALLBACK SalSysObjWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) { int bDef = TRUE; LRESULT nRet = SalSysObjWndProc( hWnd, nMsg, wParam, lParam, bDef ); if ( bDef ) - nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam ); + nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam ); return nRet; } @@ -443,12 +443,12 @@ LRESULT CALLBACK SalSysObjChildWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPA return nRet; } -LRESULT CALLBACK SalSysObjChildWndProcA( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) +LRESULT CALLBACK SalSysObjChildWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) { int bDef = TRUE; LRESULT nRet = SalSysObjChildWndProc( hWnd, nMsg, wParam, lParam, bDef ); if ( bDef ) - nRet = DefWindowProcA( hWnd, nMsg, wParam, lParam ); + nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam ); return nRet; } @@ -467,10 +467,10 @@ SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent ) if ( !pSalData->mbObjClassInit ) { - WNDCLASSEXA aWndClassEx; + WNDCLASSEXW aWndClassEx; aWndClassEx.cbSize = sizeof( aWndClassEx ); aWndClassEx.style = 0; - aWndClassEx.lpfnWndProc = SalSysObjWndProcA; + aWndClassEx.lpfnWndProc = SalSysObjWndProcW; aWndClassEx.cbClsExtra = 0; aWndClassEx.cbWndExtra = SAL_OBJECT_WNDEXTRA; aWndClassEx.hInstance = pSalData->mhInst; @@ -479,15 +479,15 @@ SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent ) aWndClassEx.hCursor = LoadCursor( nullptr, IDC_ARROW ); aWndClassEx.hbrBackground = nullptr; aWndClassEx.lpszMenuName = nullptr; - aWndClassEx.lpszClassName = SAL_OBJECT_CLASSNAMEA; - if ( RegisterClassExA( &aWndClassEx ) ) + aWndClassEx.lpszClassName = SAL_OBJECT_CLASSNAMEW; + if ( RegisterClassExW( &aWndClassEx ) ) { // Clean background first because of plugins. aWndClassEx.cbWndExtra = 0; aWndClassEx.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1); - aWndClassEx.lpfnWndProc = SalSysObjChildWndProcA; - aWndClassEx.lpszClassName = SAL_OBJECT_CHILDCLASSNAMEA; - if ( RegisterClassExA( &aWndClassEx ) ) + aWndClassEx.lpfnWndProc = SalSysObjChildWndProcW; + aWndClassEx.lpszClassName = SAL_OBJECT_CHILDCLASSNAMEW; + if ( RegisterClassExW( &aWndClassEx ) ) pSalData->mbObjClassInit = true; } } @@ -500,7 +500,7 @@ SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent ) // SystemChildWindow. Otherwise, DXCanvas (using a hidden // SystemChildWindow) clobbers applets/plugins during // animations . - HWND hWnd = CreateWindowExA( 0, SAL_OBJECT_CLASSNAMEA, "", + HWND hWnd = CreateWindowExW( 0, SAL_OBJECT_CLASSNAMEW, L"", WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0, pParent->mhWnd, nullptr, pInst->mhInst, pObject ); @@ -513,7 +513,7 @@ SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent ) // of zorder. SetWindowPos(hWnd,HWND_TOP,0,0,0,0, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOSIZE); - hWndChild = CreateWindowExA( 0, SAL_OBJECT_CHILDCLASSNAMEA, "", + hWndChild = CreateWindowExW( 0, SAL_OBJECT_CHILDCLASSNAMEW, L"", WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, 0, 0, 0, 0, hWnd, nullptr, @@ -523,13 +523,14 @@ SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent ) if ( !hWndChild ) { #if OSL_DEBUG_LEVEL > 1 - char *msg = NULL; - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER + wchar_t *msg = NULL; + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, - (LPSTR) &msg, 0, NULL); - MessageBoxA(NULL, msg, "CreateWindowExA failed", MB_OK); + (LPWSTR) &msg, 0, NULL); + MessageBoxW(NULL, msg, L"CreateWindowExW failed", MB_OK); + HeapFree(GetProcessHeap(), msg); #endif delete pObject; return nullptr; diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index 9b16270d4d1f..8f1694778a25 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -966,20 +966,20 @@ void Databases::cascadingStylesheet( const OUString& Language, aCSS = "highcontrastblack"; #ifdef _WIN32 HKEY hKey = nullptr; - LONG lResult = RegOpenKeyExA( HKEY_CURRENT_USER, "Control Panel\\Accessibility\\HighContrast", 0, KEY_QUERY_VALUE, &hKey ); + LONG lResult = RegOpenKeyExW( HKEY_CURRENT_USER, L"Control Panel\\Accessibility\\HighContrast", 0, KEY_QUERY_VALUE, &hKey ); if ( ERROR_SUCCESS == lResult ) { - CHAR szBuffer[1024]; + WCHAR szBuffer[1024]; DWORD nSize = sizeof( szBuffer ); - lResult = RegQueryValueExA( hKey, "High Contrast Scheme", nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer), &nSize ); + lResult = RegQueryValueExW( hKey, L"High Contrast Scheme", nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer), &nSize ); if ( ERROR_SUCCESS == lResult && nSize > 0 ) { szBuffer[nSize] = '\0'; - if ( strncmp( szBuffer, "High Contrast #1", strlen("High Contrast #1") ) == 0 ) + if ( wcscmp( szBuffer, L"High Contrast #1" ) == 0 ) aCSS = "highcontrast1"; - if ( strncmp( szBuffer, "High Contrast #2", strlen("High Contrast #2") ) == 0 ) + if ( wcscmp( szBuffer, L"High Contrast #2" ) == 0 ) aCSS = "highcontrast2"; - if ( strncmp( szBuffer, "High Contrast White", strlen("High Contrast White") ) == 0 ) + if ( wcscmp( szBuffer, L"High Contrast White" ) == 0 ) aCSS = "highcontrastwhite"; } RegCloseKey( hKey ); diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index 8df7520a9897..44b430fe939a 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -372,7 +372,7 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::getPerso CertEnumSystemStore(CERT_SYSTEM_STORE_CURRENT_USER, nullptr, nullptr, cert_enum_system_store_callback); #endif - hSystemKeyStore = CertOpenSystemStore( 0, "MY" ) ; + hSystemKeyStore = CertOpenSystemStoreW( 0, L"MY" ) ; if( hSystemKeyStore != nullptr ) { pCertContext = CertEnumCertificatesInStore( hSystemKeyStore, pCertContext ); while (pCertContext) @@ -420,7 +420,6 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::getPerso Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const OUString& issuerName, const Sequence< sal_Int8 >& serialNumber ) { unsigned int i ; - LPCSTR pszName ; X509Certificate_MSCryptImpl *xcert = nullptr ; PCCERT_CONTEXT pCertContext = nullptr ; HCERTSTORE hCertStore = nullptr ; @@ -434,10 +433,9 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const encoding = osl_getTextEncodingFromLocale( pLocale ) ; //Create cert info from issue and serial - OString oissuer = OUStringToOString( issuerName , encoding ) ; - pszName = oissuer.getStr() ; + LPCWSTR pszName = SAL_W( issuerName.getStr() ); - if( ! ( CertStrToName( + if( ! ( CertStrToNameW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , pszName , CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG | CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG, @@ -452,7 +450,7 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const if(!certInfo.Issuer.pbData) throw RuntimeException() ; - if( ! ( CertStrToName( + if( ! ( CertStrToNameW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , pszName , CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG | CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG, @@ -492,19 +490,19 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const hCertStore = m_hCertStore ; break; case 2: - hCertStore = CertOpenSystemStore( 0, "MY" ) ; + hCertStore = CertOpenSystemStoreW( 0, L"MY" ) ; if(hCertStore == nullptr || !m_bEnableDefault) continue ; break; case 3: - hCertStore = CertOpenSystemStore( 0, "Root" ) ; + hCertStore = CertOpenSystemStoreW( 0, L"Root" ) ; if(hCertStore == nullptr || !m_bEnableDefault) continue ; break; case 4: - hCertStore = CertOpenSystemStore( 0, "Trust" ) ; + hCertStore = CertOpenSystemStoreW( 0, L"Trust" ) ; if(hCertStore == nullptr || !m_bEnableDefault) continue ; break; case 5: - hCertStore = CertOpenSystemStore( 0, "CA" ) ; + hCertStore = CertOpenSystemStoreW( 0, L"CA" ) ; if(hCertStore == nullptr || !m_bEnableDefault) continue ; break; default: @@ -1055,7 +1053,7 @@ xmlSecKeysMngrPtr SecurityEnvironment_MSCryptImpl::createKeysManager() { */ if( defaultEnabled() ) { //Add system key store into the keys manager. - m_hMySystemStore = CertOpenSystemStore( 0, "MY" ) ; + m_hMySystemStore = CertOpenSystemStoreW( 0, L"MY" ) ; if( m_hMySystemStore != nullptr ) { if( xmlSecMSCryptoAppliedKeysMngrAdoptKeyStore( pKeysMngr, m_hMySystemStore ) < 0 ) { CertCloseStore( m_hMySystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; @@ -1065,7 +1063,7 @@ xmlSecKeysMngrPtr SecurityEnvironment_MSCryptImpl::createKeysManager() { } //Add system root store into the keys manager. - m_hRootSystemStore = CertOpenSystemStore( 0, "Root" ) ; + m_hRootSystemStore = CertOpenSystemStoreW( 0, L"Root" ) ; if( m_hRootSystemStore != nullptr ) { if( xmlSecMSCryptoAppliedKeysMngrAdoptTrustedStore( pKeysMngr, m_hRootSystemStore ) < 0 ) { CertCloseStore( m_hRootSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; @@ -1075,7 +1073,7 @@ xmlSecKeysMngrPtr SecurityEnvironment_MSCryptImpl::createKeysManager() { } //Add system trusted store into the keys manager. - m_hTrustSystemStore = CertOpenSystemStore( 0, "Trust" ) ; + m_hTrustSystemStore = CertOpenSystemStoreW( 0, L"Trust" ) ; if( m_hTrustSystemStore != nullptr ) { if( xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore( pKeysMngr, m_hTrustSystemStore ) < 0 ) { CertCloseStore( m_hTrustSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; @@ -1085,7 +1083,7 @@ xmlSecKeysMngrPtr SecurityEnvironment_MSCryptImpl::createKeysManager() { } //Add system CA store into the keys manager. - m_hCaSystemStore = CertOpenSystemStore( 0, "CA" ) ; + m_hCaSystemStore = CertOpenSystemStoreW( 0, L"CA" ) ; if( m_hCaSystemStore != nullptr ) { if( xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore( pKeysMngr, m_hCaSystemStore ) < 0 ) { CertCloseStore( m_hCaSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx index 72b50e292079..6fd3bdc85c24 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx @@ -50,13 +50,14 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL { const char* n_pCertStore ; HCERTSTORE n_hStoreHandle ; + OString sCertDir; //Initialize the crypto engine if( sCertDB.getLength() > 0 ) { - OString sCertDir(sCertDB.getStr(), sCertDB.getLength(), RTL_TEXTENCODING_ASCII_US); + sCertDir = OString(sCertDB.getStr(), sCertDB.getLength(), RTL_TEXTENCODING_ASCII_US); n_pCertStore = sCertDir.getStr(); - n_hStoreHandle = CertOpenSystemStore( NULL, n_pCertStore ) ; + n_hStoreHandle = CertOpenSystemStoreW( NULL, SAL_W(sCertDB.getStr())) ; if( n_hStoreHandle == nullptr ) { return nullptr; diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx index 7fcc699b8a25..c45b541cf3d7 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -205,9 +205,7 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSerialNu OUString SAL_CALL X509Certificate_MSCryptImpl::getIssuerName() { if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { - DWORD cbIssuer ; - - cbIssuer = CertNameToStr( + DWORD cchIssuer = CertNameToStrW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , &( m_pCertContext->pCertInfo->Issuer ), CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , @@ -215,28 +213,22 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getIssuerName() { ) ; // Here the cbIssuer count the last 0x00 , take care. - if( cbIssuer != 0 ) { - auto issuer = std::unique_ptr<char[]>(new char[ cbIssuer ]); + if( cchIssuer != 0 ) { + auto issuer = std::unique_ptr<wchar_t[]>(new wchar_t[ cchIssuer ]); - cbIssuer = CertNameToStr( + cchIssuer = CertNameToStrW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , &( m_pCertContext->pCertInfo->Issuer ), CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , - issuer.get(), cbIssuer + issuer.get(), cchIssuer ) ; - if( cbIssuer <= 0 ) { + if( cchIssuer <= 0 ) { throw RuntimeException() ; } - // for correct encoding - sal_uInt16 encoding ; - rtl_Locale *pLocale = nullptr ; - osl_getProcessLocale( &pLocale ) ; - encoding = osl_getTextEncodingFromLocale( pLocale ) ; - - if(issuer.get()[cbIssuer-1] == 0) cbIssuer--; //delimit the last 0x00; - OUString xIssuer(issuer.get() , cbIssuer ,encoding ) ; + if(issuer.get()[cchIssuer -1] == 0) cchIssuer--; //delimit the last 0x00; + OUString xIssuer(SAL_U(issuer.get()), cchIssuer) ; return replaceTagSWithTagST(xIssuer); } else { @@ -251,32 +243,29 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getSubjectName() { if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { - DWORD cbSubject ; - - cbSubject = CertNameToStrW( + DWORD cchSubject = CertNameToStrW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , &( m_pCertContext->pCertInfo->Subject ), CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , nullptr, 0 ) ; - if( cbSubject != 0 ) + if( cchSubject != 0 ) { - auto subject = std::unique_ptr<wchar_t[]>(new wchar_t[ cbSubject ]); + auto subject = std::unique_ptr<wchar_t[]>(new wchar_t[ cchSubject ]); - cbSubject = CertNameToStrW( + cchSubject = CertNameToStrW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , &( m_pCertContext->pCertInfo->Subject ), CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , - subject.get(), cbSubject + subject.get(), cchSubject ) ; - if( cbSubject <= 0 ) { + if( cchSubject <= 0 ) { throw RuntimeException() ; } - OUString xSubject( - reinterpret_cast<const sal_Unicode*>(subject.get())); + OUString xSubject(SAL_U(subject.get())); return replaceTagSWithTagST(xSubject); } else |