[Libreoffice-commits] core.git: avmedia/source basic/qa basic/source canvas/source configmgr/source connectivity/source cppuhelper/source dbaccess/source desktop/source dtrans/source embeddedobj/source embedserv/source extensions/source filter/source fpicker/source framework/source helpcompiler/inc helpcompiler/source idlc/source include/comphelper include/o3tl include/sal jvmfwk/plugins sal/osl sal/qa sfx2/source shell/source svl/source sw/source tools/source vcl/opengl vcl/win winaccessibility/source xmlsecurity/source

Mike Kaganski mike.kaganski at collabora.com
Thu Oct 5 14:03:20 UTC 2017


 avmedia/source/win/framegrabber.cxx                                   |    3 
 avmedia/source/win/player.cxx                                         |    3 
 basic/qa/cppunit/test_vba.cxx                                         |    3 
 basic/source/runtime/dllmgr-x64.cxx                                   |    3 
 basic/source/runtime/dllmgr-x86.cxx                                   |    3 
 basic/source/runtime/methods.cxx                                      |    5 
 basic/source/sbx/sbxdec.cxx                                           |   69 ++++----
 canvas/source/directx/dx_canvasfont.cxx                               |    8 -
 canvas/source/directx/dx_canvashelper.cxx                             |    3 
 configmgr/source/winreg.cxx                                           |   11 -
 connectivity/source/drivers/ado/Aolevariant.cxx                       |   17 +-
 cppuhelper/source/bootstrap.cxx                                       |    3 
 dbaccess/source/ui/dlg/adodatalinks.cxx                               |   10 -
 desktop/source/app/crashreport.cxx                                    |    3 
 dtrans/source/win32/dtobj/DataFmtTransl.cxx                           |    7 
 dtrans/source/win32/dtobj/XTDataObject.cxx                            |    7 
 dtrans/source/win32/misc/ImplHelper.cxx                               |    3 
 embeddedobj/source/msole/olecomponent.cxx                             |   27 +--
 embedserv/source/embed/ed_ioleobject.cxx                              |    7 
 embedserv/source/embed/ed_ipersiststr.cxx                             |   39 ++---
 extensions/source/config/ldap/ldapaccess.cxx                          |   19 +-
 extensions/source/ole/oleobjw.cxx                                     |   48 +++---
 extensions/source/ole/servprov.cxx                                    |    3 
 extensions/source/ole/unoconversionutilities.hxx                      |   27 +--
 extensions/source/ole/unoobjw.cxx                                     |   15 +
 extensions/source/ole/unotypewrapper.cxx                              |    4 
 extensions/source/update/check/updatecheckconfig.cxx                  |    5 
 filter/source/graphicfilter/ieps/ieps.cxx                             |    3 
 fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx               |   31 ++--
 fpicker/source/win32/folderpicker/MtaFop.cxx                          |   11 -
 framework/source/uielement/spinfieldtoolbarcontroller.cxx             |    5 
 helpcompiler/inc/HelpCompiler.hxx                                     |    3 
 helpcompiler/source/HelpLinker.cxx                                    |    3 
 idlc/source/options.cxx                                               |    7 
 include/comphelper/windowserrorstring.hxx                             |    3 
 include/o3tl/char16_t2wchar_t.hxx                                     |   59 +++++++
 include/sal/types.h                                                   |   15 -
 jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx                   |    7 
 sal/osl/w32/file.cxx                                                  |   13 -
 sal/osl/w32/file_dirvol.cxx                                           |   73 ++++-----
 sal/osl/w32/file_url.cxx                                              |   39 ++---
 sal/osl/w32/module.cxx                                                |   23 +-
 sal/osl/w32/nlsupport.cxx                                             |    7 
 sal/osl/w32/pipe.cxx                                                  |   11 -
 sal/osl/w32/process.cxx                                               |   19 +-
 sal/osl/w32/procimpl.cxx                                              |   13 -
 sal/osl/w32/profile.cxx                                               |   47 +++---
 sal/osl/w32/security.cxx                                              |   77 +++++-----
 sal/osl/w32/socket.cxx                                                |   15 +
 sal/osl/w32/tempfile.cxx                                              |    9 -
 sal/qa/osl/security/osl_Security.cxx                                  |   13 -
 sfx2/source/appl/shutdowniconw32.cxx                                  |   29 +--
 sfx2/source/doc/graphhelp.cxx                                         |    4 
 sfx2/source/doc/guisaveas.cxx                                         |    3 
 sfx2/source/doc/syspathw32.cxx                                        |    6 
 shell/source/backends/localebe/localebackend.cxx                      |    3 
 shell/source/win32/SysShExec.cxx                                      |    5 
 shell/source/win32/simplemail/smplmailclient.cxx                      |    3 
 svl/source/crypto/cryptosign.cxx                                      |    5 
 svl/source/svdde/ddedata.cxx                                          |    5 
 svl/source/svdde/ddestrg.cxx                                          |    3 
 svl/source/svdde/ddesvr.cxx                                           |    9 -
 sw/source/ui/vba/vbasystem.cxx                                        |    7 
 tools/source/stream/strmwnt.cxx                                       |    5 
 vcl/opengl/win/WinDeviceInfo.cxx                                      |   33 ++--
 vcl/win/app/salinfo.cxx                                               |   12 -
 vcl/win/app/salinst.cxx                                               |    7 
 vcl/win/gdi/salfont.cxx                                               |   29 +--
 vcl/win/gdi/salnativewidgets-luna.cxx                                 |    3 
 vcl/win/gdi/salprn.cxx                                                |   41 ++---
 vcl/win/window/salframe.cxx                                           |   19 +-
 vcl/win/window/salmenu.cxx                                            |    7 
 winaccessibility/source/UAccCOM/AccActionBase.cxx                     |    5 
 winaccessibility/source/UAccCOM/AccEditableText.cxx                   |    7 
 winaccessibility/source/UAccCOM/AccImage.cxx                          |    3 
 winaccessibility/source/UAccCOM/AccTable.cxx                          |    5 
 winaccessibility/source/UAccCOM/AccTextBase.cxx                       |   11 -
 winaccessibility/source/UAccCOM/MAccessible.cxx                       |   15 +
 winaccessibility/source/service/AccObject.cxx                         |   24 +--
 xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx        |    7 
 xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx |    7 
 xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx       |    3 
 xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx     |    5 
 83 files changed, 651 insertions(+), 540 deletions(-)

New commits:
commit 1944e3ddc0b2247de3138d2a441cd6999e21fd9a
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Thu Oct 5 06:19:56 2017 +0300

    Rename and move SAL_U/W to o3tl::toU/W
    
    Previosly (since commit 9ac98e6e3488e434bf4864ecfb13a121784f640b)
    it was expected to gradually remove SAL_U/W usage in Windows code
    by replacing with reinterpret_cast or changing to some bettertypes.
    But as it's useful to make use of fact that LibreOffice and Windows
    use compatible representation of strings, this commit puts these
    functions to a better-suited o3tl, and recommends that the functions
    be consistently used throughout Windows-specific code to reflect the
    compatibility and keep the casts safe.
    
    Change-Id: I2f7c65606d0e2d0c01a00f08812bb4ab7659c5f6
    Reviewed-on: https://gerrit.libreoffice.org/43150
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

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;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list