[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sc/inc sc/source

Eike Rathke erack at redhat.com
Wed Feb 21 14:52:59 UTC 2018


 sc/inc/document.hxx              |    5 ++++-
 sc/source/core/data/documen2.cxx |    7 +++++--
 sc/source/core/tool/interpr7.cxx |   28 +++++++++++++++++++++++++++-
 sc/source/ui/unoobj/funcuno.cxx  |    2 +-
 4 files changed, 37 insertions(+), 5 deletions(-)

New commits:
commit ac36e5b90787338c5ebdbd942ad3b12b6831af3f
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 19 23:43:51 2018 +0100

    Resolves: tdf#115710 let css::sheet::FunctionAccess execute WEBSERVICE
    
    ... independent of a LinkManager that is not present in the
    interim FunctionAccess document. FunctionAccess is executed by
    extensions, Add-Ons and macros that the user gave permission
    already.
    
    Change-Id: I9349a59ee24089c3657de7786b49e5e81946f175
    (cherry picked from commit 121fda77b0cc16d54607a1f5f7b26c0f1050284f)
    Reviewed-on: https://gerrit.libreoffice.org/50019
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index d6cd6fd79987..9264a53292bc 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -242,7 +242,8 @@ enum ScDocumentMode
 {
     SCDOCMODE_DOCUMENT,
     SCDOCMODE_CLIP,
-    SCDOCMODE_UNDO
+    SCDOCMODE_UNDO,
+    SCDOCMODE_FUNCTIONACCESS
 };
 
 enum CommentCaptionState
@@ -474,6 +475,7 @@ private:
     bool                bCalculatingFormulaTree;
     bool                bIsClip;
     bool                bIsUndo;
+    bool                bIsFunctionAccess;
     bool                bIsVisible;                     // set from view ctor
 
     bool                bIsEmbedded;                    // display/adjust Embedded area?
@@ -1423,6 +1425,7 @@ public:
     bool               IsClipboard() const                         { return bIsClip; }
     bool               IsUndoEnabled() const                       { return mbUndoEnabled; }
     SC_DLLPUBLIC void  EnableUndo( bool bVal );
+    bool                IsFunctionAccess() const        { return bIsFunctionAccess; }
 
     bool                         IsAdjustHeightLocked() const               { return nAdjustHeightLock != 0; }
     void                         LockAdjustHeight()                          { ++nAdjustHeightLock; }
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index b52ca55ed836..49b3b0f4ab1e 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -183,12 +183,13 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) :
         eHardRecalcState(HardRecalcState::OFF),
         nVisibleTab( 0 ),
         eLinkMode(LM_UNKNOWN),
-        bAutoCalc( eMode == SCDOCMODE_DOCUMENT ),
+        bAutoCalc( eMode == SCDOCMODE_DOCUMENT || eMode == SCDOCMODE_FUNCTIONACCESS ),
         bAutoCalcShellDisabled( false ),
         bForcedFormulaPending( false ),
         bCalculatingFormulaTree( false ),
         bIsClip( eMode == SCDOCMODE_CLIP ),
         bIsUndo( eMode == SCDOCMODE_UNDO ),
+        bIsFunctionAccess( eMode == SCDOCMODE_FUNCTIONACCESS ),
         bIsVisible( false ),
         bIsEmbedded( false ),
         bInsertingFromOtherDoc( false ),
@@ -228,7 +229,9 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) :
 
     eSrcSet = osl_getThreadTextEncoding();
 
-    if ( eMode == SCDOCMODE_DOCUMENT )
+    /* TODO: for SCDOCMODE_FUNCTIONACCESS it might not even be necessary to
+     * have all of these available. */
+    if ( eMode == SCDOCMODE_DOCUMENT || eMode == SCDOCMODE_FUNCTIONACCESS )
     {
         mxPoolHelper = new ScPoolHelper( this );
 
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index 9bb77db8b577..274bb69e5243 100644
--- a/sc/source/core/tool/interpr7.cxx
+++ b/sc/source/core/tool/interpr7.cxx
@@ -256,6 +256,21 @@ static ScWebServiceLink* lcl_GetWebServiceLink(const sfx2::LinkManager* pLinkMgr
     return nullptr;
 }
 
+static bool lcl_FunctionAccessLoadWebServiceLink( OUString& rResult, ScDocument* pDoc, const OUString& rURI )
+{
+    // For FunctionAccess service always force a changed data update.
+    ScWebServiceLink aLink( pDoc, rURI);
+    if (aLink.DataChanged( OUString(), css::uno::Any()) != sfx2::SvBaseLink::UpdateResult::SUCCESS)
+        return false;
+
+    if (!aLink.HasResult())
+        return false;
+
+    rResult = aLink.GetResult();
+
+    return true;
+}
+
 void ScInterpreter::ScWebservice()
 {
     sal_uInt8 nParamCount = GetByte();
@@ -279,7 +294,18 @@ void ScInterpreter::ScWebservice()
 
         if (!mpLinkManager)
         {
-            PushError(FormulaError::NoValue);
+            if (!pDok->IsFunctionAccess() || pDok->HasLinkFormulaNeedingCheck())
+            {
+                PushError( FormulaError::NoValue);
+            }
+            else
+            {
+                OUString aResult;
+                if (lcl_FunctionAccessLoadWebServiceLink( aResult, pDok, aURI))
+                    PushString( aResult);
+                else
+                    PushError( FormulaError::NoValue);
+            }
             return;
         }
 
diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx
index c0c4bebaef52..43fd7ddbb3ba 100644
--- a/sc/source/ui/unoobj/funcuno.cxx
+++ b/sc/source/ui/unoobj/funcuno.cxx
@@ -74,7 +74,7 @@ public:
 
 ScDocument* ScTempDocSource::CreateDocument()
 {
-    ScDocument* pDoc = new ScDocument;                  // SCDOCMODE_DOCUMENT
+    ScDocument* pDoc = new ScDocument( SCDOCMODE_FUNCTIONACCESS );
     pDoc->MakeTable( 0 );
     return pDoc;
 }


More information about the Libreoffice-commits mailing list