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

Mike Kaganski mike.kaganski at collabora.com
Mon Jul 31 18:24:52 UTC 2017


 sfx2/source/doc/guisaveas.cxx |   29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

New commits:
commit f0400ead0a1d02c3f714b7df243158cd26489dbe
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Mon Jul 31 15:40:21 2017 +0200

    tdf#109537: treat Temporary Internet Files as temp directory
    
    ... on Windows. Also, when testing against ordinary temp directory,
    use system path, not LibreOffice temp directory (thanks to Aron Budea).
    
    Change-Id: I52ecddc65097d6d64ec45e882cce8f1e7006794d
    Reviewed-on: https://gerrit.libreoffice.org/40594
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 22334f8a003d26c71d772a8e00fc80b7e6d2bef1)
    Reviewed-on: https://gerrit.libreoffice.org/40601
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 50a554530260..7f8542248cc9 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -97,6 +97,15 @@
 #include <com/sun/star/system/SystemShellExecute.hpp>
 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
 
+#include <osl/file.hxx>
+
+#ifdef _WIN32
+#include <Shlobj.h>
+#ifdef GetTempPath
+#undef GetTempPath
+#endif
+#endif
+
 // flags that specify requested operation
 #define EXPORT_REQUESTED            1
 #define PDFEXPORT_REQUESTED         2
@@ -1201,8 +1210,26 @@ OUString ModelData_Impl::GetRecommendedDir( const OUString& aSuggestedDir )
                 aLocation = INetURLObject( SvtPathOptions().GetWorkPath() );
         }
 
+        OUString sLocationURL( aLocation.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+        bool bIsInTempPath( false );
+        OUString sSysTempPath;
+        if( osl::FileBase::getTempDirURL( sSysTempPath ) == osl::FileBase::E_None )
+            bIsInTempPath = !sSysTempPath.isEmpty() && sLocationURL.startsWith( sSysTempPath );
+#ifdef _WIN32
+        if( !bIsInTempPath )
+        {
+            wchar_t sPath[MAX_PATH+1];
+            HRESULT hRes = SHGetFolderPathW( NULL, CSIDL_INTERNET_CACHE, NULL, SHGFP_TYPE_CURRENT, sPath );
+            if( SUCCEEDED(hRes) )
+            {
+                OUString sTempINetFiles;
+                if( osl::FileBase::getFileURLFromSystemPath(reinterpret_cast<sal_Unicode*>(sPath), sTempINetFiles) == osl::FileBase::E_None )
+                    bIsInTempPath = !sTempINetFiles.isEmpty() && sLocationURL.startsWith( sTempINetFiles );
+            }
+        }
+#endif
         // Suggest somewhere other than the system's temp directory
-        if( aLocation.GetMainURL( INetURLObject::DecodeMechanism::NONE ).startsWith( SvtPathOptions().GetTempPath() ) )
+        if( bIsInTempPath )
             aLocation = INetURLObject( SvtPathOptions().GetWorkPath() );
 
         aLocation.setFinalSlash();


More information about the Libreoffice-commits mailing list