diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-10-05 06:19:56 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-10-05 16:02:52 +0200 |
commit | 1944e3ddc0b2247de3138d2a441cd6999e21fd9a (patch) | |
tree | b59f213e245e151ee792ca424fd06b5a11c88857 /sfx2 | |
parent | 81d404803f477eb71b74eb9c7a67bba6b1af95d1 (diff) |
Rename and move SAL_U/W to o3tl::toU/W
Previosly (since commit 9ac98e6e3488e434bf4864ecfb13a121784f640b)
it was expected to gradually remove SAL_U/W usage in Windows code
by replacing with reinterpret_cast or changing to some bettertypes.
But as it's useful to make use of fact that LibreOffice and Windows
use compatible representation of strings, this commit puts these
functions to a better-suited o3tl, and recommends that the functions
be consistently used throughout Windows-specific code to reflect the
compatibility and keep the casts safe.
Change-Id: I2f7c65606d0e2d0c01a00f08812bb4ab7659c5f6
Reviewed-on: https://gerrit.libreoffice.org/43150
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/shutdowniconw32.cxx | 29 | ||||
-rw-r--r-- | sfx2/source/doc/graphhelp.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/guisaveas.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/doc/syspathw32.cxx | 6 |
4 files changed, 22 insertions, 20 deletions
diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index 98b84d2c3d64..e3bf7eabceae 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -40,6 +40,7 @@ #include <osl/thread.h> #include <systools/win32/qswin32.h> #include <comphelper/sequenceashashmap.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <set> @@ -125,7 +126,7 @@ static void addMenuItem( HMENU hMenu, UINT id, UINT iconId, const OUString& text mi.fType=MFT_STRING; mi.fState=MFS_ENABLED; mi.wID = id; - mi.dwTypeData = SAL_W( + mi.dwTypeData = o3tl::toW( const_cast<sal_Unicode *>(text.getStr())); mi.cch = text.getLength(); } @@ -252,7 +253,7 @@ static void addTaskbarIcon( HWND hWnd ) IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), LR_DEFAULTCOLOR | LR_SHARED )); - wcsncpy( nid.szTip, SAL_W(strTip.getStr()), 64 ); + wcsncpy( nid.szTip, o3tl::toW(strTip.getStr()), 64 ); nid.cbSize = sizeof(nid); nid.hWnd = hWnd; @@ -565,7 +566,7 @@ void OnMeasureItem(HWND hwnd, LPMEASUREITEMSTRUCT lpmis) HFONT hfntOld = static_cast<HFONT>(SelectObject(hdc, CreateFontIndirectW( &ncm.lfMenuFont ))); - GetTextExtentPoint32W(hdc, SAL_W(pMyItem->text.getStr()), + GetTextExtentPoint32W(hdc, o3tl::toW(pMyItem->text.getStr()), pMyItem->text.getLength(), &size); lpmis->itemWidth = size.cx + 4 + GetSystemMetrics( SM_CXSMICON ); @@ -619,7 +620,7 @@ void OnDrawItem(HWND /*hwnd*/, LPDRAWITEMSTRUCT lpdis) if ( pMyItem->module.getLength() > 0 ) { - LPCWSTR pModuleName = SAL_W( pMyItem->module.getStr() ); + LPCWSTR pModuleName = o3tl::toW( pMyItem->module.getStr() ); hModule = GetModuleHandleW( pModuleName ); if ( hModule == nullptr ) { @@ -656,7 +657,7 @@ void OnDrawItem(HWND /*hwnd*/, LPDRAWITEMSTRUCT lpdis) SIZE size; - GetTextExtentPointW( lpdis->hDC, SAL_W(pMyItem->text.getStr()), pMyItem->text.getLength(), &size ); + GetTextExtentPointW( lpdis->hDC, o3tl::toW(pMyItem->text.getStr()), pMyItem->text.getLength(), &size ); DrawStateW( lpdis->hDC, nullptr, nullptr, reinterpret_cast<LPARAM>(pMyItem->text.getStr()), (WPARAM)0, aRect.left, aRect.top + (height - size.cy)/2, 0, 0, DST_TEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) ); @@ -697,7 +698,7 @@ static OUString SHGetSpecialFolder( int nFolderID ) lpFolderA = ALLOC( WCHAR, 16000 ); SHGetPathFromIDListW( pidl, lpFolderA ); - aFolder = SAL_U( lpFolderA ); + aFolder = o3tl::toU( lpFolderA ); FREE( lpFolderA ); SHFree_( pidl ); @@ -743,18 +744,18 @@ BOOL CreateShortcut( const OUString& rAbsObject, const OUString& rAbsObjectPath, if( SUCCEEDED(hres) ) { IPersistFile* ppf; - psl->SetPath( SAL_W(rAbsObject.getStr()) ); - psl->SetWorkingDirectory( SAL_W(rAbsObjectPath.getStr()) ); - psl->SetDescription( SAL_W(rDescription.getStr()) ); + psl->SetPath( o3tl::toW(rAbsObject.getStr()) ); + psl->SetWorkingDirectory( o3tl::toW(rAbsObjectPath.getStr()) ); + psl->SetDescription( o3tl::toW(rDescription.getStr()) ); if( rParameter.getLength() ) - psl->SetArguments( SAL_W(rParameter.getStr()) ); + psl->SetArguments( o3tl::toW(rParameter.getStr()) ); CLSID clsid_IPersistFile = IID_IPersistFile; hres = psl->QueryInterface( clsid_IPersistFile, reinterpret_cast<void**>(&ppf) ); if( SUCCEEDED(hres) ) { - hres = ppf->Save( SAL_W(rAbsShortcut.getStr()), TRUE ); + hres = ppf->Save( o3tl::toW(rAbsShortcut.getStr()), TRUE ); ppf->Release(); } else return FALSE; psl->Release(); @@ -786,7 +787,7 @@ bool ShutdownIcon::IsQuickstarterInstalled() wchar_t aPath[_MAX_PATH]; GetModuleFileNameW( nullptr, aPath, _MAX_PATH-1); - OUString aOfficepath( SAL_U(aPath) ); + OUString aOfficepath( o3tl::toU(aPath) ); int i = aOfficepath.lastIndexOf('\\'); if( i != -1 ) aOfficepath = aOfficepath.copy(0, i); @@ -794,7 +795,7 @@ bool ShutdownIcon::IsQuickstarterInstalled() OUString quickstartExe(aOfficepath); quickstartExe += "\\quickstart.exe"; - return FileExistsW( SAL_W(quickstartExe.getStr()) ); + return FileExistsW( o3tl::toW(quickstartExe.getStr()) ); } void ShutdownIcon::EnableAutostartW32( const OUString &aShortcut ) @@ -802,7 +803,7 @@ void ShutdownIcon::EnableAutostartW32( const OUString &aShortcut ) wchar_t aPath[_MAX_PATH]; GetModuleFileNameW( nullptr, aPath, _MAX_PATH-1); - OUString aOfficepath( SAL_U(aPath) ); + OUString aOfficepath( o3tl::toU(aPath) ); int i = aOfficepath.lastIndexOf('\\'); if( i != -1 ) aOfficepath = aOfficepath.copy(0, i); diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index 02664519ee8a..a4df9af84b74 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -47,7 +47,7 @@ #include <unotools/ucbstreamhelper.hxx> #include <unotools/streamwrap.hxx> #include <comphelper/processfactory.hxx> - +#include <o3tl/char16_t2wchar_t.hxx> #include <sfx2/sfxresid.hxx> #include "graphhelp.hxx" @@ -98,7 +98,7 @@ void* GraphicHelper::getEnhMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta ) delete pStream; if ( !nFailed ) - pResult = GetEnhMetaFileW( SAL_W(aMetaFile.getStr()) ); + pResult = GetEnhMetaFileW( o3tl::toW(aMetaFile.getStr()) ); } } #else diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index d733ac619fe4..79c954c43e7f 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -67,6 +67,7 @@ #include <vcl/layout.hxx> #include <vcl/window.hxx> #include <toolkit/awt/vclxwindow.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <sfx2/sfxsids.hrc> #include <sfx2/strings.hrc> @@ -1195,7 +1196,7 @@ OUString ModelData_Impl::GetRecommendedDir( const OUString& aSuggestedDir ) if( SUCCEEDED(hRes) ) { OUString sTempINetFiles; - if( osl::FileBase::getFileURLFromSystemPath(SAL_U(sPath), sTempINetFiles) == osl::FileBase::E_None ) + if( osl::FileBase::getFileURLFromSystemPath(o3tl::toU(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 ea6e13c078ba..2a61f1a1cdb5 100644 --- a/sfx2/source/doc/syspathw32.cxx +++ b/sfx2/source/doc/syspathw32.cxx @@ -18,8 +18,8 @@ */ #include <sal/config.h> - #include <sal/types.h> +#include <o3tl/char16_t2wchar_t.hxx> #ifdef _WIN32 #ifdef _MSC_VER @@ -31,7 +31,7 @@ #include <shlobj.h> -#include <syspathw32.hxx> +#include "syspathw32.hxx" static bool SHGetSpecialFolderW32( int nFolderID, WCHAR* pszFolder, int nSize ) { @@ -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, SAL_W(pFolder), nSize ); + return SHGetSpecialFolderW32( CSIDL_TEMPLATES, o3tl::toW(pFolder), nSize ); #else (void)pFolder; (void)nSize; |