[Libreoffice-commits] core.git: 7 commits - basic/qa basic/source cli_ure/source configmgr/source dbaccess/source desktop/source embeddedobj/source embedserv/source include/o3tl

Stephan Bergmann sbergman at redhat.com
Mon Apr 10 08:16:43 UTC 2017


 basic/qa/cppunit/test_vba.cxx             |   15 ++++-----
 basic/source/runtime/methods.cxx          |    3 +
 basic/source/sbx/sbxdec.cxx               |    8 +++-
 cli_ure/source/climaker/climaker_app.cxx  |    3 +
 cli_ure/source/climaker/climaker_share.h  |    5 +--
 cli_ure/source/native/native_share.h      |    5 +--
 cli_ure/source/uno_bridge/cli_data.cxx    |   17 ++++++----
 configmgr/source/winreg.cxx               |   25 ++++++++++-----
 dbaccess/source/ui/dlg/adodatalinks.cxx   |   49 +++++++++++++++---------------
 desktop/source/app/crashreport.cxx        |    3 +
 embeddedobj/source/msole/olecomponent.cxx |    5 +--
 embedserv/source/embed/ed_ioleobject.cxx  |    9 ++---
 embedserv/source/embed/ed_ipersiststr.cxx |   17 +++++-----
 embedserv/source/embed/guid.cxx           |   48 ++++++++++++++---------------
 embedserv/source/embed/guid.hxx           |    5 +--
 embedserv/source/embed/tracker.cxx        |    6 ++-
 embedserv/source/inc/stdafx.h             |    6 +++
 include/o3tl/string_view.hxx              |   11 ++++++
 18 files changed, 143 insertions(+), 97 deletions(-)

New commits:
commit bad606febb291022140cb4fb637005cfafff6f98
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Apr 10 10:16:11 2017 +0200

    Clean up uses of SAL_U/SAL_W: embedserv
    
    Change-Id: I5a73acf6ccfc1709e95e55fa15c32ec6dda2657a

diff --git a/embedserv/source/embed/ed_ioleobject.cxx b/embedserv/source/embed/ed_ioleobject.cxx
index 965337547ecd..17905f13929a 100644
--- a/embedserv/source/embed/ed_ioleobject.cxx
+++ b/embedserv/source/embed/ed_ioleobject.cxx
@@ -46,11 +46,9 @@ STDMETHODIMP EmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLES
     if ( !m_aFileName.getLength() )
     {
         m_pDocHolder->setTitle(
-            OUString(
-                SAL_U(szContainerObj)));
+            OUString(reinterpret_cast<sal_Unicode const *>(szContainerObj)));
         m_pDocHolder->setContainerName(
-            OUString(
-                SAL_U(szContainerApp)));
+            OUString(reinterpret_cast<sal_Unicode const *>(szContainerApp)));
     }
 
     return S_OK;
@@ -424,7 +422,8 @@ 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(
+            reinterpret_cast<wchar_t const *>(aPreservFileName.getStr()));
     }
 
     notify( false );
diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx
index 528df24b3bb5..dc8a36ccd2bf 100644
--- a/embedserv/source/embed/ed_ipersiststr.cxx
+++ b/embedserv/source/embed/ed_ipersiststr.cxx
@@ -37,6 +37,7 @@
 #include <com/sun/star/util/XURLTransformer.hpp>
 
 #include <comphelper/processfactory.hxx>
+#include <o3tl/string_view.hxx>
 #include <osl/mutex.hxx>
 #include <osl/diagnose.h>
 #include <sal/types.h>
@@ -399,7 +400,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg )
         if ( m_xFactory.is() && pStg )
         {
             uno::Reference< frame::XModel > aDocument(
-                            m_xFactory->createInstance( getServiceNameFromGUID_Impl( &m_guid ) ),
+                            m_xFactory->createInstance( o3tl::toOUString(getServiceNameFromGUID_Impl( &m_guid )) ),
                             uno::UNO_QUERY );
             if ( aDocument.is() )
             {
@@ -421,11 +422,11 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg )
 
                 if ( hr == S_OK )
                 {
-                    OUString aCurType = getStorageTypeFromGUID_Impl( &m_guid ); // ???
+                    wchar_t const * aCurType = getStorageTypeFromGUID_Impl( &m_guid ); // ???
                     CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
                     hr = WriteFmtUserTypeStg( pStg,
                                             cf,                         // ???
-                                            SAL_W(const_cast<sal_Unicode *>(aCurType.getStr())) );
+                                            const_cast<wchar_t *>(aCurType) );
 
                     if ( hr == S_OK )
                     {
@@ -534,7 +535,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg )
         if ( xTempIn.is() )
         {
             uno::Reference< frame::XModel > aDocument(
-                                                m_xFactory->createInstance( getServiceNameFromGUID_Impl( &m_guid ) ),
+                                                m_xFactory->createInstance( o3tl::toOUString(getServiceNameFromGUID_Impl( &m_guid )) ),
                                                 uno::UNO_QUERY );
             if ( aDocument.is() )
             {
@@ -749,11 +750,11 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ )
 
     if ( FAILED( hr ) || !m_pMasterStorage ) return E_FAIL;
 
-    OUString aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ???
+    o3tl::u16string_view aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ???
     CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
     hr = WriteFmtUserTypeStg( m_pMasterStorage,
                             cf,                         // ???
-                            SAL_W(const_cast<sal_Unicode *>(aCurType.getStr())) );
+                            const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) );
     if ( FAILED( hr ) ) return E_FAIL;
 
     hr = m_pMasterStorage->SetClass( m_guid );
@@ -775,7 +776,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ )
 
 
     uno::Reference< frame::XModel > aDocument(
-                    m_xFactory->createInstance( getServiceNameFromGUID_Impl( &m_guid ) ),
+                    m_xFactory->createInstance( o3tl::toOUString(getServiceNameFromGUID_Impl( &m_guid )) ),
                     uno::UNO_QUERY );
     if ( aDocument.is() )
     {
@@ -804,7 +805,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ )
             cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
             hr = WriteFmtUserTypeStg( m_pMasterStorage,
                                     cf,                         // ???
-                                    SAL_W(const_cast<sal_Unicode *>(aCurType.getStr())) );
+                                    const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) );
 
             if ( SUCCEEDED( hr ) )
             {
diff --git a/embedserv/source/embed/guid.cxx b/embedserv/source/embed/guid.cxx
index 882408f57869..99d69bad0649 100644
--- a/embedserv/source/embed/guid.cxx
+++ b/embedserv/source/embed/guid.cxx
@@ -26,74 +26,74 @@
 
 #include <guid.hxx>
 
-OUString getStorageTypeFromGUID_Impl( GUID* guid )
+wchar_t const * getStorageTypeFromGUID_Impl( GUID* guid )
 {
     if ( *guid == OID_WriterTextServer )
-        return OUString( "soffice.StarWriterDocument.6" );
+        return L"soffice.StarWriterDocument.6";
 
     if ( *guid == OID_WriterOASISTextServer )
-        return OUString( "LibreOffice.WriterDocument.1" );
+        return L"LibreOffice.WriterDocument.1";
 
     if ( *guid == OID_CalcServer )
-        return OUString( "soffice.StarCalcDocument.6" );
+        return L"soffice.StarCalcDocument.6";
 
     if ( *guid == OID_CalcOASISServer )
-        return OUString( "LibreOffice.CalcDocument.1" );
+        return L"LibreOffice.CalcDocument.1";
 
     if ( *guid == OID_DrawingServer )
-        return OUString( "soffice.StarDrawDocument.6" );
+        return L"soffice.StarDrawDocument.6";
 
     if ( *guid == OID_DrawingOASISServer )
-        return OUString( "LibreOffice.DrawDocument.1" );
+        return L"LibreOffice.DrawDocument.1";
 
     if ( *guid == OID_PresentationServer )
-        return OUString( "soffice.StarImpressDocument.6" );
+        return L"soffice.StarImpressDocument.6";
 
     if ( *guid == OID_PresentationOASISServer )
-        return OUString( "LibreOffice.ImpressDocument.1" );
+        return L"LibreOffice.ImpressDocument.1";
 
     if ( *guid == OID_MathServer )
-        return OUString( "soffice.StarMathDocument.6" );
+        return L"soffice.StarMathDocument.6";
 
     if ( *guid == OID_MathOASISServer )
-        return OUString( "LibreOffice.MathDocument.1" );
+        return L"LibreOffice.MathDocument.1";
 
-    return OUString();
+    return L"";
 }
 
-OUString getServiceNameFromGUID_Impl( GUID* guid )
+o3tl::u16string_view getServiceNameFromGUID_Impl( GUID* guid )
 {
     if ( *guid == OID_WriterTextServer )
-        return OUString( "com.sun.star.comp.Writer.TextDocument" );
+        return u"com.sun.star.comp.Writer.TextDocument";
 
     if ( *guid == OID_WriterOASISTextServer )
-        return OUString( "com.sun.star.comp.Writer.TextDocument" );
+        return u"com.sun.star.comp.Writer.TextDocument";
 
     if ( *guid == OID_CalcServer )
-        return OUString( "com.sun.star.comp.Calc.SpreadsheetDocument" );
+        return u"com.sun.star.comp.Calc.SpreadsheetDocument";
 
     if ( *guid == OID_CalcOASISServer )
-        return OUString( "com.sun.star.comp.Calc.SpreadsheetDocument" );
+        return u"com.sun.star.comp.Calc.SpreadsheetDocument";
 
     if ( *guid == OID_DrawingServer )
-        return OUString( "com.sun.star.comp.Draw.DrawingDocument" );
+        return u"com.sun.star.comp.Draw.DrawingDocument";
 
     if ( *guid == OID_DrawingOASISServer )
-        return OUString( "com.sun.star.comp.Draw.DrawingDocument" );
+        return u"com.sun.star.comp.Draw.DrawingDocument";
 
     if ( *guid == OID_PresentationServer )
-        return OUString( "com.sun.star.comp.Draw.PresentationDocument" );
+        return u"com.sun.star.comp.Draw.PresentationDocument";
 
     if ( *guid == OID_PresentationOASISServer )
-        return OUString( "com.sun.star.comp.Draw.PresentationDocument" );
+        return u"com.sun.star.comp.Draw.PresentationDocument";
 
     if ( *guid == OID_MathServer )
-        return OUString( "com.sun.star.comp.Math.FormulaDocument" );
+        return u"com.sun.star.comp.Math.FormulaDocument";
 
     if ( *guid == OID_MathOASISServer )
-        return OUString( "com.sun.star.comp.Math.FormulaDocument" );
+        return u"com.sun.star.comp.Math.FormulaDocument";
 
-    return OUString();
+    return u"";
 }
 
 OUString getFilterNameFromGUID_Impl( GUID* guid )
diff --git a/embedserv/source/embed/guid.hxx b/embedserv/source/embed/guid.hxx
index a970fb4fb8e4..de919aa5ea7c 100644
--- a/embedserv/source/embed/guid.hxx
+++ b/embedserv/source/embed/guid.hxx
@@ -22,15 +22,16 @@
 
 #include <sal/config.h>
 
+#include <o3tl/string_view.hxx>
 #include <rtl/ustring.hxx>
 
 #include <common.h>
 
 OUString getFilterNameFromGUID_Impl( GUID* );
 
-OUString getServiceNameFromGUID_Impl( GUID* );
+o3tl::u16string_view getServiceNameFromGUID_Impl( GUID* );
 
-OUString getStorageTypeFromGUID_Impl( GUID* guid );
+wchar_t const * getStorageTypeFromGUID_Impl( GUID* guid );
 
 #endif
 
diff --git a/embedserv/source/embed/tracker.cxx b/embedserv/source/embed/tracker.cxx
index cc10886d98d1..b39f5499d53f 100644
--- a/embedserv/source/embed/tracker.cxx
+++ b/embedserv/source/embed/tracker.cxx
@@ -19,6 +19,8 @@
 
 #include <sal/config.h>
 
+#include <algorithm>
+
 #include <sal/types.h>
 
 #ifdef _MSC_VER
@@ -540,7 +542,7 @@ void Tracker::DrawTrackerRect(
         // otherwise, size depends on the style
         if (m_nStyle & hatchedBorder)
         {
-            size.cx = size.cy = max(1,GetHandleSize(&rect)-1);
+            size.cx = size.cy = std::max(1,GetHandleSize(&rect)-1);
             InflateRect(&rect,size.cx,size.cy);
         }
         else
@@ -698,7 +700,7 @@ int Tracker::GetHandleSize(LPRECT lpRect) const
     if (!(m_nStyle & resizeOutside))
     {
         // make sure size is small enough for the size of the rect
-        int sizeMax = min(abs(rect->right - rect->left),
+        int sizeMax = std::min(abs(rect->right - rect->left),
                           abs(rect->bottom - rect->top));
         if (size * 2 > sizeMax)
             size = sizeMax / 2;
diff --git a/embedserv/source/inc/stdafx.h b/embedserv/source/inc/stdafx.h
index c056c5bf714a..8e65c0af9c4d 100644
--- a/embedserv/source/inc/stdafx.h
+++ b/embedserv/source/inc/stdafx.h
@@ -35,6 +35,12 @@
 #endif
 #endif
 #include <atlbase.h>
+#if defined max
+#undef max
+#endif
+#if defined min
+#undef min
+#endif
 //You may derive a class from CComModule and use it if you want to override
 //something, but do not change the name of _Module
 extern CComModule _Module;
diff --git a/include/o3tl/string_view.hxx b/include/o3tl/string_view.hxx
index 9230909b7edf..ae284b20173d 100644
--- a/include/o3tl/string_view.hxx
+++ b/include/o3tl/string_view.hxx
@@ -862,6 +862,17 @@ template<> struct hash<o3tl::wstring_view> {
 
 }
 
+namespace o3tl {
+
+// LO-specific convenience functions:
+
+// For std::u16string_view, this will be provided by a (LIBO_INTERNAL_ONLY)
+// rtl::OUString constructor:
+inline OUString toOUString(u16string_view s)
+{ return OUString(s.data(), s.size()); }
+
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
commit cf59d64ae2f9321845af669678370d68c52b7985
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Apr 10 10:15:32 2017 +0200

    Clean up uses of SAL_U/SAL_W: embeddedobj
    
    Change-Id: I02c9ed6b4bd92346bbeee1138c49b4bf5b39ad56

diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx
index 0e2f837a0ad9..08fef37640d7 100644
--- a/embeddedobj/source/msole/olecomponent.cxx
+++ b/embeddedobj/source/msole/olecomponent.cxx
@@ -46,6 +46,7 @@
 #include <oleembobj.hxx>
 #include <mtnotification.hxx>
 #include <memory>
+#include <string>
 
 using namespace ::com::sun::star;
 using namespace ::comphelper;
@@ -922,12 +923,12 @@ void OleComponent::InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent )
             hr = pOleLink->GetSourceDisplayName( &pOleStr );
             if ( SUCCEEDED( hr ) && pOleStr )
             {
-                OUString aFilePath( SAL_U(pOleStr) );
+                std::wstring aFilePath( pOleStr );
                 if ( pMalloc )
                     pMalloc->Free( pOleStr );
 
                 hr = OleCreateFromFile( CLSID_NULL,
-                                        reinterpret_cast<LPCWSTR>(aFilePath.getStr()),
+                                        aFilePath.c_str(),
                                         IID_IUnknown,
                                         OLERENDER_DRAW, // OLERENDER_FORMAT
                                         nullptr,
commit 77a57a5cac6018552b2ca8c4a419afeb179e38e2
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Apr 10 10:15:10 2017 +0200

    Clean up uses of SAL_U/SAL_W: desktop
    
    Change-Id: Ie1f5407a347a19c000793bf83e3545d566937d72

diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx
index 678f433906a9..a12249da9096 100644
--- a/desktop/source/app/crashreport.cxx
+++ b/desktop/source/app/crashreport.cxx
@@ -122,7 +122,8 @@ 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(
+        reinterpret_cast<wchar_t const *>(aURL.getStr()));
 #endif
 }
 
commit d3f7146db6854ea844856c0f93a7fc6fb62b71a1
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Apr 10 10:14:55 2017 +0200

    Clean up uses of SAL_U/SAL_W: dbaccess
    
    Change-Id: I08816442e63ccd33148d233f21f3d761bcdde13c

diff --git a/dbaccess/source/ui/dlg/adodatalinks.cxx b/dbaccess/source/ui/dlg/adodatalinks.cxx
index 1039923a2478..2613364bc8ef 100644
--- a/dbaccess/source/ui/dlg/adodatalinks.cxx
+++ b/dbaccess/source/ui/dlg/adodatalinks.cxx
@@ -37,24 +37,10 @@
 
 #include "adodatalinks.hxx"
 
-OLECHAR const * PromptEdit(long hWnd,OLECHAR const * connstr);
-BSTR PromptNew(long hWnd);
+namespace {
 
-OUString getAdoDatalink(long hWnd,OUString& oldLink)
+OUString PromptNew(long hWnd)
 {
-    OUString dataLink;
-    if (!oldLink.isEmpty())
-    {
-        dataLink=SAL_U(PromptEdit(hWnd,SAL_W(oldLink.getStr())));
-    }
-    else
-        dataLink=reinterpret_cast<sal_Unicode *>(PromptNew(hWnd));
-    return dataLink;
-}
-
-BSTR PromptNew(long hWnd)
-{
-    BSTR connstr=nullptr;
     HRESULT hr;
     IDataSourceLocator* dlPrompt = nullptr;
     ADOConnection* piTmpConnection = nullptr;
@@ -73,14 +59,14 @@ BSTR PromptNew(long hWnd)
                     );
     if( FAILED( hr ) )
     {
-        return connstr;
+        return OUString();
     }
 
     dlPrompt->put_hWnd(hWnd);
     if( FAILED( hr ) )
     {
         dlPrompt->Release( );
-        return connstr;
+        return OUString();
     }
 
     // Prompt for connection information.
@@ -89,7 +75,7 @@ BSTR PromptNew(long hWnd)
     if( FAILED( hr ) || !piTmpConnection )
     {
         dlPrompt->Release( );
-        return connstr;
+        return OUString();
     }
 
     hr = piTmpConnection->get_ConnectionString(&_result);
@@ -97,16 +83,16 @@ BSTR PromptNew(long hWnd)
     {
         piTmpConnection->Release( );
         dlPrompt->Release( );
-        return connstr;
+        return OUString();
     }
 
     piTmpConnection->Release( );
     dlPrompt->Release( );
     CoUninitialize();
-    return _result;
+    return OUString(reinterpret_cast<sal_Unicode const *>(_result));
 }
 
-OLECHAR const * PromptEdit(long hWnd,OLECHAR const * connstr)
+OUString PromptEdit(long hWnd, OUString const & connstr)
 {
     HRESULT hr;
     IDataSourceLocator* dlPrompt = nullptr;
@@ -128,7 +114,8 @@ OLECHAR const * PromptEdit(long hWnd,OLECHAR const * connstr)
     }
 
 
-    hr = piTmpConnection->put_ConnectionString(const_cast<BSTR>(connstr));
+    hr = piTmpConnection->put_ConnectionString(
+        const_cast<BSTR>(reinterpret_cast<wchar_t const *>(connstr.getStr())));
     if( FAILED( hr ) )
     {
         piTmpConnection->Release( );
@@ -193,7 +180,21 @@ OLECHAR const * PromptEdit(long hWnd,OLECHAR const * connstr)
     piTmpConnection->Release( );
     dlPrompt->Release( );
     CoUninitialize();
-    return _result;
+    return OUString(reinterpret_cast<sal_Unicode const *>(_result));
+}
+
+}
+
+OUString getAdoDatalink(long hWnd,OUString& oldLink)
+{
+    OUString dataLink;
+    if (!oldLink.isEmpty())
+    {
+        dataLink=PromptEdit(hWnd,oldLink);
+    }
+    else
+        dataLink=PromptNew(hWnd);
+    return dataLink;
 }
 
 #endif
commit 248966215d5b6bcdf893bc603ede1d69e00ca17a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Apr 10 10:14:32 2017 +0200

    Clean up uses of SAL_U/SAL_W: configmgr
    
    Change-Id: I2c3f16b4798246175ff8f3cc22b61f2d5a9967b6

diff --git a/configmgr/source/winreg.cxx b/configmgr/source/winreg.cxx
index 76d7abe15462..a60b345ee06e 100644
--- a/configmgr/source/winreg.cxx
+++ b/configmgr/source/winreg.cxx
@@ -85,7 +85,10 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil
 {
     HKEY hCurKey;
 
-    if(RegOpenKeyExW(hKey, SAL_W(aKeyName.getStr()), 0, KEY_READ, &hCurKey) == ERROR_SUCCESS)
+    if(RegOpenKeyExW(
+           hKey, reinterpret_cast<wchar_t const *>(aKeyName.getStr()), 0,
+           KEY_READ, &hCurKey)
+       == ERROR_SUCCESS)
     {
         DWORD nSubKeys = 0;
         DWORD nValues = 0;
@@ -106,9 +109,13 @@ 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(
+                            reinterpret_cast<sal_Unicode const *>(buffKeyName));
                 else
-                    aSubkeyName = aKeyName + "\\" + OUString(SAL_U(buffKeyName));
+                    aSubkeyName = aKeyName + "\\"
+                        + OUString(
+                            reinterpret_cast<sal_Unicode const *>(buffKeyName));
 
                 //Recursion, until no more subkeys are found
                 dumpWindowsRegistryKey(hKey, aSubkeyName, aFileHandle);
@@ -119,8 +126,8 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil
             // No more subkeys, we are at a leaf
             auto pValueName = std::unique_ptr<wchar_t[]>(
                 new wchar_t[nLongestValueNameLen + 1]);
-            auto pValue = std::unique_ptr<wchar_t[]>(
-                new wchar_t[nLongestValueLen + 1]);
+            auto pValue = std::unique_ptr<unsigned char[]>(
+                new unsigned char[(nLongestValueLen + 1) * sizeof (wchar_t)]);
 
             bool bFinal = false;
             OUString aValue;
@@ -131,15 +138,17 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil
                 DWORD nValueNameLen = nLongestValueNameLen + 1;
                 DWORD nValueLen = nLongestValueLen + 1;
 
-                RegEnumValueW(hCurKey, i, pValueName.get(), &nValueNameLen, nullptr, nullptr, reinterpret_cast<LPBYTE>(pValue.get()), &nValueLen);
+                RegEnumValueW(hCurKey, i, pValueName.get(), &nValueNameLen, nullptr, nullptr, pValue.get(), &nValueLen);
                 const wchar_t wsValue[] = L"Value";
                 const wchar_t wsFinal[] = L"Final";
                 const wchar_t wsType[] = L"Type";
 
                 if(!wcscmp(pValueName.get(), wsValue))
-                    aValue = OUString(SAL_U(pValue.get()));
+                    aValue = OUString(
+                        reinterpret_cast<sal_Unicode const *>(pValue.get()));
                 if (!wcscmp(pValueName.get(), wsType))
-                    aType = OUString(SAL_U(pValue.get()));
+                    aType = OUString(
+                        reinterpret_cast<sal_Unicode const *>(pValue.get()));
                 if(!wcscmp(pValueName.get(), wsFinal) && *reinterpret_cast<DWORD*>(pValue.get()) == 1)
                     bFinal = true;
             }
commit de82b32c4a9b5b2ac0dd9dee712da061bc34c2c3
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Apr 10 10:14:11 2017 +0200

    Clean up uses of SAL_U/SAL_W: cli_ure
    
    Change-Id: I198be4023710206d66135c33fe01e1d9bb859272

diff --git a/cli_ure/source/climaker/climaker_app.cxx b/cli_ure/source/climaker/climaker_app.cxx
index 550b99a9d696..eb0cfefbba11 100644
--- a/cli_ure/source/climaker/climaker_app.cxx
+++ b/cli_ure/source/climaker/climaker_app.cxx
@@ -471,7 +471,8 @@ SAL_IMPLEMENT_MAIN()
         // setup assembly info: xxx todo set more? e.g. avoid strong versioning
         AssemblyName ^ assembly_name = gcnew AssemblyName();
         assembly_name->CodeBase = output_dir;
-        assembly_name->Name = gcnew ::System::String(SAL_W(name.getStr()));
+        assembly_name->Name = gcnew ::System::String(
+            reinterpret_cast<wchar_t const *>(name.getStr()));
         if (kp != nullptr)
             assembly_name->KeyPair= kp;
 
diff --git a/cli_ure/source/climaker/climaker_share.h b/cli_ure/source/climaker/climaker_share.h
index ee36c6831d19..ed7ab256a3ad 100644
--- a/cli_ure/source/climaker/climaker_share.h
+++ b/cli_ure/source/climaker/climaker_share.h
@@ -82,7 +82,8 @@ ref struct Constants
 
 inline ::System::String ^ ustring_to_String( OUString const & ustr )
 {
-    return gcnew ::System::String( SAL_W(ustr.getStr()), 0, ustr.getLength() );
+    return gcnew ::System::String(
+        reinterpret_cast<wchar_t const *>(ustr.getStr()), 0, ustr.getLength());
 }
 
 
@@ -90,7 +91,7 @@ inline OUString String_to_ustring( ::System::String ^ str )
 {
     OSL_ASSERT( sizeof (wchar_t) == sizeof (sal_Unicode) );
     pin_ptr<const wchar_t> chars = PtrToStringChars( str );
-    return OUString( SAL_U(chars), str->Length );
+    return OUString(reinterpret_cast<sal_Unicode const *>(chars), str->Length);
 }
 
 /* If the argument type is a typedef for an interface then the interface
diff --git a/cli_ure/source/native/native_share.h b/cli_ure/source/native/native_share.h
index 5ef576862196..f733d2558c04 100644
--- a/cli_ure/source/native/native_share.h
+++ b/cli_ure/source/native/native_share.h
@@ -35,14 +35,15 @@ namespace util
 
 inline ::System::String ^ ustring_to_String( OUString const & ustr )
 {
-    return gcnew ::System::String( SAL_W(ustr.getStr()), 0, ustr.getLength() );
+    return gcnew ::System::String(
+        reinterpret_cast<wchar_t const *>(ustr.getStr()), 0, ustr.getLength());
 }
 
 inline OUString String_to_ustring( ::System::String ^ str )
 {
     OSL_ASSERT( sizeof (wchar_t) == sizeof (sal_Unicode) );
     pin_ptr<wchar_t const> chars = PtrToStringChars( str );
-    return OUString( SAL_U(chars), str->Length );
+    return OUString(reinterpret_cast<sal_Unicode const *>(chars), str->Length);
 }
 
 template< typename T >
diff --git a/cli_ure/source/uno_bridge/cli_data.cxx b/cli_ure/source/uno_bridge/cli_data.cxx
index 24b3753ef61d..c7c027691a08 100644
--- a/cli_ure/source/uno_bridge/cli_data.cxx
+++ b/cli_ure/source/uno_bridge/cli_data.cxx
@@ -716,9 +716,11 @@ OUString mapCliString(System::String ^ data)
 
     if (data != nullptr)
     {
-        OSL_ASSERT(sizeof(wchar_t) == sizeof(sal_Unicode));
+        static_assert(sizeof(wchar_t) == sizeof(sal_Unicode), "char mismatch");
         pin_ptr<wchar_t const> pdata= PtrToStringChars(data);
-        return OUString(SAL_U(pdata), const_cast<System::String^>(data)->Length);
+        return OUString(
+            reinterpret_cast<sal_Unicode const *>(pdata),
+            const_cast<System::String^>(data)->Length);
     }
     else
     {
@@ -818,8 +820,9 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data,
             {
                 System::String ^s= safe_cast<System::String^>(cli_data);
                 pin_ptr<const wchar_t> pdata= PtrToStringChars(s);
-                rtl_uString_newFromStr_WithLength( (rtl_uString**) uno_data,
-                                                  SAL_U(pdata), s->Length );
+                rtl_uString_newFromStr_WithLength(
+                    reinterpret_cast<rtl_uString **>(uno_data),
+                    reinterpret_cast<sal_Unicode const *>(pdata), s->Length);
             }
             break;
         }
@@ -1294,8 +1297,10 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data,
                             rtl_uString** pStr=  & ((rtl_uString**) &
                                                     ((uno_Sequence*) seq.get())->elements)[i];
                             *pStr= NULL;
-                            rtl_uString_newFromStr_WithLength( pStr, SAL_U(pdata),
-                                                               arStr[i]->Length);
+                            rtl_uString_newFromStr_WithLength(
+                                pStr,
+                                reinterpret_cast<sal_Unicode const *>(pdata),
+                                arStr[i]->Length);
                         }
                         break;
                     }
commit c14ed11d77fcace619b9f63707c6c4dfc3309c6c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Apr 10 10:13:41 2017 +0200

    Clean up uses of SAL_U/SAL_W: basic
    
    Change-Id: I755b3b781c42cc9af61c0b90621d2eb7f544df62

diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index db6267fb9f2f..6638bab883c9 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -139,14 +139,14 @@ void VBATest::testMiscOLEStuff()
         return; // can't do anything, skip test
 
     const int nBufSize = 1024 * 4;
-    sal_Unicode sBuf[nBufSize];
-    SQLGetInstalledDriversW( SAL_W(sBuf), nBufSize, nullptr );
+    wchar_t sBuf[nBufSize];
+    SQLGetInstalledDriversW( sBuf, nBufSize, nullptr );
 
-    const sal_Unicode *pODBCDriverName = sBuf;
+    const wchar_t *pODBCDriverName = sBuf;
     bool bFound = false;
-    for (; wcslen( SAL_W(pODBCDriverName) ) != 0; pODBCDriverName += wcslen( SAL_W(pODBCDriverName) ) + 1 ) {
-        if( wcscmp( SAL_W(pODBCDriverName), L"Microsoft Excel Driver (*.xls)" ) == 0 ||
-            wcscmp( SAL_W(pODBCDriverName), L"Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)" ) == 0 ) {
+    for (; wcslen( pODBCDriverName ) != 0; pODBCDriverName += wcslen( pODBCDriverName ) + 1 ) {
+        if( wcscmp( pODBCDriverName, L"Microsoft Excel Driver (*.xls)" ) == 0 ||
+            wcscmp( pODBCDriverName, L"Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)" ) == 0 ) {
             bFound = true;
             break;
         }
@@ -171,7 +171,8 @@ void VBATest::testMiscOLEStuff()
     sPath = sPath.replaceAll( "/", "\\" );
 
     aArgs[ 0 ] <<= sPath;
-    aArgs[ 1 ] <<= OUString(pODBCDriverName);
+    aArgs[ 1 ] <<= OUString(
+        reinterpret_cast<sal_Unicode const *>(pODBCDriverName));
 
     for ( sal_uInt32  i=0; i<SAL_N_ELEMENTS( macroSource ); ++i )
     {
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 67c0534f6821..bc0da7541f4e 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -416,7 +416,8 @@ RTLFUNC(CurDir)
     wchar_t pBuffer[ _MAX_PATH ];
     if ( _wgetdcwd( nCurDir, pBuffer, _MAX_PATH ) != nullptr )
     {
-        rPar.Get(0)->PutString( OUString( SAL_U(pBuffer) ) );
+        rPar.Get(0)->PutString(
+            OUString( reinterpret_cast<sal_Unicode const *>(pBuffer) ) );
     }
     else
     {
diff --git a/basic/source/sbx/sbxdec.cxx b/basic/source/sbx/sbxdec.cxx
index a7421647bd1b..fa82edd39178 100644
--- a/basic/source/sbx/sbxdec.cxx
+++ b/basic/source/sbx/sbxdec.cxx
@@ -226,11 +226,15 @@ bool SbxDecimal::setString( OUString* pOUString )
                 pBuffer[i] = ',';
             i++;
         }
-        hResult = VarDecFromStr( SAL_W(pBuffer.get()), nLANGID, 0, &maDec );
+        hResult = VarDecFromStr(
+            reinterpret_cast<wchar_t const *>(pBuffer.get()), nLANGID, 0,
+            &maDec );
     }
     else
     {
-        hResult = VarDecFromStr( SAL_W(pOUString->getStr()), nLANGID, 0, &maDec );
+        hResult = VarDecFromStr(
+            reinterpret_cast<wchar_t const *>(pOUString->getStr()), nLANGID, 0,
+            &maDec );
     }
     bRet = ( hResult == S_OK );
     return bRet;


More information about the Libreoffice-commits mailing list