diff options
83 files changed, 651 insertions, 540 deletions
diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx index e6c808787bee..aa270660a7f4 100644 --- a/avmedia/source/win/framegrabber.cxx +++ b/avmedia/source/win/framegrabber.cxx @@ -44,6 +44,7 @@ #include <tools/stream.hxx> #include <vcl/graph.hxx> #include <vcl/dibtools.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #define AVMEDIA_WIN_FRAMEGRABBER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.FrameGrabber_DirectX" #define AVMEDIA_WIN_FRAMEGRABBER_SERVICENAME "com.sun.star.media.FrameGrabber_DirectX" @@ -78,7 +79,7 @@ IMediaDet* implCreateMediaDet( const OUString& rURL ) if( osl::FileBase::getSystemPathFromFileURL( rURL, aLocalStr ) == osl::FileBase::E_None ) { - BSTR bstrFilename = SysAllocString(SAL_W(aLocalStr.getStr())); + BSTR bstrFilename = SysAllocString(o3tl::toW(aLocalStr.getStr())); if( !SUCCEEDED( pDet->put_Filename( bstrFilename ) ) ) { // Shouldn't we free this string unconditionally, not only in case of failure? diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx index 6ecb6a261ecc..4aef762f63bd 100644 --- a/avmedia/source/win/player.cxx +++ b/avmedia/source/win/player.cxx @@ -34,6 +34,7 @@ #include "framegrabber.hxx" #include "window.hxx" #include <cppuhelper/supportsservice.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #define AVMEDIA_WIN_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_DirectX" #define AVMEDIA_WIN_PLAYER_SERVICENAME "com.sun.star.media.Player_DirectX" @@ -148,7 +149,7 @@ bool Player::create( const OUString& rURL ) // It disables the desktop composition as soon as RenderFile is called // also causes some other problems: video rendering is not reliable - if( SUCCEEDED( hR = mpGB->RenderFile( SAL_W(rURL.getStr()), nullptr ) ) && + if( SUCCEEDED( hR = mpGB->RenderFile( o3tl::toW(rURL.getStr()), nullptr ) ) && SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaControl, reinterpret_cast<void**>(&mpMC) ) ) && SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaEventEx, reinterpret_cast<void**>(&mpME) ) ) && SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaSeeking, reinterpret_cast<void**>(&mpMS) ) ) && diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx index 39efcb7d5805..0289f641f771 100644 --- a/basic/qa/cppunit/test_vba.cxx +++ b/basic/qa/cppunit/test_vba.cxx @@ -9,6 +9,7 @@ #include "basictest.hxx" #include <comphelper/processfactory.hxx> #include <unotools/syslocaleoptions.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #ifdef _WIN32 #include <string.h> @@ -233,7 +234,7 @@ void VBATest::testMiscOLEStuff() sPath = sPath.replaceAll( "/", "\\" ); aArgs[ 0 ] <<= sPath; - aArgs[ 1 ] <<= OUString(SAL_U(pODBCDriverName)); + aArgs[ 1 ] <<= OUString(o3tl::toU(pODBCDriverName)); for ( sal_uInt32 i=0; i<SAL_N_ELEMENTS( macroSource ); ++i ) { diff --git a/basic/source/runtime/dllmgr-x64.cxx b/basic/source/runtime/dllmgr-x64.cxx index fdd54b129da8..96aa4fcbdd78 100644 --- a/basic/source/runtime/dllmgr-x64.cxx +++ b/basic/source/runtime/dllmgr-x64.cxx @@ -37,6 +37,7 @@ #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <salhelper/simplereferenceobject.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #undef max @@ -734,7 +735,7 @@ Dll * SbiDllMgr::Impl::getDll(OUString const & name) { Dlls::iterator i(dlls.find(name)); if (i == dlls.end()) { i = dlls.emplace(name, new Dll).first; - HMODULE h = LoadLibraryW(SAL_W(name.getStr())); + HMODULE h = LoadLibraryW(o3tl::toW(name.getStr())); if (h == nullptr) { dlls.erase(i); return nullptr; diff --git a/basic/source/runtime/dllmgr-x86.cxx b/basic/source/runtime/dllmgr-x86.cxx index ff3e80549e71..576e3da1b736 100644 --- a/basic/source/runtime/dllmgr-x86.cxx +++ b/basic/source/runtime/dllmgr-x86.cxx @@ -37,6 +37,7 @@ #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <salhelper/simplereferenceobject.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #undef max @@ -688,7 +689,7 @@ Dll * SbiDllMgr::Impl::getDll(OUString const & name) { Dlls::iterator i(dlls.find(name)); if (i == dlls.end()) { i = dlls.emplace(name, new Dll).first; - HMODULE h = LoadLibraryW(SAL_W(name.getStr())); + HMODULE h = LoadLibraryW(o3tl::toW(name.getStr())); if (h == 0) { dlls.erase(i); return 0; diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 748675bfd272..377cb27f13a9 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -61,6 +61,7 @@ #include <memory> #include <random> #include <o3tl/make_unique.hxx> +#include <o3tl/char16_t2wchar_t.hxx> using namespace comphelper; using namespace osl; @@ -387,7 +388,7 @@ void SbRtl_CurDir(StarBASIC * pBasic, SbxArray & rPar, bool bWrite) wchar_t pBuffer[ _MAX_PATH ]; if ( _wgetdcwd( nCurDir, pBuffer, _MAX_PATH ) != nullptr ) { - rPar.Get(0)->PutString( SAL_U(pBuffer) ); + rPar.Get(0)->PutString( o3tl::toU(pBuffer) ); } else { @@ -2957,7 +2958,7 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite) OUString aPathURL = getFullPath( rPar.Get(1)->GetOUString() ); OUString aPath; FileBase::getSystemPathFromFileURL( aPathURL, aPath ); - DWORD nRealFlags = GetFileAttributesW (SAL_W(aPath.getStr())); + DWORD nRealFlags = GetFileAttributesW (o3tl::toW(aPath.getStr())); if (nRealFlags != 0xffffffff) { if (nRealFlags == FILE_ATTRIBUTE_NORMAL) diff --git a/basic/source/sbx/sbxdec.cxx b/basic/source/sbx/sbxdec.cxx index f546434df434..8356d36cab77 100644 --- a/basic/source/sbx/sbxdec.cxx +++ b/basic/source/sbx/sbxdec.cxx @@ -18,6 +18,7 @@ */ #include <vcl/errcode.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <basic/sbx.hxx> #include <basic/sberrors.hxx> @@ -213,25 +214,21 @@ bool SbxDecimal::setString( OUString* pOUString ) pBuffer[nLen] = 0; const sal_Unicode* pSrc = pOUString->getStr(); - int i; - for( i = 0 ; i < nLen ; ++i ) - pBuffer[i] = pSrc[i]; - - sal_Unicode c; - i = 0; - while( (c = pBuffer[i]) != 0 ) + for( int i = 0 ; i < nLen ; ++i ) { - if( c == cDecimalSep ) - pBuffer[i] = '.'; - else if( c == cThousandSep ) - pBuffer[i] = ','; - i++; + sal_Unicode c = pSrc[i]; + if (c == cDecimalSep) + c = '.'; + else if (c == cThousandSep) + c = ','; + + pBuffer[i] = c; } - hResult = VarDecFromStr( SAL_W(pBuffer.get()), nLANGID, 0, &maDec ); + hResult = VarDecFromStr( o3tl::toW(pBuffer.get()), nLANGID, 0, &maDec ); } else { - hResult = VarDecFromStr( SAL_W(pOUString->getStr()), nLANGID, 0, &maDec ); + hResult = VarDecFromStr( o3tl::toW(pOUString->getStr()), nLANGID, 0, &maDec ); } bRet = ( hResult == S_OK ); return bRet; @@ -349,35 +346,31 @@ void SbxDecimal::getString( OUString& rString ) #ifdef _WIN32 static LCID nLANGID = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ); - OLECHAR sz[100]; - BSTR aBStr = SysAllocString( sz ); - if( aBStr != nullptr ) + BSTR pBStr = nullptr; + // VarBstrFromDec allocates new BSTR that needs to be released with SysFreeString + HRESULT hResult = VarBstrFromDec( &maDec, nLANGID, 0, &pBStr ); + if( hResult == S_OK ) { - HRESULT hResult = VarBstrFromDec( &maDec, nLANGID, 0, &aBStr ); - if( hResult == S_OK ) - { - // Convert delimiter - sal_Unicode cDecimalSep; - sal_Unicode cThousandSep; - ImpGetIntntlSep( cDecimalSep, cThousandSep ); + // Convert delimiter + sal_Unicode cDecimalSep; + sal_Unicode cThousandSep; + ImpGetIntntlSep( cDecimalSep, cThousandSep ); - if( cDecimalSep != '.' || cThousandSep != ',' ) + if( cDecimalSep != '.' || cThousandSep != ',' ) + { + sal_Unicode c; + int i = 0; + while( (c = pBStr[i]) != 0 ) { - sal_Unicode c; - int i = 0; - while( (c = aBStr[i]) != 0 ) - { - if( c == '.' ) - aBStr[i] = cDecimalSep; - else if( c == ',' ) - aBStr[i] = cThousandSep; - i++; - } + if( c == '.' ) + pBStr[i] = cDecimalSep; + else if( c == ',' ) + pBStr[i] = cThousandSep; + i++; } - rString = SAL_U(aBStr); } - - SysFreeString( aBStr ); + rString = o3tl::toU( pBStr ); + SysFreeString( pBStr ); } #else (void)rString; diff --git a/canvas/source/directx/dx_canvasfont.cxx b/canvas/source/directx/dx_canvasfont.cxx index 0fa32688ea6f..5bf74ccc0d2e 100644 --- a/canvas/source/directx/dx_canvasfont.cxx +++ b/canvas/source/directx/dx_canvasfont.cxx @@ -18,6 +18,7 @@ */ #include <sal/config.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <com/sun/star/rendering/PanoseWeight.hpp> #include <com/sun/star/rendering/XSpriteCanvas.hpp> @@ -56,12 +57,7 @@ namespace dxcanvas maFontRequest( rFontRequest ), maFontMatrix( fontMatrix ) { - const sal_Int32 nLen(rFontRequest.FontDescription.FamilyName.getLength()); - const sal_Unicode* pStr(rFontRequest.FontDescription.FamilyName.getStr()); - std::vector< sal_Unicode > pStrBuf(nLen+1,0); - std::copy(pStr,pStr+nLen,&pStrBuf[0]); - - mpFontFamily.reset( new Gdiplus::FontFamily(SAL_W(&pStrBuf[0]),nullptr) ); + mpFontFamily.reset( new Gdiplus::FontFamily(o3tl::toW(rFontRequest.FontDescription.FamilyName.getStr()),nullptr) ); if( !mpFontFamily->IsAvailable() ) mpFontFamily.reset( new Gdiplus::FontFamily(L"Arial",nullptr) ); diff --git a/canvas/source/directx/dx_canvashelper.cxx b/canvas/source/directx/dx_canvashelper.cxx index 87b9066fc08f..86222437d090 100644 --- a/canvas/source/directx/dx_canvashelper.cxx +++ b/canvas/source/directx/dx_canvashelper.cxx @@ -31,6 +31,7 @@ #include <com/sun/star/rendering/RepaintResult.hpp> #include <com/sun/star/rendering/TexturingMode.hpp> #include <comphelper/sequence.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <rtl/math.hxx> #include <tools/diagnose_ex.h> @@ -521,7 +522,7 @@ namespace dxcanvas // TODO(F2): Proper layout (BiDi, CTL)! IMHO must use // DrawDriverString here, and perform layouting myself... ENSURE_OR_THROW( - Gdiplus::Ok == pGraphics->DrawString( SAL_W(text.Text.copy( text.StartPosition, + Gdiplus::Ok == pGraphics->DrawString( o3tl::toW(text.Text.copy( text.StartPosition, text.Length ).getStr()), text.Length, pFont->getFont().get(), diff --git a/configmgr/source/winreg.cxx b/configmgr/source/winreg.cxx index bf30f8045d8f..995202806931 100644 --- a/configmgr/source/winreg.cxx +++ b/configmgr/source/winreg.cxx @@ -27,6 +27,7 @@ #include <sal/log.hxx> #include <osl/file.h> #include <osl/file.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include "winreg.hxx" #include "writemodfile.hxx" @@ -86,7 +87,7 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil HKEY hCurKey; if(RegOpenKeyExW( - hKey, SAL_W(aKeyName.getStr()), 0, + hKey, o3tl::toW(aKeyName.getStr()), 0, KEY_READ, &hCurKey) == ERROR_SUCCESS) { @@ -109,9 +110,9 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil //Make up full key name if(aKeyName.isEmpty()) - aSubkeyName = aKeyName + OUString(SAL_U(buffKeyName)); + aSubkeyName = aKeyName + OUString(o3tl::toU(buffKeyName)); else - aSubkeyName = aKeyName + "\\" + OUString(SAL_U(buffKeyName)); + aSubkeyName = aKeyName + "\\" + OUString(o3tl::toU(buffKeyName)); //Recursion, until no more subkeys are found dumpWindowsRegistryKey(hKey, aSubkeyName, aFileHandle); @@ -140,9 +141,9 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil const wchar_t wsType[] = L"Type"; if(!wcscmp(pValueName.get(), wsValue)) - aValue = SAL_U(pValue.get()); + aValue = o3tl::toU(pValue.get()); else if (!wcscmp(pValueName.get(), wsType)) - aType = SAL_U(pValue.get()); + aType = o3tl::toU(pValue.get()); else if(!wcscmp(pValueName.get(), wsFinal) && *reinterpret_cast<DWORD*>(pValue.get()) == 1) bFinal = true; } diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx index 8094e96ac997..09c0b2dc723e 100644 --- a/connectivity/source/drivers/ado/Aolevariant.cxx +++ b/connectivity/source/drivers/ado/Aolevariant.cxx @@ -20,6 +20,7 @@ #include "ado/Aolevariant.hxx" #include <connectivity/dbconversion.hxx> #include <osl/diagnose.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <com/sun/star/sdbc/SQLException.hpp> #include <com/sun/star/util/Time.hpp> #include <com/sun/star/util/Date.hpp> @@ -46,7 +47,7 @@ OLEString::OLEString(const BSTR& _sBStr) } OLEString::OLEString(const OUString& _sBStr) { - m_sStr = ::SysAllocString(SAL_W(_sBStr.getStr())); + m_sStr = ::SysAllocString(o3tl::toW(_sBStr.getStr())); } OLEString::~OLEString() { @@ -57,7 +58,7 @@ OLEString& OLEString::operator=(const OUString& _rSrc) { if(m_sStr) ::SysFreeString(m_sStr); - m_sStr = ::SysAllocString(SAL_W(_rSrc.getStr())); + m_sStr = ::SysAllocString(o3tl::toW(_rSrc.getStr())); return *this; } OLEString& OLEString::operator=(const OLEString& _rSrc) @@ -79,7 +80,7 @@ OLEString& OLEString::operator=(const BSTR& _rSrc) } OUString OLEString::asOUString() const { - return (m_sStr != nullptr) ? OUString(SAL_U(LPCOLESTR(m_sStr)),::SysStringLen(m_sStr)) : OUString(); + return (m_sStr != nullptr) ? OUString(o3tl::toU(LPCOLESTR(m_sStr)),::SysStringLen(m_sStr)) : OUString(); } BSTR OLEString::asBSTR() const { @@ -121,7 +122,7 @@ OLEVariant::OLEVariant(const OUString& us) { ::VariantInit(this); vt = VT_BSTR; - bstrVal = SysAllocString(SAL_W(us.getStr())); + bstrVal = SysAllocString(o3tl::toW(us.getStr())); } OLEVariant::~OLEVariant() { @@ -277,7 +278,7 @@ void OLEVariant::setString(const OUString& us) HRESULT eRet = VariantClear(this); OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); vt = VT_BSTR; - bstrVal = ::SysAllocString(SAL_W(us.getStr())); + bstrVal = ::SysAllocString(o3tl::toW(us.getStr())); } void OLEVariant::setNoArg() { @@ -377,7 +378,7 @@ void OLEVariant::set(double n) OUString OLEVariant::getString() const { if (V_VT(this) == VT_BSTR) - return SAL_U(LPCOLESTR(V_BSTR(this))); + return o3tl::toU(LPCOLESTR(V_BSTR(this))); if(isNull()) return OUString(); @@ -386,7 +387,7 @@ OUString OLEVariant::getString() const varDest.ChangeType(VT_BSTR, this); - return SAL_U(LPCOLESTR(V_BSTR(&varDest))); + return o3tl::toU(LPCOLESTR(V_BSTR(&varDest))); } @@ -692,7 +693,7 @@ css::uno::Any OLEVariant::makeAny() const } case VT_BSTR: { - OUString b(SAL_U(bstrVal)); + OUString b(o3tl::toU(bstrVal)); aValue.setValue( &b, cppu::UnoType<decltype(b)>::get()); break; } diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx index 923d0e925795..c16d90681ab4 100644 --- a/cppuhelper/source/bootstrap.cxx +++ b/cppuhelper/source/bootstrap.cxx @@ -31,6 +31,7 @@ #include <osl/file.hxx> #include <osl/security.hxx> #include <osl/thread.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <cppuhelper/bootstrap.hxx> #include <cppuhelper/findsofficepath.h> @@ -94,7 +95,7 @@ Reference< XComponentContext > SAL_CALL bootstrap() } rtl::OUString p2; #if defined(_WIN32) - p2 = SAL_U(p1); + p2 = o3tl::toU(p1); free(p1); #else bool bOk = rtl_convertStringToUString( diff --git a/dbaccess/source/ui/dlg/adodatalinks.cxx b/dbaccess/source/ui/dlg/adodatalinks.cxx index 3b1e552f6db0..ef4bc2601b36 100644 --- a/dbaccess/source/ui/dlg/adodatalinks.cxx +++ b/dbaccess/source/ui/dlg/adodatalinks.cxx @@ -31,6 +31,8 @@ #pragma warning(push, 1) #endif +#include <o3tl/char16_t2wchar_t.hxx> + #include <initguid.h> #include <adoid.h> #include <adoint.h> @@ -89,7 +91,8 @@ OUString PromptNew(long hWnd) piTmpConnection->Release( ); dlPrompt->Release( ); CoUninitialize(); - return SAL_U(_result); + // Don't we need SysFreeString(_result)? + return o3tl::toU(_result); } OUString PromptEdit(long hWnd, OUString const & connstr) @@ -115,7 +118,7 @@ OUString PromptEdit(long hWnd, OUString const & connstr) hr = piTmpConnection->put_ConnectionString( - const_cast<BSTR>(SAL_W(connstr.getStr()))); + const_cast<BSTR>(o3tl::toW(connstr.getStr()))); if( FAILED( hr ) ) { piTmpConnection->Release( ); @@ -180,7 +183,8 @@ OUString PromptEdit(long hWnd, OUString const & connstr) piTmpConnection->Release( ); dlPrompt->Release( ); CoUninitialize(); - return SAL_U(_result); + // Don't we need SysFreeString(_result)? + return o3tl::toU(_result); } } diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx index 28360ca4dfeb..24205e8b2b8b 100644 --- a/desktop/source/app/crashreport.cxx +++ b/desktop/source/app/crashreport.cxx @@ -11,6 +11,7 @@ #include <rtl/bootstrap.hxx> #include <osl/file.hxx> #include <unotools/bootstrap.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <config_version.h> #include <config_folders.h> @@ -122,7 +123,7 @@ void CrashReporter::updateMinidumpLocation() mpExceptionHandler->set_minidump_descriptor(descriptor); #elif defined WNT OUString aURL = getCrashDirectory(); - mpExceptionHandler->set_dump_path(SAL_W(aURL.getStr())); + mpExceptionHandler->set_dump_path(o3tl::toW(aURL.getStr())); #endif } diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.cxx b/dtrans/source/win32/dtobj/DataFmtTransl.cxx index c72f2646563b..ddb0ee6d750f 100644 --- a/dtrans/source/win32/dtobj/DataFmtTransl.cxx +++ b/dtrans/source/win32/dtobj/DataFmtTransl.cxx @@ -26,6 +26,7 @@ #include "MimeAttrib.hxx" #include "DTransHelper.hxx" #include <rtl/string.h> +#include <o3tl/char16_t2wchar_t.hxx> #include "Fetc.hxx" #include <com/sun/star/datatransfer/DataFormatTranslator.hpp> @@ -87,7 +88,7 @@ CFormatEtc CDataFormatTranslator::getFormatEtcFromDataFlavor( const DataFlavor& aFormat >>= aClipFmtName; OSL_ASSERT( aClipFmtName.getLength( ) ); - cf = RegisterClipboardFormatW( SAL_W(aClipFmtName.getStr( )) ); + cf = RegisterClipboardFormatW( o3tl::toW(aClipFmtName.getStr( )) ); OSL_ENSURE( CF_INVALID != cf, "RegisterClipboardFormat failed" ); } @@ -163,7 +164,7 @@ CFormatEtc SAL_CALL CDataFormatTranslator::getFormatEtcForClipformatName( const if ( !aClipFmtName.getLength( ) ) return CFormatEtc( CF_INVALID ); - CLIPFORMAT cf = sal::static_int_cast<CLIPFORMAT>(RegisterClipboardFormatW( SAL_W(aClipFmtName.getStr( )) )); + CLIPFORMAT cf = sal::static_int_cast<CLIPFORMAT>(RegisterClipboardFormatW( o3tl::toW(aClipFmtName.getStr( )) )); return getFormatEtcForClipformat( cf ); } @@ -172,7 +173,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, SAL_W(wBuff), MAX_CLIPFORMAT_NAME ); + sal_Int32 nLen = GetClipboardFormatNameW( aClipformat, o3tl::toW(wBuff), MAX_CLIPFORMAT_NAME ); return OUString( wBuff, nLen ); } diff --git a/dtrans/source/win32/dtobj/XTDataObject.cxx b/dtrans/source/win32/dtobj/XTDataObject.cxx index ed498372d0aa..76442f27fd7c 100644 --- a/dtrans/source/win32/dtobj/XTDataObject.cxx +++ b/dtrans/source/win32/dtobj/XTDataObject.cxx @@ -18,6 +18,7 @@ */ #include <osl/diagnose.h> +#include <o3tl/char16_t2wchar_t.hxx> #include "XTDataObject.hxx" #include <com/sun/star/datatransfer/DataFlavor.hpp> @@ -26,8 +27,8 @@ #include "TxtCnvtHlp.hxx" #include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp> -#include "com/sun/star/awt/AsyncCallback.hpp" -#include "com/sun/star/awt/XCallback.hpp" +#include <com/sun/star/awt/AsyncCallback.hpp> +#include <com/sun/star/awt/XCallback.hpp> #include "FmtFilter.hxx" #include <comphelper/processfactory.hxx> #include <cppuhelper/implbase.hxx> @@ -505,7 +506,7 @@ void SAL_CALL CXTDataObject::renderSynthesizedTextAndSetupStgMedium( FORMATETC& WideCharToMultiByteEx( GetACP( ), - SAL_W( aUnicodeText.getStr( ) ), + o3tl::toW( aUnicodeText.getStr( ) ), aUnicodeText.getLength( ), stgTransfHelper ); diff --git a/dtrans/source/win32/misc/ImplHelper.cxx b/dtrans/source/win32/misc/ImplHelper.cxx index f9d5a07a7f28..356985a931f8 100644 --- a/dtrans/source/win32/misc/ImplHelper.cxx +++ b/dtrans/source/win32/misc/ImplHelper.cxx @@ -20,6 +20,7 @@ #include <osl/diagnose.h> #include "ImplHelper.hxx" #include <rtl/tencinfo.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <string.h> #include <memory> @@ -107,7 +108,7 @@ OUString SAL_CALL getWinCPFromLocaleId( LCID lcid, LCTYPE lctype ) OSL_ASSERT(nResult); if (nResult) - winCP = SAL_U( buff.get() ); + winCP = o3tl::toU( buff.get() ); } diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 48cba783fcfd..738d87fa6452 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -30,21 +30,22 @@ #include <com/sun/star/io/XTruncate.hpp> #include <com/sun/star/awt/XRequestCallback.hpp> -#include <platform.h> +#include "platform.h" #include <cppuhelper/interfacecontainer.h> #include <comphelper/mimeconfighelper.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/storagehelper.hxx> #include <osl/file.hxx> #include <rtl/ref.hxx> +#include <o3tl/char16_t2wchar_t.hxx> -#include <graphconvert.hxx> -#include <olecomponent.hxx> -#include <olepersist.hxx> -#include <olewrapclient.hxx> -#include <advisesink.hxx> +#include "graphconvert.hxx" +#include "olecomponent.hxx" +#include "olepersist.hxx" +#include "olewrapclient.hxx" +#include "advisesink.hxx" #include <oleembobj.hxx> -#include <mtnotification.hxx> +#include "mtnotification.hxx" #include <memory> #include <string> @@ -262,7 +263,7 @@ HRESULT OpenIStorageFromURL_Impl( const OUString& aURL, IStorage** ppIStorage ) if ( !ppIStorage || ::osl::FileBase::getSystemPathFromFileURL( aURL, aFilePath ) != ::osl::FileBase::E_None ) throw uno::RuntimeException(); // TODO: something dangerous happened - return StgOpenStorage( SAL_W(aFilePath.getStr()), + return StgOpenStorage( o3tl::toW(aFilePath.getStr()), nullptr, STGM_READWRITE | STGM_TRANSACTED, // | STGM_DELETEONRELEASE, nullptr, @@ -546,7 +547,7 @@ void OleComponent::CreateNewIStorage_Impl() if ( ::osl::FileBase::getSystemPathFromFileURL( aTempURL, aTempFilePath ) != ::osl::FileBase::E_None ) throw uno::RuntimeException(); // TODO: something dangerous happened - HRESULT hr = StgCreateDocfile( SAL_W(aTempFilePath.getStr()), STGM_CREATE | STGM_READWRITE | STGM_TRANSACTED | STGM_DELETEONRELEASE, 0, &m_pNativeImpl->m_pIStorage ); + HRESULT hr = StgCreateDocfile( o3tl::toW(aTempFilePath.getStr()), STGM_CREATE | STGM_READWRITE | STGM_TRANSACTED | STGM_DELETEONRELEASE, 0, &m_pNativeImpl->m_pIStorage ); if ( FAILED( hr ) || !m_pNativeImpl->m_pIStorage ) throw io::IOException(); // TODO: transport error code? } @@ -827,7 +828,7 @@ void OleComponent::CreateObjectFromFile( const OUString& aFileURL ) throw uno::RuntimeException(); // TODO: something dangerous happened HRESULT hr = OleCreateFromFile( CLSID_NULL, - SAL_W(aFilePath.getStr()), + o3tl::toW(aFilePath.getStr()), IID_IUnknown, OLERENDER_DRAW, // OLERENDER_FORMAT nullptr, @@ -856,7 +857,7 @@ void OleComponent::CreateLinkFromFile( const OUString& aFileURL ) if ( ::osl::FileBase::getSystemPathFromFileURL( aFileURL, aFilePath ) != ::osl::FileBase::E_None ) throw uno::RuntimeException(); // TODO: something dangerous happened - HRESULT hr = OleCreateLinkToFile( SAL_W(aFilePath.getStr()), + HRESULT hr = OleCreateLinkToFile( o3tl::toW(aFilePath.getStr()), IID_IUnknown, OLERENDER_DRAW, // OLERENDER_FORMAT nullptr, @@ -1036,7 +1037,7 @@ uno::Sequence< embed::VerbDescriptor > OleComponent::GetVerbList() for( sal_uInt32 nInd = 0; nInd < nNum; nInd++ ) { m_aVerbList[nSeqSize-nNum+nInd].VerbID = szEle[ nInd ].lVerb; - m_aVerbList[nSeqSize-nNum+nInd].VerbName = WinAccToVcl_Impl( SAL_U(szEle[ nInd ].lpszVerbName) ); + m_aVerbList[nSeqSize-nNum+nInd].VerbName = WinAccToVcl_Impl( o3tl::toU(szEle[ nInd ].lpszVerbName) ); m_aVerbList[nSeqSize-nNum+nInd].VerbFlags = szEle[ nInd ].fuFlags; m_aVerbList[nSeqSize-nNum+nInd].VerbAttributes = szEle[ nInd ].grfAttribs; } @@ -1076,7 +1077,7 @@ void OleComponent::SetHostName( const OUString&, if ( !m_pNativeImpl->m_pOleObject ) throw embed::WrongStateException(); // TODO: the object is in wrong state - m_pNativeImpl->m_pOleObject->SetHostNames( L"app name", SAL_W( aEmbDocName.getStr() ) ); + m_pNativeImpl->m_pOleObject->SetHostNames( L"app name", o3tl::toW( aEmbDocName.getStr() ) ); } diff --git a/embedserv/source/embed/ed_ioleobject.cxx b/embedserv/source/embed/ed_ioleobject.cxx index 8e068ba3555d..140efc12fd3f 100644 --- a/embedserv/source/embed/ed_ioleobject.cxx +++ b/embedserv/source/embed/ed_ioleobject.cxx @@ -19,6 +19,7 @@ #include "embeddoc.hxx" #include <osl/diagnose.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <com/sun/star/beans/PropertyValue.hpp> @@ -44,8 +45,8 @@ STDMETHODIMP EmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLES // the code should be ignored for links if ( !m_aFileName.getLength() ) { - m_pDocHolder->setTitle(SAL_U(szContainerObj)); - m_pDocHolder->setContainerName(SAL_U(szContainerApp)); + m_pDocHolder->setTitle(o3tl::toU(szContainerObj)); + m_pDocHolder->setContainerName(o3tl::toU(szContainerApp)); } return S_OK; @@ -417,7 +418,7 @@ HRESULT EmbedDocument_Impl::SaveObject() // in case of links the containers does not provide client site sometimes hr = Save( static_cast<LPCOLESTR>(nullptr), FALSE ); // triggers saving to the link location - SaveCompleted(SAL_W(aPreservFileName.getStr())); + SaveCompleted(o3tl::toW(aPreservFileName.getStr())); } notify( false ); diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx index bba4d2d59bc6..db14f3fb4893 100644 --- a/embedserv/source/embed/ed_ipersiststr.cxx +++ b/embedserv/source/embed/ed_ipersiststr.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/util/XURLTransformer.hpp> #include <comphelper/processfactory.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <o3tl/string_view.hxx> #include <osl/mutex.hxx> #include <osl/diagnose.h> @@ -220,7 +221,7 @@ uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Imp uno::Reference< util::XURLTransformer > aTransformer( util::URLTransformer::create(comphelper::getComponentContext(m_xFactory)) ); util::URL aURL; - aURL.Complete = SAL_U(pFilePath); + aURL.Complete = o3tl::toU(pFilePath); if ( aTransformer->parseSmart( aURL, OUString() ) ) sDocUrl = aURL.Complete; @@ -429,7 +430,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg ) if ( hr == S_OK ) { - hr = pStg->CreateStream( SAL_W(aOfficeEmbedStreamName.getStr()), + hr = pStg->CreateStream( o3tl::toW(aOfficeEmbedStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, @@ -437,7 +438,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg ) if ( hr == S_OK && m_pOwnStream ) { - hr = pStg->CreateStream( SAL_W(aExtentStreamName.getStr()), + hr = pStg->CreateStream( o3tl::toW(aExtentStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, @@ -483,7 +484,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) if ( FAILED( hr ) ) return E_FAIL; DWORD nStreamMode = aStat.grfMode; - hr = pStg->OpenStream( SAL_W(aOfficeEmbedStreamName.getStr()), + hr = pStg->OpenStream( o3tl::toW(aOfficeEmbedStreamName.getStr()), nullptr, nStreamMode & 0x73, 0, @@ -492,7 +493,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) if ( SUCCEEDED( hr ) ) { - hr = pStg->OpenStream( SAL_W(aExtentStreamName.getStr()), + hr = pStg->OpenStream( o3tl::toW(aExtentStreamName.getStr()), nullptr, nStreamMode & 0x73, 0, @@ -565,8 +566,8 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) { m_pOwnStream = CComPtr< IStream >(); m_pExtStream = CComPtr< IStream >(); - hr = pStg->DestroyElement( SAL_W(aOfficeEmbedStreamName.getStr()) ); - hr = pStg->DestroyElement( SAL_W(aExtentStreamName.getStr()) ); + hr = pStg->DestroyElement( o3tl::toW(aOfficeEmbedStreamName.getStr()) ); + hr = pStg->DestroyElement( o3tl::toW(aExtentStreamName.getStr()) ); OSL_ENSURE( SUCCEEDED( hr ), "Can not destroy created stream!" ); if ( FAILED( hr ) ) @@ -595,14 +596,14 @@ STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad ) if ( FAILED( hr ) ) return E_FAIL; DWORD nStreamMode = aStat.grfMode; - hr = pStgSave->CreateStream( SAL_W(aOfficeEmbedStreamName.getStr()), + hr = pStgSave->CreateStream( o3tl::toW(aOfficeEmbedStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, &pTargetStream ); if ( FAILED( hr ) || !pTargetStream ) return E_FAIL; - hr = pStgSave->CreateStream( SAL_W(aExtentStreamName.getStr()), + hr = pStgSave->CreateStream( o3tl::toW(aExtentStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, @@ -690,14 +691,14 @@ STDMETHODIMP EmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) if ( FAILED( hr ) ) return E_OUTOFMEMORY; DWORD nStreamMode = aStat.grfMode; - hr = m_pMasterStorage->OpenStream( SAL_W(aOfficeEmbedStreamName.getStr()), + hr = m_pMasterStorage->OpenStream( o3tl::toW(aOfficeEmbedStreamName.getStr()), nullptr, nStreamMode & 0x73, 0, &m_pOwnStream ); if ( FAILED( hr ) || !m_pOwnStream ) return E_OUTOFMEMORY; - hr = m_pMasterStorage->OpenStream( SAL_W(aExtentStreamName.getStr()), + hr = m_pMasterStorage->OpenStream( o3tl::toW(aExtentStreamName.getStr()), nullptr, nStreamMode & 0x73, 0, @@ -753,20 +754,20 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? - const_cast<LPOLESTR>( SAL_W(aCurType.data())) ); + const_cast<LPOLESTR>( o3tl::toW(aCurType.data())) ); if ( FAILED( hr ) ) return E_FAIL; hr = m_pMasterStorage->SetClass( m_guid ); if ( FAILED( hr ) ) return E_FAIL; - hr = m_pMasterStorage->CreateStream( SAL_W(aOfficeEmbedStreamName.getStr()), + hr = m_pMasterStorage->CreateStream( o3tl::toW(aOfficeEmbedStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, &m_pOwnStream ); if ( FAILED( hr ) || !m_pOwnStream ) return E_FAIL; - hr = m_pMasterStorage->CreateStream( SAL_W(aExtentStreamName.getStr()), + hr = m_pMasterStorage->CreateStream( o3tl::toW(aExtentStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, @@ -791,7 +792,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) pszFileName ) ); hr = S_OK; - m_aFileName = SAL_U(pszFileName); + m_aFileName = o3tl::toU(pszFileName); } catch( const uno::Exception& ) { @@ -804,7 +805,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? - const_cast<LPOLESTR>( SAL_W(aCurType.data())) ); + const_cast<LPOLESTR>( o3tl::toW(aCurType.data())) ); if ( SUCCEEDED( hr ) ) { @@ -863,7 +864,7 @@ STDMETHODIMP EmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRemember ) else { util::URL aURL; - aURL.Complete = SAL_U( pszFileName ); + aURL.Complete = o3tl::toU( pszFileName ); uno::Reference< util::XURLTransformer > aTransformer( util::URLTransformer::create(comphelper::getComponentContext(m_xFactory)) ); @@ -891,7 +892,7 @@ STDMETHODIMP EmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRemember ) STDMETHODIMP EmbedDocument_Impl::SaveCompleted( LPCOLESTR pszFileName ) { // the different file name would mean error here - m_aFileName = SAL_U(pszFileName); + m_aFileName = o3tl::toU(pszFileName); return S_OK; } @@ -903,7 +904,7 @@ STDMETHODIMP EmbedDocument_Impl::GetCurFile( LPOLESTR *ppszFileName ) if ( FAILED( hr ) || !pMalloc ) return E_FAIL; *ppszFileName = static_cast<LPOLESTR>( pMalloc->Alloc( sizeof( sal_Unicode ) * ( m_aFileName.getLength() + 1 ) ) ); - wcsncpy( *ppszFileName, SAL_W(m_aFileName.getStr()), m_aFileName.getLength() + 1 ); + wcsncpy( *ppszFileName, o3tl::toW(m_aFileName.getStr()), m_aFileName.getLength() + 1 ); return m_aFileName.getLength() ? S_OK : S_FALSE; } diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx index 8dcd911e7034..1f6667ce4851 100644 --- a/extensions/source/config/ldap/ldapaccess.cxx +++ b/extensions/source/config/ldap/ldapaccess.cxx @@ -23,6 +23,7 @@ #include <osl/diagnose.h> #include <rtl/ustrbuf.hxx> #include <rtl/strbuf.hxx> +#include <o3tl/char16_t2wchar_t.hxx> namespace extensions { namespace config { namespace ldap { @@ -131,8 +132,8 @@ void LdapConnection::connectSimple() // Do the bind #ifdef _WIN32 LdapErrCode retCode = ldap_simple_bind_sW(mConnection, - const_cast<PWSTR>(SAL_W(mLdapDefinition.mAnonUser.getStr())), - const_cast<PWSTR>(SAL_W(mLdapDefinition.mAnonCredentials.getStr())) ); + const_cast<PWSTR>(o3tl::toW(mLdapDefinition.mAnonUser.getStr())), + const_cast<PWSTR>(o3tl::toW(mLdapDefinition.mAnonCredentials.getStr())) ); #else LdapErrCode retCode = ldap_simple_bind_s(mConnection, OUStringToOString( mLdapDefinition.mAnonUser, RTL_TEXTENCODING_UTF8 ).getStr(), @@ -153,7 +154,7 @@ void LdapConnection::initConnection() if (mLdapDefinition.mPort == 0) mLdapDefinition.mPort = LDAP_PORT; #ifdef _WIN32 - mConnection = ldap_initW(const_cast<PWSTR>(SAL_W(mLdapDefinition.mServer.getStr())), + mConnection = ldap_initW(const_cast<PWSTR>(o3tl::toW(mLdapDefinition.mServer.getStr())), mLdapDefinition.mPort) ; #else mConnection = ldap_init(OUStringToOString( mLdapDefinition.mServer, RTL_TEXTENCODING_UTF8 ).getStr(), @@ -178,7 +179,7 @@ void LdapConnection::initConnection() LdapMessageHolder result; #ifdef _WIN32 LdapErrCode retCode = ldap_search_sW(mConnection, - const_cast<PWSTR>(SAL_W(aUserDn.getStr())), + const_cast<PWSTR>(o3tl::toW(aUserDn.getStr())), LDAP_SCOPE_BASE, const_cast<PWSTR>( L"(objectclass=*)" ), nullptr, @@ -201,8 +202,8 @@ void LdapConnection::initConnection() while (attr) { PWCHAR * values = ldap_get_valuesW(mConnection, result.msg, attr); if (values) { - const OUString aAttr( SAL_U( attr ) ); - const OUString aValues( SAL_U( *values ) ); + const OUString aAttr( o3tl::toU( attr ) ); + const OUString aValues( o3tl::toU( *values ) ); data->emplace( aAttr, aValues ); ldap_value_freeW(values); } @@ -243,9 +244,9 @@ void LdapConnection::initConnection() #ifdef _WIN32 PWCHAR attributes [2] = { const_cast<PWCHAR>( L"1.1" ), nullptr }; LdapErrCode retCode = ldap_search_sW(mConnection, - const_cast<PWSTR>(SAL_W(mLdapDefinition.mBaseDN.getStr())), + const_cast<PWSTR>(o3tl::toW(mLdapDefinition.mBaseDN.getStr())), LDAP_SCOPE_SUBTREE, - const_cast<PWSTR>(SAL_W(filter.makeStringAndClear().getStr())), attributes, 0, &result.msg) ; + const_cast<PWSTR>(o3tl::toW(filter.makeStringAndClear().getStr())), attributes, 0, &result.msg) ; #else sal_Char * attributes [2] = { const_cast<sal_Char *>(LDAP_NO_ATTRS), nullptr }; LdapErrCode retCode = ldap_search_s(mConnection, @@ -262,7 +263,7 @@ void LdapConnection::initConnection() #ifdef _WIN32 PWCHAR charsDn = ldap_get_dnW(mConnection, entry) ; - userDn = OUString( SAL_U( charsDn ) ); + userDn = OUString( o3tl::toU( charsDn ) ); ldap_memfreeW(charsDn) ; #else sal_Char *charsDn = ldap_get_dn(mConnection, entry) ; diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index 3caab88a4765..c856992fbc96 100644 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -18,12 +18,12 @@ */ #include "ole2uno.hxx" -#include "rtl/ustrbuf.hxx" +#include <rtl/ustrbuf.hxx> +#include <o3tl/char16_t2wchar_t.hxx> - -#include "osl/diagnose.h" -#include "osl/doublecheckedlocking.h" -#include "osl/thread.h" +#include <osl/diagnose.h> +#include <osl/doublecheckedlocking.h> +#include <osl/thread.h> #include <memory> #include <com/sun/star/script/CannotConvertException.hpp> @@ -32,8 +32,8 @@ #include <com/sun/star/script/XInvocation.hpp> #include <com/sun/star/bridge/ModelDependent.hpp> -#include "com/sun/star/bridge/oleautomation/NamedArgument.hpp" -#include "com/sun/star/bridge/oleautomation/PropertyPutArgument.hpp" +#include <com/sun/star/bridge/oleautomation/NamedArgument.hpp> +#include <com/sun/star/bridge/oleautomation/PropertyPutArgument.hpp> #include <typelib/typedescription.hxx> #include <rtl/uuid.h> @@ -459,7 +459,7 @@ Any SAL_CALL IUnknownWrapper_Impl::getValue( const OUString& aPropertyName ) if ( SUCCEEDED( pInfo->GetDocumentation( -1, &sName, nullptr, nullptr, nullptr ) ) ) { - OUString sTmp( SAL_U(LPCOLESTR(sName))); + OUString sTmp( o3tl::toU(LPCOLESTR(sName))); if ( sTmp.startsWith("_") ) sTmp = sTmp.copy(1); // do we own the memory for pTypeLib, msdn doc is vague @@ -470,7 +470,7 @@ Any SAL_CALL IUnknownWrapper_Impl::getValue( const OUString& aPropertyName ) { if ( SUCCEEDED( pTypeLib->GetDocumentation( -1, &sName, nullptr, nullptr, nullptr ) ) ) { - OUString sLibName( SAL_U(LPCOLESTR(sName))); + OUString sLibName( o3tl::toU(LPCOLESTR(sName))); m_sTypeName = sLibName.concat( "." ).concat( sTmp ); } @@ -538,13 +538,13 @@ Any SAL_CALL IUnknownWrapper_Impl::getValue( const OUString& aPropertyName ) case DISP_E_BADPARAMCOUNT: case DISP_E_BADVARTYPE: case DISP_E_EXCEPTION: - throw RuntimeException(OUString(SAL_U(excepinfo.bstrDescription))); + throw RuntimeException(OUString(o3tl::toU(excepinfo.bstrDescription))); break; case DISP_E_MEMBERNOTFOUND: - throw UnknownPropertyException(OUString(SAL_U(excepinfo.bstrDescription))); + throw UnknownPropertyException(OUString(o3tl::toU(excepinfo.bstrDescription))); break; default: - throw RuntimeException(OUString(SAL_U(excepinfo.bstrDescription))); + throw RuntimeException(OUString(o3tl::toU(excepinfo.bstrDescription))); break; } } @@ -1184,7 +1184,7 @@ void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArgument CComBSTR defaultMemberName; if ( SUCCEEDED( pType->GetDocumentation(0, &defaultMemberName, nullptr, nullptr, nullptr ) ) ) { - OUString usName(SAL_U(LPCOLESTR(defaultMemberName))); + OUString usName(o3tl::toU(LPCOLESTR(defaultMemberName))); FuncDesc aDescGet(pType); FuncDesc aDescPut(pType); VarDesc aVarDesc(pType); @@ -1280,7 +1280,7 @@ uno::Any SAL_CALL IUnknownWrapper_Impl::directInvoke( const OUString& aName, con std::unique_ptr<OLECHAR*[]> saNames(new OLECHAR*[nSizeAr]); OLECHAR ** pNames = saNames.get(); - pNames[0] = const_cast<OLECHAR*>(SAL_W(aName.getStr())); + pNames[0] = const_cast<OLECHAR*>(o3tl::toW(aName.getStr())); int cNamedArg = 0; for ( size_t nInd = 0; nInd < dispparams.cArgs; nInd++ ) @@ -1292,7 +1292,7 @@ uno::Any SAL_CALL IUnknownWrapper_Impl::directInvoke( const OUString& aName, con //We put the parameter names in reverse order into the array, //so we can use the DISPID array for DISPPARAMS::rgdispidNamedArgs //The first name in the array is the method name - pNames[nSizeAr - 1 - cNamedArg++] = const_cast<OLECHAR*>(SAL_W(arg.Name.getStr())); + pNames[nSizeAr - 1 - cNamedArg++] = const_cast<OLECHAR*>(o3tl::toW(arg.Name.getStr())); } } @@ -1419,7 +1419,7 @@ uno::Any SAL_CALL IUnknownWrapper_Impl::directInvoke( const OUString& aName, con break; case DISP_E_EXCEPTION: message = "[automation bridge]: "; - message += OUString(SAL_U(excepinfo.bstrDescription), + message += OUString(o3tl::toU(excepinfo.bstrDescription), ::SysStringLen(excepinfo.bstrDescription)); throw InvocationTargetException(message, Reference<XInterface>(), Any()); break; @@ -1719,7 +1719,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, std::unique_ptr<OLECHAR*[]> saNames(new OLECHAR*[nSizeAr]); OLECHAR ** arNames = saNames.get(); - arNames[0] = const_cast<OLECHAR*>(SAL_W(sFuncName.getStr())); + arNames[0] = const_cast<OLECHAR*>(o3tl::toW(sFuncName.getStr())); int cNamedArg = 0; for (size_t iParams = 0; iParams < dispparams.cArgs; iParams ++) @@ -1731,7 +1731,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, //We put the parameter names in reverse order into the array, //so we can use the DISPID array for DISPPARAMS::rgdispidNamedArgs //The first name in the array is the method name - arNames[nSizeAr - 1 - cNamedArg++] = const_cast<OLECHAR*>(SAL_W(arg.Name.getStr())); + arNames[nSizeAr - 1 - cNamedArg++] = const_cast<OLECHAR*>(o3tl::toW(arg.Name.getStr())); } } @@ -2045,7 +2045,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, break; case DISP_E_EXCEPTION: message = "[automation bridge]: "; - message += OUString(SAL_U(excepinfo.bstrDescription), + message += OUString(o3tl::toU(excepinfo.bstrDescription), ::SysStringLen(excepinfo.bstrDescription)); throw InvocationTargetException(message, Reference<XInterface>(), Any()); @@ -2154,7 +2154,7 @@ void IUnknownWrapper_Impl::getFuncDescForInvoke(const OUString & sFuncName, bool IUnknownWrapper_Impl::getDispid(const OUString& sFuncName, DISPID * id) { OSL_ASSERT(m_spDispatch); - LPOLESTR lpsz = const_cast<LPOLESTR> (SAL_W(sFuncName.getStr())); + LPOLESTR lpsz = const_cast<LPOLESTR> (o3tl::toW(sFuncName.getStr())); HRESULT hr = m_spDispatch->GetIDsOfNames(IID_NULL, &lpsz, 1, LOCALE_USER_DEFAULT, id); return hr == S_OK; } @@ -2181,7 +2181,7 @@ void IUnknownWrapper_Impl::getFuncDesc(const OUString & sFuncName, FUNCDESC ** p //get the associated index and add an entry to the map //with the name sFuncName which differs in the casing of the letters to //the actual name as obtained from ITypeInfo - OUString sRealName(SAL_U(LPCOLESTR(memberName))); + OUString sRealName(o3tl::toU(LPCOLESTR(memberName))); cit itOrg = m_mapComFunc.find(sRealName); OSL_ASSERT(itOrg != m_mapComFunc.end()); // maybe this is a property, if so we need @@ -2246,7 +2246,7 @@ void IUnknownWrapper_Impl::getPropDesc(const OUString & sFuncName, FUNCDESC ** p //As opposed to getFuncDesc, we do not add the value because we would // need to find the get and set description for the property. This would //mean to iterate over all FUNCDESCs again. - p = m_mapComFunc.equal_range(OUString(SAL_U(LPCOLESTR(memberName)))); + p = m_mapComFunc.equal_range(OUString(o3tl::toU(LPCOLESTR(memberName)))); } } } @@ -2387,7 +2387,7 @@ void IUnknownWrapper_Impl::buildComTlbIndex() unsigned int pcNames=0; if( SUCCEEDED(pType->GetNames( funcDesc->memid, & memberName, 1, &pcNames))) { - OUString usName(SAL_U(LPCOLESTR(memberName))); + OUString usName(o3tl::toU(LPCOLESTR(memberName))); m_mapComFunc.emplace(usName, i); } else @@ -2414,7 +2414,7 @@ void IUnknownWrapper_Impl::buildComTlbIndex() { if (varDesc->varkind == VAR_DISPATCH) { - OUString usName(SAL_U(LPCOLESTR(memberName))); + OUString usName(o3tl::toU(LPCOLESTR(memberName))); m_mapComFunc.emplace(usName, i); } } diff --git a/extensions/source/ole/servprov.cxx b/extensions/source/ole/servprov.cxx index f3cacec755a7..4fa08a3a6181 100644 --- a/extensions/source/ole/servprov.cxx +++ b/extensions/source/ole/servprov.cxx @@ -28,6 +28,7 @@ #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/supportsservice.hxx> #include <o3tl/any.hxx> +#include <o3tl/char16_t2wchar_t.hxx> using namespace cppu; using namespace osl; @@ -537,7 +538,7 @@ Reference<XInterface> SAL_CALL OleClient_Impl::createInstance(const OUString& Se o2u_attachCurrentThread(); result = CLSIDFromProgID( - SAL_W(ServiceSpecifier.getStr()), //Pointer to the ProgID + o3tl::toW(ServiceSpecifier.getStr()), //Pointer to the ProgID &classId); //Pointer to the CLSID diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx index 5b5612c42a1b..98f1885367d2 100644 --- a/extensions/source/ole/unoconversionutilities.hxx +++ b/extensions/source/ole/unoconversionutilities.hxx @@ -20,16 +20,17 @@ #define INCLUDED_EXTENSIONS_SOURCE_OLE_UNOCONVERSIONUTILITIES_HXX #include <memory> -#include "com/sun/star/script/XInvocationAdapterFactory.hpp" -#include "com/sun/star/script/XInvocationAdapterFactory2.hpp" -#include "com/sun/star/script/XTypeConverter.hpp" -#include "com/sun/star/script/FailReason.hpp" -#include "com/sun/star/bridge/oleautomation/Date.hpp" -#include "com/sun/star/bridge/oleautomation/Currency.hpp" -#include "com/sun/star/bridge/oleautomation/SCode.hpp" -#include "com/sun/star/bridge/oleautomation/Decimal.hpp" -#include "typelib/typedescription.hxx" +#include <com/sun/star/script/XInvocationAdapterFactory.hpp> +#include <com/sun/star/script/XInvocationAdapterFactory2.hpp> +#include <com/sun/star/script/XTypeConverter.hpp> +#include <com/sun/star/script/FailReason.hpp> +#include <com/sun/star/bridge/oleautomation/Date.hpp> +#include <com/sun/star/bridge/oleautomation/Currency.hpp> +#include <com/sun/star/bridge/oleautomation/SCode.hpp> +#include <com/sun/star/bridge/oleautomation/Decimal.hpp> +#include <typelib/typedescription.hxx> #include <o3tl/any.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include "ole2uno.hxx" #include <cppuhelper/weakref.hxx> @@ -812,7 +813,7 @@ void UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny) if (rAny >>= value) { pVariant->vt = VT_BSTR; - pVariant->bstrVal = SysAllocString(SAL_W(value.getStr())); + pVariant->bstrVal = SysAllocString(o3tl::toW(value.getStr())); } else { @@ -1507,7 +1508,7 @@ void UnoConversionUtilities<T>::variantToAny( const VARIANT* pVariant, Any& rAny } case VT_BSTR: { - OUString b(SAL_U(var.bstrVal)); + OUString b(o3tl::toU(var.bstrVal)); rAny.setValue( &b, cppu::UnoType<decltype(b)>::get()); break; } @@ -1528,7 +1529,7 @@ void UnoConversionUtilities<T>::variantToAny( const VARIANT* pVariant, Any& rAny { throw CannotConvertException( "[automation bridge]UnoConversionUtilities<T>::variantToAny \n" - "A UNO type with the name: " + OUString(SAL_U(LPCOLESTR(sName))) + + "A UNO type with the name: " + OUString(o3tl::toU(LPCOLESTR(sName))) + "does not exist!", nullptr, TypeClass_UNKNOWN, FailReason::TYPE_NOT_SUPPORTED,0); } @@ -1992,7 +1993,7 @@ void UnoConversionUtilities<T>::dispatchExObject2Sequence( const VARIANTARG* pva for( sal_Int32 i= 0; i< length; i++) { OUString ousIndex=OUString::number( i); - OLECHAR* sindex = const_cast<OLECHAR *>(SAL_W(ousIndex.getStr())); + OLECHAR* sindex = const_cast<OLECHAR *>(o3tl::toW(ousIndex.getStr())); if( FAILED( hr= pdispEx->GetIDsOfNames(IID_NULL, &sindex , 1, LOCALE_USER_DEFAULT, &dispid))) { diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index cb2634ac6a87..f3355d2acf21 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -45,6 +45,7 @@ #include <com/sun/star/uno/genfunc.h> #include <comphelper/processfactory.hxx> #include <comphelper/profilezone.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include "comifaces.hxx" #include "jscriptclasses.hxx" @@ -84,7 +85,7 @@ static void writeExcepinfo(EXCEPINFO * pInfo, const OUString& message) { pInfo->wCode = UNO_2_OLE_EXCEPTIONCODE; pInfo->bstrSource = SysAllocString(L"[automation bridge] "); - pInfo->bstrDescription = SysAllocString(SAL_W(message.getStr())); + pInfo->bstrDescription = SysAllocString(o3tl::toW(message.getStr())); } } @@ -219,7 +220,7 @@ STDMETHODIMP InterfaceOleWrapper_Impl::GetIDsOfNames(REFIID /*riid*/, if (m_xInvocation.is() && (cNames > 0)) { - OUString name(SAL_U(rgszNames[0])); + OUString name(o3tl::toU(rgszNames[0])); NameToIdMap::iterator iter = m_nameToDispIdMap.find(name); if (iter == m_nameToDispIdMap.end()) @@ -538,7 +539,7 @@ bool getType( const BSTR name, Type & type) { bool ret = false; typelib_TypeDescription * pDesc= nullptr; - OUString str(SAL_U(name)); + OUString str(o3tl::toU(name)); typelib_typedescription_getByName( &pDesc, str.pData ); if( pDesc) { @@ -1023,7 +1024,7 @@ HRESULT InterfaceOleWrapper_Impl::doSetProperty( DISPPARAMS * /*pdispparams*/, V pexcepinfo->wCode = UNO_2_OLE_EXCEPTIONCODE; pexcepinfo->bstrSource = SysAllocString(L"any ONE component"); pexcepinfo->bstrDescription = SysAllocString( - SAL_W(org.getValueType().getTypeName().getStr())); + o3tl::toW(org.getValueType().getTypeName().getStr())); } ret = DISP_E_EXCEPTION; } @@ -1085,7 +1086,7 @@ HRESULT InterfaceOleWrapper_Impl::InvokeGeneral( DISPID dispidMember, unsigned s CComVariant arg; if( pdispparams->cArgs == 1 && SUCCEEDED( arg.ChangeType( VT_BSTR, &pdispparams->rgvarg[0])) ) { - Reference<XIdlClass> classStruct= xRefl->forName(SAL_U(arg.bstrVal)); + Reference<XIdlClass> classStruct= xRefl->forName(o3tl::toU(arg.bstrVal)); if( classStruct.is()) { Any anyStruct; @@ -1119,7 +1120,7 @@ HRESULT InterfaceOleWrapper_Impl::InvokeGeneral( DISPID dispidMember, unsigned s if (!getType(arg.bstrVal, type)) { writeExcepinfo(pexcepinfo, "[automation bridge] A UNO type with the name " + - OUString(SAL_U(arg.bstrVal)) + " does not exist!"); + OUString(o3tl::toU(arg.bstrVal)) + " does not exist!"); return DISP_E_EXCEPTION; } @@ -1255,7 +1256,7 @@ STDMETHODIMP UnoObjectWrapperRemoteOpt::GetIDsOfNames ( REFIID /*riid*/, OLECHA if (m_xInvocation.is() && (cNames > 0)) { - OUString name(SAL_U(rgszNames[0])); + OUString name(o3tl::toU(rgszNames[0])); // has this name been determined as "bad" BadNameMap::iterator badIter= m_badNameMap.find( name); if( badIter == m_badNameMap.end() ) diff --git a/extensions/source/ole/unotypewrapper.cxx b/extensions/source/ole/unotypewrapper.cxx index e719e8c66f43..fa12a9636e53 100644 --- a/extensions/source/ole/unotypewrapper.cxx +++ b/extensions/source/ole/unotypewrapper.cxx @@ -20,7 +20,7 @@ #include "unotypewrapper.hxx" #include "rtl/ustring.hxx" #include <osl/diagnose.h> - +#include <o3tl/char16_t2wchar_t.hxx> bool createUnoTypeWrapper(BSTR sTypeName, VARIANT * pVar) { @@ -47,7 +47,7 @@ bool createUnoTypeWrapper(BSTR sTypeName, VARIANT * pVar) bool createUnoTypeWrapper(const OUString& sTypeName, VARIANT * pVar) { - CComBSTR bstr(SAL_W(sTypeName.getStr())); + CComBSTR bstr(o3tl::toW(sTypeName.getStr())); return createUnoTypeWrapper(bstr, pVar); } diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx index 81d94c0c1f63..26967b7e55c9 100644 --- a/extensions/source/update/check/updatecheckconfig.cxx +++ b/extensions/source/update/check/updatecheckconfig.cxx @@ -28,6 +28,7 @@ #include <osl/time.h> #include <osl/file.hxx> #include <sal/macros.h> +#include <o3tl/char16_t2wchar_t.hxx> #ifdef _WIN32 #ifdef _MSC_VER @@ -169,7 +170,7 @@ OUString UpdateCheckConfig::getDownloadsDirectory() if (SHGetKnownFolderPath(FOLDERID_Downloads, 0, nullptr, &szPath) == S_OK) { - aRet = SAL_U(szPath); + aRet = o3tl::toU(szPath); CoTaskMemFree(szPath); osl::FileBase::getFileURLFromSystemPath( aRet, aRet ); } @@ -197,7 +198,7 @@ OUString UpdateCheckConfig::getAllUsersDirectory() if (TRUE == SHGetSpecialFolderPathW(nullptr, szPath, CSIDL_COMMON_DOCUMENTS, true)) { - aRet = SAL_U(szPath); + aRet = o3tl::toU(szPath); osl::FileBase::getFileURLFromSystemPath( aRet, aRet ); } #else diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index bc04fe9eaee1..4c9f66e49ab7 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -35,6 +35,7 @@ #include <osl/process.h> #include <osl/file.hxx> #include <osl/thread.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <memory> class FilterConfigItem; @@ -169,7 +170,7 @@ static oslProcessError runProcessWithPathSearch(const OUString &rProgName, * */ OUString url; - OUString path(SAL_U(_wgetenv(L"PATH"))); + OUString path(o3tl::toU(_wgetenv(L"PATH"))); oslFileError err = osl_searchFileURL(rProgName.pData, path.pData, &url.pData); if (err != osl_File_E_None) diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index f435811ec62a..430ac9d208b1 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -30,6 +30,7 @@ #include <osl/file.hxx> #include <osl/mutex.hxx> #include <rtl/process.h> +#include <o3tl/char16_t2wchar_t.hxx> #include "../misc/WinImplHelper.hxx" #include <shlguid.h> @@ -59,7 +60,7 @@ bool createFolderItem(OUString const & url, ComPtr<IShellItem> & folder) { return false; } HRESULT res = SHCreateItemFromParsingName( - SAL_W(path.getStr()), nullptr, + o3tl::toW(path.getStr()), nullptr, IID_PPV_ARGS(&folder)); return SUCCEEDED(res); } @@ -104,11 +105,11 @@ OUString lcl_getURLFromShellItem (IShellItem* pItem) if ( FAILED(hr) ) return OUString(); - sURL = SAL_U(pStr); + sURL = o3tl::toU(pStr); } else { - ::osl::FileBase::getFileURLFromSystemPath( SAL_U(pStr), sURL ); + ::osl::FileBase::getFileURLFromSystemPath( o3tl::toU(pStr), sURL ); } CoTaskMemFree (pStr); @@ -126,8 +127,8 @@ OUString lcl_getURLFromShellItem (IShellItem* pItem) { COMDLG_FILTERSPEC aSpec; - aSpec.pszName = SAL_W(aFilter.first.getStr()) ; - aSpec.pszSpec = SAL_W(aFilter.second.getStr()); + aSpec.pszName = o3tl::toW(aFilter.first.getStr()) ; + aSpec.pszSpec = o3tl::toW(aFilter.second.getStr()); lList.push_back(aSpec); } @@ -495,7 +496,7 @@ static void setLabelToControl(TFileDialogCustomize iCustom, sal_uInt16 nControlI { OUString aLabel = CResourceProvider::getResString(nControlId); aLabel = SOfficeToWindowsLabel(aLabel); - iCustom->SetControlLabel(nControlId, SAL_W(aLabel.getStr()) ); + iCustom->SetControlLabel(nControlId, o3tl::toW(aLabel.getStr()) ); } @@ -660,7 +661,7 @@ void VistaFilePickerImpl::impl_sta_SetTitle(const RequestRef& rRequest) aLock.clear(); // <- SYNCHRONIZED - iDialog->SetTitle(SAL_W(sTitle.getStr())); + iDialog->SetTitle(o3tl::toW(sTitle.getStr())); } @@ -674,7 +675,7 @@ void VistaFilePickerImpl::impl_sta_SetFileName(const RequestRef& rRequest) aLock.clear(); // <- SYNCHRONIZED - iDialog->SetFileName(SAL_W(sFileName.getStr())); + iDialog->SetFileName(o3tl::toW(sFileName.getStr())); } @@ -747,7 +748,7 @@ void VistaFilePickerImpl::impl_sta_SetDefaultName(const RequestRef& rRequest) sFilename = sFilename.copy(0, nSepPos); } - iDialog->SetFileName (SAL_W(sFilename.getStr())); + iDialog->SetFileName (o3tl::toW(sFilename.getStr())); m_sFilename = sFilename; } @@ -920,7 +921,7 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest) lpFilterExt = wcsrchr( lpFilterExt, '.' ); if ( lpFilterExt ) - aFileURL += SAL_U(lpFilterExt); + aFileURL += o3tl::toU(lpFilterExt); } } } @@ -930,7 +931,7 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest) osl_getSystemPathFromFileURL( aFileURL.pData, &aSystemPath.pData ); WIN32_FIND_DATAW aFindFileData; - HANDLE hFind = FindFirstFileW( SAL_W(aSystemPath.getStr()), &aFindFileData ); + HANDLE hFind = FindFirstFileW( o3tl::toW(aSystemPath.getStr()), &aFindFileData ); if (hFind != INVALID_HANDLE_VALUE) iDialog->SetFolder(pFolder); else @@ -1067,7 +1068,7 @@ void VistaFilePickerImpl::impl_sta_SetControlValue(const RequestRef& rRequest) for (::sal_Int32 i=0; i<lItems.getLength(); ++i) { const OUString& sItem = lItems[i]; - hResult = iCustom->AddControlItem(nId, i, SAL_W(sItem.getStr())); + hResult = iCustom->AddControlItem(nId, i, o3tl::toW(sItem.getStr())); } } break; @@ -1137,7 +1138,7 @@ void VistaFilePickerImpl::impl_sta_SetControlLabel(const RequestRef& rRequest) TFileDialogCustomize iCustom = impl_getCustomizeInterface(); if ( ! iCustom.is()) return; - iCustom->SetControlLabel (nId, SAL_W(sLabel.getStr())); + iCustom->SetControlLabel (nId, o3tl::toW(sLabel.getStr())); } @@ -1183,7 +1184,7 @@ void VistaFilePickerImpl::impl_SetDefaultExtension( const OUString& currentFilte posOfSemiColon = FilterExt.getLength() - 1; FilterExt = OUString(pFirstExtStart, posOfSemiColon - posOfPoint); - iDialog->SetDefaultExtension ( SAL_W(FilterExt.getStr()) ); + iDialog->SetDefaultExtension ( o3tl::toW(FilterExt.getStr()) ); } } @@ -1205,7 +1206,7 @@ void VistaFilePickerImpl::onAutoExtensionChanged (bool bChecked) PCWSTR pExt = nullptr; if ( bChecked ) { - pExt = SAL_W(sExt.getStr()); + pExt = o3tl::toW(sExt.getStr()); pExt = wcsrchr( pExt, '.' ); if ( pExt ) pExt++; diff --git a/fpicker/source/win32/folderpicker/MtaFop.cxx b/fpicker/source/win32/folderpicker/MtaFop.cxx index b0bd86550f52..4958699a7e5d 100644 --- a/fpicker/source/win32/folderpicker/MtaFop.cxx +++ b/fpicker/source/win32/folderpicker/MtaFop.cxx @@ -19,6 +19,7 @@ #include <osl/diagnose.h> #include <osl/thread.h> +#include <o3tl/char16_t2wchar_t.hxx> #include "MtaFop.hxx" #include <wchar.h> @@ -364,10 +365,10 @@ bool SAL_CALL CMtaFolderPicker::onBrowseForFolder( ) // pre SHBrowseFroFolder m_bi.pidlRoot = nullptr; - m_bi.pszDisplayName = SAL_W(m_pathBuff); + m_bi.pszDisplayName = o3tl::toW(m_pathBuff); if ( m_Description.getLength( ) ) - m_bi.lpszTitle = SAL_W(m_Description.getStr( )); + m_bi.lpszTitle = o3tl::toW(m_Description.getStr( )); lpiid = SHBrowseForFolderW( &m_bi ); bRet = ( nullptr != lpiid ); @@ -409,7 +410,7 @@ LPITEMIDLIST SAL_CALL CMtaFolderPicker::getItemIdListFromPath( const OUString& a pIShellFolder->ParseDisplayName( nullptr, nullptr, - const_cast<LPWSTR>(SAL_W( aDirectory.getStr( ) )), + const_cast<LPWSTR>(o3tl::toW( aDirectory.getStr( ) )), nullptr, &lpItemIdList, nullptr ); @@ -425,7 +426,7 @@ OUString SAL_CALL CMtaFolderPicker::getPathFromItemIdList( LPCITEMIDLIST lpItemI if ( lpItemIdList ) { - bool bRet = SHGetPathFromIDListW( lpItemIdList, SAL_W(m_pathBuff) ); + bool bRet = SHGetPathFromIDListW( lpItemIdList, o3tl::toW(m_pathBuff) ); if ( bRet ) path = m_pathBuff; } @@ -506,7 +507,7 @@ int CALLBACK CMtaFolderPicker::FolderPickerCallback( HWND hwnd, UINT uMsg, LPARA case BFFM_INITIALIZED: pImpl->m_hwnd = hwnd; pImpl->onInitialized( ); - SetWindowTextW( hwnd, SAL_W(pImpl->m_dialogTitle.getStr()) ); + SetWindowTextW( hwnd, o3tl::toW(pImpl->m_dialogTitle.getStr()) ); break; case BFFM_SELCHANGED: diff --git a/framework/source/uielement/spinfieldtoolbarcontroller.cxx b/framework/source/uielement/spinfieldtoolbarcontroller.cxx index 135a708e069b..941dc21107f1 100644 --- a/framework/source/uielement/spinfieldtoolbarcontroller.cxx +++ b/framework/source/uielement/spinfieldtoolbarcontroller.cxx @@ -31,6 +31,7 @@ #include <vcl/svapp.hxx> #include <vcl/mnemonic.hxx> #include <vcl/toolbox.hxx> +#include <o3tl/char16_t2wchar_t.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -459,9 +460,9 @@ OUString SpinfieldToolbarController::impl_formatOutputString( double fValue ) aBuffer[0] = 0; if ( m_bFloat ) - _snwprintf( SAL_W(aBuffer), SAL_N_ELEMENTS(aBuffer), SAL_W(m_aOutFormat.getStr()), fValue ); + _snwprintf( o3tl::toW(aBuffer), SAL_N_ELEMENTS(aBuffer), o3tl::toW(m_aOutFormat.getStr()), fValue ); else - _snwprintf( SAL_W(aBuffer), SAL_N_ELEMENTS(aBuffer), SAL_W(m_aOutFormat.getStr()), sal_Int32( fValue )); + _snwprintf( o3tl::toW(aBuffer), SAL_N_ELEMENTS(aBuffer), o3tl::toW(m_aOutFormat.getStr()), sal_Int32( fValue )); return aBuffer; #else diff --git a/helpcompiler/inc/HelpCompiler.hxx b/helpcompiler/inc/HelpCompiler.hxx index 8d8a920da696..f9827eb2bbbe 100644 --- a/helpcompiler/inc/HelpCompiler.hxx +++ b/helpcompiler/inc/HelpCompiler.hxx @@ -42,6 +42,7 @@ #include <osl/thread.h> #include <osl/process.h> #include <osl/file.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <BasCodeTagger.hxx> #include <helpcompiler/compilehelp.hxx> @@ -92,7 +93,7 @@ namespace fs { OUString ustrSystemPath; osl::File::getSystemPathFromFileURL(data, ustrSystemPath); - return std::wstring(SAL_W(ustrSystemPath.getStr())); + return std::wstring(o3tl::toW(ustrSystemPath.getStr())); } #endif std::string toUTF8() const diff --git a/helpcompiler/source/HelpLinker.cxx b/helpcompiler/source/HelpLinker.cxx index 07303afe9e6a..9589da095405 100644 --- a/helpcompiler/source/HelpLinker.cxx +++ b/helpcompiler/source/HelpLinker.cxx @@ -34,6 +34,7 @@ #include <sal/types.h> #include <osl/time.h> #include <rtl/bootstrap.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <expat.h> #include <memory> @@ -42,7 +43,7 @@ namespace { FILE* fopen_impl(const fs::path& rPath, const char* szMode) { #ifdef _WIN32 //We need _wfopen to support long file paths on Windows XP - return _wfopen(rPath.native_file_string_w().c_str(), SAL_W(OUString::createFromAscii(szMode).getStr())); + return _wfopen(rPath.native_file_string_w().c_str(), o3tl::toW(OUString::createFromAscii(szMode).getStr())); #else return fopen(rPath.native_file_string().c_str(), szMode); #endif diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx index 1ae892471ac3..58908c9f38ad 100644 --- a/idlc/source/options.cxx +++ b/idlc/source/options.cxx @@ -24,8 +24,9 @@ #include <rtl/string.hxx> #include <rtl/strbuf.hxx> -#include "rtl/ustring.hxx" -#include "osl/file.hxx" +#include <rtl/ustring.hxx> +#include <osl/file.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #ifdef _WIN32 # if !defined WIN32_LEAN_AND_MEAN @@ -192,7 +193,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( - SAL_W(path.getStr()), SAL_W(&vec[0]), path.getLength() + 1); + o3tl::toW(path.getStr()), o3tl::toW(&vec[0]), path.getLength() + 1); if (len > 0) { diff --git a/include/comphelper/windowserrorstring.hxx b/include/comphelper/windowserrorstring.hxx index 59f27711a5f8..b8cac3f8dbe9 100644 --- a/include/comphelper/windowserrorstring.hxx +++ b/include/comphelper/windowserrorstring.hxx @@ -13,6 +13,7 @@ #include <prewin.h> #include <postwin.h> #include <rtl/ustring.hxx> +#include <o3tl/char16_t2wchar_t.hxx> namespace { @@ -29,7 +30,7 @@ inline OUString WindowsErrorString(DWORD nErrorCode) nullptr) == 0) return OUString::number(nErrorCode, 16); - OUString result(SAL_U(pMsgBuf)); + OUString result(o3tl::toU(pMsgBuf)); result.endsWith("\r\n", &result); LocalFree(pMsgBuf); diff --git a/include/o3tl/char16_t2wchar_t.hxx b/include/o3tl/char16_t2wchar_t.hxx new file mode 100644 index 000000000000..6ffab02e78c9 --- /dev/null +++ b/include/o3tl/char16_t2wchar_t.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_O3TL_CHAR16_T2WCHAR_T_HXX +#define INCLUDED_O3TL_CHAR16_T2WCHAR_T_HXX + +#include <sal/config.h> + +namespace o3tl { + +#if defined _WIN32 +// Helpers for safe conversion between wchar_t and char16_t in MSVC + +static_assert(sizeof(char16_t) == sizeof(wchar_t), + "These helper functions are only applicable to implementations with 16-bit wchar_t"); + +// While other implementations define wchar_t as 32-bit integral value, and mostly use +// char-based UTF-8 string APIs, in MSVC wchar_t is (non-conformant) 16-bit, and Unicode +// support is implemented by Unicode-aware WinAPI functions taking UTF-16 LE strings, +// and also stdlib functions taking those strings. +// +// In LibreOffice, internal string representation is also UTF-16 with system endianness +// (sal_Unicode that is typedef for char16_t); so it is an important implementation concept +// to treat internal strings as directly usable by WinAPI/stdlib functions and vice versa. +// Also, it's important to use safe conversion between unrelated underlying C++ types +// used for MSVC and LibreOffice string storage without plain reinterpret_cast that brings +// risks of masking errors like casting char buffers to wchar_t/char16_t. +// +// Use these helpers for wchar_t (WSTR, WCHAR, OLESTR etc) to char16_t (sal_Unicode) string +// conversions instead of reinterpret-cast in Windows-specific code. +inline wchar_t * toW(char16_t * p) +{ + return reinterpret_cast<wchar_t *>(p); +} +inline wchar_t const * toW(char16_t const * p) +{ + return reinterpret_cast<wchar_t const *>(p); +} +inline char16_t * toU(wchar_t * p) +{ + return reinterpret_cast<char16_t *>(p); +} +inline char16_t const * toU(wchar_t const * p) +{ + return reinterpret_cast<char16_t const *>(p); +} +#endif + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/sal/types.h b/include/sal/types.h index a138a90858df..14c8e90d293d 100644 --- a/include/sal/types.h +++ b/include/sal/types.h @@ -682,21 +682,6 @@ template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) { /// @endcond -#if defined LIBO_INTERNAL_ONLY && defined __cplusplus && defined SAL_W32 -/// @cond INTERNAL -// Temporary scaffolding for the MSVC sal_Unicode wchar_t -> char16_t change; to -// be removed again: -inline wchar_t * SAL_W(char16_t * p) -{ return reinterpret_cast<wchar_t *>(p); } -inline wchar_t const * SAL_W(char16_t const * p) -{ return reinterpret_cast<wchar_t const *>(p); } -inline char16_t * SAL_U(wchar_t * p) -{ return reinterpret_cast<char16_t *>(p); } -inline char16_t const * SAL_U(wchar_t const * p) -{ return reinterpret_cast<char16_t const *>(p); } -/// @endcond -#endif - /// @cond INTERNAL /** Annotate pointer-returning functions to indicate that such a pointer is never nullptr. diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 2dc5b5aa76c7..f97dbce54a38 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -49,6 +49,7 @@ #include "osl/file.hxx" #include "rtl/instance.hxx" #include "osl/getglobalmutex.hxx" +#include <o3tl/char16_t2wchar_t.hxx> #include <setjmp.h> #include <signal.h> #include <stack> @@ -485,7 +486,7 @@ static void load_msvcr(OUString const & jvm_dll, OUStringLiteral msvcr) } if (LoadLibraryW( - SAL_W(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr()))) + o3tl::toW(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr()))) return; // Then check if msvcr71.dll is in the parent folder of where @@ -497,7 +498,7 @@ static void load_msvcr(OUString const & jvm_dll, OUStringLiteral msvcr) return; LoadLibraryW( - SAL_W(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr())); + o3tl::toW(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr())); } // Check if the jvm DLL imports msvcr71.dll, and in that case try @@ -518,7 +519,7 @@ static void do_msvcr_magic(OUString const &jvm_dll) return; } - FILE *f = _wfopen(SAL_W(Module.getStr()), L"rb"); + FILE *f = _wfopen(o3tl::toW(Module.getStr()), L"rb"); if (!f) { diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index a211464aa2cd..e64e5b306277 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -22,6 +22,7 @@ #include <osl/file.hxx> #include <rtl/alloc.h> #include <rtl/byteseq.h> +#include <o3tl/char16_t2wchar_t.hxx> #include "file_url.hxx" #include "file_error.hxx" @@ -717,7 +718,7 @@ oslFileError SAL_CALL osl_openFile( dwCreation |= OPEN_EXISTING; HANDLE hFile = CreateFileW( - SAL_W(rtl_uString_getStr(strSysPath)), + o3tl::toW(rtl_uString_getStr(strSysPath)), dwAccess, dwShare, nullptr, dwCreation, 0, nullptr); // @@@ ERROR HANDLING @@@ @@ -1073,7 +1074,7 @@ oslFileError SAL_CALL osl_removeFile(rtl_uString* strPath) if (error == osl_File_E_None) { - if (DeleteFileW(SAL_W(rtl_uString_getStr(strSysPath)))) + if (DeleteFileW(o3tl::toW(rtl_uString_getStr(strSysPath)))) error = osl_File_E_None; else error = oslTranslateFileError(GetLastError()); @@ -1093,8 +1094,8 @@ oslFileError SAL_CALL osl_copyFile(rtl_uString* strPath, rtl_uString *strDestPat if (error == osl_File_E_None) { - LPCWSTR src = SAL_W(rtl_uString_getStr(strSysPath)); - LPCWSTR dst = SAL_W(rtl_uString_getStr(strSysDestPath)); + LPCWSTR src = o3tl::toW(rtl_uString_getStr(strSysPath)); + LPCWSTR dst = o3tl::toW(rtl_uString_getStr(strSysDestPath)); if (CopyFileW(src, dst, FALSE)) error = osl_File_E_None; @@ -1120,8 +1121,8 @@ oslFileError SAL_CALL osl_moveFile(rtl_uString* strPath, rtl_uString *strDestPat if (error == osl_File_E_None) { - LPCWSTR src = SAL_W(rtl_uString_getStr(strSysPath)); - LPCWSTR dst = SAL_W(rtl_uString_getStr(strSysDestPath)); + LPCWSTR src = o3tl::toW(rtl_uString_getStr(strSysPath)); + LPCWSTR dst = o3tl::toW(rtl_uString_getStr(strSysDestPath)); if (MoveFileExW(src, dst, MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING)) error = osl_File_E_None; diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx index f94c91f5aaf4..3ef290140a0a 100644 --- a/sal/osl/w32/file_dirvol.cxx +++ b/sal/osl/w32/file_dirvol.cxx @@ -17,17 +17,18 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "systools/win32/uwinapi.h" +#include <systools/win32/uwinapi.h> #include "file_url.hxx" -#include <filetime.hxx> +#include "filetime.hxx" #include "file_error.hxx" #include "path_helper.hxx" -#include "rtl/alloc.h" -#include "rtl/ustring.hxx" +#include <rtl/alloc.h> +#include <rtl/ustring.hxx> #include <rtl/character.hxx> +#include <o3tl/char16_t2wchar_t.hxx> static const wchar_t UNC_PREFIX[] = L"\\\\"; static const wchar_t BACKSLASH = '\\'; @@ -119,7 +120,7 @@ namespace }; inline bool is_UNC_path(const sal_Unicode* path) - { return (0 == wcsncmp(UNC_PREFIX, SAL_W(path), SAL_N_ELEMENTS(UNC_PREFIX) - 1)); } + { return (0 == wcsncmp(UNC_PREFIX, o3tl::toW(path), SAL_N_ELEMENTS(UNC_PREFIX) - 1)); } void parse_UNC_path(const sal_Unicode* path, UNCComponents* puncc) { @@ -344,7 +345,7 @@ static HANDLE WINAPI OpenDirectory( rtl_uString* pPath) WCHAR* szFileMask = static_cast< WCHAR* >( rtl_allocateMemory( sizeof( WCHAR ) * ( nLen + nSuffLen + 1 ) ) ); - wcscpy( szFileMask, SAL_W(rtl_uString_getStr( pPath )) ); + wcscpy( szFileMask, o3tl::toW(rtl_uString_getStr( pPath )) ); wcscat( szFileMask, pSuffix ); pDirectory = static_cast<LPDIRECTORY>(HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY))); @@ -550,7 +551,7 @@ static oslFileError SAL_CALL osl_openNetworkServer( ZeroMemory( &aNetResource, sizeof(aNetResource) ); - aNetResource.lpRemoteName = SAL_W(strSysDirPath->buffer); + aNetResource.lpRemoteName = o3tl::toW(strSysDirPath->buffer); dwError = WNetOpenEnumW( RESOURCE_GLOBALNET, @@ -581,7 +582,7 @@ static DWORD create_dir_with_callback( // user specified callback function. On success // the function returns ERROR_SUCCESS else a Win32 error code. - BOOL bCreated = CreateDirectoryW( SAL_W(rtl_uString_getStr( dir_path )), nullptr ); + BOOL bCreated = CreateDirectoryW( o3tl::toW(rtl_uString_getStr( dir_path )), nullptr ); if ( bCreated ) { @@ -681,7 +682,7 @@ oslFileError osl_createDirectoryWithFlags(rtl_uString * strPath, sal_uInt32) if ( osl_File_E_None == error ) { - BOOL bCreated = CreateDirectoryW( SAL_W(rtl_uString_getStr( strSysPath )), nullptr ); + BOOL bCreated = CreateDirectoryW( o3tl::toW(rtl_uString_getStr( strSysPath )), nullptr ); if ( !bCreated ) { @@ -716,7 +717,7 @@ oslFileError SAL_CALL osl_removeDirectory(rtl_uString* strPath) if ( osl_File_E_None == error ) { - if ( RemoveDirectoryW( SAL_W(rtl_uString_getStr( strSysPath ) )) ) + if ( RemoveDirectoryW( o3tl::toW(rtl_uString_getStr( strSysPath ) )) ) error = osl_File_E_None; else error = oslTranslateFileError( GetLastError() ); @@ -869,7 +870,7 @@ static oslFileError SAL_CALL osl_getNextFileItem( pItemImpl->nRefCount = 1; rtl_uString* pTmpFileName = nullptr; - rtl_uString_newFromStr( &pTmpFileName, SAL_U(pItemImpl->FindData.cFileName) ); + rtl_uString_newFromStr( &pTmpFileName, o3tl::toU(pItemImpl->FindData.cFileName) ); rtl_uString_newConcat( &pItemImpl->m_pFullPath, pDirImpl->m_pDirectoryPath, pTmpFileName ); rtl_uString_release( pTmpFileName ); @@ -1040,7 +1041,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector osl_acquireDirectoryItem( static_cast<oslDirectoryItem>(pItemImpl) ); - wcscpy( pItemImpl->cDriveString, SAL_W(strSysFilePath->buffer) ); + wcscpy( pItemImpl->cDriveString, o3tl::toW(strSysFilePath->buffer) ); pItemImpl->cDriveString[0] = rtl::toAsciiUpperCase( pItemImpl->cDriveString[0] ); if ( pItemImpl->cDriveString[wcslen(pItemImpl->cDriveString) - 1] != '\\' ) @@ -1060,7 +1061,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector if ( strSysFilePath->length > 0 && strSysFilePath->buffer[strSysFilePath->length - 1] == '\\' ) rtl_uString_newFromStr_WithLength( &strSysFilePath, strSysFilePath->buffer, strSysFilePath->length - 1 ); - hFind = FindFirstFileW( SAL_W(rtl_uString_getStr(strSysFilePath)), &aFindData ); + hFind = FindFirstFileW( o3tl::toW(rtl_uString_getStr(strSysFilePath)), &aFindData ); if ( hFind != INVALID_HANDLE_VALUE ) { @@ -1158,7 +1159,7 @@ bool is_floppy_volume_mount_point(const rtl::OUString& path) osl::systemPathEnsureSeparator(p); WCHAR vn[51]; - if (GetVolumeNameForVolumeMountPointW(SAL_W(p.getStr()), vn, SAL_N_ELEMENTS(vn))) + if (GetVolumeNameForVolumeMountPointW(o3tl::toW(p.getStr()), vn, SAL_N_ELEMENTS(vn))) { WCHAR vnfloppy[51]; if (is_floppy_A_present() && @@ -1197,13 +1198,13 @@ static bool is_volume_mount_point(const rtl::OUString& path) if (!is_floppy_drive(p)) { - DWORD fattr = GetFileAttributesW(SAL_W(p.getStr())); + DWORD fattr = GetFileAttributesW(o3tl::toW(p.getStr())); if ((INVALID_FILE_ATTRIBUTES != fattr) && (FILE_ATTRIBUTE_REPARSE_POINT & fattr)) { WIN32_FIND_DATAW find_data; - HANDLE h_find = FindFirstFileW(SAL_W(p.getStr()), &find_data); + HANDLE h_find = FindFirstFileW(o3tl::toW(p.getStr()), &find_data); if (IsValidHandle(h_find) && (FILE_ATTRIBUTE_REPARSE_POINT & find_data.dwFileAttributes) && @@ -1227,7 +1228,7 @@ static UINT get_volume_mount_point_drive_type(const rtl::OUString& path) osl::systemPathEnsureSeparator(p); WCHAR vn[51]; - if (GetVolumeNameForVolumeMountPointW(SAL_W(p.getStr()), vn, SAL_N_ELEMENTS(vn))) + if (GetVolumeNameForVolumeMountPointW(o3tl::toW(p.getStr()), vn, SAL_N_ELEMENTS(vn))) return GetDriveTypeW(vn); return DRIVE_NO_ROOT_DIR; @@ -1247,7 +1248,7 @@ static oslFileError osl_get_drive_type( if (is_volume_mount_point(path)) drive_type = get_volume_mount_point_drive_type(path); else - drive_type = GetDriveTypeW(SAL_W(path.getStr())); + drive_type = GetDriveTypeW(o3tl::toW(path.getStr())); if (DRIVE_NO_ROOT_DIR == drive_type) return oslTranslateFileError(ERROR_INVALID_DRIVE); @@ -1296,7 +1297,7 @@ static void get_volume_space_information( const rtl::OUString& path, oslVolumeInfo *pInfo) { BOOL ret = GetDiskFreeSpaceExW( - SAL_W(path.getStr()), + o3tl::toW(path.getStr()), reinterpret_cast<PULARGE_INTEGER>(&pInfo->uFreeSpace), reinterpret_cast<PULARGE_INTEGER>(&pInfo->uTotalSpace), nullptr); @@ -1343,7 +1344,7 @@ static oslFileError get_filesystem_attributes( DWORD mcl; DWORD flags; - LPCWSTR pszPath = SAL_W(path.getStr()); + LPCWSTR pszPath = o3tl::toW(path.getStr()); if (GetVolumeInformationW(pszPath, vn, MAX_PATH+1, &serial, &mcl, &flags, fsn, MAX_PATH+1)) { // Currently sal does not use this value, instead MAX_PATH is used @@ -1355,7 +1356,7 @@ static oslFileError get_filesystem_attributes( pInfo->uMaxPathLength = MAX_PATH; pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName; - rtl_uString_newFromStr(&pInfo->ustrFileSystemName, SAL_U(fsn)); + rtl_uString_newFromStr(&pInfo->ustrFileSystemName, o3tl::toU(fsn)); // volumes (even NTFS) will always be considered case // insensitive because the Win32 API is not able to @@ -1459,9 +1460,9 @@ static oslFileError SAL_CALL osl_getDriveInfo( LPCWSTR lpLastBkSlash = wcschr( &lpFirstBkSlash[1], '\\' ); if ( lpLastBkSlash ) - rtl_uString_newFromStr_WithLength( &pStatus->ustrFileName, SAL_U(&lpFirstBkSlash[1]), lpLastBkSlash - lpFirstBkSlash - 1 ); + rtl_uString_newFromStr_WithLength( &pStatus->ustrFileName, o3tl::toU(&lpFirstBkSlash[1]), lpLastBkSlash - lpFirstBkSlash - 1 ); else - rtl_uString_newFromStr( &pStatus->ustrFileName, SAL_U(&lpFirstBkSlash[1]) ); + rtl_uString_newFromStr( &pStatus->ustrFileName, o3tl::toU(&lpFirstBkSlash[1]) ); pStatus->uValidFields |= osl_FileStatus_Mask_FileName; } } @@ -1479,10 +1480,10 @@ static oslFileError SAL_CALL osl_getDriveInfo( WCHAR szFileName[dwBufsizeConst + 16]; swprintf( szFileName, L"%s [%s]", cDrive, szBuffer ); - rtl_uString_newFromStr( &pStatus->ustrFileName, SAL_U(szFileName) ); + rtl_uString_newFromStr( &pStatus->ustrFileName, o3tl::toU(szFileName) ); } else - rtl_uString_newFromStr( &pStatus->ustrFileName, SAL_U(cDrive) ); + rtl_uString_newFromStr( &pStatus->ustrFileName, o3tl::toU(cDrive) ); } pStatus->uValidFields |= osl_FileStatus_Mask_FileName; break; @@ -1496,17 +1497,17 @@ static oslFileError SAL_CALL osl_getDriveInfo( WCHAR szFileName[dwBufsizeConst + 16]; swprintf( szFileName, L"%s [%s]", cDrive, szVolumeNameBuffer ); - rtl_uString_newFromStr( &pStatus->ustrFileName, SAL_U(szFileName) ); + rtl_uString_newFromStr( &pStatus->ustrFileName, o3tl::toU(szFileName) ); } else - rtl_uString_newFromStr( &pStatus->ustrFileName, SAL_U(cDrive) ); + rtl_uString_newFromStr( &pStatus->ustrFileName, o3tl::toU(cDrive) ); } pStatus->uValidFields |= osl_FileStatus_Mask_FileName; break; case DRIVE_CDROM: case DRIVE_REMOVABLE: pStatus->uValidFields |= osl_FileStatus_Mask_FileName; - rtl_uString_newFromStr( &pStatus->ustrFileName, SAL_U(cRoot) ); + rtl_uString_newFromStr( &pStatus->ustrFileName, o3tl::toU(cRoot) ); break; case DRIVE_UNKNOWN: default: @@ -1521,7 +1522,7 @@ static oslFileError SAL_CALL osl_getDriveInfo( { rtl_uString *ustrSystemPath = nullptr; - rtl_uString_newFromStr( &ustrSystemPath, SAL_U(pItemImpl->cDriveString) ); + rtl_uString_newFromStr( &ustrSystemPath, o3tl::toU(pItemImpl->cDriveString) ); oslFileError error = osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL ); rtl_uString_release( ustrSystemPath ); if (error != osl_File_E_None) @@ -1574,7 +1575,7 @@ oslFileError SAL_CALL osl_getFileStatus( if ( uFieldMask & osl_FileStatus_Mask_Validate ) { - HANDLE hFind = FindFirstFileW( SAL_W(rtl_uString_getStr( pItemImpl->m_pFullPath )), &pItemImpl->FindData ); + HANDLE hFind = FindFirstFileW( o3tl::toW(rtl_uString_getStr( pItemImpl->m_pFullPath )), &pItemImpl->FindData ); if ( hFind != INVALID_HANDLE_VALUE ) FindClose( hFind ); @@ -1613,7 +1614,7 @@ oslFileError SAL_CALL osl_getFileStatus( /* Most of the fields are already set, regardless of requiered fields */ - rtl_uString_newFromStr( &pStatus->ustrFileName, SAL_U(pItemImpl->FindData.cFileName) ); + rtl_uString_newFromStr( &pStatus->ustrFileName, o3tl::toU(pItemImpl->FindData.cFileName) ); pStatus->uValidFields |= osl_FileStatus_Mask_FileName; if ((FILE_ATTRIBUTE_REPARSE_POINT & pItemImpl->FindData.dwFileAttributes) && @@ -1646,8 +1647,8 @@ oslFileError SAL_CALL osl_getFileStatus( if ( !pItemImpl->bFullPathNormalized ) { ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH ); - sal_uInt32 nNewLen = GetCaseCorrectPathName( SAL_W(rtl_uString_getStr( pItemImpl->m_pFullPath )), - SAL_W( aBuffer ), + sal_uInt32 nNewLen = GetCaseCorrectPathName( o3tl::toW(rtl_uString_getStr( pItemImpl->m_pFullPath )), + o3tl::toW( aBuffer ), aBuffer.getBufSizeInSymbols(), true ); @@ -1682,7 +1683,7 @@ oslFileError SAL_CALL osl_setFileAttributes( if ( osl_File_E_None != error ) return error; - dwFileAttributes = GetFileAttributesW( SAL_W(rtl_uString_getStr(ustrSysPath)) ); + dwFileAttributes = GetFileAttributesW( o3tl::toW(rtl_uString_getStr(ustrSysPath)) ); if ( (DWORD)-1 != dwFileAttributes ) { @@ -1694,7 +1695,7 @@ oslFileError SAL_CALL osl_setFileAttributes( if ( uAttributes & osl_File_Attribute_Hidden ) dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN; - fSuccess = SetFileAttributesW( SAL_W(rtl_uString_getStr(ustrSysPath)), dwFileAttributes ); + fSuccess = SetFileAttributesW( o3tl::toW(rtl_uString_getStr(ustrSysPath)), dwFileAttributes ); } else { @@ -1731,7 +1732,7 @@ oslFileError SAL_CALL osl_setFileTime( if (error==osl_File_E_INVAL) return error; - hFile=CreateFileW(SAL_W(rtl_uString_getStr(sysPath)), GENERIC_WRITE, 0, nullptr , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + hFile=CreateFileW(o3tl::toW(rtl_uString_getStr(sysPath)), GENERIC_WRITE, 0, nullptr , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); rtl_uString_release(sysPath); if (hFile==INVALID_HANDLE_VALUE) diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx index 88bd38bcac86..e5fac8590a53 100644 --- a/sal/osl/w32/file_url.cxx +++ b/sal/osl/w32/file_url.cxx @@ -22,9 +22,10 @@ #include "file_url.hxx" #include "file_error.hxx" -#include "rtl/alloc.h" +#include <rtl/alloc.h> #include <rtl/ustring.hxx> -#include "osl/mutex.h" +#include <osl/mutex.h> +#include <o3tl/char16_t2wchar_t.hxx> #include "path_helper.hxx" @@ -165,13 +166,13 @@ DWORD IsValidFilePath(rtl_uString *path, DWORD dwFlags, rtl_uString **corrected) DWORD dwCandidatPathType = PATHTYPE_ERROR; - if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, SAL_U(WSTR_LONG_PATH_PREFIX_UNC), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) ) + if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, o3tl::toU(WSTR_LONG_PATH_PREFIX_UNC), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1 ) ) { /* This is long path in UNC notation */ lpComponent = lpszPath + SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX_UNC) - 1; dwCandidatPathType = PATHTYPE_ABSOLUTE_UNC | PATHTYPE_IS_LONGPATH; } - else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, SAL_U(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) + else if ( 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( path->buffer, nLength, o3tl::toU(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) { /* This is long path */ lpComponent = lpszPath + SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1; @@ -663,7 +664,7 @@ oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **p /* Indicates local root */ if ( nDecodedLen == nSkip ) - rtl_uString_newFromStr_WithLength( &strTempPath, SAL_U(WSTR_SYSTEM_ROOT_PATH), SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ); + rtl_uString_newFromStr_WithLength( &strTempPath, o3tl::toU(WSTR_SYSTEM_ROOT_PATH), SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ); else { /* do not separate the directory and file case, so the maximal path length without prefix is MAX_PATH-12 */ @@ -674,14 +675,14 @@ oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **p else { ::osl::LongPathBuffer< sal_Unicode > aBuf( MAX_LONG_PATH ); - sal_uInt32 nNewLen = GetCaseCorrectPathName( SAL_W(pDecodedURL) + nSkip, - SAL_W(aBuf), + sal_uInt32 nNewLen = GetCaseCorrectPathName( o3tl::toW(pDecodedURL) + nSkip, + o3tl::toW(aBuf), aBuf.getBufSizeInSymbols(), false ); if ( nNewLen <= MAX_PATH - 12 - || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, SAL_U(WSTR_SYSTEM_ROOT_PATH), SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1, SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ) - || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, SAL_U(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) + || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, o3tl::toU(WSTR_SYSTEM_ROOT_PATH), SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1, SAL_N_ELEMENTS(WSTR_SYSTEM_ROOT_PATH) - 1 ) + || 0 == rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL + nSkip, nDecodedLen - nSkip, o3tl::toU(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1, SAL_N_ELEMENTS(WSTR_LONG_PATH_PREFIX) - 1 ) ) { rtl_uString_newFromStr_WithLength( &strTempPath, aBuf, nNewLen ); } @@ -690,7 +691,7 @@ oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **p /* it should be an UNC path, use the according prefix */ rtl_uString *strSuffix = nullptr; rtl_uString *strPrefix = nullptr; - rtl_uString_newFromStr_WithLength( &strPrefix, SAL_U(WSTR_LONG_PATH_PREFIX_UNC), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX_UNC ) - 1 ); + rtl_uString_newFromStr_WithLength( &strPrefix, o3tl::toU(WSTR_LONG_PATH_PREFIX_UNC), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX_UNC ) - 1 ); rtl_uString_newFromStr_WithLength( &strSuffix, aBuf + 2, nNewLen - 2 ); rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix ); @@ -702,7 +703,7 @@ oslFileError osl_getSystemPathFromFileURL_( rtl_uString *strURL, rtl_uString **p { rtl_uString *strSuffix = nullptr; rtl_uString *strPrefix = nullptr; - rtl_uString_newFromStr_WithLength( &strPrefix, SAL_U(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX ) - 1 ); + rtl_uString_newFromStr_WithLength( &strPrefix, o3tl::toU(WSTR_LONG_PATH_PREFIX), SAL_N_ELEMENTS( WSTR_LONG_PATH_PREFIX ) - 1 ); rtl_uString_newFromStr_WithLength( &strSuffix, aBuf, nNewLen ); rtl_uString_newConcat( &strTempPath, strPrefix, strSuffix ); @@ -888,8 +889,8 @@ oslFileError SAL_CALL osl_searchFileURL( do { /* If search path is empty use a nullptr pointer instead according to MSDN documentation of SearchPath */ - LPCWSTR lpszSearchPath = ustrSystemSearchPath && ustrSystemSearchPath->length ? SAL_W(ustrSystemSearchPath->buffer) : nullptr; - LPCWSTR lpszSearchFile = SAL_W(ustrSysPath->buffer); + LPCWSTR lpszSearchPath = ustrSystemSearchPath && ustrSystemSearchPath->length ? o3tl::toW(ustrSystemSearchPath->buffer) : nullptr; + LPCWSTR lpszSearchFile = o3tl::toW(ustrSysPath->buffer); /* Allocate space for buffer according to previous returned count of required chars */ /* +1 is not necessary if we follow MSDN documentation but for robustness we do so */ @@ -906,7 +907,7 @@ oslFileError SAL_CALL osl_searchFileURL( if ( dwResult ) { - rtl_uString_newFromStr( &ustrSysPath, SAL_U(lpBuffer) ); + rtl_uString_newFromStr( &ustrSysPath, o3tl::toU(lpBuffer) ); error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath ); } else @@ -917,7 +918,7 @@ oslFileError SAL_CALL osl_searchFileURL( /* something went wrong, perhaps the path was absolute */ error = oslTranslateFileError( GetLastError() ); - hFind = FindFirstFileW( SAL_W(ustrSysPath->buffer), &aFindFileData ); + hFind = FindFirstFileW( o3tl::toW(ustrSysPath->buffer), &aFindFileData ); if ( IsValidHandle(hFind) ) { @@ -975,15 +976,15 @@ oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uStr { osl_acquireMutex( g_CurrentDirectoryMutex ); - GetCurrentDirectoryW( aCurrentDir.getBufSizeInSymbols(), SAL_W(aCurrentDir) ); - SetCurrentDirectoryW( SAL_W(ustrBaseSysPath->buffer) ); + GetCurrentDirectoryW( aCurrentDir.getBufSizeInSymbols(), o3tl::toW(aCurrentDir) ); + SetCurrentDirectoryW( o3tl::toW(ustrBaseSysPath->buffer) ); } - dwResult = GetFullPathNameW( SAL_W(ustrRelSysPath->buffer), aBuffer.getBufSizeInSymbols(), SAL_W(aBuffer), &lpFilePart ); + dwResult = GetFullPathNameW( o3tl::toW(ustrRelSysPath->buffer), aBuffer.getBufSizeInSymbols(), o3tl::toW(aBuffer), &lpFilePart ); if ( ustrBaseSysPath ) { - SetCurrentDirectoryW( SAL_W(aCurrentDir) ); + SetCurrentDirectoryW( o3tl::toW(aCurrentDir) ); osl_releaseMutex( g_CurrentDirectoryMutex ); } diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx index 6ba859263ac1..c6f11d2a1cf7 100644 --- a/sal/osl/w32/module.cxx +++ b/sal/osl/w32/module.cxx @@ -27,6 +27,7 @@ #include <osl/diagnose.h> #include <osl/thread.h> #include <osl/file.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <vector> /* @@ -44,7 +45,7 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM oslModule ret = nullptr; oslFileError nError; - SAL_INFO( "sal.osl", "osl_loadModule: " << OUString(strModuleName->buffer, wcslen(SAL_W(strModuleName->buffer))) ); + SAL_INFO( "sal.osl", "osl_loadModule: " << OUString(strModuleName->buffer, wcslen(o3tl::toW(strModuleName->buffer))) ); OSL_ASSERT(strModuleName); nError = osl_getSystemPathFromFileURL(strModuleName, &Module); @@ -52,10 +53,10 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM if ( osl_File_E_None != nError ) rtl_uString_assign(&Module, strModuleName); - h = LoadLibraryW(SAL_W(Module->buffer)); + h = LoadLibraryW(o3tl::toW(Module->buffer)); if (h == nullptr) - h = LoadLibraryExW(SAL_W(Module->buffer), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); + h = LoadLibraryExW(o3tl::toW(Module->buffer), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); // In case of long path names (\\?\c:\...) try to shorten the filename. // LoadLibrary cannot handle file names which exceed 260 letters. @@ -65,7 +66,7 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 /*nRtldM if (h == nullptr && Module->length > 260) { std::vector<WCHAR> vec(Module->length + 1); - DWORD len = GetShortPathNameW(SAL_W(Module->buffer), &vec[0], Module->length + 1); + DWORD len = GetShortPathNameW(o3tl::toW(Module->buffer), &vec[0], Module->length + 1); if (len ) { h = LoadLibraryW(&vec[0]); @@ -113,7 +114,7 @@ oslModule osl_loadModuleRelativeAscii( sal_Bool SAL_CALL osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult) { - LPCWSTR pName = pModuleName ? SAL_W(pModuleName->buffer) : nullptr; + LPCWSTR pName = pModuleName ? o3tl::toW(pModuleName->buffer) : nullptr; HMODULE h = GetModuleHandleW(pName); if( h ) { @@ -254,19 +255,19 @@ static bool SAL_CALL osl_addressGetModuleURL_NT4_( void *pv, rtl_uString **pustr ::osl::LongPathBuffer< sal_Unicode > aModuleFileName( MAX_LONG_PATH ); LPWSTR lpSearchPath = nullptr; - if ( GetModuleFileNameW( nullptr, SAL_W(aModuleFileName), aModuleFileName.getBufSizeInSymbols() ) ) + if ( GetModuleFileNameW( nullptr, o3tl::toW(aModuleFileName), aModuleFileName.getBufSizeInSymbols() ) ) { - wchar_t *pLastBkSlash = wcsrchr( SAL_W(aModuleFileName), L'\\' ); + wchar_t *pLastBkSlash = wcsrchr( o3tl::toW(aModuleFileName), L'\\' ); if ( pLastBkSlash && - pLastBkSlash > SAL_W(aModuleFileName) + pLastBkSlash > o3tl::toW(aModuleFileName) && *(pLastBkSlash - 1) != L':' && *(pLastBkSlash - 1) != L'\\' ) { *pLastBkSlash = 0; - lpSearchPath = SAL_W(aModuleFileName); + lpSearchPath = o3tl::toW(aModuleFileName); } } @@ -288,7 +289,7 @@ static bool SAL_CALL osl_addressGetModuleURL_NT4_( void *pv, rtl_uString **pustr { rtl_uString *ustrSysPath = nullptr; - rtl_uString_newFromStr( &ustrSysPath, SAL_U(ModuleInfo.LoadedImageName) ); + rtl_uString_newFromStr( &ustrSysPath, o3tl::toU(ModuleInfo.LoadedImageName) ); OSL_ASSERT(ustrSysPath != nullptr); osl_getFileURLFromSystemPath( ustrSysPath, pustrURL ); rtl_uString_release( ustrSysPath ); @@ -365,7 +366,7 @@ static bool SAL_CALL osl_addressGetModuleURL_NT_( void *pv, rtl_uString **pustrU ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH ); rtl_uString *ustrSysPath = nullptr; - GetModuleFileNameW( lpModules[iModule], SAL_W(aBuffer), aBuffer.getBufSizeInSymbols() ); + GetModuleFileNameW( lpModules[iModule], o3tl::toW(aBuffer), aBuffer.getBufSizeInSymbols() ); rtl_uString_newFromStr( &ustrSysPath, aBuffer ); osl_getFileURLFromSystemPath( ustrSysPath, pustrURL ); diff --git a/sal/osl/w32/nlsupport.cxx b/sal/osl/w32/nlsupport.cxx index 8721804fd0b2..9a7c41040c26 100644 --- a/sal/osl/w32/nlsupport.cxx +++ b/sal/osl/w32/nlsupport.cxx @@ -34,6 +34,7 @@ #include <osl/diagnose.h> #include <osl/process.h> #include <rtl/tencinfo.h> +#include <o3tl/char16_t2wchar_t.hxx> /* XXX NOTE: * http://msdn.microsoft.com/en-us/library/windows/desktop/dd373848.aspx @@ -167,10 +168,10 @@ rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale ) /* copy in parameters to structure */ if( pLocale && pLocale->Language && pLocale->Language->length < ELP_LANGUAGE_FIELD_LENGTH ) { - wcscpy( params.Language, SAL_W(pLocale->Language->buffer) ); + wcscpy( params.Language, o3tl::toW(pLocale->Language->buffer) ); if( pLocale->Country && pLocale->Country->length < ELP_COUNTRY_FIELD_LENGTH ) - wcscpy( params.Country, SAL_W(pLocale->Country->buffer) ); + wcscpy( params.Country, o3tl::toW(pLocale->Country->buffer) ); /* save pointer to local structure in TLS */ TlsSetValue( g_dwTLSLocaleEncId, ¶ms ); @@ -200,7 +201,7 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale ) if( GetLocaleInfoW( localeId, LOCALE_SISO639LANGNAME , langCode, ELP_LANGUAGE_FIELD_LENGTH ) && GetLocaleInfoW( localeId, LOCALE_SISO3166CTRYNAME , ctryCode, ELP_COUNTRY_FIELD_LENGTH ) ) { - *ppLocale = rtl_locale_register( SAL_U(langCode), SAL_U(ctryCode), u"" ); + *ppLocale = rtl_locale_register( o3tl::toU(langCode), o3tl::toU(ctryCode), u"" ); } else { diff --git a/sal/osl/w32/pipe.cxx b/sal/osl/w32/pipe.cxx index 2240ade36b6f..febc4f19c562 100644 --- a/sal/osl/w32/pipe.cxx +++ b/sal/osl/w32/pipe.cxx @@ -28,6 +28,7 @@ #include <osl/process.h> #include <rtl/alloc.h> #include <sal/log.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <cassert> #include <string.h> @@ -167,7 +168,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options { SetLastError(ERROR_SUCCESS); - pPipe->m_NamedObject = CreateMutexW(nullptr, FALSE, SAL_W(name->buffer)); + pPipe->m_NamedObject = CreateMutexW(nullptr, FALSE, o3tl::toW(name->buffer)); if (pPipe->m_NamedObject) { @@ -178,7 +179,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options /* try to open system pipe */ pPipe->m_File = CreateNamedPipeW( - SAL_W(path->buffer), + o3tl::toW(path->buffer), PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_WAIT | PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, PIPE_UNLIMITED_INSTANCES, @@ -208,13 +209,13 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options do { /* free instance should be available first */ - bPipeAvailable = WaitNamedPipeW(SAL_W(path->buffer), NMPWAIT_WAIT_FOREVER); + bPipeAvailable = WaitNamedPipeW(o3tl::toW(path->buffer), NMPWAIT_WAIT_FOREVER); /* first try to open system pipe */ if (bPipeAvailable) { pPipe->m_File = CreateFileW( - SAL_W(path->buffer), + o3tl::toW(path->buffer), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, @@ -344,7 +345,7 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe) // prepare for next accept pPipe->m_File = - CreateNamedPipeW(SAL_W(path->buffer), + CreateNamedPipeW(o3tl::toW(path->buffer), PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_WAIT | PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, PIPE_UNLIMITED_INSTANCES, diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index 7d989d548477..0fe42bbdbe27 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -31,6 +31,7 @@ #include <memory> #include <osl/nlsupport.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <filetime.hxx> #include <nlsupport.hxx> @@ -286,7 +287,7 @@ oslProcessError bootstrap_getExecutableFile(rtl_uString ** ppFileURL) ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH ); DWORD buflen = 0; - if ((buflen = GetModuleFileNameW (nullptr, SAL_W(aBuffer), aBuffer.getBufSizeInSymbols())) > 0) + if ((buflen = GetModuleFileNameW (nullptr, o3tl::toW(aBuffer), aBuffer.getBufSizeInSymbols())) > 0) { rtl_uString * pAbsPath = nullptr; rtl_uString_newFromStr_WithLength (&pAbsPath, aBuffer, buflen); @@ -336,7 +337,7 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **) for (i = 0; i < nArgs; i++) { /* Convert to unicode */ - rtl_uString_newFromStr( &(ppArgs[i]), SAL_U(wargv[i]) ); + rtl_uString_newFromStr( &(ppArgs[i]), o3tl::toU(wargv[i]) ); } if (ppArgs[0] != nullptr) { @@ -345,7 +346,7 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **) DWORD dwResult = 0; dwResult = SearchPathW ( - nullptr, SAL_W(ppArgs[0]->buffer), L".exe", aBuffer.getBufSizeInSymbols(), SAL_W(aBuffer), nullptr); + nullptr, o3tl::toW(ppArgs[0]->buffer), L".exe", aBuffer.getBufSizeInSymbols(), o3tl::toW(aBuffer), nullptr); if ((0 < dwResult) && (dwResult < aBuffer.getBufSizeInSymbols())) { /* Replace argv[0] with its absolute path */ @@ -445,9 +446,9 @@ oslProcessError SAL_CALL osl_getEnvironment(rtl_uString *ustrVar, rtl_uString ** { WCHAR buff[ENV_BUFFER_SIZE]; - if (GetEnvironmentVariableW(SAL_W(ustrVar->buffer), buff, ENV_BUFFER_SIZE) > 0) + if (GetEnvironmentVariableW(o3tl::toW(ustrVar->buffer), buff, ENV_BUFFER_SIZE) > 0) { - rtl_uString_newFromStr(ustrValue, SAL_U(buff)); + rtl_uString_newFromStr(ustrValue, o3tl::toU(buff)); return osl_Process_E_None; } return osl_Process_E_Unknown; @@ -456,8 +457,8 @@ oslProcessError SAL_CALL osl_getEnvironment(rtl_uString *ustrVar, rtl_uString ** oslProcessError SAL_CALL osl_setEnvironment(rtl_uString *ustrVar, rtl_uString *ustrValue) { // set Windows environment variable - LPCWSTR lpName = SAL_W(ustrVar->buffer); - LPCWSTR lpValue = SAL_W(ustrValue->buffer); + LPCWSTR lpName = o3tl::toW(ustrVar->buffer); + LPCWSTR lpValue = o3tl::toW(ustrValue->buffer); if (SetEnvironmentVariableW(lpName, lpValue)) { auto buffer = std::unique_ptr<wchar_t[]>( @@ -475,7 +476,7 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString *ustrVar) { // delete the variable from the current process environment // by setting SetEnvironmentVariable's second parameter to NULL - LPCWSTR lpName = SAL_W(ustrVar->buffer); + LPCWSTR lpName = o3tl::toW(ustrVar->buffer); if (SetEnvironmentVariableW(lpName, nullptr)) { auto buffer = std::unique_ptr<wchar_t[]>( @@ -494,7 +495,7 @@ oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir DWORD dwLen = 0; osl_acquireMutex( g_CurrentDirectoryMutex ); - dwLen = GetCurrentDirectoryW( aBuffer.getBufSizeInSymbols(), SAL_W(aBuffer) ); + dwLen = GetCurrentDirectoryW( aBuffer.getBufSizeInSymbols(), o3tl::toW(aBuffer) ); osl_releaseMutex( g_CurrentDirectoryMutex ); if ( dwLen && dwLen < aBuffer.getBufSizeInSymbols() ) diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx index 0cdc6a2eefbc..da48691685fc 100644 --- a/sal/osl/w32/procimpl.cxx +++ b/sal/osl/w32/procimpl.cxx @@ -35,6 +35,7 @@ #include <rtl/ustrbuf.hxx> #include "secimpl.hxx" #include <osl/file.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <vector> #include <algorithm> @@ -112,7 +113,7 @@ namespace /* private */ while (size_t l = wcslen(p)) { - environment->push_back(SAL_U(p)); + environment->push_back(o3tl::toU(p)); p += l + 1; } FreeEnvironmentStringsW(env); @@ -279,7 +280,7 @@ namespace /* private */ std::vector<sal_Unicode> vec(path.getLength() + 1); //GetShortPathNameW only works if the file can be found! const DWORD len = GetShortPathNameW( - SAL_W(path.getStr()), SAL_W(&vec[0]), path.getLength() + 1); + o3tl::toW(path.getStr()), o3tl::toW(&vec[0]), path.getLength() + 1); if (!len && GetLastError() == ERROR_FILE_NOT_FOUND && extension.getLength()) @@ -288,7 +289,7 @@ namespace /* private */ std::vector<sal_Unicode> vec2( extPath.getLength() + 1); const DWORD len2 = GetShortPathNameW( - SAL_W(extPath.getStr()), SAL_W(&vec2[0]), extPath.getLength() + 1); + o3tl::toW(extPath.getStr()), o3tl::toW(&vec2[0]), extPath.getLength() + 1); ret = rtl::OUString(&vec2[0], len2); } else @@ -468,7 +469,7 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( if (ustrDirectory && ustrDirectory->length && (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(ustrDirectory, cwd))) return osl_Process_E_InvalidError; - LPCWSTR p_cwd = (cwd.getLength()) ? SAL_W(cwd.getStr()) : nullptr; + LPCWSTR p_cwd = (cwd.getLength()) ? o3tl::toW(cwd.getStr()) : nullptr; if ((Options & osl_Process_DETACHED) && !(flags & CREATE_NEW_CONSOLE)) flags |= DETACHED_PROCESS; @@ -533,14 +534,14 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( { bRet = CreateProcessAsUserW( static_cast<oslSecurityImpl*>(Security)->m_hToken, - nullptr, const_cast<LPWSTR>(SAL_W(cmdline.getStr())), nullptr, nullptr, + nullptr, const_cast<LPWSTR>(o3tl::toW(cmdline.getStr())), nullptr, nullptr, b_inherit_handles, flags, p_environment, p_cwd, &startup_info, &process_info); } else { bRet = CreateProcessW( - nullptr, const_cast<LPWSTR>(SAL_W(cmdline.getStr())), nullptr, nullptr, + nullptr, const_cast<LPWSTR>(o3tl::toW(cmdline.getStr())), nullptr, nullptr, b_inherit_handles, flags, p_environment, p_cwd, &startup_info, &process_info); } diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx index 2de8f4d0e5ed..e9d573411d64 100644 --- a/sal/osl/w32/profile.cxx +++ b/sal/osl/w32/profile.cxx @@ -30,6 +30,7 @@ #include <osl/file.h> #include <rtl/alloc.h> #include <sal/macros.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <algorithm> #include <vector> using std::min; @@ -382,12 +383,12 @@ DWORD GetPrivateProfileStringWrapper(const osl_TProfileImpl* pProfile, OSL_ASSERT(pDefault); } - LPCWSTR pWSection = (pSection ? SAL_W(rtl_uString_getStr(pSection)) : nullptr), - pWEntry = (pEntry ? SAL_W(rtl_uString_getStr(pEntry)) : nullptr), - pWDefault = (pDefault ? SAL_W(rtl_uString_getStr(pDefault)) : nullptr); + LPCWSTR pWSection = (pSection ? o3tl::toW(rtl_uString_getStr(pSection)) : nullptr), + pWEntry = (pEntry ? o3tl::toW(rtl_uString_getStr(pEntry)) : nullptr), + pWDefault = (pDefault ? o3tl::toW(rtl_uString_getStr(pDefault)) : nullptr); std::vector<wchar_t> aBuf(MaxLen + 1); - GetPrivateProfileStringW(pWSection, pWEntry, pWDefault, &aBuf[0], MaxLen, SAL_W(rtl_uString_getStr(pProfile->m_strFileName))); + GetPrivateProfileStringW(pWSection, pWEntry, pWDefault, &aBuf[0], MaxLen, o3tl::toW(rtl_uString_getStr(pProfile->m_strFileName))); if (pDefault) rtl_uString_release(pDefault); @@ -419,11 +420,11 @@ BOOL WritePrivateProfileStringWrapper(const osl_TProfileImpl* pProfile, OSL_ASSERT(pString); } - LPCWSTR pWSection = SAL_W(pSection->buffer), - pWEntry = (pEntry ? SAL_W(rtl_uString_getStr(pEntry)) : nullptr), - pWString = (pString ? SAL_W(rtl_uString_getStr(pString)) : nullptr); + LPCWSTR pWSection = o3tl::toW(pSection->buffer), + pWEntry = (pEntry ? o3tl::toW(rtl_uString_getStr(pEntry)) : nullptr), + pWString = (pString ? o3tl::toW(rtl_uString_getStr(pString)) : nullptr); - BOOL bResult = WritePrivateProfileStringW(pWSection, pWEntry, pWString, SAL_W(rtl_uString_getStr(pProfile->m_strFileName))); + BOOL bResult = WritePrivateProfileStringW(pWSection, pWEntry, pWString, o3tl::toW(rtl_uString_getStr(pProfile->m_strFileName))); if (pString) rtl_uString_release(pString); @@ -897,7 +898,7 @@ bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, rtl else if ((rtl_ustr_ascii_compare_WithLength(pPath, RTL_CONSTASCII_LENGTH(STR_INI_METASYS), STR_INI_METASYS) == 0) && ((nLen == RTL_CONSTASCII_LENGTH(STR_INI_METASYS)) || (pPath[RTL_CONSTASCII_LENGTH(STR_INI_METASYS)] == '/'))) { - if (((nPathLen = GetWindowsDirectoryW(SAL_W(aPath), aPath.getBufSizeInSymbols())) == 0) || (nPathLen >= aPath.getBufSizeInSymbols())) + if (((nPathLen = GetWindowsDirectoryW(o3tl::toW(aPath), aPath.getBufSizeInSymbols())) == 0) || (nPathLen >= aPath.getBufSizeInSymbols())) return false; if (nLen > RTL_CONSTASCII_LENGTH(STR_INI_METASYS)) @@ -1008,7 +1009,7 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuff else { std::vector<wchar_t> aBuf(MaxLen + 1); - GetPrivateProfileSectionNamesW(&aBuf[0], MaxLen, SAL_W(rtl_uString_getStr(pProfile->m_strFileName))); + GetPrivateProfileSectionNamesW(&aBuf[0], MaxLen, o3tl::toW(rtl_uString_getStr(pProfile->m_strFileName))); n = WideCharToMultiByte(CP_ACP, 0, &aBuf[0], -1, pszBuffer, MaxLen, nullptr, nullptr); } @@ -1076,7 +1077,7 @@ static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption Profi if (! bWriteable) { - pFile->m_Handle = CreateFileW( SAL_W(rtl_uString_getStr( strFileName )), GENERIC_READ, + pFile->m_Handle = CreateFileW( o3tl::toW(rtl_uString_getStr( strFileName )), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); @@ -1089,7 +1090,7 @@ static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption Profi SAL_INFO("sal.osl", "opening read/write " << pszFilename); #endif - if ((pFile->m_Handle = CreateFileW( SAL_W(rtl_uString_getStr( strFileName )), GENERIC_READ | GENERIC_WRITE, + if ((pFile->m_Handle = CreateFileW( o3tl::toW(rtl_uString_getStr( strFileName )), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr)) == INVALID_HANDLE_VALUE) @@ -1819,13 +1820,13 @@ static bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile) ustrExtension=nullptr; /* unlink bak */ - DeleteFileW( SAL_W(rtl_uString_getStr( ustrBakFile )) ); + DeleteFileW( o3tl::toW(rtl_uString_getStr( ustrBakFile )) ); /* rename ini bak */ - MoveFileExW( SAL_W(rtl_uString_getStr( ustrIniFile )), SAL_W(rtl_uString_getStr( ustrBakFile )), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH ); + MoveFileExW( o3tl::toW(rtl_uString_getStr( ustrIniFile )), o3tl::toW(rtl_uString_getStr( ustrBakFile )), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH ); /* rename tmp ini */ - MoveFileExW( SAL_W(rtl_uString_getStr( ustrTmpFile )), SAL_W(rtl_uString_getStr( ustrIniFile )), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH ); + MoveFileExW( o3tl::toW(rtl_uString_getStr( ustrTmpFile )), o3tl::toW(rtl_uString_getStr( ustrIniFile )), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH ); return false; } @@ -1975,7 +1976,7 @@ static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile while ((strPath[i] != L'"') && (strPath[i] != L'\0')) i++; - WideCharToMultiByte(CP_ACP,0, SAL_W(strPath), i, Product, sizeof(Product), nullptr, nullptr); + WideCharToMultiByte(CP_ACP,0, o3tl::toW(strPath), i, Product, sizeof(Product), nullptr, nullptr); Product[i] = '\0'; strPath += i; @@ -2124,7 +2125,7 @@ static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile /* if we have no product identification use the executable file name */ if (*Product == 0) { - WideCharToMultiByte(CP_ACP,0, SAL_W(strExecutable->buffer + nPos + 1), -1, Product, sizeof(Product), nullptr, nullptr); + WideCharToMultiByte(CP_ACP,0, o3tl::toW(strExecutable->buffer + nPos + 1), -1, Product, sizeof(Product), nullptr, nullptr); /* remove extension */ if ((pChr = strrchr(Product, '.')) != nullptr) @@ -2147,7 +2148,7 @@ static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile { ::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH ); - WideCharToMultiByte(CP_ACP,0, SAL_W(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), nullptr, nullptr); + WideCharToMultiByte(CP_ACP,0, o3tl::toW(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), nullptr, nullptr); /* if file not exists, remove any specified subdirectories like "bin" or "program" */ @@ -2171,7 +2172,7 @@ static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile } else { - dwPathLen = nPos + MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, SAL_W(aPath + nPos + 1), aPath.getBufSizeInSymbols() - (nPos + 1) ); + dwPathLen = nPos + MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, o3tl::toW(aPath + nPos + 1), aPath.getBufSizeInSymbols() - (nPos + 1) ); } } else @@ -2196,7 +2197,7 @@ static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile { ::osl::LongPathBuffer< sal_Char > aTmpPath( MAX_LONG_PATH ); - WideCharToMultiByte(CP_ACP,0, SAL_W(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), nullptr, nullptr); + WideCharToMultiByte(CP_ACP,0, o3tl::toW(aPath), -1, aTmpPath, aTmpPath.getBufSizeInSymbols(), nullptr, nullptr); if ((access(aTmpPath, 0) < 0) && (Product[0] != '\0')) { @@ -2245,7 +2246,7 @@ static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile if (Buffer[0] != '\0') { dwPathLen = MultiByteToWideChar( - CP_ACP, 0, Buffer, -1, SAL_W(aPath), aPath.getBufSizeInSymbols() ); + CP_ACP, 0, Buffer, -1, o3tl::toW(aPath), aPath.getBufSizeInSymbols() ); dwPathLen -=1; /* build full path */ @@ -2266,7 +2267,7 @@ static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile int n; if ((n = WideCharToMultiByte( - CP_ACP,0, SAL_W(aPath), -1, aTmpPath2, + CP_ACP,0, o3tl::toW(aPath), -1, aTmpPath2, aTmpPath2.getBufSizeInSymbols(), nullptr, nullptr)) > 0) { @@ -2275,7 +2276,7 @@ static bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile { dwPathLen += MultiByteToWideChar( CP_ACP, 0, SVERSION_USER, -1, - SAL_W(aPath + dwPathLen), + o3tl::toW(aPath + dwPathLen), aPath.getBufSizeInSymbols() - dwPathLen ); } } diff --git a/sal/osl/w32/security.cxx b/sal/osl/w32/security.cxx index b25e3076af70..120b5c98258d 100644 --- a/sal/osl/w32/security.cxx +++ b/sal/osl/w32/security.cxx @@ -25,6 +25,7 @@ #include <osl/file.h> #include <systools/win32/uwinapi.h> #include <sal/macros.h> +#include <o3tl/char16_t2wchar_t.hxx> #include "secimpl.hxx" /* Data for use in (un)LoadProfile Functions */ @@ -88,11 +89,11 @@ oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString * oslSecurityError ret; sal_Unicode* strUser; - sal_Unicode* strDomain = SAL_U(_wcsdup(SAL_W(rtl_uString_getStr(strUserName)))); + sal_Unicode* strDomain = o3tl::toU(_wcsdup(o3tl::toW(rtl_uString_getStr(strUserName)))); HANDLE hUserToken; LUID luid; - if (nullptr != (strUser = SAL_U(wcschr(SAL_W(strDomain), L'/')))) + if (nullptr != (strUser = o3tl::toU(wcschr(o3tl::toW(strDomain), L'/')))) *strUser++ = L'\0'; else { @@ -104,7 +105,7 @@ oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString * 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)), + if (LogonUserW(o3tl::toW(strUser), strDomain ? o3tl::toW(strDomain) : L"", o3tl::toW(rtl_uString_getStr(strPasswd)), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUserToken)) { @@ -113,7 +114,7 @@ oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString * pSecImpl->m_pNetResource = nullptr; pSecImpl->m_hToken = hUserToken; pSecImpl->m_hProfile = nullptr; - wcscpy(SAL_W(pSecImpl->m_User), SAL_W(strUser)); + wcscpy(o3tl::toW(pSecImpl->m_User), o3tl::toW(strUser)); *pSecurity = pSecImpl; ret = osl_Security_E_None; @@ -145,25 +146,25 @@ oslSecurityError SAL_CALL osl_loginUserOnFileServer(rtl_uString *strUserName, remoteName = static_cast<sal_Unicode *>(malloc((rtl_uString_getLength(strFileServer) + rtl_uString_getLength(strUserName) + 4) * sizeof(sal_Unicode))); userName = static_cast<sal_Unicode *>(malloc((rtl_uString_getLength(strFileServer) + rtl_uString_getLength(strUserName) + 2) * sizeof(sal_Unicode))); - wcscpy(SAL_W(remoteName), L"\\\\"); - wcscat(SAL_W(remoteName), SAL_W(rtl_uString_getStr(strFileServer))); - wcscat(SAL_W(remoteName), L"\\"); - wcscat(SAL_W(remoteName), SAL_W(rtl_uString_getStr(strUserName))); + wcscpy(o3tl::toW(remoteName), L"\\\\"); + wcscat(o3tl::toW(remoteName), o3tl::toW(rtl_uString_getStr(strFileServer))); + wcscat(o3tl::toW(remoteName), L"\\"); + wcscat(o3tl::toW(remoteName), o3tl::toW(rtl_uString_getStr(strUserName))); - wcscpy(SAL_W(userName), SAL_W(rtl_uString_getStr(strFileServer))); - wcscat(SAL_W(userName), L"\\"); - wcscat(SAL_W(userName), SAL_W(rtl_uString_getStr(strUserName))); + wcscpy(o3tl::toW(userName), o3tl::toW(rtl_uString_getStr(strFileServer))); + wcscat(o3tl::toW(userName), L"\\"); + wcscat(o3tl::toW(userName), o3tl::toW(rtl_uString_getStr(strUserName))); netResource.dwScope = RESOURCE_GLOBALNET; netResource.dwType = RESOURCETYPE_DISK; netResource.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE; netResource.dwUsage = RESOURCEUSAGE_CONNECTABLE; netResource.lpLocalName = nullptr; - netResource.lpRemoteName = SAL_W(remoteName); + netResource.lpRemoteName = o3tl::toW(remoteName); netResource.lpComment = nullptr; netResource.lpProvider = nullptr; - err = WNetAddConnection2W(&netResource, SAL_W(rtl_uString_getStr(strPasswd)), SAL_W(userName), 0); + err = WNetAddConnection2W(&netResource, o3tl::toW(rtl_uString_getStr(strPasswd)), o3tl::toW(userName), 0); if ((err == NO_ERROR) || (err == ERROR_ALREADY_ASSIGNED)) { @@ -174,7 +175,7 @@ oslSecurityError SAL_CALL osl_loginUserOnFileServer(rtl_uString *strUserName, pSecImpl->m_hToken = nullptr; pSecImpl->m_hProfile = nullptr; - wcscpy(SAL_W(pSecImpl->m_User), SAL_W(rtl_uString_getStr(strUserName))); + wcscpy(o3tl::toW(pSecImpl->m_User), o3tl::toW(rtl_uString_getStr(strUserName))); *pSecurity = pSecImpl; @@ -346,12 +347,12 @@ sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent) sal_Unicode *Ident=static_cast<sal_Unicode *>(malloc(88*sizeof(sal_Unicode))); /* prepare S-SID_REVISION- */ - dwSidSize=wsprintfW(SAL_W(Ident), L"S-%lu-", SID_REVISION); + dwSidSize=wsprintfW(o3tl::toW(Ident), L"S-%lu-", SID_REVISION); /* prepare SidIdentifierAuthority */ if ((psia->Value[0] != 0) || (psia->Value[1] != 0)) { - dwSidSize+=wsprintfW(SAL_W(Ident) + wcslen(SAL_W(Ident)), + dwSidSize+=wsprintfW(o3tl::toW(Ident) + wcslen(o3tl::toW(Ident)), L"0x%02hx%02hx%02hx%02hx%02hx%02hx", (USHORT)psia->Value[0], (USHORT)psia->Value[1], @@ -362,7 +363,7 @@ sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent) } else { - dwSidSize+=wsprintfW(SAL_W(Ident) + wcslen(SAL_W(Ident)), + dwSidSize+=wsprintfW(o3tl::toW(Ident) + wcslen(o3tl::toW(Ident)), L"%lu", (ULONG)(psia->Value[5] ) + (ULONG)(psia->Value[4] << 8) + @@ -373,7 +374,7 @@ sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent) /* loop through SidSubAuthorities */ for (dwCounter=0; dwCounter < dwSubAuthorities; dwCounter++) { - dwSidSize+=wsprintfW(SAL_W(Ident) + dwSidSize, L"-%lu", + dwSidSize+=wsprintfW(o3tl::toW(Ident) + dwSidSize, L"-%lu", *GetSidSubAuthority(pSid, dwCounter) ); } @@ -396,9 +397,9 @@ sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent) Ident = static_cast<sal_Unicode *>(malloc(needed*sizeof(sal_Unicode))); - if (WNetGetUserW(nullptr, SAL_W(Ident), &needed) != NO_ERROR) + if (WNetGetUserW(nullptr, o3tl::toW(Ident), &needed) != NO_ERROR) { - wcscpy(SAL_W(Ident), L"unknown"); + wcscpy(o3tl::toW(Ident), L"unknown"); Ident[7] = L'\0'; } @@ -434,7 +435,7 @@ sal_Bool SAL_CALL osl_getHomeDir(oslSecurity Security, rtl_uString **pustrDirect if (pSecImpl->m_pNetResource != nullptr) { - rtl_uString_newFromStr( &ustrSysDir, SAL_U(pSecImpl->m_pNetResource->lpRemoteName)); + rtl_uString_newFromStr( &ustrSysDir, o3tl::toU(pSecImpl->m_pNetResource->lpRemoteName)); bSuccess = osl_File_E_None == osl_getFileURLFromSystemPath( ustrSysDir, pustrDirectory ); } @@ -463,7 +464,7 @@ sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **pustrDire { rtl_uString *ustrSysDir = nullptr; - rtl_uString_newFromStr( &ustrSysDir, SAL_U(pSecImpl->m_pNetResource->lpRemoteName)); + rtl_uString_newFromStr( &ustrSysDir, o3tl::toU(pSecImpl->m_pNetResource->lpRemoteName)); bSuccess = osl_File_E_None == osl_getFileURLFromSystemPath( ustrSysDir, pustrDirectory); if ( ustrSysDir ) @@ -483,7 +484,7 @@ sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **pustrDire if ( !GetSpecialFolder( &ustrFile, CSIDL_APPDATA) ) { - OSL_VERIFY(GetWindowsDirectoryW(SAL_W(sFile), _MAX_DIR) > 0); + OSL_VERIFY(GetWindowsDirectoryW(o3tl::toW(sFile), _MAX_DIR) > 0); rtl_uString_newFromStr( &ustrFile, sFile); } @@ -549,7 +550,7 @@ sal_Bool SAL_CALL osl_loadUserProfile(oslSecurity Security) ZeroMemory(&pi, sizeof(pi)); pi.dwSize = sizeof(pi); - pi.lpUserName = SAL_W(rtl_uString_getStr(buffer)); + pi.lpUserName = o3tl::toW(rtl_uString_getStr(buffer)); pi.dwFlags = PI_NOUI; if (fLoadUserProfile(hAccessToken, &pi)) @@ -627,7 +628,7 @@ static bool GetSpecialFolder(rtl_uString **strPath, int nFolder) if (pSHGetSpecialFolderPathW) { - if (pSHGetSpecialFolderPathW(GetActiveWindow(), SAL_W(PathW), nFolder, TRUE)) + if (pSHGetSpecialFolderPathW(GetActiveWindow(), o3tl::toW(PathW), nFolder, TRUE)) { rtl_uString_newFromStr( strPath, PathW); bRet = true; @@ -677,8 +678,8 @@ static bool GetSpecialFolder(rtl_uString **strPath, int nFolder) if ((lRet == ERROR_SUCCESS) && (Type == REG_SZ)) { - if (_waccess(SAL_W(PathW), 0) < 0) - CreateDirectoryW(SAL_W(PathW), nullptr); + if (_waccess(o3tl::toW(PathW), 0) < 0) + CreateDirectoryW(o3tl::toW(PathW), nullptr); hr = pSHGetSpecialFolderLocation(GetActiveWindow(), nFolder, &pidl); } @@ -689,11 +690,11 @@ static bool GetSpecialFolder(rtl_uString **strPath, int nFolder) if (SUCCEEDED(hr)) { - if (pSHGetPathFromIDListW(pidl, SAL_W(PathW))) + if (pSHGetPathFromIDListW(pidl, o3tl::toW(PathW))) { /* if directory does not exist, create it */ - if (_waccess(SAL_W(PathW), 0) < 0) - CreateDirectoryW(SAL_W(PathW), nullptr); + if (_waccess(o3tl::toW(PathW), 0) < 0) + CreateDirectoryW(o3tl::toW(PathW), nullptr); rtl_uString_newFromStr( strPath, PathW); bRet = true; @@ -790,18 +791,18 @@ static bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **strName SID_NAME_USE sUse; if (LookupAccountSidW(nullptr, reinterpret_cast<PTOKEN_USER>(pInfoBuffer)->User.Sid, - SAL_W(UserName), &nUserName, - SAL_W(DomainName), &nDomainName, &sUse)) + o3tl::toW(UserName), &nUserName, + o3tl::toW(DomainName), &nDomainName, &sUse)) { if (bIncludeDomain) { - wcscpy(SAL_W(Name), SAL_W(DomainName)); - wcscat(SAL_W(Name), L"/"); - wcscat(SAL_W(Name), SAL_W(UserName)); + wcscpy(o3tl::toW(Name), o3tl::toW(DomainName)); + wcscat(o3tl::toW(Name), L"/"); + wcscat(o3tl::toW(Name), o3tl::toW(UserName)); } else { - wcscpy(SAL_W(Name), SAL_W(UserName)); + wcscpy(o3tl::toW(Name), o3tl::toW(UserName)); } } @@ -820,7 +821,7 @@ static bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **strName WNetGetUserW(nullptr, nullptr, &needed); pNameW = static_cast<sal_Unicode *>(malloc (needed*sizeof(sal_Unicode))); - if (WNetGetUserW(nullptr, SAL_W(pNameW), &needed) == NO_ERROR) + if (WNetGetUserW(nullptr, o3tl::toW(pNameW), &needed) == NO_ERROR) { rtl_uString_newFromStr( strName, pNameW); @@ -830,7 +831,7 @@ static bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **strName } else if (pSecImpl->m_User[0] != '\0') { - rtl_uString_newFromStr(strName, SAL_U(pSecImpl->m_pNetResource->lpRemoteName)); + rtl_uString_newFromStr(strName, o3tl::toU(pSecImpl->m_pNetResource->lpRemoteName)); if (pNameW) free(pNameW); diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx index 6cd8c8efe244..9c6715be2627 100644 --- a/sal/osl/w32/socket.cxx +++ b/sal/osl/w32/socket.cxx @@ -23,6 +23,7 @@ #include <osl/diagnose.h> #include <rtl/alloc.h> #include <sal/log.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include "sockimpl.hxx" @@ -357,7 +358,7 @@ oslSocketAddr SAL_CALL osl_createInetBroadcastAddr ( if (strDottedAddr && strDottedAddr->length) { IN_ADDR addr; - INT ret = InetPtonW(AF_INET, SAL_W(strDottedAddr->buffer), & addr); + INT ret = InetPtonW(AF_INET, o3tl::toW(strDottedAddr->buffer), & addr); if (1 == ret) { nAddr = addr.S_un.S_addr; @@ -403,7 +404,7 @@ oslSocketAddr SAL_CALL osl_createInetSocketAddr ( sal_uInt32 Addr; IN_ADDR addr; - INT ret = InetPtonW(AF_INET, SAL_W(strDottedAddr->buffer), & addr); + INT ret = InetPtonW(AF_INET, o3tl::toW(strDottedAddr->buffer), & addr); Addr = ret == 1 ? addr.S_un.S_addr : OSL_INADDR_NONE; oslSocketAddr pAddr = nullptr; @@ -493,7 +494,7 @@ oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname) PADDRINFOW pAddrInfo = nullptr; int ret = GetAddrInfoW( - SAL_W(strHostname->buffer), nullptr, nullptr, & pAddrInfo); + o3tl::toW(strHostname->buffer), nullptr, nullptr, & pAddrInfo); if (0 == ret) { oslHostAddr pRet = nullptr; @@ -503,7 +504,7 @@ oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname) { pRet = static_cast<oslHostAddr>( rtl_allocateZeroMemory(sizeof(struct oslHostAddrImpl))); - rtl_uString_newFromStr(&pRet->pHostName, SAL_U(pIter->ai_canonname)); + rtl_uString_newFromStr(&pRet->pHostName, o3tl::toU(pIter->ai_canonname)); pRet->pSockAddr = createSocketAddr(); memcpy(& pRet->pSockAddr->m_sockaddr, pIter->ai_addr, pIter->ai_addrlen); @@ -541,7 +542,7 @@ oslHostAddr SAL_CALL osl_createHostAddrByAddr(const oslSocketAddr pAddr) { oslHostAddr pRet = static_cast<oslHostAddr>( rtl_allocateZeroMemory(sizeof(struct oslHostAddrImpl))); - rtl_uString_newFromStr(&pRet->pHostName, SAL_U(buf)); + rtl_uString_newFromStr(&pRet->pHostName, o3tl::toU(buf)); pRet->pSockAddr = createSocketAddr(); memcpy(& pRet->pSockAddr->m_sockaddr, & pAddr->m_sockaddr, sizeof(struct sockaddr)); @@ -764,7 +765,7 @@ oslSocketResult SAL_CALL osl_getDottedInetAddrOfSocketAddr ( SAL_INFO("sal.osl", "InetNtopW failed: " << WSAGetLastError()); return osl_Socket_Error; } - rtl_uString_newFromStr(strDottedInetAddr, SAL_U(ret)); + rtl_uString_newFromStr(strDottedInetAddr, o3tl::toU(ret)); OSL_ASSERT(*strDottedInetAddr != nullptr); return osl_Socket_Ok; @@ -1602,7 +1603,7 @@ void SAL_CALL osl_getLastSocketErrorDescription ( { sal_Unicode message[128]; - wsprintfW(SAL_W(message), L"Unknown WinSock Error Number %d", error); + wsprintfW(o3tl::toW(message), L"Unknown WinSock Error Number %d", error); rtl_uString_newFromStr (strError, message); } diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx index f59107214aa4..a538b5dd9720 100644 --- a/sal/osl/w32/tempfile.cxx +++ b/sal/osl/w32/tempfile.cxx @@ -20,6 +20,7 @@ #include "systools/win32/uwinapi.h" #include "osl/file.h" +#include <o3tl/char16_t2wchar_t.hxx> #include <file-impl.hxx> #include "file_error.hxx" @@ -95,7 +96,7 @@ static oslFileError osl_win32_GetTempFileName_impl_( oslFileError osl_error = osl_File_E_None; if (GetTempFileNameW( - SAL_W(rtl_uString_getStr(base_directory)), + o3tl::toW(rtl_uString_getStr(base_directory)), L"", 0, temp_file_name) == 0) @@ -157,7 +158,7 @@ static oslFileError osl_createTempFile_impl_( if ((osl_error == osl_File_E_None) && !b_delete_on_close) { rtl_uString* pustr = nullptr; - rtl_uString_newFromStr(&pustr, SAL_U(tmp_name)); + rtl_uString_newFromStr(&pustr, o3tl::toU(tmp_name)); osl_getFileURLFromSystemPath(pustr, ppustrTempFileURL); rtl_uString_release(pustr); } @@ -211,7 +212,7 @@ oslFileError SAL_CALL osl_createTempFile( oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir) { ::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH ); - LPWSTR lpBuffer = SAL_W(aBuffer); + LPWSTR lpBuffer = o3tl::toW(aBuffer); DWORD nBufferLength = aBuffer.getBufSizeInSymbols() - 1; DWORD nLength; @@ -231,7 +232,7 @@ oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir) if ( '\\' == lpBuffer[nLength-1] ) lpBuffer[nLength-1] = 0; - rtl_uString_newFromStr( &ustrTempPath, SAL_U(lpBuffer) ); + rtl_uString_newFromStr( &ustrTempPath, o3tl::toU(lpBuffer) ); error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir ); diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index 90502118cfed..c6692f3ef0f1 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -29,6 +29,7 @@ #include <osl/thread.h> #include <rtl/process.h> #include <rtl/strbuf.hxx> +#include <o3tl/char16_t2wchar_t.hxx> using namespace osl; using namespace rtl; @@ -366,11 +367,11 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, lpszSystemInfo = wchBuffer; if( GetUserNameW(lpszSystemInfo, &cchBuff) ) - strUserName = SAL_U(lpszSystemInfo); + strUserName = o3tl::toU(lpszSystemInfo); cchBuff = BUFSIZE; if( GetComputerNameW(lpszSystemInfo, &cchBuff) ) - strComputerName = SAL_U(lpszSystemInfo); + strComputerName = o3tl::toU(lpszSystemInfo); /// Get user home directory. HKEY hRegKey; @@ -382,7 +383,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, DWORD Type; lRet = RegQueryValueExW(hRegKey, L"AppData", nullptr, &Type, reinterpret_cast<unsigned char *>(PathW), &lSize); - if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _waccess( SAL_W(PathW), 0 ) == 0 ) ) + if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _waccess( o3tl::toW(PathW), 0 ) == 0 ) ) { CPPUNIT_ASSERT_EQUAL_MESSAGE( "#Convert from system path to URL failed.", ::osl::File::E_None, ::osl::File::getFileURLFromSystemPath( PathW, strConfigDirectory ) ); @@ -390,7 +391,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, lSize = sizeof(PathW); lRet = RegQueryValueExW(hRegKey, L"Personal", nullptr, &Type, reinterpret_cast<unsigned char *>(PathW), &lSize); - if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _waccess( SAL_W(PathW), 0 ) == 0 ) ) + if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _waccess( o3tl::toW(PathW), 0 ) == 0 ) ) { CPPUNIT_ASSERT_EQUAL_MESSAGE( "#Convert from system path to URL failed.", ::osl::File::E_None, ::osl::File::getFileURLFromSystemPath( PathW, strHomeDirectory ) ); @@ -411,7 +412,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, SID_NAME_USE eSidType; DWORD dwErrorCode = 0; - LPCWSTR wszAccName = SAL_W(strUserName.getStr( )); + LPCWSTR wszAccName = o3tl::toW(strUserName.getStr( )); // Create buffers for the SID and the domain name. PSID pSid = static_cast<PSID>(new BYTE[dwSidBufferSize]); @@ -524,7 +525,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, *GetSidSubAuthority(pSid, dwCounter) ); } - strUserID = SAL_U(Ident); + strUserID = o3tl::toU(Ident); free(Ident); delete [] static_cast<BYTE*>(pSid); 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; diff --git a/shell/source/backends/localebe/localebackend.cxx b/shell/source/backends/localebe/localebackend.cxx index 0b896a3fadc6..7ff388a1f26d 100644 --- a/shell/source/backends/localebe/localebackend.cxx +++ b/shell/source/backends/localebe/localebackend.cxx @@ -27,6 +27,7 @@ #include <cppuhelper/supportsservice.hxx> #include <osl/time.h> #include <rtl/character.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <stdio.h> @@ -54,7 +55,7 @@ css::beans::Optional<css::uno::Any> ImplGetLocale(LCID lcid) // #i50822# minus character must be written before cp *(cp - 1) = '-'; - return {true, css::uno::Any(OUString(SAL_U(buffer)))}; + return {true, css::uno::Any(OUString(o3tl::toU(buffer)))}; } return {false, {}}; diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx index 3b569ed7c7c1..55b20e62fc46 100644 --- a/shell/source/win32/SysShExec.cxx +++ b/shell/source/win32/SysShExec.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/system/SystemShellExecuteFlags.hpp> #include <com/sun/star/uri/UriReferenceFactory.hpp> #include <cppuhelper/supportsservice.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #define WIN32_LEAN_AND_MEAN #if defined _MSC_VER @@ -297,8 +298,8 @@ void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aPa ZeroMemory(&sei, sizeof( sei)); sei.cbSize = sizeof(sei); - sei.lpFile = SAL_W(preprocessed_command.getStr()); - sei.lpParameters = SAL_W(aParameter.getStr()); + sei.lpFile = o3tl::toW(preprocessed_command.getStr()); + sei.lpParameters = o3tl::toW(aParameter.getStr()); sei.nShow = SW_SHOWNORMAL; if (NO_SYSTEM_ERROR_MESSAGE & nFlags) diff --git a/shell/source/win32/simplemail/smplmailclient.cxx b/shell/source/win32/simplemail/smplmailclient.cxx index 16ef55b6230d..b38061c37037 100644 --- a/shell/source/win32/simplemail/smplmailclient.cxx +++ b/shell/source/win32/simplemail/smplmailclient.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/system/SimpleMailClientFlags.hpp> #include <com/sun/star/system/XSimpleMailMessage2.hpp> #include <osl/file.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #define WIN32_LEAN_AND_MEAN #if defined _MSC_VER @@ -81,7 +82,7 @@ namespace /* private */ lret = RegQueryValueW(hkey, nullptr, buff, &sz); if (lret == ERROR_SUCCESS) { - osl::FileBase::getFileURLFromSystemPath(SAL_U(buff), altSenddocUrl); + osl::FileBase::getFileURLFromSystemPath(o3tl::toU(buff), altSenddocUrl); } RegCloseKey(hkey); } diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx index 83840fb8de5a..0130e9cc3408 100644 --- a/svl/source/crypto/cryptosign.cxx +++ b/svl/source/crypto/cryptosign.cxx @@ -26,6 +26,7 @@ #include <unotools/datetime.hxx> #include <xmloff/xmluconv.hxx> #include <tools/zcodec.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #if HAVE_FEATURE_NSS && !defined(_WIN32) // NSS headers for PDF signing @@ -1573,7 +1574,7 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer) aTsPara.cExtension = 0; aTsPara.rgExtension = nullptr; - if (!CryptRetrieveTimeStamp(SAL_W(m_aSignTSA.getStr()), + if (!CryptRetrieveTimeStamp(o3tl::toW(m_aSignTSA.getStr()), 0, 10000, szOID_NIST_sha256, @@ -1946,7 +1947,7 @@ OUString GetSubjectName(PCCERT_CONTEXT pCertContext) return subjectName; } - subjectName = SAL_U(szName); + subjectName = o3tl::toU(szName); LocalFree(szName); return subjectName; diff --git a/svl/source/svdde/ddedata.cxx b/svl/source/svdde/ddedata.cxx index 5ee335ee67ec..05de89628ffe 100644 --- a/svl/source/svdde/ddedata.cxx +++ b/svl/source/svdde/ddedata.cxx @@ -25,6 +25,7 @@ #include <string.h> #include "ddeimp.hxx" #include <svl/svdde.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <osl/thread.h> @@ -134,7 +135,7 @@ sal_uLong DdeData::GetExternalFormat(SotClipboardFormatId nFmt) #if defined(_WIN32) OUString aName( SotExchange::GetFormatName( nFmt ) ); if( !aName.isEmpty() ) - return RegisterClipboardFormatW( SAL_W(aName.getStr()) ); + return RegisterClipboardFormatW( o3tl::toW(aName.getStr()) ); #endif } } @@ -158,7 +159,7 @@ SotClipboardFormatId DdeData::GetInternalFormat(sal_uLong nFmt) WCHAR szName[ 256 ]; if(GetClipboardFormatNameW( nFmt, szName, SAL_N_ELEMENTS(szName) )) - return SotExchange::RegisterFormatName( SAL_U(szName) ); + return SotExchange::RegisterFormatName( o3tl::toU(szName) ); } #endif break; diff --git a/svl/source/svdde/ddestrg.cxx b/svl/source/svdde/ddestrg.cxx index 70cde9aa8594..43fbe5b6d9e4 100644 --- a/svl/source/svdde/ddestrg.cxx +++ b/svl/source/svdde/ddestrg.cxx @@ -20,11 +20,12 @@ #include "ddeimp.hxx" #include <svl/svdde.hxx> +#include <o3tl/char16_t2wchar_t.hxx> DdeString::DdeString( DWORD hDdeInst, const OUString& r) : m_aString(r) { - hString = DdeCreateStringHandleW( hDdeInst, SAL_W(r.getStr()), CP_WINUNICODE ); + hString = DdeCreateStringHandleW( hDdeInst, o3tl::toW(r.getStr()), CP_WINUNICODE ); hInst = hDdeInst; } diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx index 5fa56f50f5ad..ad46b8a85ab5 100644 --- a/svl/source/svdde/ddesvr.cxx +++ b/svl/source/svdde/ddesvr.cxx @@ -25,6 +25,7 @@ #include <svl/svdde.hxx> #include <osl/thread.h> #include <o3tl/sorted_vector.hxx> +#include <o3tl/char16_t2wchar_t.hxx> enum DdeItemType { @@ -97,7 +98,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( while( -1 != n ) { OUString s( sTopics.getToken( 0, '\t', n )); - if( s == SAL_U(chTopicBuf) ) + if( s == o3tl::toU(chTopicBuf) ) ++nTopics; } } @@ -124,7 +125,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( { OUString s( sTopics.getToken( 0, '\t', n )); s = s.replaceAll("\n", "").replaceAll("\r", ""); - if( !hText1 || s == SAL_U(chTopicBuf) ) + if( !hText1 || s == o3tl::toU(chTopicBuf) ) { DdeString aDStr( pInst->hDdeInstSvr, s ); pTopic = FindTopic( *pService, aDStr.getHSZ() ); @@ -423,7 +424,7 @@ DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem ) // Let's query our subclass WCHAR chBuf[250]; DdeQueryStringW(pInst->hDdeInstSvr,hItem,chBuf,SAL_N_ELEMENTS(chBuf),CP_WINUNICODE ); - bContinue = rTopic.MakeItem( SAL_U(chBuf) ); + bContinue = rTopic.MakeItem( o3tl::toU(chBuf) ); // We need to search again } while( bContinue ); @@ -914,7 +915,7 @@ OUString DdeService::Formats() { WCHAR buf[128]; GetClipboardFormatNameW( (UINT)f, buf, SAL_N_ELEMENTS(buf) ); - s += SAL_U(buf); + s += o3tl::toU(buf); } break; } diff --git a/sw/source/ui/vba/vbasystem.cxx b/sw/source/ui/vba/vbasystem.cxx index 95eec3f1ed2e..693cd8e13679 100644 --- a/sw/source/ui/vba/vbasystem.cxx +++ b/sw/source/ui/vba/vbasystem.cxx @@ -23,6 +23,7 @@ #include <tools/config.hxx> #include <osl/file.hxx> #include <tools/urlobj.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #ifdef _WIN32 #if defined _MSC_VER @@ -106,7 +107,7 @@ uno::Any PrivateProfileStringListener::getValueEvent() if( ERROR_SUCCESS == lResult ) { OUString sUValName = OStringToOUString(maKey, RTL_TEXTENCODING_DONTKNOW); - LPCWSTR lpValueName = SAL_W(sUValName.getStr()); + LPCWSTR lpValueName = o3tl::toW(sUValName.getStr()); WCHAR szBuffer[1024]; DWORD cbData = sizeof(szBuffer); lResult = RegQueryValueExW( hKey, lpValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer), &cbData ); @@ -114,7 +115,7 @@ uno::Any PrivateProfileStringListener::getValueEvent() // https://msdn.microsoft.com/en-us/ms724911 mentions that // "the string may not have been stored with the proper terminating null characters" szBuffer[std::min(size_t(cbData / sizeof(szBuffer[0])), SAL_N_ELEMENTS(szBuffer)-1)] = 0; - sValue = SAL_U(szBuffer); + sValue = o3tl::toU(szBuffer); } } #else @@ -153,7 +154,7 @@ void PrivateProfileStringListener::setValueEvent( const css::uno::Any& value ) { DWORD cbData = sizeof(WCHAR) * (aValue.getLength() + 1); OUString sUValName = OStringToOUString(maKey, RTL_TEXTENCODING_DONTKNOW); - LPCWSTR lpValueName = SAL_W(sUValName.getStr()); + LPCWSTR lpValueName = o3tl::toW(sUValName.getStr()); lResult = RegSetValueExW( hKey, lpValueName, 0 /* Reserved */, REG_SZ, reinterpret_cast<BYTE const *>(aValue.getStr()), cbData ); RegCloseKey( hKey ); } diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx index c0c5373573e2..6a549deddcaa 100644 --- a/tools/source/stream/strmwnt.cxx +++ b/tools/source/stream/strmwnt.cxx @@ -31,6 +31,7 @@ #include <osl/thread.h> #include <tools/stream.hxx> +#include <o3tl/char16_t2wchar_t.hxx> // class FileBase #include <osl/file.hxx> @@ -317,7 +318,7 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode ) } pInstanceData->hFile = CreateFileW( - SAL_W(aFilename.getStr()), + o3tl::toW(aFilename.getStr()), nAccessMode, nShareMode, nullptr, @@ -351,7 +352,7 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode ) nOpenAction = OPEN_EXISTING; SetLastError( ERROR_SUCCESS ); pInstanceData->hFile = CreateFileW( - SAL_W(aFilename.getStr()), + o3tl::toW(aFilename.getStr()), GENERIC_READ, nShareMode, nullptr, diff --git a/vcl/opengl/win/WinDeviceInfo.cxx b/vcl/opengl/win/WinDeviceInfo.cxx index 841abed10748..b6d39e51b88c 100644 --- a/vcl/opengl/win/WinDeviceInfo.cxx +++ b/vcl/opengl/win/WinDeviceInfo.cxx @@ -26,6 +26,7 @@ #include <rtl/bootstrap.hxx> #include <rtl/ustrbuf.hxx> #include <tools/stream.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <desktop/crashreport.hxx> @@ -117,7 +118,7 @@ bool GetKeyValue(const WCHAR* keyLocation, const WCHAR* keyName, OUString& destS wCharValue[strLen-1] = '\0'; if (isValid) - destString = OUString(SAL_U(wCharValue)); + destString = OUString(o3tl::toU(wCharValue)); } else @@ -616,10 +617,10 @@ void WinOpenGLDeviceInfo::GetData() } // chop off DEVICE_KEY_PREFIX - maDeviceKey = SAL_U(displayDevice.DeviceKey) + ArrayLength(DEVICE_KEY_PREFIX)-1; + maDeviceKey = o3tl::toU(displayDevice.DeviceKey) + ArrayLength(DEVICE_KEY_PREFIX)-1; - maDeviceID = SAL_U(displayDevice.DeviceID); - maDeviceString = SAL_U(displayDevice.DeviceString); + maDeviceID = o3tl::toU(displayDevice.DeviceID); + maDeviceString = o3tl::toU(displayDevice.DeviceString); if (maDeviceID.isEmpty() && (maDeviceString == "RDPDD Chained DD" || @@ -632,7 +633,7 @@ void WinOpenGLDeviceInfo::GetData() } /* create a device information set composed of the current display device */ - HDEVINFO devinfo = SetupDiGetClassDevsW(nullptr, SAL_W(maDeviceID.getStr()), nullptr, + HDEVINFO devinfo = SetupDiGetClassDevsW(nullptr, o3tl::toW(maDeviceID.getStr()), nullptr, DIGCF_PRESENT | DIGCF_PROFILE | DIGCF_ALLCLASSES); if (devinfo != INVALID_HANDLE_VALUE) @@ -658,8 +659,8 @@ void WinOpenGLDeviceInfo::GetData() nullptr)) { OUString driverKey("System\\CurrentControlSet\\Control\\Class\\"); - driverKey += SAL_U(value); - result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, SAL_W(driverKey.getStr()), 0, KEY_QUERY_VALUE, &key); + driverKey += o3tl::toU(value); + result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, o3tl::toW(driverKey.getStr()), 0, KEY_QUERY_VALUE, &key); if (result == ERROR_SUCCESS) { /* we've found the driver we're looking for */ @@ -668,7 +669,7 @@ void WinOpenGLDeviceInfo::GetData() reinterpret_cast<LPBYTE>(value), &dwcbData); if (result == ERROR_SUCCESS) { - maDriverVersion = OUString(SAL_U(value)); + maDriverVersion = OUString(o3tl::toU(value)); } else { @@ -680,7 +681,7 @@ void WinOpenGLDeviceInfo::GetData() reinterpret_cast<LPBYTE>(value), &dwcbData); if (result == ERROR_SUCCESS) { - maDriverDate = SAL_U(value); + maDriverDate = o3tl::toU(value); } else { @@ -746,8 +747,8 @@ void WinOpenGLDeviceInfo::GetData() nullptr)) { OUString driverKey2("System\\CurrentControlSet\\Control\\Class\\"); - driverKey2 += SAL_U(value); - result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, SAL_W(driverKey2.getStr()), 0, KEY_QUERY_VALUE, &key); + driverKey2 += o3tl::toU(value); + result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, o3tl::toW(driverKey2.getStr()), 0, KEY_QUERY_VALUE, &key); if (result == ERROR_SUCCESS) { dwcbData = sizeof(value); @@ -757,7 +758,7 @@ void WinOpenGLDeviceInfo::GetData() { continue; } - aDeviceID2 = SAL_U(value); + aDeviceID2 = o3tl::toU(value); OUString aAdapterVendorID2String; OUString aAdapterDeviceID2String; adapterVendorID2 = ParseIDFromDeviceID(aDeviceID2, "VEN_", 4); @@ -773,7 +774,7 @@ void WinOpenGLDeviceInfo::GetData() // If this device is missing driver information, it is unlikely to // be a real display adapter. - if (!GetKeyValue(SAL_W(driverKey2.getStr()), L"InstalledDisplayDrivers", + if (!GetKeyValue(o3tl::toW(driverKey2.getStr()), L"InstalledDisplayDrivers", aAdapterDriver2, REG_MULTI_SZ)) { RegCloseKey(key); @@ -787,7 +788,7 @@ void WinOpenGLDeviceInfo::GetData() RegCloseKey(key); continue; } - aDriverVersion2 = SAL_U(value); + aDriverVersion2 = o3tl::toU(value); dwcbData = sizeof(value); result = RegQueryValueExW(key, L"DriverDate", nullptr, nullptr, reinterpret_cast<LPBYTE>(value), &dwcbData); @@ -796,7 +797,7 @@ void WinOpenGLDeviceInfo::GetData() RegCloseKey(key); continue; } - aDriverDate2 = SAL_U(value); + aDriverDate2 = o3tl::toU(value); dwcbData = sizeof(value); result = RegQueryValueExW(key, L"Device Description", nullptr, nullptr, reinterpret_cast<LPBYTE>(value), &dwcbData); @@ -810,7 +811,7 @@ void WinOpenGLDeviceInfo::GetData() if (result == ERROR_SUCCESS) { mbHasDualGPU = true; - maDeviceString2 = SAL_U(value); + maDeviceString2 = o3tl::toU(value); maDeviceID2 = aDeviceID2; maDeviceKey2 = driverKey2; maDriverVersion2 = aDriverVersion2; diff --git a/vcl/win/app/salinfo.cxx b/vcl/win/app/salinfo.cxx index c96f80862b53..52398b3b13f1 100644 --- a/vcl/win/app/salinfo.cxx +++ b/vcl/win/app/salinfo.cxx @@ -19,7 +19,7 @@ #include "svsys.h" #include "rtl/ustrbuf.hxx" - +#include <o3tl/char16_t2wchar_t.hxx> #include <vcl/window.hxx> @@ -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( SAL_U(aInfo.szDevice) ); + OUString aDeviceName( o3tl::toU(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( SAL_U(aDev.DeviceName) ); - OUString aDeviceString( SAL_U(aDev.DeviceString) ); + OUString aDeviceName( o3tl::toU(aDev.DeviceName) ); + OUString aDeviceString( o3tl::toU(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, - SAL_W(rMessage.getStr()), - SAL_W(rTitle.getStr()), + o3tl::toW(rMessage.getStr()), + o3tl::toW(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 3cfa96a5b0b4..a0a323b2d037 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -25,6 +25,7 @@ #include <osl/file.hxx> #include <tools/time.hxx> #include <comphelper/solarmutex.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <vcl/inputtypes.hxx> #include <vcl/opengl/OpenGLHelper.hxx> @@ -88,7 +89,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, SAL_W(rErrorText.getStr()) ); + FatalAppExitW( 0, o3tl::toW(rErrorText.getStr()) ); } } @@ -834,7 +835,7 @@ void WinSalInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUS { IShellItem* pShellItem = nullptr; - HRESULT hr = SHCreateItemFromParsingName(SAL_W(system_path.getStr()), nullptr, IID_PPV_ARGS(&pShellItem)); + HRESULT hr = SHCreateItemFromParsingName(o3tl::toW(system_path.getStr()), nullptr, IID_PPV_ARGS(&pShellItem)); if ( SUCCEEDED(hr) && pShellItem ) { @@ -869,7 +870,7 @@ void WinSalInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUS SHARDAPPIDINFO info; info.psi = pShellItem; - info.pszAppID = SAL_W(sApplicationID.getStr()); + info.pszAppID = o3tl::toW(sApplicationID.getStr()); SHAddToRecentDocs ( SHARD_APPIDINFO, &info ); return; diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 19c6424e6dfd..53de8bcad5ba 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -34,6 +34,7 @@ #include <osl/file.hxx> #include <osl/process.h> #include <rtl/bootstrap.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <tools/helpers.hxx> #include <tools/stream.hxx> #include <unotools/fontcfg.hxx> @@ -527,7 +528,7 @@ static FontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXW& rEnumFont aDFA.SetSymbolFlag(rLogFont.lfCharSet == SYMBOL_CHARSET); // get the font face name - aDFA.SetFamilyName(SAL_U(rLogFont.lfFaceName)); + aDFA.SetFamilyName(o3tl::toU(rLogFont.lfFaceName)); // use the face's style name only if it looks reasonable const wchar_t* pStyleName = rEnumFont.elfStyle; @@ -537,7 +538,7 @@ static FontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXW& rEnumFont if( *p < 0x0020 ) break; if( p < pEnd ) - aDFA.SetStyleName(SAL_U(pStyleName)); + aDFA.SetStyleName(o3tl::toU(pStyleName)); // heuristics for font quality // - opentypeTT > truetype @@ -571,7 +572,7 @@ static WinFontFace* ImplLogMetricToDevFontDataW( const ENUMLOGFONTEXW* pLogFont, void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, Font& rFont ) { - OUString aFontName( SAL_U(rLogFont.lfFaceName) ); + OUString aFontName( o3tl::toU(rLogFont.lfFaceName) ); if (!aFontName.isEmpty()) { rFont.SetFamilyName( aFontName ); @@ -945,7 +946,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa wchar_t aFaceName[LF_FACESIZE+60]; if( GetTextFaceW( getHDC(), SAL_N_ELEMENTS(aFaceName), aFaceName ) ) - rxFontMetric->SetFamilyName(SAL_U(aFaceName)); + rxFontMetric->SetFamilyName(o3tl::toU(aFaceName)); const DWORD nHheaTag = CalcTag("hhea"); const DWORD nOS2Tag = CalcTag("OS/2"); @@ -1019,7 +1020,7 @@ int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe, // Ignore vertical fonts if ( pLogFont->elfLogFont.lfFaceName[0] != '@' ) { - OUString aName = SAL_U(pLogFont->elfLogFont.lfFaceName); + OUString aName = o3tl::toU(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; @@ -1037,7 +1038,7 @@ int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe, { if ((nFontType & RASTER_FONTTYPE) && !(nFontType & DEVICE_FONTTYPE)) { - SAL_INFO("vcl.gdi", "Unsupported printer font ignored: " << OUString(SAL_U(pLogFont->elfLogFont.lfFaceName))); + SAL_INFO("vcl.gdi", "Unsupported printer font ignored: " << OUString(o3tl::toU(pLogFont->elfLogFont.lfFaceName))); return 1; } } @@ -1046,7 +1047,7 @@ int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe, !(pMetric->ntmTm.ntmFlags & NTM_PS_OPENTYPE) && !(pMetric->ntmTm.ntmFlags & NTM_TT_OPENTYPE)) { - SAL_INFO("vcl.gdi", "Unsupported font ignored: " << OUString(SAL_U(pLogFont->elfLogFont.lfFaceName))); + SAL_INFO("vcl.gdi", "Unsupported font ignored: " << OUString(o3tl::toU(pLogFont->elfLogFont.lfFaceName))); return 1; } @@ -1072,7 +1073,7 @@ bool ImplAddTempFont( SalData& rSalData, const OUString& rFontFileURL ) OUString aUSytemPath; OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, aUSytemPath ) ); - nRet = AddFontResourceExW( SAL_W(aUSytemPath.getStr()), FR_PRIVATE, nullptr ); + nRet = AddFontResourceExW( o3tl::toW(aUSytemPath.getStr()), FR_PRIVATE, nullptr ); if ( !nRet ) { @@ -1089,7 +1090,7 @@ bool ImplAddTempFont( SalData& rSalData, const OUString& rFontFileURL ) DeleteFileW( aResourceName ); // TODO: font should be private => need to investigate why it doesn't work then - if( !CreateScalableFontResourceW( 0, aResourceName, SAL_W(aUSytemPath.getStr()), nullptr ) ) + if( !CreateScalableFontResourceW( 0, aResourceName, o3tl::toW(aUSytemPath.getStr()), nullptr ) ) return false; ++nCounter; @@ -1097,7 +1098,7 @@ bool ImplAddTempFont( SalData& rSalData, const OUString& rFontFileURL ) if( nRet > 0 ) { TempFontItem* pNewItem = new TempFontItem; - pNewItem->maResourcePath = SAL_U( aResourceName ); + pNewItem->maResourcePath = o3tl::toU( aResourceName ); pNewItem->maFontFilePath = aUSytemPath; pNewItem->mpNextItem = rSalData.mpTempFontItem; rSalData.mpTempFontItem = pNewItem; @@ -1115,13 +1116,13 @@ void ImplReleaseTempFonts( SalData& rSalData ) ++nCount; if( p->maResourcePath.getLength() ) { - const wchar_t* pResourcePath = SAL_W(p->maResourcePath.getStr()); + const wchar_t* pResourcePath = o3tl::toW(p->maResourcePath.getStr()); RemoveFontResourceW( pResourcePath ); DeleteFileW( pResourcePath ); } else { - RemoveFontResourceW( SAL_W(p->maFontFilePath.getStr()) ); + RemoveFontResourceW( o3tl::toW(p->maFontFilePath.getStr()) ); } rSalData.mpTempFontItem = p->mpNextItem; @@ -1152,10 +1153,10 @@ static bool ImplGetFontAttrFromFile( const OUString& rFontFileURL, DeleteFileW( aResourceName ); // Create font resource file (typically with a .fot file name extension). - CreateScalableFontResourceW( 0, aResourceName, SAL_W(aUSytemPath.getStr()), nullptr ); + CreateScalableFontResourceW( 0, aResourceName, o3tl::toW(aUSytemPath.getStr()), nullptr ); // Open and read the font resource file - OUString aFotFileName = SAL_U( aResourceName ); + OUString aFotFileName = o3tl::toU( aResourceName ); osl::FileBase::getFileURLFromSystemPath( aFotFileName, aFotFileName ); osl::File aFotFile( aFotFileName ); osl::FileBase::RC aError = aFotFile.open( osl_File_OpenFlag_Read ); diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx index 22ed3bf1262a..a04fbfcf06dc 100644 --- a/vcl/win/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/gdi/salnativewidgets-luna.cxx @@ -34,6 +34,7 @@ #include "rtl/ustring.h" #include "osl/module.h" +#include <o3tl/char16_t2wchar_t.hxx> #include <opengl/win/gdiimpl.hxx> #include <vcl/svapp.hxx> @@ -351,7 +352,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, - SAL_W(aStr.getStr()), -1, + o3tl::toW(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 008f9a9e5817..07c2da6d7504 100644 --- a/vcl/win/gdi/salprn.cxx +++ b/vcl/win/gdi/salprn.cxx @@ -25,6 +25,7 @@ #include <svsys.h> #include <osl/module.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <tools/urlobj.hxx> @@ -162,7 +163,7 @@ void WinSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) for ( i = 0; i < nInfoPrn4; i++ ) { SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo; - pInfo->maPrinterName = SAL_U(pWinInfo4[i].pPrinterName); + pInfo->maPrinterName = o3tl::toU(pWinInfo4[i].pPrinterName); pInfo->mnStatus = PrintQueueFlags::NONE; pInfo->mnJobs = 0; pInfo->mpSysData = nullptr; @@ -176,7 +177,7 @@ void WinSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) void WinSalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) { HANDLE hPrinter = nullptr; - LPWSTR pPrnName = const_cast<LPWSTR>(SAL_W(pInfo->maPrinterName.getStr())); + LPWSTR pPrnName = const_cast<LPWSTR>(o3tl::toW(pInfo->maPrinterName.getStr())); if( OpenPrinterW( pPrnName, &hPrinter, nullptr ) ) { DWORD nBytes = 0; @@ -187,18 +188,18 @@ void WinSalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) if( GetPrinterW( hPrinter, 2, reinterpret_cast<LPBYTE>(pWinInfo2), nBytes, &nBytes ) ) { if( pWinInfo2->pDriverName ) - pInfo->maDriver = SAL_U(pWinInfo2->pDriverName); + pInfo->maDriver = o3tl::toU(pWinInfo2->pDriverName); OUString aPortName; if ( pWinInfo2->pPortName ) - aPortName = SAL_U(pWinInfo2->pPortName); + aPortName = o3tl::toU(pWinInfo2->pPortName); // pLocation can be 0 (the Windows docu doesn't describe this) if ( pWinInfo2->pLocation && *pWinInfo2->pLocation ) - pInfo->maLocation = SAL_U(pWinInfo2->pLocation); + pInfo->maLocation = o3tl::toU(pWinInfo2->pLocation); else pInfo->maLocation = aPortName; // pComment can be 0 (the Windows docu doesn't describe this) if ( pWinInfo2->pComment ) - pInfo->maComment = SAL_U(pWinInfo2->pComment); + pInfo->maComment = o3tl::toU(pWinInfo2->pComment); pInfo->mnStatus = ImplWinQueueStatusToSal( pWinInfo2->Status ); pInfo->mnJobs = pWinInfo2->cJobs; if( ! pInfo->mpSysData ) @@ -226,7 +227,7 @@ OUString WinSalInstance::GetDefaultPrinter() OUString aDefPrt; if( GetDefaultPrinterW( pStr, &nChars ) ) { - aDefPrt = SAL_U(pStr); + aDefPrt = o3tl::toU(pStr); } rtl_freeMemory( pStr ); if( !aDefPrt.isEmpty() ) @@ -243,7 +244,7 @@ OUString WinSalInstance::GetDefaultPrinter() wchar_t* pTmp = pBuf; while ( *pTmp && (*pTmp != ',') ) pTmp++; - return OUString( SAL_U(pBuf), static_cast<sal_Int32>(pTmp-pBuf) ); + return OUString( o3tl::toU(pBuf), static_cast<sal_Int32>(pTmp-pBuf) ); } else return OUString(); @@ -258,8 +259,8 @@ static DWORD ImplDeviceCaps( WinSalInfoPrinter const * pPrinter, WORD nCaps, else pDevMode = SAL_DEVMODE_W( pSetupData ); - return DeviceCapabilitiesW( SAL_W(pPrinter->maDeviceName.getStr()), - SAL_W(pPrinter->maPortName.getStr()), + return DeviceCapabilitiesW( o3tl::toW(pPrinter->maDeviceName.getStr()), + o3tl::toW(pPrinter->maPortName.getStr()), nCaps, reinterpret_cast<LPWSTR>(pOutput), pDevMode ); } @@ -288,7 +289,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 = const_cast<LPWSTR>(SAL_W(pPrinter->maDeviceName.getStr())); + LPWSTR pPrinterNameW = const_cast<LPWSTR>(o3tl::toW(pPrinter->maDeviceName.getStr())); if ( !OpenPrinterW( pPrinterNameW, &hPrn, nullptr ) ) return FALSE; @@ -350,7 +351,7 @@ static bool ImplUpdateSalJobSetup( WinSalInfoPrinter const * pPrinter, ImplJobSe bool bIn, WinSalFrame* pVisibleDlgParent ) { HANDLE hPrn; - LPWSTR pPrinterNameW = const_cast<LPWSTR>(SAL_W(pPrinter->maDeviceName.getStr())); + LPWSTR pPrinterNameW = const_cast<LPWSTR>(o3tl::toW(pPrinter->maDeviceName.getStr())); if ( !OpenPrinterW( pPrinterNameW, &hPrn, nullptr ) ) return FALSE; // #131642# hPrn==HGDI_ERROR even though OpenPrinter() succeeded! @@ -418,13 +419,13 @@ static bool ImplUpdateSalJobSetup( WinSalInfoPrinter const * pPrinter, ImplJobSe // fill up string buffers with 0 so they do not influence a JobSetup's memcmp if( reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmSize >= 64 ) { - sal_Int32 nLen = rtl_ustr_getLength( SAL_U(reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmDeviceName) ); + sal_Int32 nLen = rtl_ustr_getLength( o3tl::toU(reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmDeviceName) ); if ( sal::static_int_cast<size_t>(nLen) < SAL_N_ELEMENTS( reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmDeviceName ) ) memset( reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmDeviceName+nLen, 0, sizeof( reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmDeviceName )-(nLen*sizeof(sal_Unicode)) ); } if( reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmSize >= 166 ) { - sal_Int32 nLen = rtl_ustr_getLength( SAL_U(reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmFormName) ); + sal_Int32 nLen = rtl_ustr_getLength( o3tl::toU(reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmFormName) ); if ( sal::static_int_cast<size_t>(nLen) < SAL_N_ELEMENTS( reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmFormName ) ) memset( reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmFormName+nLen, 0, sizeof( reinterpret_cast<LPDEVMODEW>(pOutDevMode)->dmFormName )-(nLen*sizeof(sal_Unicode)) ); } @@ -1023,8 +1024,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( SAL_W(pDriverName), - SAL_W(pDeviceName), + hDC = ImplCreateICW_WithCatch( o3tl::toW(pDriverName), + o3tl::toW(pDeviceName), pDevMode ); return hDC; } @@ -1438,8 +1439,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( SAL_W(aDrvBuf), - SAL_W(aDevBuf), + hDC = CreateDCW( o3tl::toW(aDrvBuf), + o3tl::toW(aDevBuf), nullptr, pDevModeW ); @@ -1493,12 +1494,12 @@ bool WinSalPrinter::StartJob( const OUString* pFileName, DOCINFOW aInfo; memset( &aInfo, 0, sizeof( DOCINFOW ) ); aInfo.cbSize = sizeof( aInfo ); - aInfo.lpszDocName = SAL_W(rJobName.getStr()); + aInfo.lpszDocName = o3tl::toW(rJobName.getStr()); if ( pFileName || aOutFileName.getLength() ) { if ( (pFileName && !pFileName->isEmpty()) || aOutFileName.getLength() ) { - aInfo.lpszOutput = SAL_W((pFileName && !pFileName->isEmpty()) ? pFileName->getStr() : aOutFileName.getStr()); + aInfo.lpszOutput = o3tl::toW((pFileName && !pFileName->isEmpty()) ? pFileName->getStr() : aOutFileName.getStr()); } else aInfo.lpszOutput = L"FILE:"; diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index e8a7c5090172..622fa7bba2b2 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -41,6 +41,7 @@ #include <tools/debug.hxx> #include <o3tl/enumarray.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <vcl/sysdata.hxx> #include <vcl/timer.hxx> @@ -1070,7 +1071,7 @@ void WinSalFrame::SetTitle( const OUString& rTitle ) { static_assert( sizeof( WCHAR ) == sizeof( sal_Unicode ), "must be the same size" ); - SetWindowTextW( mhWnd, SAL_W(rTitle.getStr()) ); + SetWindowTextW( mhWnd, o3tl::toW(rTitle.getStr()) ); } void WinSalFrame::SetIcon( sal_uInt16 nIcon ) @@ -1844,7 +1845,7 @@ void WinSalFrame::SetApplicationID( const OUString &rApplicationID ) PROPVARIANT pv; if ( !rApplicationID.isEmpty() ) { - hr = InitPropVariantFromString( SAL_W(rApplicationID.getStr()), &pv ); + hr = InitPropVariantFromString( o3tl::toW(rApplicationID.getStr()), &pv ); mbPropertiesStored = TRUE; } else @@ -2303,7 +2304,7 @@ static void ImplGetKeyNameText( LONG lParam, sal_Unicode* pBuf, else { nKeyLen = aRet.getLength(); - wcscpy( aKeyBuf, SAL_W( aRet.getStr() )); + wcscpy( aKeyBuf, o3tl::toW( aRet.getStr() )); } } @@ -2554,7 +2555,7 @@ static void ImplSalUpdateStyleFontW( HDC hDC, const LOGFONTW& rLogFont, vcl::Fon // 6 Point is the smallest one if ( rFont.GetFontHeight() < 8 ) { - if ( rtl_ustr_compareIgnoreAsciiCase( SAL_U(rLogFont.lfFaceName), SAL_U(L"MS Sans Serif") ) == 0 ) + if ( rtl_ustr_compareIgnoreAsciiCase( o3tl::toU(rLogFont.lfFaceName), o3tl::toU(L"MS Sans Serif") ) == 0 ) rFont.SetFontHeight( 8 ); else if ( rFont.GetFontHeight() < 6 ) rFont.SetFontHeight( 6 ); @@ -4453,7 +4454,7 @@ static int ImplMeasureItem( HWND hWnd, WPARAM wParam, LPARAM lParam ) aStr += " "; aStr += pSalMenuItem->mAccelText; } - GetTextExtentPoint32W( hdc, SAL_W(aStr.getStr()), + GetTextExtentPoint32W( hdc, o3tl::toW(aStr.getStr()), aStr.getLength(), &strSize ); // image @@ -4590,7 +4591,7 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) SIZE strSize; OUString aStr( pSalMenuItem->mText ); - GetTextExtentPoint32W( pDI->hDC, SAL_W(aStr.getStr()), + GetTextExtentPoint32W( pDI->hDC, o3tl::toW(aStr.getStr()), aStr.getLength(), &strSize ); if(!DrawStateW( pDI->hDC, nullptr, nullptr, @@ -4603,7 +4604,7 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) { SIZE strSizeA; aStr = pSalMenuItem->mAccelText; - GetTextExtentPoint32W( pDI->hDC, SAL_W(aStr.getStr()), + GetTextExtentPoint32W( pDI->hDC, o3tl::toW(aStr.getStr()), aStr.getLength(), &strSizeA ); TEXTMETRICW tm; GetTextMetricsW( pDI->hDC, &tm ); @@ -4969,7 +4970,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( SAL_U(pTextBuf.get()), (sal_Int32)nTextLen ); + aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), (sal_Int32)nTextLen ); } aEvt.mnCursorPos = aEvt.maText.getLength(); @@ -4995,7 +4996,7 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, { 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 ); + aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), (sal_Int32)nTextLen ); } std::unique_ptr<BYTE> pAttrBuf; diff --git a/vcl/win/window/salmenu.cxx b/vcl/win/window/salmenu.cxx index 5ca16c496829..592813759e88 100644 --- a/vcl/win/window/salmenu.cxx +++ b/vcl/win/window/salmenu.cxx @@ -21,6 +21,7 @@ #include <vcl/menu.hxx> #include <vcl/sysdata.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <win/wincomp.hxx> #include <win/saldata.hxx> @@ -93,7 +94,7 @@ SalMenuItem* WinSalInstance::CreateMenuItem( const SalItemParams* pItemData ) pSalMenuItem->mInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID | MIIM_DATA; pSalMenuItem->mInfo.fType = MFT_STRING; - pSalMenuItem->mInfo.dwTypeData = SAL_W(const_cast<sal_Unicode *>(pSalMenuItem->mText.getStr())); + pSalMenuItem->mInfo.dwTypeData = o3tl::toW(const_cast<sal_Unicode *>(pSalMenuItem->mText.getStr())); pSalMenuItem->mInfo.cch = pSalMenuItem->mText.getLength(); pSalMenuItem->mInfo.wID = pItemData->nId; @@ -307,7 +308,7 @@ void WinSalMenu::SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const OU { aStr += "\t" + pWItem->mAccelText; } - pWItem->mInfo.dwTypeData = SAL_W(const_cast<sal_Unicode *>(aStr.getStr())); + pWItem->mInfo.dwTypeData = o3tl::toW(const_cast<sal_Unicode *>(aStr.getStr())); pWItem->mInfo.cch = aStr.getLength(); if(!::SetMenuItemInfoW( mhMenu, nPos, TRUE, &pWItem->mInfo )) @@ -332,7 +333,7 @@ void WinSalMenu::SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const { aStr += "\t" + pWItem->mAccelText; } - pWItem->mInfo.dwTypeData = SAL_W(const_cast<sal_Unicode *>(aStr.getStr())); + pWItem->mInfo.dwTypeData = o3tl::toW(const_cast<sal_Unicode *>(aStr.getStr())); pWItem->mInfo.cch = aStr.getLength(); if(!::SetMenuItemInfoW( mhMenu, nPos, TRUE, &pWItem->mInfo )) diff --git a/winaccessibility/source/UAccCOM/AccActionBase.cxx b/winaccessibility/source/UAccCOM/AccActionBase.cxx index 8feee0227c83..c1227a33c55a 100644 --- a/winaccessibility/source/UAccCOM/AccActionBase.cxx +++ b/winaccessibility/source/UAccCOM/AccActionBase.cxx @@ -29,6 +29,7 @@ #include <com/sun/star/accessibility/XAccessibleContext.hpp> #include <vcl/svapp.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include "AccessibleKeyStroke.h" @@ -117,7 +118,7 @@ STDMETHODIMP CAccActionBase::get_description(long actionIndex,BSTR __RPC_FAR *de // #CHECK# SAFE_SYSFREESTRING(*description); - *description = SysAllocString(SAL_W(ouStr.getStr())); + *description = SysAllocString(o3tl::toW(ouStr.getStr())); return S_OK; @@ -176,7 +177,7 @@ STDMETHODIMP CAccActionBase::get_keyBinding( { auto const wString = GetkeyBindingStrByXkeyBinding( (binding.get())->getAccessibleKeyBinding(index) ); - (*keyBinding)[index] = SysAllocString(SAL_W(wString.getStr())); + (*keyBinding)[index] = SysAllocString(o3tl::toW(wString.getStr())); } *nBinding = nCount; diff --git a/winaccessibility/source/UAccCOM/AccEditableText.cxx b/winaccessibility/source/UAccCOM/AccEditableText.cxx index a2141605867f..93d3d76e251b 100644 --- a/winaccessibility/source/UAccCOM/AccEditableText.cxx +++ b/winaccessibility/source/UAccCOM/AccEditableText.cxx @@ -33,6 +33,7 @@ #endif #include <vcl/svapp.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/accessibility/XAccessibleContext.hpp> @@ -119,7 +120,7 @@ STDMETHODIMP CAccEditableText::insertText(long offset, BSTR * text) if( !pRXEdtTxt.is() ) return E_FAIL; - ::rtl::OUString ouStr(SAL_U(*text)); + ::rtl::OUString ouStr(o3tl::toU(*text)); if( GetXInterface()->insertText( ouStr, offset ) ) return S_OK; @@ -196,7 +197,7 @@ STDMETHODIMP CAccEditableText::replaceText(long startOffset, long endOffset, BST if( !pRXEdtTxt.is() ) return E_FAIL; - ::rtl::OUString ouStr(SAL_U(*text)); + ::rtl::OUString ouStr(o3tl::toU(*text)); if( GetXInterface()->replaceText( startOffset,endOffset, ouStr) ) return S_OK; @@ -225,7 +226,7 @@ STDMETHODIMP CAccEditableText::setAttributes(long startOffset, long endOffset, B if( !pRXEdtTxt.is() ) return E_FAIL; - ::rtl::OUString ouStr(SAL_U(*attributes)); + ::rtl::OUString ouStr(o3tl::toU(*attributes)); sal_Int32 nIndex = 0; vector< ::rtl::OUString > vecAttr; diff --git a/winaccessibility/source/UAccCOM/AccImage.cxx b/winaccessibility/source/UAccCOM/AccImage.cxx index 5b0e88fd47d1..14cdfdd7379d 100644 --- a/winaccessibility/source/UAccCOM/AccImage.cxx +++ b/winaccessibility/source/UAccCOM/AccImage.cxx @@ -30,6 +30,7 @@ #endif #include <vcl/svapp.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/accessibility/XAccessibleContext.hpp> @@ -56,7 +57,7 @@ STDMETHODIMP CAccImage::get_description(BSTR * description) ::rtl::OUString ouStr = GetXInterface()->getAccessibleImageDescription(); SAFE_SYSFREESTRING(*description); - *description = SysAllocString(SAL_W(ouStr.getStr())); + *description = SysAllocString(o3tl::toW(ouStr.getStr())); return S_OK; diff --git a/winaccessibility/source/UAccCOM/AccTable.cxx b/winaccessibility/source/UAccCOM/AccTable.cxx index 6c6aebf32761..c2b5f7796b0e 100644 --- a/winaccessibility/source/UAccCOM/AccTable.cxx +++ b/winaccessibility/source/UAccCOM/AccTable.cxx @@ -33,6 +33,7 @@ #endif #include <vcl/svapp.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <com/sun/star/accessibility/XAccessible.hpp> #include "MAccessible.h" @@ -132,7 +133,7 @@ STDMETHODIMP CAccTable::get_columnDescription(long column, BSTR * description) // #CHECK# SAFE_SYSFREESTRING(*description);//?? - *description = SysAllocString(SAL_W(ouStr.getStr())); + *description = SysAllocString(o3tl::toW(ouStr.getStr())); if(description==nullptr) return E_FAIL; return S_OK; @@ -351,7 +352,7 @@ STDMETHODIMP CAccTable::get_rowDescription(long row, BSTR * description) // #CHECK# SAFE_SYSFREESTRING(*description); - *description = SysAllocString(SAL_W(ouStr.getStr())); + *description = SysAllocString(o3tl::toW(ouStr.getStr())); if(description==nullptr) return E_FAIL; diff --git a/winaccessibility/source/UAccCOM/AccTextBase.cxx b/winaccessibility/source/UAccCOM/AccTextBase.cxx index 651a1abe5347..4b78d75a4b54 100644 --- a/winaccessibility/source/UAccCOM/AccTextBase.cxx +++ b/winaccessibility/source/UAccCOM/AccTextBase.cxx @@ -25,6 +25,7 @@ #include "AccTextBase.h" #include <vcl/svapp.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <com/sun/star/accessibility/AccessibleTextType.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> @@ -183,7 +184,7 @@ STDMETHODIMP CAccTextBase::get_attributes(long offset, long * startOffset, long // #CHECK# if(*textAttributes) SysFreeString(*textAttributes); - *textAttributes = SysAllocString(SAL_W(strAttrs.makeStringAndClear().getStr())); + *textAttributes = SysAllocString(o3tl::toW(strAttrs.makeStringAndClear().getStr())); if( offset < GetXInterface()->getCharacterCount() ) { @@ -491,7 +492,7 @@ STDMETHODIMP CAccTextBase::get_text(long startOffset, long endOffset, BSTR * tex } SysFreeString(*text); - *text = SysAllocString(SAL_W(ouStr.getStr())); + *text = SysAllocString(o3tl::toW(ouStr.getStr())); return S_OK; LEAVE_PROTECTED_BLOCK @@ -576,7 +577,7 @@ STDMETHODIMP CAccTextBase::get_textBeforeOffset(long offset, IA2TextBoundaryType TextSegment segment = GetXInterface()->getTextBeforeIndex( offset, sal_Int16(lUnoBoundaryType)); ::rtl::OUString ouStr = segment.SegmentText; SysFreeString(*text); - *text = SysAllocString(SAL_W(ouStr.getStr())); + *text = SysAllocString(o3tl::toW(ouStr.getStr())); *startOffset = segment.SegmentStart; *endOffset = segment.SegmentEnd; @@ -662,7 +663,7 @@ STDMETHODIMP CAccTextBase::get_textAfterOffset(long offset, IA2TextBoundaryType TextSegment segment = GetXInterface()->getTextBehindIndex( offset, sal_Int16(lUnoBoundaryType)); ::rtl::OUString ouStr = segment.SegmentText; SysFreeString(*text); - *text = SysAllocString(SAL_W(ouStr.getStr())); + *text = SysAllocString(o3tl::toW(ouStr.getStr())); *startOffset = segment.SegmentStart; *endOffset = segment.SegmentEnd; @@ -749,7 +750,7 @@ STDMETHODIMP CAccTextBase::get_textAtOffset(long offset, IA2TextBoundaryType bou TextSegment segment = GetXInterface()->getTextAtIndex( offset, sal_Int16(lUnoBoundaryType)); ::rtl::OUString ouStr = segment.SegmentText; SysFreeString(*text); - *text = SysAllocString(SAL_W(ouStr.getStr())); + *text = SysAllocString(o3tl::toW(ouStr.getStr())); *startOffset = segment.SegmentStart; *endOffset = segment.SegmentEnd; diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 4a713760c21c..4e1be33c585c 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -44,6 +44,7 @@ #include "AccHyperLink.h" #include <vcl/svapp.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <com/sun/star/accessibility/XAccessibleText.hpp> #include <com/sun/star/accessibility/XAccessibleEditableText.hpp> @@ -737,7 +738,7 @@ STDMETHODIMP CMAccessible::get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKe } SAFE_SYSFREESTRING(*pszKeyboardShortcut); - *pszKeyboardShortcut = SysAllocString(SAL_W(wString.getStr())); + *pszKeyboardShortcut = SysAllocString(o3tl::toW(wString.getStr())); return S_OK; } @@ -2958,7 +2959,7 @@ void CMAccessible::ConvertAnyToVariant(const css::uno::Any &rAnyVal, VARIANT *pv pvData->vt = VT_BSTR; ::rtl::OUString val; rAnyVal >>= val; - pvData->bstrVal = SysAllocString(SAL_W(val.getStr())); + pvData->bstrVal = SysAllocString(o3tl::toW(val.getStr())); break; } @@ -3011,7 +3012,7 @@ void CMAccessible::ConvertAnyToVariant(const css::uno::Any &rAnyVal, VARIANT *pv case TypeClass::TypeClass_MAKE_FIXED_SIZE: // Output the type string, if there is other uno value type. pvData->vt = VT_BSTR; - pvData->bstrVal = SysAllocString(SAL_W(rAnyVal.getValueTypeName().getStr())); + pvData->bstrVal = SysAllocString(o3tl::toW(rAnyVal.getValueTypeName().getStr())); break; default: @@ -3125,9 +3126,9 @@ STDMETHODIMP CMAccessible:: get_locale( IA2Locale __RPC_FAR *locale ) return E_FAIL; css::lang::Locale unoLoc = m_xContext.get()->getLocale(); - locale->language = SysAllocString(SAL_W(unoLoc.Language.getStr())); - locale->country = SysAllocString(SAL_W(unoLoc.Country.getStr())); - locale->variant = SysAllocString(SAL_W(unoLoc.Variant.getStr())); + locale->language = SysAllocString(o3tl::toW(unoLoc.Language.getStr())); + locale->country = SysAllocString(o3tl::toW(unoLoc.Country.getStr())); + locale->variant = SysAllocString(o3tl::toW(unoLoc.Variant.getStr())); return S_OK; @@ -3214,7 +3215,7 @@ STDMETHODIMP CMAccessible::get_attributes(/*[out]*/ BSTR *pAttr) if(*pAttr) SAFE_SYSFREESTRING(*pAttr); - *pAttr = SysAllocString(SAL_W(val.getStr())); + *pAttr = SysAllocString(o3tl::toW(val.getStr())); return S_OK; } diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx index 04f09d7c7725..dbc78300f4b0 100644 --- a/winaccessibility/source/service/AccObject.cxx +++ b/winaccessibility/source/service/AccObject.cxx @@ -24,6 +24,8 @@ #include <com/sun/star/accessibility/XAccessibleComponent.hpp> #include <com/sun/star/accessibility/XAccessibleText.hpp> +#include <o3tl/char16_t2wchar_t.hxx> + #include <stdlib.h> #include <memory.h> #include <stdio.h> @@ -271,7 +273,7 @@ void AccObject::UpdateName( ) } if( ( TEXT_FRAME == m_accRole ) && ( m_pParentObj !=nullptr )&& ( SCROLL_PANE == m_pParentObj -> m_accRole ) ) - m_pIMAcc->Put_XAccName( SAL_W(m_pParentObj->m_xAccContextRef->getAccessibleName().getStr()) ); + m_pIMAcc->Put_XAccName( o3tl::toW(m_pParentObj->m_xAccContextRef->getAccessibleName().getStr()) ); //IAccessibility2 Implementation 2009----- if ( PARAGRAPH == m_accRole) { @@ -279,7 +281,7 @@ void AccObject::UpdateName( ) } //-----IAccessibility2 Implementation 2009 else - m_pIMAcc->Put_XAccName(SAL_W(m_xAccContextRef->getAccessibleName().getStr())); + m_pIMAcc->Put_XAccName(o3tl::toW(m_xAccContextRef->getAccessibleName().getStr())); return ; } @@ -296,7 +298,7 @@ void AccObject::UpdateDescription() return; } - m_pIMAcc->Put_XAccDescription(SAL_W(m_xAccContextRef->getAccessibleDescription().getStr())); + m_pIMAcc->Put_XAccDescription(o3tl::toW(m_xAccContextRef->getAccessibleDescription().getStr())); return ; } @@ -365,7 +367,7 @@ void AccObject::UpdateDefaultAction( ) case CHECK_BOX: case TREE_ITEM: case BUTTON_DROPDOWN: - m_pIMAcc->Put_ActionDescription( SAL_W(m_xAccActionRef->getAccessibleActionDescription((sal_Int32)0).getStr()) ); + m_pIMAcc->Put_ActionDescription( o3tl::toW(m_xAccActionRef->getAccessibleActionDescription((sal_Int32)0).getStr()) ); return; } } @@ -401,19 +403,19 @@ void AccObject::SetValue( Any pAny ) { val = pRText->getText(); } - m_pIMAcc->Put_XAccValue( SAL_W(val.getStr()) ); + m_pIMAcc->Put_XAccValue( o3tl::toW(val.getStr()) ); break; case TREE_ITEM: //case CHECK_BOX: //Commented by Li Xing to disable the value for general checkbox case COMBO_BOX: case NOTE: case SCROLL_BAR: - m_pIMAcc->Put_XAccValue( SAL_W(GetMAccessibleValueFromAny(pAny).getStr()) ); + m_pIMAcc->Put_XAccValue( o3tl::toW(GetMAccessibleValueFromAny(pAny).getStr()) ); break ; // Added by Li Xing, only the checkbox in tree should have the value. case CHECK_BOX: if( ( m_pParentObj !=nullptr ) && (TREE == m_pParentObj->m_accRole || TREE_ITEM == m_pParentObj->m_accRole )) - m_pIMAcc->Put_XAccValue( SAL_W(GetMAccessibleValueFromAny(pAny).getStr()) ); + m_pIMAcc->Put_XAccValue( o3tl::toW(GetMAccessibleValueFromAny(pAny).getStr()) ); break; default: break; @@ -499,7 +501,7 @@ void AccObject::SetName( Any pAny) if( nullptr == m_pIMAcc ) return ; - m_pIMAcc->Put_XAccName( SAL_W(GetMAccessibleValueFromAny(pAny).getStr()) ); + m_pIMAcc->Put_XAccName( o3tl::toW(GetMAccessibleValueFromAny(pAny).getStr()) ); } @@ -512,7 +514,7 @@ void AccObject::SetDescription( Any pAny ) { if( nullptr == m_pIMAcc ) return ; - m_pIMAcc->Put_XAccDescription( SAL_W(GetMAccessibleValueFromAny(pAny).getStr()) ); + m_pIMAcc->Put_XAccDescription( o3tl::toW(GetMAccessibleValueFromAny(pAny).getStr()) ); } /** @@ -754,7 +756,7 @@ void AccObject::UpdateActionDesc() } ::rtl::OUString pXString = m_xAccContextRef->getAccessibleDescription(); - m_pIMAcc->Put_XAccDescription(SAL_W(pXString.getStr())); + m_pIMAcc->Put_XAccDescription(o3tl::toW(pXString.getStr())); long Role = m_accRole; if( Role == PUSH_BUTTON || Role == RADIO_BUTTON || Role == MENU_ITEM || @@ -776,7 +778,7 @@ void AccObject::UpdateActionDesc() pXString = m_xAccActionRef->getAccessibleActionDescription( 0 ); //Solution: if string length is more than zero, action is set. if( pXString.getLength() > 0) - m_pIMAcc->Put_ActionDescription( SAL_W(pXString.getStr()) ); + m_pIMAcc->Put_ActionDescription( o3tl::toW(pXString.getStr()) ); } } } diff --git a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx index fbff7f04f588..54eaafbfc036 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/security/CertAltNameEntry.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <comphelper/sequence.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include "sanextension_mscryptimpl.hxx" @@ -93,11 +94,11 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: } case CERT_ALT_NAME_RFC822_NAME : arrCertAltNameEntry[i].Type = ExtAltNameType_RFC822_NAME; - arrCertAltNameEntry[i].Value <<= OUString(SAL_U(pEntry->pwszRfc822Name)); + arrCertAltNameEntry[i].Value <<= OUString(o3tl::toU(pEntry->pwszRfc822Name)); break; case CERT_ALT_NAME_DNS_NAME : arrCertAltNameEntry[i].Type = ExtAltNameType_DNS_NAME; - arrCertAltNameEntry[i].Value <<= OUString(SAL_U(pEntry->pwszDNSName)); + arrCertAltNameEntry[i].Value <<= OUString(o3tl::toU(pEntry->pwszDNSName)); break; case CERT_ALT_NAME_DIRECTORY_NAME : { @@ -106,7 +107,7 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: } case CERT_ALT_NAME_URL : arrCertAltNameEntry[i].Type = ExtAltNameType_URL; - arrCertAltNameEntry[i].Value <<= OUString(SAL_U(pEntry->pwszURL)); + arrCertAltNameEntry[i].Value <<= OUString(o3tl::toU(pEntry->pwszURL)); break; case CERT_ALT_NAME_IP_ADDRESS : { diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index 32bb0a82f0a8..d7c41b731c11 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -50,6 +50,7 @@ #include <rtl/locale.h> #include <osl/nlsupport.h> #include <osl/process.h> +#include <o3tl/char16_t2wchar_t.hxx> using namespace ::com::sun::star::uno ; using namespace ::com::sun::star::lang ; @@ -299,7 +300,7 @@ static OUString get_system_name(const void *pvSystemStore, { ppwszSystemName = static_cast<LPCWSTR>(pvSystemStore); } - return SAL_U(ppwszSystemName); + return o3tl::toU(ppwszSystemName); } extern "C" BOOL WINAPI cert_enum_physical_store_callback(const void *, @@ -309,7 +310,7 @@ extern "C" BOOL WINAPI cert_enum_physical_store_callback(const void *, void *, void *) { - OUString name(SAL_U(pwszStoreName)); + OUString name(o3tl::toU(pwszStoreName)); if (dwFlags & CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG) name += " (implicitly created)"; SAL_INFO("xmlsecurity.xmlsec", " Physical store: " << name); @@ -433,7 +434,7 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const encoding = osl_getTextEncodingFromLocale( pLocale ) ; //Create cert info from issue and serial - LPCWSTR pszName = SAL_W( issuerName.getStr() ); + LPCWSTR pszName = o3tl::toW( issuerName.getStr() ); if( ! ( CertStrToNameW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx index 6fd3bdc85c24..2c3357e7fd9e 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/xml/crypto/XMLSecurityContext.hpp> #include <comphelper/processfactory.hxx> #include <cppuhelper/supportsservice.hxx> +#include <o3tl/char16_t2wchar_t.hxx> namespace cssu = com::sun::star::uno; namespace cssl = com::sun::star::lang; @@ -57,7 +58,7 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL { sCertDir = OString(sCertDB.getStr(), sCertDB.getLength(), RTL_TEXTENCODING_ASCII_US); n_pCertStore = sCertDir.getStr(); - n_hStoreHandle = CertOpenSystemStoreW( NULL, SAL_W(sCertDB.getStr())) ; + n_hStoreHandle = CertOpenSystemStoreW( NULL, o3tl::toW(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 c45b541cf3d7..a4069a91798a 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -31,6 +31,7 @@ #include <rtl/locale.h> #include <osl/nlsupport.h> #include <osl/process.h> +#include <o3tl/char16_t2wchar_t.hxx> #include <memory> #include <utility> @@ -228,7 +229,7 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getIssuerName() { } if(issuer.get()[cchIssuer -1] == 0) cchIssuer--; //delimit the last 0x00; - OUString xIssuer(SAL_U(issuer.get()), cchIssuer) ; + OUString xIssuer(o3tl::toU(issuer.get()), cchIssuer) ; return replaceTagSWithTagST(xIssuer); } else { @@ -265,7 +266,7 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getSubjectName() throw RuntimeException() ; } - OUString xSubject(SAL_U(subject.get())); + OUString xSubject(o3tl::toU(subject.get())); return replaceTagSWithTagST(xSubject); } else |