[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.3' - fpicker/source

Stephan Bergmann sbergman at redhat.com
Fri Dec 12 02:29:55 PST 2014


 fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx |   38 ++++++++++------
 1 file changed, 25 insertions(+), 13 deletions(-)

New commits:
commit 975c0abd7c019f24b9a4887b78874dadb2e44287
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Dec 12 10:49:28 2014 +0100

    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)

diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
index 22a5b9d..579ec54 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);
         }
     }
 


More information about the Libreoffice-commits mailing list