diff options
author | Eike Rathke <erack@redhat.com> | 2018-02-19 23:43:51 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-02-19 23:53:51 +0100 |
commit | 121fda77b0cc16d54607a1f5f7b26c0f1050284f (patch) | |
tree | d2643dc4ec631567426d602f1ab0f1028c2f7588 | |
parent | b5b2628a280a820c83705f95f2eab561570cfd2d (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
-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 c74e6789cf36..a2e661a76dd0 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -243,7 +243,8 @@ enum ScDocumentMode { SCDOCMODE_DOCUMENT, SCDOCMODE_CLIP, - SCDOCMODE_UNDO + SCDOCMODE_UNDO, + SCDOCMODE_FUNCTIONACCESS }; enum CommentCaptionState @@ -480,6 +481,7 @@ private: bool bCalculatingFormulaTree; bool bIsClip; bool bIsUndo; + bool bIsFunctionAccess; bool bIsVisible; // set from view ctor bool bIsEmbedded; // display/adjust Embedded area? @@ -1433,6 +1435,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 ec2cb2eb6684..2db842f8e78f 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 d4d1e53b5443..01f202642137 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; } |