summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-12-12 10:49:28 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-12-12 10:55:22 +0100
commit483e7103e895f4da84aa7de94938b373b5fcd64b (patch)
treeb7baf45532fa7424421ec0fc19a85fb4195292f5
parent470d96d4e0becff7d1cd23365d94e459086c0675 (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 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);
}
}