diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-05-11 12:28:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-05-11 15:08:34 +0200 |
commit | b55572c8abe2d01e5d8489b6ff32f72fa32bfea2 (patch) | |
tree | 93ee5f38e761c95b33a13db6ca89556d7bca5fd2 /sfx2 | |
parent | cc08616bbe9178fdba94445a81090dad1a8cd1dc (diff) |
de-duplicate cut and paste function
Change-Id: I9569a10562e50ab5660a5638c518680c58fc97dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93961
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 31 | ||||
-rw-r--r-- | sfx2/source/notify/eventsupplier.cxx | 25 |
2 files changed, 15 insertions, 41 deletions
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 3bb958246670..e3e07dd5c306 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1327,27 +1327,24 @@ ErrCode SfxObjectShell::CallBasic( const OUString& rMacro, return nRet; } -namespace +bool SfxObjectShell::isScriptAccessAllowed( const Reference< XInterface >& _rxScriptContext ) { - bool lcl_isScriptAccessAllowed_nothrow( const Reference< XInterface >& _rxScriptContext ) + try { - try - { - Reference< XEmbeddedScripts > xScripts( _rxScriptContext, UNO_QUERY ); - if ( !xScripts.is() ) - { - Reference< XScriptInvocationContext > xContext( _rxScriptContext, UNO_QUERY_THROW ); - xScripts.set( xContext->getScriptContainer(), UNO_SET_THROW ); - } - - return xScripts->getAllowMacroExecution(); - } - catch( const Exception& ) + Reference< XEmbeddedScripts > xScripts( _rxScriptContext, UNO_QUERY ); + if ( !xScripts.is() ) { - DBG_UNHANDLED_EXCEPTION("sfx.doc"); + Reference< XScriptInvocationContext > xContext( _rxScriptContext, UNO_QUERY_THROW ); + xScripts.set( xContext->getScriptContainer(), UNO_SET_THROW ); } - return false; + + return xScripts->getAllowMacroExecution(); } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("sfx.doc"); + } + return false; } // don't allow LibreLogo to be used with our mouseover/etc dom-alike events @@ -1392,7 +1389,7 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon Any aException; try { - if ( !lcl_isScriptAccessAllowed_nothrow( _rxScriptContext ) ) + if (!isScriptAccessAllowed(_rxScriptContext)) return ERRCODE_IO_ACCESSDENIED; if ( UnTrustedScript(_rScriptURL) ) diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index a8a674d2f531..65a50da3ef75 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -151,29 +151,6 @@ sal_Bool SAL_CALL SfxEvents_Impl::hasElements() return maEventNames.hasElements(); } -namespace -{ - bool lcl_isScriptAccessAllowed_nothrow(const uno::Reference<uno::XInterface>& rxScriptContext) - { - try - { - uno::Reference<document::XEmbeddedScripts> xScripts(rxScriptContext, uno::UNO_QUERY); - if (!xScripts.is()) - { - uno::Reference<document::XScriptInvocationContext> xContext(rxScriptContext, uno::UNO_QUERY_THROW); - xScripts.set(xContext->getScriptContainer(), uno::UNO_SET_THROW); - } - - return xScripts->getAllowMacroExecution(); - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("sfx.doc"); - } - return false; - } -} - void SfxEvents_Impl::Execute( uno::Any const & aEventData, const document::DocumentEvent& aTrigger, SfxObjectShell* pDoc ) { uno::Sequence < beans::PropertyValue > aProperties; @@ -215,7 +192,7 @@ void SfxEvents_Impl::Execute( uno::Any const & aEventData, const document::Docum if (!pDoc) pDoc = SfxObjectShell::Current(); - if (pDoc && !lcl_isScriptAccessAllowed_nothrow(pDoc->GetModel())) + if (pDoc && !SfxObjectShell::isScriptAccessAllowed(pDoc->GetModel())) return; if (aType == STAR_BASIC) |