diff options
Diffstat (limited to 'sc/source/ui/docshell/externalrefmgr.cxx')
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 77 |
1 files changed, 42 insertions, 35 deletions
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index e3293a7eed5b..a0581ec0d1c3 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -61,6 +61,7 @@ #include "sfx2/linkmgr.hxx" #include "tools/urlobj.hxx" #include "unotools/ucbhelper.hxx" +#include "unotools/localfilehelper.hxx" #include <memory> #include <algorithm> @@ -934,26 +935,6 @@ void ScExternalRefCache::getAllNumberFormats(vector<sal_uInt32>& rNumFmts) const rNumFmts.swap(aNumFmts); } -bool ScExternalRefCache::hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const -{ - DocItem* pDoc = getDocItem(nFileId); - if (!pDoc) - return false; - - String aUpperName = ScGlobal::pCharClass->upper(rTabName); - vector<TableName>::const_iterator itrBeg = pDoc->maTableNames.begin(), itrEnd = pDoc->maTableNames.end(); - vector<TableName>::const_iterator itr = ::std::find_if( - itrBeg, itrEnd, TabNameSearchPredicate(aUpperName)); - - return itr != itrEnd; -} - -size_t ScExternalRefCache::getCacheTableCount(sal_uInt16 nFileId) const -{ - DocItem* pDoc = getDocItem(nFileId); - return pDoc ? pDoc->maTables.size() : 0; -} - bool ScExternalRefCache::setCacheDocReferenced( sal_uInt16 nFileId ) { DocItem* pDocItem = getDocItem(nFileId); @@ -1576,16 +1557,6 @@ void ScExternalRefManager::getAllCachedNumberFormats(vector<sal_uInt32>& rNumFmt maRefCache.getAllNumberFormats(rNumFmts); } -bool ScExternalRefManager::hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const -{ - return maRefCache.hasCacheTable(nFileId, rTabName); -} - -size_t ScExternalRefManager::getCacheTableCount(sal_uInt16 nFileId) const -{ - return maRefCache.getCacheTableCount(nFileId); -} - sal_uInt16 ScExternalRefManager::getExternalFileCount() const { return static_cast< sal_uInt16 >( maSrcFiles.size() ); @@ -2026,7 +1997,10 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, Stri return NULL; String aOptions( pFileData->maFilterOptions ); - ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false); + if ( pFileData->maFilterName.Len() ) + rFilter = pFileData->maFilterName; // don't overwrite stored filter with guessed filter + else + ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false); const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName(rFilter); if (!pFileData->maRelativeName.Len()) @@ -2093,10 +2067,18 @@ bool ScExternalRefManager::isFileLoadable(const String& rFile) const if (isOwnDocument(rFile)) return false; - if (utl::UCBContentHelper::IsFolder(rFile)) - return false; + String aPhysical; + if (utl::LocalFileHelper::ConvertURLToPhysicalName(rFile, aPhysical) && aPhysical.Len()) + { + // #i114504# try IsFolder/Exists only for file URLs + + if (utl::UCBContentHelper::IsFolder(rFile)) + return false; - return utl::UCBContentHelper::Exists(rFile); + return utl::UCBContentHelper::Exists(rFile); + } + else + return true; // for http and others, Exists doesn't work, but the URL can still be opened } void ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId) @@ -2111,7 +2093,16 @@ void ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId) return; String aFilter, aOptions; - ScDocumentLoader::GetFilterName(*pFileName, aFilter, aOptions, true, false); + const SrcFileData* pFileData = getExternalFileData(nFileId); + if (pFileData) + { + aFilter = pFileData->maFilterName; + aOptions = pFileData->maFilterOptions; + } + // 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.Len()) + ScDocumentLoader::GetFilterName(*pFileName, aFilter, aOptions, true, false); sfx2::LinkManager* pLinkMgr = mpDoc->GetLinkManager(); ScExternalRefLink* pLink = new ScExternalRefLink(mpDoc, nFileId, aFilter); DBG_ASSERT(pFileName, "ScExternalRefManager::insertExternalFileLink: file name pointer is NULL"); @@ -2344,6 +2335,22 @@ void ScExternalRefManager::resetSrcFileData(const String& rBaseFileUrl) } } +void ScExternalRefManager::updateAbsAfterLoad() +{ + String aOwn( getOwnDocumentName() ); + for (vector<SrcFileData>::iterator itr = maSrcFiles.begin(), itrEnd = maSrcFiles.end(); + itr != itrEnd; ++itr) + { + // update maFileName to the real file name, + // to be called when the original name is no longer needed (after CompileXML) + + itr->maybeCreateRealFileName( aOwn ); + String aReal = itr->maRealFileName; + if (aReal.Len()) + itr->maFileName = aReal; + } +} + void ScExternalRefManager::removeRefCell(ScFormulaCell* pCell) { for_each(maRefCells.begin(), maRefCells.end(), RemoveFormulaCell(pCell)); |