diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-29 17:33:15 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-30 19:08:28 +0200 |
commit | c3609f107b16eb888edf284f4637be6cb09234eb (patch) | |
tree | da52e05b5cdf26d5d3a57f510f8b32d8af10a026 | |
parent | tdf#112735: Pivot table: page field displays empty string (diff) | |
download | core-c3609f107b16eb888edf284f4637be6cb09234eb.tar.gz core-c3609f107b16eb888edf284f4637be6cb09234eb.zip |
Use SAL_W/SAL_U instead of reinterpret_cast btwn wchar_t* and sal_Unicode*
This is type-safe, and allows to catch cases where a source type
is changed for some reason, but reinterpret_cast masks that
Change-Id: Ib64b6fa2e22d94a6bba890f0ccc3e20325c6f0a1
Reviewed-on: https://gerrit.libreoffice.org/42961
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
24 files changed, 136 insertions, 158 deletions
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx index 97470dd515a5..39efcb7d5805 100644 --- a/basic/qa/cppunit/test_vba.cxx +++ b/basic/qa/cppunit/test_vba.cxx @@ -233,8 +233,7 @@ void VBATest::testMiscOLEStuff() sPath = sPath.replaceAll( "/", "\\" ); aArgs[ 0 ] <<= sPath; - aArgs[ 1 ] <<= OUString( - reinterpret_cast<sal_Unicode const *>(pODBCDriverName)); + aArgs[ 1 ] <<= OUString(SAL_U(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 cef5dd269a3a..748675bfd272 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -387,8 +387,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( - OUString( reinterpret_cast<sal_Unicode const *>(pBuffer) ) ); + rPar.Get(0)->PutString( SAL_U(pBuffer) ); } else { diff --git a/basic/source/sbx/sbxdec.cxx b/basic/source/sbx/sbxdec.cxx index 99d46128c9da..f546434df434 100644 --- a/basic/source/sbx/sbxdec.cxx +++ b/basic/source/sbx/sbxdec.cxx @@ -227,15 +227,11 @@ bool SbxDecimal::setString( OUString* pOUString ) pBuffer[i] = ','; i++; } - hResult = VarDecFromStr( - reinterpret_cast<wchar_t const *>(pBuffer.get()), nLANGID, 0, - &maDec ); + hResult = VarDecFromStr( SAL_W(pBuffer.get()), nLANGID, 0, &maDec ); } else { - hResult = VarDecFromStr( - reinterpret_cast<wchar_t const *>(pOUString->getStr()), nLANGID, 0, - &maDec ); + hResult = VarDecFromStr( SAL_W(pOUString->getStr()), nLANGID, 0, &maDec ); } bRet = ( hResult == S_OK ); return bRet; @@ -378,7 +374,7 @@ void SbxDecimal::getString( OUString& rString ) i++; } } - rString = reinterpret_cast<const sal_Unicode*>(aBStr); + rString = SAL_U(aBStr); } SysFreeString( aBStr ); diff --git a/configmgr/source/winreg.cxx b/configmgr/source/winreg.cxx index a60b345ee06e..bf30f8045d8f 100644 --- a/configmgr/source/winreg.cxx +++ b/configmgr/source/winreg.cxx @@ -86,7 +86,7 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil HKEY hCurKey; if(RegOpenKeyExW( - hKey, reinterpret_cast<wchar_t const *>(aKeyName.getStr()), 0, + hKey, SAL_W(aKeyName.getStr()), 0, KEY_READ, &hCurKey) == ERROR_SUCCESS) { @@ -109,13 +109,9 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil //Make up full key name if(aKeyName.isEmpty()) - aSubkeyName = aKeyName - + OUString( - reinterpret_cast<sal_Unicode const *>(buffKeyName)); + aSubkeyName = aKeyName + OUString(SAL_U(buffKeyName)); else - aSubkeyName = aKeyName + "\\" - + OUString( - reinterpret_cast<sal_Unicode const *>(buffKeyName)); + aSubkeyName = aKeyName + "\\" + OUString(SAL_U(buffKeyName)); //Recursion, until no more subkeys are found dumpWindowsRegistryKey(hKey, aSubkeyName, aFileHandle); @@ -126,8 +122,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<unsigned char[]>( - new unsigned char[(nLongestValueLen + 1) * sizeof (wchar_t)]); + auto pValue = std::unique_ptr<wchar_t[]>( + new wchar_t[nLongestValueLen/sizeof(wchar_t) + 1]); bool bFinal = false; OUString aValue; @@ -138,18 +134,16 @@ 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, pValue.get(), &nValueLen); + RegEnumValueW(hCurKey, i, pValueName.get(), &nValueNameLen, nullptr, nullptr, reinterpret_cast<LPBYTE>(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( - reinterpret_cast<sal_Unicode const *>(pValue.get())); - if (!wcscmp(pValueName.get(), wsType)) - aType = OUString( - reinterpret_cast<sal_Unicode const *>(pValue.get())); - if(!wcscmp(pValueName.get(), wsFinal) && *reinterpret_cast<DWORD*>(pValue.get()) == 1) + aValue = SAL_U(pValue.get()); + else if (!wcscmp(pValueName.get(), wsType)) + aType = SAL_U(pValue.get()); + else if(!wcscmp(pValueName.get(), wsFinal) && *reinterpret_cast<DWORD*>(pValue.get()) == 1) bFinal = true; } sal_Int32 aLastSeparator = aKeyName.lastIndexOf('\\'); diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx index 319b02ad6f52..8094e96ac997 100644 --- a/connectivity/source/drivers/ado/Aolevariant.cxx +++ b/connectivity/source/drivers/ado/Aolevariant.cxx @@ -46,7 +46,7 @@ OLEString::OLEString(const BSTR& _sBStr) } OLEString::OLEString(const OUString& _sBStr) { - m_sStr = ::SysAllocString(reinterpret_cast<LPCOLESTR>(_sBStr.getStr())); + m_sStr = ::SysAllocString(SAL_W(_sBStr.getStr())); } OLEString::~OLEString() { @@ -57,7 +57,7 @@ OLEString& OLEString::operator=(const OUString& _rSrc) { if(m_sStr) ::SysFreeString(m_sStr); - m_sStr = ::SysAllocString(reinterpret_cast<LPCOLESTR>(_rSrc.getStr())); + m_sStr = ::SysAllocString(SAL_W(_rSrc.getStr())); return *this; } OLEString& OLEString::operator=(const OLEString& _rSrc) @@ -79,7 +79,7 @@ OLEString& OLEString::operator=(const BSTR& _rSrc) } OUString OLEString::asOUString() const { - return (m_sStr != nullptr) ? OUString(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(m_sStr)),::SysStringLen(m_sStr)) : OUString(); + return (m_sStr != nullptr) ? OUString(SAL_U(LPCOLESTR(m_sStr)),::SysStringLen(m_sStr)) : OUString(); } BSTR OLEString::asBSTR() const { @@ -121,7 +121,7 @@ OLEVariant::OLEVariant(const OUString& us) { ::VariantInit(this); vt = VT_BSTR; - bstrVal = SysAllocString(reinterpret_cast<LPCOLESTR>(us.getStr())); + bstrVal = SysAllocString(SAL_W(us.getStr())); } OLEVariant::~OLEVariant() { @@ -277,7 +277,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(reinterpret_cast<LPCOLESTR>(us.getStr())); + bstrVal = ::SysAllocString(SAL_W(us.getStr())); } void OLEVariant::setNoArg() { @@ -377,7 +377,7 @@ void OLEVariant::set(double n) OUString OLEVariant::getString() const { if (V_VT(this) == VT_BSTR) - return reinterpret_cast<const sal_Unicode*>(LPCOLESTR(V_BSTR(this))); + return SAL_U(LPCOLESTR(V_BSTR(this))); if(isNull()) return OUString(); @@ -386,7 +386,7 @@ OUString OLEVariant::getString() const varDest.ChangeType(VT_BSTR, this); - return reinterpret_cast<const sal_Unicode*>(LPCOLESTR(V_BSTR(&varDest))); + return SAL_U(LPCOLESTR(V_BSTR(&varDest))); } @@ -692,7 +692,7 @@ css::uno::Any OLEVariant::makeAny() const } case VT_BSTR: { - OUString b(reinterpret_cast<const sal_Unicode*>(bstrVal)); + OUString b(SAL_U(bstrVal)); aValue.setValue( &b, cppu::UnoType<decltype(b)>::get()); break; } diff --git a/dbaccess/source/ui/dlg/adodatalinks.cxx b/dbaccess/source/ui/dlg/adodatalinks.cxx index f2a18c8c8acc..3b1e552f6db0 100644 --- a/dbaccess/source/ui/dlg/adodatalinks.cxx +++ b/dbaccess/source/ui/dlg/adodatalinks.cxx @@ -89,7 +89,7 @@ OUString PromptNew(long hWnd) piTmpConnection->Release( ); dlPrompt->Release( ); CoUninitialize(); - return OUString(reinterpret_cast<sal_Unicode const *>(_result)); + return SAL_U(_result); } OUString PromptEdit(long hWnd, OUString const & connstr) @@ -115,7 +115,7 @@ OUString PromptEdit(long hWnd, OUString const & connstr) hr = piTmpConnection->put_ConnectionString( - const_cast<BSTR>(reinterpret_cast<wchar_t const *>(connstr.getStr()))); + const_cast<BSTR>(SAL_W(connstr.getStr()))); if( FAILED( hr ) ) { piTmpConnection->Release( ); @@ -180,7 +180,7 @@ OUString PromptEdit(long hWnd, OUString const & connstr) piTmpConnection->Release( ); dlPrompt->Release( ); CoUninitialize(); - return OUString(reinterpret_cast<sal_Unicode const *>(_result)); + return SAL_U(_result); } } diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 3ae151b01b21..8fbe0aa6b121 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -262,7 +262,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( reinterpret_cast<LPCWSTR>(aFilePath.getStr()), + return StgOpenStorage( SAL_W(aFilePath.getStr()), nullptr, STGM_READWRITE | STGM_TRANSACTED, // | STGM_DELETEONRELEASE, nullptr, @@ -546,7 +546,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( reinterpret_cast<LPCWSTR>(aTempFilePath.getStr()), STGM_CREATE | STGM_READWRITE | STGM_TRANSACTED | STGM_DELETEONRELEASE, 0, &m_pNativeImpl->m_pIStorage ); + HRESULT hr = StgCreateDocfile( SAL_W(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 +827,7 @@ void OleComponent::CreateObjectFromFile( const OUString& aFileURL ) throw uno::RuntimeException(); // TODO: something dangerous happened HRESULT hr = OleCreateFromFile( CLSID_NULL, - reinterpret_cast<LPCWSTR>(aFilePath.getStr()), + SAL_W(aFilePath.getStr()), IID_IUnknown, OLERENDER_DRAW, // OLERENDER_FORMAT nullptr, @@ -856,7 +856,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( reinterpret_cast<LPCWSTR>(aFilePath.getStr()), + HRESULT hr = OleCreateLinkToFile( SAL_W(aFilePath.getStr()), IID_IUnknown, OLERENDER_DRAW, // OLERENDER_FORMAT nullptr, @@ -1036,7 +1036,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( reinterpret_cast<const sal_Unicode*>(szEle[ nInd ].lpszVerbName) ); + m_aVerbList[nSeqSize-nNum+nInd].VerbName = WinAccToVcl_Impl( SAL_U(szEle[ nInd ].lpszVerbName) ); m_aVerbList[nSeqSize-nNum+nInd].VerbFlags = szEle[ nInd ].fuFlags; m_aVerbList[nSeqSize-nNum+nInd].VerbAttributes = szEle[ nInd ].grfAttribs; } @@ -1076,7 +1076,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", reinterpret_cast<const wchar_t*>( aEmbDocName.getStr() ) ); + m_pNativeImpl->m_pOleObject->SetHostNames( L"app name", SAL_W( aEmbDocName.getStr() ) ); } diff --git a/embedserv/source/embed/ed_ioleobject.cxx b/embedserv/source/embed/ed_ioleobject.cxx index 56ba1ecf5d4c..8e068ba3555d 100644 --- a/embedserv/source/embed/ed_ioleobject.cxx +++ b/embedserv/source/embed/ed_ioleobject.cxx @@ -44,10 +44,8 @@ STDMETHODIMP EmbedDocument_Impl::SetHostNames( LPCOLESTR szContainerApp, LPCOLES // the code should be ignored for links if ( !m_aFileName.getLength() ) { - m_pDocHolder->setTitle( - OUString(reinterpret_cast<sal_Unicode const *>(szContainerObj))); - m_pDocHolder->setContainerName( - OUString(reinterpret_cast<sal_Unicode const *>(szContainerApp))); + m_pDocHolder->setTitle(SAL_U(szContainerObj)); + m_pDocHolder->setContainerName(SAL_U(szContainerApp)); } return S_OK; @@ -419,8 +417,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( - reinterpret_cast<wchar_t const *>(aPreservFileName.getStr())); + SaveCompleted(SAL_W(aPreservFileName.getStr())); } notify( false ); diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx index 70c8b226a4df..bba4d2d59bc6 100644 --- a/embedserv/source/embed/ed_ipersiststr.cxx +++ b/embedserv/source/embed/ed_ipersiststr.cxx @@ -220,7 +220,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 = OUString( reinterpret_cast<const sal_Unicode*>(pFilePath) ); + aURL.Complete = SAL_U(pFilePath); if ( aTransformer->parseSmart( aURL, OUString() ) ) sDocUrl = aURL.Complete; @@ -429,7 +429,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg ) if ( hr == S_OK ) { - hr = pStg->CreateStream( reinterpret_cast<LPCWSTR>(aOfficeEmbedStreamName.getStr()), + hr = pStg->CreateStream( SAL_W(aOfficeEmbedStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, @@ -437,7 +437,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg ) if ( hr == S_OK && m_pOwnStream ) { - hr = pStg->CreateStream( reinterpret_cast<LPCWSTR>(aExtentStreamName.getStr()), + hr = pStg->CreateStream( SAL_W(aExtentStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, @@ -483,7 +483,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) if ( FAILED( hr ) ) return E_FAIL; DWORD nStreamMode = aStat.grfMode; - hr = pStg->OpenStream( reinterpret_cast<LPCWSTR>(aOfficeEmbedStreamName.getStr()), + hr = pStg->OpenStream( SAL_W(aOfficeEmbedStreamName.getStr()), nullptr, nStreamMode & 0x73, 0, @@ -492,7 +492,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) if ( SUCCEEDED( hr ) ) { - hr = pStg->OpenStream( reinterpret_cast<LPCWSTR>(aExtentStreamName.getStr()), + hr = pStg->OpenStream( SAL_W(aExtentStreamName.getStr()), nullptr, nStreamMode & 0x73, 0, @@ -565,8 +565,8 @@ STDMETHODIMP EmbedDocument_Impl::Load( IStorage *pStg ) { m_pOwnStream = CComPtr< IStream >(); m_pExtStream = CComPtr< IStream >(); - hr = pStg->DestroyElement( reinterpret_cast<LPCWSTR>(aOfficeEmbedStreamName.getStr()) ); - hr = pStg->DestroyElement( reinterpret_cast<LPCWSTR>(aExtentStreamName.getStr()) ); + hr = pStg->DestroyElement( SAL_W(aOfficeEmbedStreamName.getStr()) ); + hr = pStg->DestroyElement( SAL_W(aExtentStreamName.getStr()) ); OSL_ENSURE( SUCCEEDED( hr ), "Can not destroy created stream!" ); if ( FAILED( hr ) ) @@ -595,14 +595,14 @@ STDMETHODIMP EmbedDocument_Impl::Save( IStorage *pStgSave, BOOL fSameAsLoad ) if ( FAILED( hr ) ) return E_FAIL; DWORD nStreamMode = aStat.grfMode; - hr = pStgSave->CreateStream( reinterpret_cast<LPCWSTR>(aOfficeEmbedStreamName.getStr()), + hr = pStgSave->CreateStream( SAL_W(aOfficeEmbedStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, &pTargetStream ); if ( FAILED( hr ) || !pTargetStream ) return E_FAIL; - hr = pStgSave->CreateStream( reinterpret_cast<LPCWSTR>(aExtentStreamName.getStr()), + hr = pStgSave->CreateStream( SAL_W(aExtentStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, @@ -690,14 +690,14 @@ STDMETHODIMP EmbedDocument_Impl::SaveCompleted( IStorage *pStgNew ) if ( FAILED( hr ) ) return E_OUTOFMEMORY; DWORD nStreamMode = aStat.grfMode; - hr = m_pMasterStorage->OpenStream( reinterpret_cast<LPCWSTR>(aOfficeEmbedStreamName.getStr()), + hr = m_pMasterStorage->OpenStream( SAL_W(aOfficeEmbedStreamName.getStr()), nullptr, nStreamMode & 0x73, 0, &m_pOwnStream ); if ( FAILED( hr ) || !m_pOwnStream ) return E_OUTOFMEMORY; - hr = m_pMasterStorage->OpenStream( reinterpret_cast<LPCWSTR>(aExtentStreamName.getStr()), + hr = m_pMasterStorage->OpenStream( SAL_W(aExtentStreamName.getStr()), nullptr, nStreamMode & 0x73, 0, @@ -753,20 +753,20 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? - const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) ); + const_cast<LPOLESTR>( SAL_W(aCurType.data())) ); if ( FAILED( hr ) ) return E_FAIL; hr = m_pMasterStorage->SetClass( m_guid ); if ( FAILED( hr ) ) return E_FAIL; - hr = m_pMasterStorage->CreateStream( reinterpret_cast<LPCWSTR>(aOfficeEmbedStreamName.getStr()), + hr = m_pMasterStorage->CreateStream( SAL_W(aOfficeEmbedStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, &m_pOwnStream ); if ( FAILED( hr ) || !m_pOwnStream ) return E_FAIL; - hr = m_pMasterStorage->CreateStream( reinterpret_cast<LPCWSTR>(aExtentStreamName.getStr()), + hr = m_pMasterStorage->CreateStream( SAL_W(aExtentStreamName.getStr()), STGM_CREATE | ( nStreamMode & 0x73 ), 0, 0, @@ -791,7 +791,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) pszFileName ) ); hr = S_OK; - m_aFileName = OUString( reinterpret_cast<const sal_Unicode*>(pszFileName) ); + m_aFileName = SAL_U(pszFileName); } catch( const uno::Exception& ) { @@ -804,7 +804,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? - const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) ); + const_cast<LPOLESTR>( SAL_W(aCurType.data())) ); if ( SUCCEEDED( hr ) ) { @@ -863,7 +863,7 @@ STDMETHODIMP EmbedDocument_Impl::Save( LPCOLESTR pszFileName, BOOL fRemember ) else { util::URL aURL; - aURL.Complete = OUString( reinterpret_cast<const sal_Unicode*>( pszFileName ) ); + aURL.Complete = SAL_U( pszFileName ); uno::Reference< util::XURLTransformer > aTransformer( util::URLTransformer::create(comphelper::getComponentContext(m_xFactory)) ); @@ -891,7 +891,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 = OUString( reinterpret_cast<const sal_Unicode*>(pszFileName) ); + m_aFileName = SAL_U(pszFileName); return S_OK; } @@ -903,7 +903,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, reinterpret_cast<LPCWSTR>(m_aFileName.getStr()), m_aFileName.getLength() + 1 ); + wcsncpy( *ppszFileName, SAL_W(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 0ef10fb913b0..8dcd911e7034 100644 --- a/extensions/source/config/ldap/ldapaccess.cxx +++ b/extensions/source/config/ldap/ldapaccess.cxx @@ -131,8 +131,8 @@ void LdapConnection::connectSimple() // Do the bind #ifdef _WIN32 LdapErrCode retCode = ldap_simple_bind_sW(mConnection, - reinterpret_cast<wchar_t *>(const_cast<sal_Unicode *>(mLdapDefinition.mAnonUser.getStr())), - reinterpret_cast<wchar_t *>(const_cast<sal_Unicode *>(mLdapDefinition.mAnonCredentials.getStr())) ); + const_cast<PWSTR>(SAL_W(mLdapDefinition.mAnonUser.getStr())), + const_cast<PWSTR>(SAL_W(mLdapDefinition.mAnonCredentials.getStr())) ); #else LdapErrCode retCode = ldap_simple_bind_s(mConnection, OUStringToOString( mLdapDefinition.mAnonUser, RTL_TEXTENCODING_UTF8 ).getStr(), @@ -153,7 +153,7 @@ void LdapConnection::initConnection() if (mLdapDefinition.mPort == 0) mLdapDefinition.mPort = LDAP_PORT; #ifdef _WIN32 - mConnection = ldap_initW(reinterpret_cast<wchar_t *>(const_cast<sal_Unicode *>(mLdapDefinition.mServer.getStr())), + mConnection = ldap_initW(const_cast<PWSTR>(SAL_W(mLdapDefinition.mServer.getStr())), mLdapDefinition.mPort) ; #else mConnection = ldap_init(OUStringToOString( mLdapDefinition.mServer, RTL_TEXTENCODING_UTF8 ).getStr(), @@ -178,9 +178,9 @@ void LdapConnection::initConnection() LdapMessageHolder result; #ifdef _WIN32 LdapErrCode retCode = ldap_search_sW(mConnection, - reinterpret_cast<wchar_t *>(const_cast<sal_Unicode *>(aUserDn.getStr())), + const_cast<PWSTR>(SAL_W(aUserDn.getStr())), LDAP_SCOPE_BASE, - const_cast<PWCHAR>( L"(objectclass=*)" ), + const_cast<PWSTR>( L"(objectclass=*)" ), nullptr, 0, // Attributes + values &result.msg) ; @@ -201,8 +201,8 @@ void LdapConnection::initConnection() while (attr) { PWCHAR * values = ldap_get_valuesW(mConnection, result.msg, attr); if (values) { - const OUString aAttr( reinterpret_cast<sal_Unicode*>( attr ) ); - const OUString aValues( reinterpret_cast<sal_Unicode*>( *values ) ); + const OUString aAttr( SAL_U( attr ) ); + const OUString aValues( SAL_U( *values ) ); data->emplace( aAttr, aValues ); ldap_value_freeW(values); } @@ -243,9 +243,9 @@ void LdapConnection::initConnection() #ifdef _WIN32 PWCHAR attributes [2] = { const_cast<PWCHAR>( L"1.1" ), nullptr }; LdapErrCode retCode = ldap_search_sW(mConnection, - reinterpret_cast<wchar_t *>(const_cast<sal_Unicode *>(mLdapDefinition.mBaseDN.getStr())), + const_cast<PWSTR>(SAL_W(mLdapDefinition.mBaseDN.getStr())), LDAP_SCOPE_SUBTREE, - reinterpret_cast<wchar_t *>(const_cast<sal_Unicode *>(filter.makeStringAndClear().getStr())), attributes, 0, &result.msg) ; + const_cast<PWSTR>(SAL_W(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 +262,7 @@ void LdapConnection::initConnection() #ifdef _WIN32 PWCHAR charsDn = ldap_get_dnW(mConnection, entry) ; - userDn = OUString( reinterpret_cast<const sal_Unicode*>( charsDn ) ); + userDn = OUString( SAL_U( 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 197e635f1937..ccb4004eabf5 100644 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -459,7 +459,7 @@ Any SAL_CALL IUnknownWrapper_Impl::getValue( const OUString& aPropertyName ) if ( SUCCEEDED( pInfo->GetDocumentation( -1, &sName, nullptr, nullptr, nullptr ) ) ) { - OUString sTmp( reinterpret_cast<const sal_Unicode*>(LPCOLESTR(sName))); + OUString sTmp( SAL_U(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( reinterpret_cast<const sal_Unicode*>(LPCOLESTR(sName))); + OUString sLibName( SAL_U(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(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription))); + throw RuntimeException(OUString(SAL_U(excepinfo.bstrDescription))); break; case DISP_E_MEMBERNOTFOUND: - throw UnknownPropertyException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription))); + throw UnknownPropertyException(OUString(SAL_U(excepinfo.bstrDescription))); break; default: - throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription))); + throw RuntimeException(OUString(SAL_U(excepinfo.bstrDescription))); break; } } @@ -1187,7 +1187,7 @@ void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArgument CComBSTR defaultMemberName; if ( SUCCEEDED( pType->GetDocumentation(0, &defaultMemberName, nullptr, nullptr, nullptr ) ) ) { - OUString usName(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(defaultMemberName))); + OUString usName(SAL_U(LPCOLESTR(defaultMemberName))); FuncDesc aDescGet(pType); FuncDesc aDescPut(pType); VarDesc aVarDesc(pType); @@ -1283,7 +1283,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*>(reinterpret_cast<LPCOLESTR>(aName.getStr())); + pNames[0] = const_cast<OLECHAR*>(SAL_W(aName.getStr())); int cNamedArg = 0; for ( size_t nInd = 0; nInd < dispparams.cArgs; nInd++ ) @@ -1295,7 +1295,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*>(reinterpret_cast<LPCOLESTR>(arg.Name.getStr())); + pNames[nSizeAr - 1 - cNamedArg++] = const_cast<OLECHAR*>(SAL_W(arg.Name.getStr())); } } @@ -1422,7 +1422,7 @@ uno::Any SAL_CALL IUnknownWrapper_Impl::directInvoke( const OUString& aName, con break; case DISP_E_EXCEPTION: message = "[automation bridge]: "; - message += OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription), + message += OUString(SAL_U(excepinfo.bstrDescription), ::SysStringLen(excepinfo.bstrDescription)); throw InvocationTargetException(message, Reference<XInterface>(), Any()); break; @@ -1722,7 +1722,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, std::unique_ptr<OLECHAR*[]> saNames(new OLECHAR*[nSizeAr]); OLECHAR ** arNames = saNames.get(); - arNames[0] = const_cast<OLECHAR*>(reinterpret_cast<LPCOLESTR>(sFuncName.getStr())); + arNames[0] = const_cast<OLECHAR*>(SAL_W(sFuncName.getStr())); int cNamedArg = 0; for (size_t iParams = 0; iParams < dispparams.cArgs; iParams ++) @@ -1734,7 +1734,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*>(reinterpret_cast<LPCOLESTR>(arg.Name.getStr())); + arNames[nSizeAr - 1 - cNamedArg++] = const_cast<OLECHAR*>(SAL_W(arg.Name.getStr())); } } @@ -2048,7 +2048,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, break; case DISP_E_EXCEPTION: message = "[automation bridge]: "; - message += OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription), + message += OUString(SAL_U(excepinfo.bstrDescription), ::SysStringLen(excepinfo.bstrDescription)); throw InvocationTargetException(message, Reference<XInterface>(), Any()); @@ -2157,7 +2157,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> (reinterpret_cast<LPCOLESTR>(sFuncName.getStr())); + LPOLESTR lpsz = const_cast<LPOLESTR> (SAL_W(sFuncName.getStr())); HRESULT hr = m_spDispatch->GetIDsOfNames(IID_NULL, &lpsz, 1, LOCALE_USER_DEFAULT, id); return hr == S_OK; } @@ -2184,7 +2184,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(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName))); + OUString sRealName(SAL_U(LPCOLESTR(memberName))); cit itOrg = m_mapComFunc.find(sRealName); OSL_ASSERT(itOrg != m_mapComFunc.end()); // maybe this is a property, if so we need @@ -2252,7 +2252,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(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName)))); + p = m_mapComFunc.equal_range(OUString(SAL_U(LPCOLESTR(memberName)))); } } } @@ -2393,7 +2393,7 @@ void IUnknownWrapper_Impl::buildComTlbIndex() unsigned int pcNames=0; if( SUCCEEDED(pType->GetNames( funcDesc->memid, & memberName, 1, &pcNames))) { - OUString usName(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName))); + OUString usName(SAL_U(LPCOLESTR(memberName))); m_mapComFunc.emplace(usName, i); } else @@ -2420,7 +2420,7 @@ void IUnknownWrapper_Impl::buildComTlbIndex() { if (varDesc->varkind == VAR_DISPATCH) { - OUString usName(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName))); + OUString usName(SAL_U(LPCOLESTR(memberName))); m_mapComFunc.emplace(usName, i); } } diff --git a/extensions/source/ole/servprov.cxx b/extensions/source/ole/servprov.cxx index 76663c49ec28..f3cacec755a7 100644 --- a/extensions/source/ole/servprov.cxx +++ b/extensions/source/ole/servprov.cxx @@ -59,7 +59,7 @@ ProviderOleWrapper_Impl::ProviderOleWrapper_Impl(const Reference<XMultiServiceFa { m_guid = *pGuid; - Reference<XInterface> xInt = smgr->createInstance(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier")); + Reference<XInterface> xInt = smgr->createInstance("com.sun.star.bridge.oleautomation.BridgeSupplier"); if (xInt.is()) { @@ -196,7 +196,7 @@ OneInstanceOleWrapper_Impl::OneInstanceOleWrapper_Impl( const Reference<XMultiS { m_guid = *pGuid; - Reference<XInterface> xInt = m_smgr->createInstance(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier")); + Reference<XInterface> xInt = m_smgr->createInstance("com.sun.star.bridge.oleautomation.BridgeSupplier"); if (xInt.is()) { @@ -537,7 +537,7 @@ Reference<XInterface> SAL_CALL OleClient_Impl::createInstance(const OUString& Se o2u_attachCurrentThread(); result = CLSIDFromProgID( - reinterpret_cast<LPCWSTR>(ServiceSpecifier.getStr()), //Pointer to the ProgID + SAL_W(ServiceSpecifier.getStr()), //Pointer to the ProgID &classId); //Pointer to the CLSID @@ -615,7 +615,7 @@ Reference< XInterface > OleClient_Impl::createComWrapperInstance( ) OleServer_Impl::OleServer_Impl( const Reference<XMultiServiceFactory>& smgr): m_smgr( smgr) { - Reference<XInterface> xInt = m_smgr->createInstance(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier")); + Reference<XInterface> xInt = m_smgr->createInstance("com.sun.star.bridge.oleautomation.BridgeSupplier"); if (xInt.is()) { diff --git a/extensions/source/ole/servreg.cxx b/extensions/source/ole/servreg.cxx index bb2b1f839464..70dfe403338d 100644 --- a/extensions/source/ole/servreg.cxx +++ b/extensions/source/ole/servreg.cxx @@ -62,28 +62,28 @@ extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL oleautobridge_component_getFacto OUString aImplName( OUString::createFromAscii( pImplName ) ); Reference< XSingleServiceFactory > xFactory; Sequence<OUString> seqServiceNames; - if (pServiceManager && aImplName.equals( reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverter2") )) + if (pServiceManager && aImplName == "com.sun.star.comp.ole.OleConverter2") { xFactory= createSingleFactory( static_cast< XMultiServiceFactory*>(pServiceManager), - "com.sun.star.comp.ole.OleConverter2", + aImplName, ConverterProvider_CreateInstance2, seqServiceNames ); } - else if (pServiceManager && aImplName.equals( reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverterVar1") )) + else if (pServiceManager && aImplName == "com.sun.star.comp.ole.OleConverterVar1") { xFactory= createSingleFactory( static_cast<XMultiServiceFactory*>(pServiceManager), - "com.sun.star.comp.ole.OleConverterVar1", + aImplName, ConverterProvider_CreateInstanceVar1, seqServiceNames ); } - else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleClient"))) + else if(pServiceManager && aImplName == "com.sun.star.comp.ole.OleClient") { xFactory= createSingleFactory( static_cast< XMultiServiceFactory*>(pServiceManager), - "com.sun.star.comp.ole.OleClient", + aImplName, OleClient_CreateInstance, seqServiceNames ); } - else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleServer"))) + else if(pServiceManager && aImplName == "com.sun.star.comp.ole.OleServer") { xFactory= createOneInstanceFactory( static_cast< XMultiServiceFactory*>(pServiceManager), - "com.sun.star.comp.ole.OleServer", + aImplName, OleServer_CreateInstance, seqServiceNames ); } diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx index 194bdf6942ff..56ab58a1e9e8 100644 --- a/extensions/source/ole/unoconversionutilities.hxx +++ b/extensions/source/ole/unoconversionutilities.hxx @@ -42,13 +42,13 @@ typedef unsigned char BYTE; #define INTERFACE_OLE_WRAPPER_IMPL 1 #define UNO_OBJECT_WRAPPER_REMOTE_OPT 2 -#define INVOCATION_SERVICE reinterpret_cast<const sal_Unicode*>(L"com.sun.star.script.Invocation") +#define INVOCATION_SERVICE "com.sun.star.script.Invocation" // classes for wrapping ole objects #define IUNKNOWN_WRAPPER_IMPL 1 -#define INTERFACE_ADAPTER_FACTORY reinterpret_cast<const sal_Unicode*>(L"com.sun.star.script.InvocationAdapterFactory") +#define INTERFACE_ADAPTER_FACTORY "com.sun.star.script.InvocationAdapterFactory" // COM or JScript objects implementing UNO interfaces have to implement this property #define SUPPORTED_INTERFACES_PROP L"_implementedInterfaces" // Second property without leading underscore for use in VB @@ -812,7 +812,7 @@ void UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny) if (rAny >>= value) { pVariant->vt = VT_BSTR; - pVariant->bstrVal = SysAllocString(reinterpret_cast<LPCOLESTR>(value.getStr())); + pVariant->bstrVal = SysAllocString(SAL_W(value.getStr())); } else { @@ -1507,7 +1507,7 @@ void UnoConversionUtilities<T>::variantToAny( const VARIANT* pVariant, Any& rAny } case VT_BSTR: { - OUString b(reinterpret_cast<const sal_Unicode*>(var.bstrVal)); + OUString b(SAL_U(var.bstrVal)); rAny.setValue( &b, cppu::UnoType<decltype(b)>::get()); break; } @@ -1528,7 +1528,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(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(sName))) + + "A UNO type with the name: " + OUString(SAL_U(LPCOLESTR(sName))) + "does not exist!", nullptr, TypeClass_UNKNOWN, FailReason::TYPE_NOT_SUPPORTED,0); } @@ -1993,8 +1993,7 @@ void UnoConversionUtilities<T>::dispatchExObject2Sequence( const VARIANTARG* pva for( sal_Int32 i= 0; i< length; i++) { OUString ousIndex=OUString::number( i); - OLECHAR* sindex = reinterpret_cast<wchar_t *>( - const_cast<sal_Unicode *>(ousIndex.getStr())); + OLECHAR* sindex = const_cast<OLECHAR *>(SAL_W(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 bd8f386a5b50..cb2634ac6a87 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -84,7 +84,7 @@ static void writeExcepinfo(EXCEPINFO * pInfo, const OUString& message) { pInfo->wCode = UNO_2_OLE_EXCEPTIONCODE; pInfo->bstrSource = SysAllocString(L"[automation bridge] "); - pInfo->bstrDescription = SysAllocString(reinterpret_cast<LPCOLESTR>(message.getStr())); + pInfo->bstrDescription = SysAllocString(SAL_W(message.getStr())); } } @@ -219,7 +219,7 @@ STDMETHODIMP InterfaceOleWrapper_Impl::GetIDsOfNames(REFIID /*riid*/, if (m_xInvocation.is() && (cNames > 0)) { - OUString name(reinterpret_cast<const sal_Unicode*>(rgszNames[0])); + OUString name(SAL_U(rgszNames[0])); NameToIdMap::iterator iter = m_nameToDispIdMap.find(name); if (iter == m_nameToDispIdMap.end()) @@ -538,7 +538,7 @@ bool getType( const BSTR name, Type & type) { bool ret = false; typelib_TypeDescription * pDesc= nullptr; - OUString str( reinterpret_cast<const sal_Unicode*>(name)); + OUString str(SAL_U(name)); typelib_typedescription_getByName( &pDesc, str.pData ); if( pDesc) { @@ -1023,7 +1023,7 @@ HRESULT InterfaceOleWrapper_Impl::doSetProperty( DISPPARAMS * /*pdispparams*/, V pexcepinfo->wCode = UNO_2_OLE_EXCEPTIONCODE; pexcepinfo->bstrSource = SysAllocString(L"any ONE component"); pexcepinfo->bstrDescription = SysAllocString( - reinterpret_cast<LPCOLESTR>(org.getValueType().getTypeName().getStr())); + SAL_W(org.getValueType().getTypeName().getStr())); } ret = DISP_E_EXCEPTION; } @@ -1085,7 +1085,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( reinterpret_cast<const sal_Unicode*>(arg.bstrVal)); + Reference<XIdlClass> classStruct= xRefl->forName(SAL_U(arg.bstrVal)); if( classStruct.is()) { Any anyStruct; @@ -1118,9 +1118,8 @@ HRESULT InterfaceOleWrapper_Impl::InvokeGeneral( DISPID dispidMember, unsigned s Type type; if (!getType(arg.bstrVal, type)) { - writeExcepinfo(pexcepinfo,OUString( - "[automation bridge] A UNO type with the name " + - OUString(reinterpret_cast<const sal_Unicode*>(arg.bstrVal)) + " does not exist!")); + writeExcepinfo(pexcepinfo, "[automation bridge] A UNO type with the name " + + OUString(SAL_U(arg.bstrVal)) + " does not exist!"); return DISP_E_EXCEPTION; } @@ -1256,7 +1255,7 @@ STDMETHODIMP UnoObjectWrapperRemoteOpt::GetIDsOfNames ( REFIID /*riid*/, OLECHA if (m_xInvocation.is() && (cNames > 0)) { - OUString name(reinterpret_cast<const sal_Unicode*>(rgszNames[0])); + OUString name(SAL_U(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/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx index 5befb380f243..81d94c0c1f63 100644 --- a/extensions/source/update/check/updatecheckconfig.cxx +++ b/extensions/source/update/check/updatecheckconfig.cxx @@ -169,7 +169,7 @@ OUString UpdateCheckConfig::getDownloadsDirectory() if (SHGetKnownFolderPath(FOLDERID_Downloads, 0, nullptr, &szPath) == S_OK) { - aRet = OUString( reinterpret_cast< sal_Unicode * >(szPath) ); + aRet = SAL_U(szPath); CoTaskMemFree(szPath); osl::FileBase::getFileURLFromSystemPath( aRet, aRet ); } @@ -197,7 +197,7 @@ OUString UpdateCheckConfig::getAllUsersDirectory() if (TRUE == SHGetSpecialFolderPathW(nullptr, szPath, CSIDL_COMMON_DOCUMENTS, true)) { - aRet = OUString( reinterpret_cast< sal_Unicode * >(szPath) ); + aRet = SAL_U(szPath); osl::FileBase::getFileURLFromSystemPath( aRet, aRet ); } #else diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index d7331e73c364..bc04fe9eaee1 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -169,7 +169,7 @@ static oslProcessError runProcessWithPathSearch(const OUString &rProgName, * */ OUString url; - OUString path(reinterpret_cast<const sal_Unicode*>(_wgetenv(L"PATH"))); + OUString path(SAL_U(_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 c615abd49afd..f435811ec62a 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -59,7 +59,7 @@ bool createFolderItem(OUString const & url, ComPtr<IShellItem> & folder) { return false; } HRESULT res = SHCreateItemFromParsingName( - reinterpret_cast<wchar_t const *>(path.getStr()), nullptr, + SAL_W(path.getStr()), nullptr, IID_PPV_ARGS(&folder)); return SUCCEEDED(res); } @@ -104,11 +104,11 @@ OUString lcl_getURLFromShellItem (IShellItem* pItem) if ( FAILED(hr) ) return OUString(); - sURL = OUString(reinterpret_cast<sal_Unicode*>(pStr)); + sURL = SAL_U(pStr); } else { - ::osl::FileBase::getFileURLFromSystemPath( reinterpret_cast<sal_Unicode*>(pStr), sURL ); + ::osl::FileBase::getFileURLFromSystemPath( SAL_U(pStr), sURL ); } CoTaskMemFree (pStr); @@ -126,8 +126,8 @@ OUString lcl_getURLFromShellItem (IShellItem* pItem) { COMDLG_FILTERSPEC aSpec; - aSpec.pszName = reinterpret_cast<PCWSTR>(aFilter.first.getStr()) ; - aSpec.pszSpec = reinterpret_cast<PCWSTR>(aFilter.second.getStr()); + aSpec.pszName = SAL_W(aFilter.first.getStr()) ; + aSpec.pszSpec = SAL_W(aFilter.second.getStr()); lList.push_back(aSpec); } @@ -495,7 +495,7 @@ static void setLabelToControl(TFileDialogCustomize iCustom, sal_uInt16 nControlI { OUString aLabel = CResourceProvider::getResString(nControlId); aLabel = SOfficeToWindowsLabel(aLabel); - iCustom->SetControlLabel(nControlId, reinterpret_cast<PCWSTR>(aLabel.getStr()) ); + iCustom->SetControlLabel(nControlId, SAL_W(aLabel.getStr()) ); } @@ -660,7 +660,7 @@ void VistaFilePickerImpl::impl_sta_SetTitle(const RequestRef& rRequest) aLock.clear(); // <- SYNCHRONIZED - iDialog->SetTitle(reinterpret_cast<PCWSTR>(sTitle.getStr())); + iDialog->SetTitle(SAL_W(sTitle.getStr())); } @@ -674,7 +674,7 @@ void VistaFilePickerImpl::impl_sta_SetFileName(const RequestRef& rRequest) aLock.clear(); // <- SYNCHRONIZED - iDialog->SetFileName(reinterpret_cast<PCWSTR>(sFileName.getStr())); + iDialog->SetFileName(SAL_W(sFileName.getStr())); } @@ -747,7 +747,7 @@ void VistaFilePickerImpl::impl_sta_SetDefaultName(const RequestRef& rRequest) sFilename = sFilename.copy(0, nSepPos); } - iDialog->SetFileName ( reinterpret_cast<PCWSTR>(sFilename.getStr())); + iDialog->SetFileName (SAL_W(sFilename.getStr())); m_sFilename = sFilename; } @@ -920,7 +920,7 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest) lpFilterExt = wcsrchr( lpFilterExt, '.' ); if ( lpFilterExt ) - aFileURL += reinterpret_cast<const sal_Unicode*>(lpFilterExt); + aFileURL += SAL_U(lpFilterExt); } } } @@ -1067,7 +1067,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, reinterpret_cast<PCWSTR>(sItem.getStr())); + hResult = iCustom->AddControlItem(nId, i, SAL_W(sItem.getStr())); } } break; @@ -1137,7 +1137,7 @@ void VistaFilePickerImpl::impl_sta_SetControlLabel(const RequestRef& rRequest) TFileDialogCustomize iCustom = impl_getCustomizeInterface(); if ( ! iCustom.is()) return; - iCustom->SetControlLabel ( nId, reinterpret_cast<PCWSTR>(sLabel.getStr())); + iCustom->SetControlLabel (nId, SAL_W(sLabel.getStr())); } @@ -1183,7 +1183,7 @@ void VistaFilePickerImpl::impl_SetDefaultExtension( const OUString& currentFilte posOfSemiColon = FilterExt.getLength() - 1; FilterExt = OUString(pFirstExtStart, posOfSemiColon - posOfPoint); - iDialog->SetDefaultExtension ( reinterpret_cast<PCWSTR>(FilterExt.getStr()) ); + iDialog->SetDefaultExtension ( SAL_W(FilterExt.getStr()) ); } } @@ -1205,7 +1205,7 @@ void VistaFilePickerImpl::onAutoExtensionChanged (bool bChecked) PCWSTR pExt = nullptr; if ( bChecked ) { - pExt = reinterpret_cast<PCWSTR>(sExt.getStr()); + pExt = SAL_W(sExt.getStr()); pExt = wcsrchr( pExt, '.' ); if ( pExt ) pExt++; diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 7a9cefd78f34..2dc5b5aa76c7 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -518,7 +518,7 @@ static void do_msvcr_magic(OUString const &jvm_dll) return; } - FILE *f = _wfopen(reinterpret_cast<LPCWSTR>(Module.getStr()), L"rb"); + FILE *f = _wfopen(SAL_W(Module.getStr()), L"rb"); if (!f) { diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx index e92dad2e8bca..055ef736695b 100644 --- a/pyuno/source/module/pyuno_util.cxx +++ b/pyuno/source/module/pyuno_util.cxx @@ -43,7 +43,7 @@ PyRef ustring2PyUnicode( const OUString & str ) ret = PyRef( PyUnicode_FromUnicode( reinterpret_cast<const unsigned short *>(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE ); #else static_assert(sizeof (wchar_t) == Py_UNICODE_SIZE, "bad assumption"); - ret = PyRef( PyUnicode_FromUnicode( reinterpret_cast<wchar_t const *>(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE ); + ret = PyRef( PyUnicode_FromUnicode( SAL_W(str.getStr()), str.getLength() ), SAL_NO_ACQUIRE ); #endif #else OString sUtf8(OUStringToOString(str, RTL_TEXTENCODING_UTF8)); @@ -64,8 +64,7 @@ OUString pyString2ustring( PyObject *pystr ) if( PyUnicode_Check( pystr ) ) { #if Py_UNICODE_SIZE == 2 - ret = OUString( - reinterpret_cast<sal_Unicode const *>(PyUnicode_AS_UNICODE( pystr )) ); + ret = SAL_U(PyUnicode_AS_UNICODE( pystr )); #else #if PY_MAJOR_VERSION >= 3 Py_ssize_t size(0); diff --git a/shell/source/win32/simplemail/smplmailclient.cxx b/shell/source/win32/simplemail/smplmailclient.cxx index c29bc044d0a1..16ef55b6230d 100644 --- a/shell/source/win32/simplemail/smplmailclient.cxx +++ b/shell/source/win32/simplemail/smplmailclient.cxx @@ -81,7 +81,7 @@ namespace /* private */ lret = RegQueryValueW(hkey, nullptr, buff, &sz); if (lret == ERROR_SUCCESS) { - osl::FileBase::getFileURLFromSystemPath(reinterpret_cast<const sal_Unicode*>(buff), altSenddocUrl); + osl::FileBase::getFileURLFromSystemPath(SAL_U(buff), altSenddocUrl); } RegCloseKey(hkey); } diff --git a/winaccessibility/source/UAccCOM/AccEditableText.cxx b/winaccessibility/source/UAccCOM/AccEditableText.cxx index 14eaeea32f61..a2141605867f 100644 --- a/winaccessibility/source/UAccCOM/AccEditableText.cxx +++ b/winaccessibility/source/UAccCOM/AccEditableText.cxx @@ -119,7 +119,7 @@ STDMETHODIMP CAccEditableText::insertText(long offset, BSTR * text) if( !pRXEdtTxt.is() ) return E_FAIL; - ::rtl::OUString ouStr(reinterpret_cast<sal_Unicode const *>(*text)); + ::rtl::OUString ouStr(SAL_U(*text)); if( GetXInterface()->insertText( ouStr, offset ) ) return S_OK; @@ -196,7 +196,7 @@ STDMETHODIMP CAccEditableText::replaceText(long startOffset, long endOffset, BST if( !pRXEdtTxt.is() ) return E_FAIL; - ::rtl::OUString ouStr(reinterpret_cast<sal_Unicode const *>(*text)); + ::rtl::OUString ouStr(SAL_U(*text)); if( GetXInterface()->replaceText( startOffset,endOffset, ouStr) ) return S_OK; @@ -225,7 +225,7 @@ STDMETHODIMP CAccEditableText::setAttributes(long startOffset, long endOffset, B if( !pRXEdtTxt.is() ) return E_FAIL; - ::rtl::OUString ouStr(reinterpret_cast<sal_Unicode const *>(*attributes)); + ::rtl::OUString ouStr(SAL_U(*attributes)); sal_Int32 nIndex = 0; vector< ::rtl::OUString > vecAttr; diff --git a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx index de0eb3873f2a..fbff7f04f588 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx @@ -93,14 +93,11 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: } case CERT_ALT_NAME_RFC822_NAME : arrCertAltNameEntry[i].Type = ExtAltNameType_RFC822_NAME; - arrCertAltNameEntry[i].Value <<= OUString( - reinterpret_cast<sal_Unicode const *>( - pEntry->pwszRfc822Name)); + arrCertAltNameEntry[i].Value <<= OUString(SAL_U(pEntry->pwszRfc822Name)); break; case CERT_ALT_NAME_DNS_NAME : arrCertAltNameEntry[i].Type = ExtAltNameType_DNS_NAME; - arrCertAltNameEntry[i].Value <<= OUString( - reinterpret_cast<sal_Unicode const *>(pEntry->pwszDNSName)); + arrCertAltNameEntry[i].Value <<= OUString(SAL_U(pEntry->pwszDNSName)); break; case CERT_ALT_NAME_DIRECTORY_NAME : { @@ -109,8 +106,7 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: } case CERT_ALT_NAME_URL : arrCertAltNameEntry[i].Type = ExtAltNameType_URL; - arrCertAltNameEntry[i].Value <<= OUString( - reinterpret_cast<sal_Unicode const *>(pEntry->pwszURL)); + arrCertAltNameEntry[i].Value <<= OUString(SAL_U(pEntry->pwszURL)); break; case CERT_ALT_NAME_IP_ADDRESS : { diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index 44b430fe939a..32bb0a82f0a8 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -299,7 +299,7 @@ static OUString get_system_name(const void *pvSystemStore, { ppwszSystemName = static_cast<LPCWSTR>(pvSystemStore); } - return reinterpret_cast<sal_Unicode const *>(ppwszSystemName); + return SAL_U(ppwszSystemName); } extern "C" BOOL WINAPI cert_enum_physical_store_callback(const void *, @@ -309,7 +309,7 @@ extern "C" BOOL WINAPI cert_enum_physical_store_callback(const void *, void *, void *) { - OUString name(reinterpret_cast<sal_Unicode const *>(pwszStoreName)); + OUString name(SAL_U(pwszStoreName)); if (dwFlags & CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG) name += " (implicitly created)"; SAL_INFO("xmlsecurity.xmlsec", " Physical store: " << name); |