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 /fpicker | |
parent | 8a4df9376bf299beb49fe116882ffdbd10b5e02b (diff) |
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>
Diffstat (limited to 'fpicker')
-rw-r--r-- | fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx | 28 |
1 files changed, 14 insertions, 14 deletions
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++; |