[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sc/inc sc/source

Eike Rathke erack at redhat.com
Wed Feb 21 09:12:28 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 392794b9cd5238587cbe5d965aac46bc691a61c6
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.
    
    (cherry picked from commit 121fda77b0cc16d54607a1f5f7b26c0f1050284f)
    
    Change-Id: I9349a59ee24089c3657de7786b49e5e81946f175

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index a40c07509d27..884651a580ab 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -235,7 +235,8 @@ enum ScDocumentMode
 {
     SCDOCMODE_DOCUMENT,
     SCDOCMODE_CLIP,
-    SCDOCMODE_UNDO
+    SCDOCMODE_UNDO,
+    SCDOCMODE_FUNCTIONACCESS
 };
 
 struct ScDocStat
@@ -422,6 +423,7 @@ private:
     bool                bCalculatingFormulaTree;
     bool                bIsClip;
     bool                bIsUndo;
+    bool                bIsFunctionAccess;
     bool                bIsVisible;                     // set from view ctor
 
     bool                bIsEmbedded;                    // display/adjust Embedded area?
@@ -1376,6 +1378,7 @@ public:
     bool            IsClipboard() const                         { return bIsClip; }
     bool            IsUndoEnabled() const                       { return mbUndoEnabled; }
     SC_DLLPUBLIC void EnableUndo( bool bVal );
+    bool            IsFunctionAccess() const                    { return bIsFunctionAccess; }
 
     bool            IsAdjustHeightEnabled() const               { return mbAdjustHeightEnabled; }
     void            EnableAdjustHeight( bool bVal )             { mbAdjustHeightEnabled = bVal; }
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index c6016cc15320..18c42893cd0d 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -180,12 +180,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 ),
@@ -224,7 +225,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 )
     {
         xPoolHelper = new ScPoolHelper( this );
 
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index e2f562848a31..381dd4488ba3 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 e9dd22b0ba0a..76585ab8d585 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