[Libreoffice-commits] core.git: sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Jul 18 19:42:06 UTC 2018
sc/inc/formulacell.hxx | 2 ++
sc/source/core/data/formulacell.cxx | 5 +++++
sc/source/core/tool/interpr7.cxx | 26 ++++++++++++++++++++++++--
3 files changed, 31 insertions(+), 2 deletions(-)
New commits:
commit d2e5283f0caeb87e316040e2db1aade8cc408f62
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Wed Jul 18 18:02:58 2018 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Wed Jul 18 21:41:43 2018 +0200
Related: tdf#118735 WEBSERVICE preserve the hybrid string result, if possible
Possible only for constant literal URI arguments, as otherwise we
wouldn't know whether the hybrid string result actually matches
the call, and possible only for the very first recalc as the
hybrid string result will be replaced by the calculated result.
However, executing an initial recalc is necessary to add the (then
determined and maybe calculated) URI to the link manager after
having loaded a document.
Change-Id: I67738c13ecce54b43ebb52ea8a8282aebee5f03a
Reviewed-on: https://gerrit.libreoffice.org/57696
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 34c578076d97..8091a00198f5 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -402,6 +402,8 @@ public:
svl::SharedString GetResultString() const;
+ bool HasHybridStringResult() const;
+
/* Sets the shared code array to error state in addition to the cell result */
void SetErrCode( FormulaError n );
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 7377144d8b5b..112d215bc2f7 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2537,6 +2537,11 @@ svl::SharedString ScFormulaCell::GetResultString() const
return aResult.GetString();
}
+bool ScFormulaCell::HasHybridStringResult() const
+{
+ return aResult.GetType() == formula::svHybridCell && !aResult.GetString().isEmpty();
+}
+
void ScFormulaCell::SetResultMatrix( SCCOL nCols, SCROW nRows, const ScConstMatrixRef& pMat, const formula::FormulaToken* pUL )
{
aResult.SetMatrix(nCols, nRows, pMat, pUL);
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index ab8e0092985a..108d5f4445ea 100644
--- a/sc/source/core/tool/interpr7.cxx
+++ b/sc/source/core/tool/interpr7.cxx
@@ -320,6 +320,7 @@ void ScInterpreter::ScWebservice()
ScWebServiceLink* pLink = lcl_GetWebServiceLink(mpLinkManager, aURI);
bool bWasError = (pMyFormulaCell && pMyFormulaCell->GetRawError() != FormulaError::NONE);
+ bool bLinkFormulaNeedingCheck = false;
if (!pLink)
{
@@ -335,7 +336,8 @@ 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
- if (!pDok->HasLinkFormulaNeedingCheck())
+ bLinkFormulaNeedingCheck = pDok->HasLinkFormulaNeedingCheck();
+ if (!bLinkFormulaNeedingCheck)
{
pLink->Update();
}
@@ -360,7 +362,27 @@ void ScInterpreter::ScWebservice()
if (pLink->HasResult())
PushString(pLink->GetResult());
else
- PushError(FormulaError::NoValue);
+ {
+ // If this formula cell is recalculated just after load and the
+ // expression is exactly WEBSERVICE("literal_URI") (i.e. no other
+ // calculation involved, not even a cell reference) and a cached
+ // result is set as hybrid string then use that as result value to
+ // prevent a #VALUE! result due to the "Automatic update of
+ // 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())
+ {
+ formula::FormulaToken const * const * pRPN = pMyFormulaCell->GetCode()->GetCode();
+ if (pRPN[0]->GetType() == formula::svString && pRPN[1]->GetOpCode() == ocWebservice)
+ PushString( pMyFormulaCell->GetResultString());
+ else
+ PushError(FormulaError::NoValue);
+ }
+ else
+ PushError(FormulaError::NoValue);
+ }
pDok->EnableIdle(bOldEnabled);
mpLinkManager->CloseCachedComps();
More information about the Libreoffice-commits
mailing list