summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2019-07-11 15:50:07 +0200
committerAndras Timar <andras.timar@collabora.com>2019-08-22 12:33:16 +0200
commitee25ad3358a61ae7143eaf38ae9da196e068b562 (patch)
tree84eac64dd15d3b24e2d0a7612b2a6571e74a183a
parentcf502de3bf9c86d2d5d32f9b4d4c13f1876894c7 (diff)
Postpone loading of all external references, including INDIRECT()
... which can be constructed with an arbitrary URI text string not an svExternal* token type, until link updates are allowed. Reviewed-on: https://gerrit.libreoffice.org/75422 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit b824b23860b2cf533d4f2428d4a750bd72576181) Reviewed-on: https://gerrit.libreoffice.org/76304 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Change-Id: I2ce4de415ff99ace04c083c36c1383d76a4ef40d (cherry picked from commit 31b1d2af8ce01804049168b7b0317d93d77a42d7) (cherry picked from commit e374cd045665226e0af82e1ba787bcb2a3879d31)
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx54
1 files changed, 36 insertions, 18 deletions
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index b854e705d498..ea4279318c55 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -133,11 +133,12 @@ struct UpdateFormulaCell : public unary_function<ScFormulaCell*, void>
{
void operator() (ScFormulaCell* pCell) const
{
- // Check to make sure the cell really contains ocExternalRef.
+ // Check to make sure the cell really contains svExternal*.
// External names, external cell and range references all have a
- // ocExternalRef token.
+ // token of svExternal*. Additionally check for INDIRECT() that can be
+ // called with any constructed URI string.
ScTokenArray* pCode = pCell->GetCode();
- if (!pCode->HasExternalRef())
+ if (!pCode->HasExternalRef() && !pCode->HasOpCode(ocIndirect))
return;
if (pCode->GetCodeError() != FormulaError::NONE)
@@ -1675,6 +1676,17 @@ static std::unique_ptr<ScTokenArray> lcl_fillEmptyMatrix(const ScRange& rRange)
return pArray;
}
+namespace {
+bool isLinkUpdateAllowedInDoc(const ScDocument& rDoc)
+{
+ SfxObjectShell* pDocShell = rDoc.GetDocumentShell();
+ if (!pDocShell)
+ return false;
+
+ return pDocShell->GetEmbeddedObjectContainer().getUserAllowsLinkUpdate();
+}
+}
+
ScExternalRefManager::ScExternalRefManager(ScDocument* pDoc) :
mpDoc(pDoc),
mbInReferenceMarking(false),
@@ -1963,8 +1975,19 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken(
pSrcDoc = getSrcDocument(nFileId);
if (!pSrcDoc)
{
- // Source document not reachable. Throw a reference error.
- pToken.reset(new FormulaErrorToken(FormulaError::NoRef));
+ // Source document not reachable.
+#if 0
+ if (!isLinkUpdateAllowedInDoc(*mpDoc))
+ {
+ // Indicate with specific error.
+ pToken.reset(new FormulaErrorToken(FormulaError::LinkFormulaNeedingCheck));
+ }
+ else
+#endif
+ {
+ // Throw a reference error.
+ pToken.reset(new FormulaErrorToken(FormulaError::NoRef));
+ }
return pToken;
}
@@ -2171,15 +2194,6 @@ void insertRefCellByIterator(
}
}
-bool IsLinkUpdateAllowedInDoc(const ScDocument& rDoc)
-{
- SfxObjectShell* pDocShell = rDoc.GetDocumentShell();
- if (!pDocShell)
- return false;
-
- return pDocShell->GetEmbeddedObjectContainer().getUserAllowsLinkUpdate();
-}
-
}
void ScExternalRefManager::insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell)
@@ -2389,8 +2403,8 @@ ScDocument* ScExternalRefManager::getInMemorySrcDocument(sal_uInt16 nFileId)
if (!pFileName)
return nullptr;
- // Do not load document until it was allowed
- if (!IsLinkUpdateAllowedInDoc(*mpDoc))
+ // Do not load document until it was allowed.
+ if (!isLinkUpdateAllowedInDoc(*mpDoc))
return nullptr;
ScDocument* pSrcDoc = nullptr;
@@ -2499,6 +2513,10 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
if (!isFileLoadable(aFile))
return nullptr;
+ // Do not load document until it was allowed.
+ if (!isLinkUpdateAllowedInDoc(*mpDoc))
+ return nullptr;
+
OUString aOptions = pFileData->maFilterOptions;
if ( !pFileData->maFilterName.isEmpty() )
rFilter = pFileData->maFilterName; // don't overwrite stored filter with guessed filter
@@ -2637,9 +2655,9 @@ void ScExternalRefManager::maybeLinkExternalFile( sal_uInt16 nFileId, bool bDefe
aOptions = pFileData->maFilterOptions;
}
- // Filter detection may access external links; defer it until we are allowed
+ // Filter detection may access external links; defer it until we are allowed.
if (!bDeferFilterDetection)
- bDeferFilterDetection = !IsLinkUpdateAllowedInDoc(*mpDoc);
+ bDeferFilterDetection = !isLinkUpdateAllowedInDoc(*mpDoc);
// If a filter was already set (for example, loading the cached table),
// don't call GetFilterName which has to access the source file.