summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-12-12 10:49:28 +0100
committerAndras Timar <andras.timar@collabora.com>2014-12-12 11:17:25 +0100
commite11d83703b39f921cb038f490ca3526c206efddd (patch)
tree8216fc34971f86fa97a2bef0168b9e5bcffef5c5
parent9e9fd1844248e4a3e3d9e1ce40e419e77f557689 (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 (cherry picked from commit e123ffd66088783ce74a7b5f15e9d324b39ecf67)
-rw-r--r--fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx38
1 files changed, 25 insertions, 13 deletions
diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
index 64eb6752e79d..be42d41001f9 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{
@@ -683,12 +705,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 )
@@ -876,12 +893,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())
{
@@ -929,7 +941,7 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest)
FindClose( hFind );
}
else
- hResult = iDialog->AddPlace(pFolder, FDAP_TOP);
+ iDialog->AddPlace(pFolder, FDAP_TOP);
}
}