diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-12-12 10:49:28 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-12-12 10:49:28 +0100 |
commit | e123ffd66088783ce74a7b5f15e9d324b39ecf67 (patch) | |
tree | 366699fb10343f29ca7fbcc9f0ee431f2d12ad8a /fpicker/source/win32 | |
parent | dbe8aaa9b93950d148d2417b6d8627e696c0db53 (diff) |
fdo#37814: SHCreateItemFromParsingName doesn't like LO's file URLs
...but apparently wants pathnames instead, cf. the other use of it in
WinSalInstance::AddToRecentDocumentList (vcl/win/source/app/salinst.cxx).
Change-Id: Iaa64ff82915f7cbfee55b4389387b226f7adc919
Diffstat (limited to 'fpicker/source/win32')
-rw-r--r-- | fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index b0cfdc412ba9..9716c1e564ee 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -51,6 +51,28 @@ HWND choose_parent_window() return hwnd_parent; } +namespace { + +bool createFolderItem(OUString const & url, ComPtr<IShellItem> & folder) { + OUString path; + if (osl::FileBase::getSystemPathFromFileURL(url, path) + != osl::FileBase::E_None) + { + return false; + } +#if defined __MINGW32__ + HRESULT res = SHCreateItemFromParsingName( + reinterpret_cast<LPCTSTR>(path.getStr()), NULL, IID_IShellItem, + reinterpret_cast<void **>(&folder)); +#else + HRESULT res = SHCreateItemFromParsingName( + path.getStr(), NULL, IID_PPV_ARGS(&folder)); +#endif + return SUCCEEDED(res); +} + +} + namespace fpicker{ namespace win32{ namespace vista{ @@ -681,12 +703,7 @@ void VistaFilePickerImpl::impl_sta_SetDirectory(const RequestRef& rRequest) // <- SYNCHRONIZED ComPtr< IShellItem > pFolder; -#ifdef __MINGW32__ - HRESULT hResult = SHCreateItemFromParsingName ( reinterpret_cast<LPCTSTR>(sDirectory.getStr()), NULL, IID_IShellItem, reinterpret_cast<void**>(&pFolder) ); -#else - HRESULT hResult = SHCreateItemFromParsingName ( sDirectory.getStr(), NULL, IID_PPV_ARGS(&pFolder) ); -#endif - if ( FAILED(hResult) ) + if ( !createFolderItem(sDirectory, pFolder) ) return; if ( m_bInExecute || bForce ) @@ -878,12 +895,7 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest) if( m_sDirectory.getLength()) { ComPtr< IShellItem > pFolder; - #ifdef __MINGW32__ - HRESULT hResult = SHCreateItemFromParsingName ( reinterpret_cast<LPCTSTR>(m_sDirectory.getStr()), NULL, IID_IShellItem, reinterpret_cast<void**>(&pFolder) ); - #else - HRESULT hResult = SHCreateItemFromParsingName ( m_sDirectory.getStr(), NULL, IID_PPV_ARGS(&pFolder) ); - #endif - if ( SUCCEEDED(hResult) ) + if ( createFolderItem(m_sDirectory, pFolder) ) { if (m_sFilename.getLength()) { @@ -931,7 +943,7 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest) FindClose( hFind ); } else - hResult = iDialog->AddPlace(pFolder, FDAP_TOP); + iDialog->AddPlace(pFolder, FDAP_TOP); } } |