diff options
author | Eike Rathke <erack@redhat.com> | 2018-02-19 23:43:51 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-21 15:52:48 +0100 |
commit | 4a412bdf0387cc2cb59d656d0738a63a286ec497 (patch) | |
tree | 5aa15a469988e760fc70ca7ed2a59ccd97025543 /sc | |
parent | a8a34468f9988ef7633a7b63f825cc484b5dc60f (diff) |
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/50020
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/document.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 7 | ||||
-rw-r--r-- | sc/source/core/tool/interpr7.cxx | 28 | ||||
-rw-r--r-- | sc/source/ui/unoobj/funcuno.cxx | 2 |
4 files changed, 37 insertions, 5 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index fedd52423c53..f0fc4563fe1d 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 }; enum CommentCaptionState @@ -430,6 +431,7 @@ private: bool bCalculatingFormulaTree; bool bIsClip; bool bIsUndo; + bool bIsFunctionAccess; bool bIsVisible; // set from view ctor bool bIsEmbedded; // display/adjust Embedded area? @@ -1372,6 +1374,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 90afbfdca234..a55f48008bfe 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -181,12 +181,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 ), @@ -225,7 +226,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 9af943e05bca..710bfa9483a0 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 c3b66b9d447f..807608f8e6b6 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; } |