[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source

Eike Rathke erack at redhat.com
Thu Jun 15 11:56:16 UTC 2017


 sc/inc/externalrefmgr.hxx                |    2 +-
 sc/source/ui/docshell/externalrefmgr.cxx |   13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 3d6797cde0663f3a558568a26ad19c7b5c98efa7
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Jun 14 23:30:57 2017 +0200

    Resolves: tdf#104875 defer filter detection to first load/update of external
    
     This is a combination of 2 commits.
    
    This could never have been meant
    
    Since commit 67b374980f340faa2695001984aaf98886a32fad
    executing ScDocumentLoader::GetFilterName() twice if there was no stored
    filter, and still executing it if there was one, even if the comment says we
    shouldn't.
    
    (cherry picked from commit 1bc793f8ab8f9b4ce435bd3585f9579df4a11819)
    
    Resolves: tdf#104875 defer filter detection to first load/update of external
    
    Attempting to access all linked external documents right on load time was
    specifically nasty for non-local URIs (unmounted smb, http, ...)
    
    (cherry picked from commit 416752b9e4bc4605c479d3eff7797be9f0ef2a38)
    
    f4a7414dfe36875b505c73b8c963b650eeffe204
    
    Change-Id: Iaf4b88e63b3987fb661df0e9b095f06b29076894
    Reviewed-on: https://gerrit.libreoffice.org/38819
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 27002763d88e..5a63a0030797 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -772,7 +772,7 @@ private:
      */
     ScDocument& cacheNewDocShell( sal_uInt16 nFileId, SrcShell& rSrcShell );
 
-    void maybeLinkExternalFile(sal_uInt16 nFileId);
+    void maybeLinkExternalFile( sal_uInt16 nFileId, bool bDeferFilterDetection = false );
 
     /**
      * Try to create a "real" file name from the relative path.  The original
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index c8680615b789..a83a4799c879 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2479,7 +2479,6 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
         rFilter = pFileData->maFilterName;      // don't overwrite stored filter with guessed filter
     else
         ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false);
-    ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false);
     std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName(rFilter);
 
     if (pFileData->maRelativeName.isEmpty())
@@ -2594,7 +2593,7 @@ bool ScExternalRefManager::isFileLoadable(const OUString& rFile) const
         return true;    // for http and others, Exists doesn't work, but the URL can still be opened
 }
 
-void ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId)
+void ScExternalRefManager::maybeLinkExternalFile( sal_uInt16 nFileId, bool bDeferFilterDetection )
 {
     if (maLinkedDocs.count(nFileId))
         // file already linked, or the link has been broken.
@@ -2614,7 +2613,9 @@ void ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId)
     }
     // If a filter was already set (for example, loading the cached table),
     // don't call GetFilterName which has to access the source file.
-    if (aFilter.isEmpty())
+    // If filter detection is deferred, the next successfull loadSrcDocument()
+    // will update SrcFileData filter name.
+    if (aFilter.isEmpty() && !bDeferFilterDetection)
         ScDocumentLoader::GetFilterName(*pFileName, aFilter, aOptions, true, false);
     sfx2::LinkManager* pLinkMgr = mpDoc->GetLinkManager();
     if (!pLinkMgr)
@@ -2624,8 +2625,8 @@ void ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId)
     }
     ScExternalRefLink* pLink = new ScExternalRefLink(mpDoc, nFileId, aFilter);
     OSL_ENSURE(pFileName, "ScExternalRefManager::maybeLinkExternalFile: file name pointer is NULL");
-    OUString aTmp = aFilter;
-    pLinkMgr->InsertFileLink(*pLink, OBJECT_CLIENT_FILE, *pFileName, &aTmp);
+    pLinkMgr->InsertFileLink(*pLink, OBJECT_CLIENT_FILE, *pFileName,
+            (aFilter.isEmpty() && bDeferFilterDetection ? nullptr : &aFilter));
 
     pLink->SetDoReferesh(false);
     pLink->Update();
@@ -2643,7 +2644,7 @@ void ScExternalRefManager::addFilesToLinkManager()
             "sc.ui", "ScExternalRefManager::addFilesToLinkManager: files overflow");
     const sal_uInt16 nSize = static_cast<sal_uInt16>( std::min<size_t>( maSrcFiles.size(), SAL_MAX_UINT16));
     for (sal_uInt16 nFileId = 0; nFileId < nSize; ++nFileId)
-        maybeLinkExternalFile( nFileId);
+        maybeLinkExternalFile( nFileId, true);
 }
 
 void ScExternalRefManager::SrcFileData::maybeCreateRealFileName(const OUString& rOwnDocName)


More information about the Libreoffice-commits mailing list