[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - fpicker/source

Stephan Bergmann sbergman at redhat.com
Fri Dec 12 01:56:24 PST 2014


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

New commits:
commit 483e7103e895f4da84aa7de94938b373b5fcd64b
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 b0cfdc4..9716c1e 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);
         }
     }
 


More information about the Libreoffice-commits mailing list