include/formula/errorcodes.hxx | 4 +++ sc/inc/globstr.hrc | 1 sc/source/core/data/global.cxx | 3 ++ sc/source/core/tool/interpr7.cxx | 35 +++++++++++++++++++++---------- sc/source/ui/docshell/externalrefmgr.cxx | 23 ++++++++++++++------ 5 files changed, 48 insertions(+), 18 deletions(-)
New commits: commit 225a229650dc01350ceb70eb45fc88989ed9dc43 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Jul 9 18:44:42 2019 +1000 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Sun Jul 28 00:22:40 2019 +0200 Postpone filter detection until link update is allowed Change-Id: I85b2185e550f2a133ceb485241ef513b40593e34 Reviewed-on: https://gerrit.libreoffice.org/75301 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 03c708bf085f91480c014d7fa31e7a317b2c7b8f) Reviewed-on: https://gerrit.libreoffice.org/76303 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 48ae556cf485..1dc2be93efc9 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -2154,6 +2154,15 @@ 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) @@ -2365,13 +2374,8 @@ ScDocument* ScExternalRefManager::getInMemorySrcDocument(sal_uInt16 nFileId) return nullptr; // Do not load document until it was allowed - SfxObjectShell* pDocShell = mpDoc->GetDocumentShell(); - if ( pDocShell ) - { - const comphelper::EmbeddedObjectContainer& rContainer = pDocShell->GetEmbeddedObjectContainer(); - if ( !rContainer.getUserAllowsLinkUpdate() ) - return nullptr; - } + if (!IsLinkUpdateAllowedInDoc(*mpDoc)) + return nullptr; ScDocument* pSrcDoc = nullptr; ScDocShell* pShell = static_cast<ScDocShell*>(SfxObjectShell::GetFirst(checkSfxObjectShell<ScDocShell>, false)); @@ -2616,6 +2620,11 @@ void ScExternalRefManager::maybeLinkExternalFile( sal_uInt16 nFileId, bool bDefe aFilter = pFileData->maFilterName; aOptions = pFileData->maFilterOptions; } + + // Filter detection may access external links; defer it until we are allowed + if (!bDeferFilterDetection) + 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. // If filter detection is deferred, the next successful loadSrcDocument() commit c7746e1811f99df12a75c6bff09ebc56d2a2a190 Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Jul 19 17:39:02 2018 +0200 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Sun Jul 28 00:22:22 2019 +0200 Related: tdf#118735 introduce FormulaError::LinkFormulaNeedingCheck (Err:540) To indicate why the result isn't available ("External content disabled") and in future maybe signal to the formula cell that it could keep the hybrid string result, see source code comment. Change-Id: Ic5d336b8489e8776f7b640b7e46815e71d0a82a4 Reviewed-on: https://gerrit.libreoffice.org/57738 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins (cherry picked from commit da9a6f426b61937d9cda17f5be3f82d2e15e6ecd) Reviewed-on: https://gerrit.libreoffice.org/76302 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/include/formula/errorcodes.hxx b/include/formula/errorcodes.hxx index d4324a998db0..7afce495b6de 100644 --- a/include/formula/errorcodes.hxx +++ b/include/formula/errorcodes.hxx @@ -83,6 +83,9 @@ enum class FormulaError : sal_uInt16 MatrixSize = 538, // Bad inline array content, non-value/non-string. BadArrayContent = 539, +// Interpreter: signal result not available because updating links is not +// allowed (yet) and tell to try hybrid string as result. + LinkFormulaNeedingCheck = 540, // Interpreter: NA() not available condition, not a real error NotAvailable = 0x7fff @@ -171,6 +174,7 @@ inline bool isPublishedFormulaError( FormulaError nErr ) return false; case FormulaError::MatrixSize: + case FormulaError::LinkFormulaNeedingCheck: return true; case FormulaError::NotAvailable: diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index 326c9f01c455..09caaf80423c 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -510,6 +510,7 @@ #define STR_TEXT NC_("STR_TEXT", "Text") #define STR_QUERY_PIVOTTABLE_DELTAB NC_("STR_QUERY_PIVOTTABLE_DELTAB", "The selected sheet(s) contain source data of related pivot tables that will be lost. Are you sure you want to delete the selected sheet(s)?") #define STR_ERR_NAME_INVALID_CELL_REF NC_("STR_ERR_NAME_INVALID_CELL_REF", "Invalid name. Reference to a cell, or a range of cells not allowed.") +#define STR_ERR_LONG_LINK_FORMULA_NEEDING_CHECK NC_("STR_ERR_LONG_LINK_FORMULA_NEEDING_CHECK", "External content disabled.") #endif diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index cb5a13ceed0f..819dcb384dc7 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -424,6 +424,9 @@ OUString ScGlobal::GetLongErrorString(FormulaError nErr) case FormulaError::BadArrayContent: pErrNumber = STR_ERR_LONG_BAD_ARRAY_CONTENT; break; + case FormulaError::LinkFormulaNeedingCheck: + pErrNumber = STR_ERR_LONG_LINK_FORMULA_NEEDING_CHECK; + break; case FormulaError::NoValue: pErrNumber = STR_LONG_ERR_NO_VALUE; break; diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx index fcd579a8419b..d67d131d8d22 100644 --- a/sc/source/core/tool/interpr7.cxx +++ b/sc/source/core/tool/interpr7.cxx @@ -320,7 +320,6 @@ void ScInterpreter::ScWebservice() ScWebServiceLink* pLink = lcl_GetWebServiceLink(mpLinkManager, aURI); bool bWasError = (pMyFormulaCell && pMyFormulaCell->GetRawError() != FormulaError::NONE); - bool bLinkFormulaNeedingCheck = false; if (!pLink) { @@ -336,8 +335,7 @@ void ScInterpreter::ScWebservice() //if the document was just loaded, but the ScDdeLink entry was missing, then //don't update this link until the links are updated in response to the users //decision - bLinkFormulaNeedingCheck = pDok->HasLinkFormulaNeedingCheck(); - if (!bLinkFormulaNeedingCheck) + if (!pDok->HasLinkFormulaNeedingCheck()) { pLink->Update(); } @@ -361,7 +359,7 @@ void ScInterpreter::ScWebservice() // check the value if (pLink->HasResult()) PushString(pLink->GetResult()); - else + else if (pDok->HasLinkFormulaNeedingCheck()) { // If this formula cell is recalculated just after load and the // expression is exactly WEBSERVICE("literal_URI") (i.e. no other @@ -371,18 +369,33 @@ void ScInterpreter::ScWebservice() // external links has been disabled." // This will work only once, as the new formula cell result won't // be a hybrid anymore. - if (bLinkFormulaNeedingCheck && pMyFormulaCell && pMyFormulaCell->GetCode()->GetCodeLen() == 2 && - pMyFormulaCell->HasHybridStringResult()) + /* TODO: the FormulaError::LinkFormulaNeedingCheck could be used as + * a signal for the formula cell to keep the hybrid string as + * result of the overall formula *iff* no higher prioritized + * ScRecalcMode than ONLOAD_LENIENT is present in the entire + * document (i.e. the formula result could not be influenced by an + * ONLOAD_MUST or ALWAYS recalc, necessary as we don't track + * interim results of subexpressions that could be compared), which + * also means to track setting ScRecalcMode somehow.. note this is + * just a vague idea so far and might or might not work. */ + if (pMyFormulaCell && pMyFormulaCell->HasHybridStringResult()) { - formula::FormulaToken const * const * pRPN = pMyFormulaCell->GetCode()->GetCode(); - if (pRPN[0]->GetType() == formula::svString && pRPN[1]->GetOpCode() == ocWebservice) - PushString( pMyFormulaCell->GetResultString()); + if (pMyFormulaCell->GetCode()->GetCodeLen() == 2) + { + formula::FormulaToken const * const * pRPN = pMyFormulaCell->GetCode()->GetCode(); + if (pRPN[0]->GetType() == formula::svString && pRPN[1]->GetOpCode() == ocWebservice) + PushString( pMyFormulaCell->GetResultString()); + else + PushError(FormulaError::LinkFormulaNeedingCheck); + } else - PushError(FormulaError::NoValue); + PushError(FormulaError::LinkFormulaNeedingCheck); } else - PushError(FormulaError::NoValue); + PushError(FormulaError::LinkFormulaNeedingCheck); } + else + PushError(FormulaError::NoValue); pDok->EnableIdle(bOldEnabled); mpLinkManager->CloseCachedComps(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits