diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-26 11:28:57 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-30 11:23:41 +0200 |
commit | 362a21d3a129b90149f6ef645c127f5e86e0ba61 (patch) | |
tree | 8583cb29b33de56e4489cb8950d2714a1fb2957e /vcl/win | |
parent | 81ce629c9e8a4fc26ded9d49157e3f3263991e03 (diff) |
Use explicit function names for fooA/fooW WinAPI; prefer fooW
We should only use generic foo function name when it takes params
that are also dependent on UNICODE define, like
LoadCursor( nullptr, IDC_ARROW )
where IDC_ARROW is defined in MSVC headers synchronised with
LoadCursor definition.
We should always use Unicode API for any file paths operations,
because otherwise we will get "?" for any character in path that
is not in current non-unicode codepage, which will result in failed
file operations.
Change-Id: I3a7f453ca0f893002d8a9764318919709fd8b633
Reviewed-on: https://gerrit.libreoffice.org/42935
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/app/salinfo.cxx | 10 | ||||
-rw-r--r-- | vcl/win/app/salinst.cxx | 42 | ||||
-rw-r--r-- | vcl/win/app/salshl.cxx | 12 | ||||
-rwxr-xr-x | vcl/win/gdi/DWriteTextRenderer.cxx | 8 | ||||
-rw-r--r-- | vcl/win/gdi/salbmp.cxx | 6 | ||||
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 76 | ||||
-rw-r--r-- | vcl/win/gdi/salnativewidgets-luna.cxx | 2 | ||||
-rw-r--r-- | vcl/win/gdi/salprn.cxx | 45 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 2 | ||||
-rw-r--r-- | vcl/win/window/salframe.cxx | 122 | ||||
-rw-r--r-- | vcl/win/window/salobj.cxx | 39 |
11 files changed, 180 insertions, 184 deletions
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; |