[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - sc/inc sc/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Sat Jul 27 22:22:46 UTC 2019


 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 0cbf9ce40e1e8de3658cd22770b8f701e7b47e62
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Wed Jul 18 18:02:58 2018 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Sun Jul 28 00:21:51 2019 +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
    (cherry picked from commit d2e5283f0caeb87e316040e2db1aade8cc408f62)
    Reviewed-on: https://gerrit.libreoffice.org/76301
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 78eb1f6265b8..af781894b299 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -396,6 +396,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 b43e908352ed..4e64de30c000 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2485,6 +2485,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 7b11e6faddab..fcd579a8419b 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