summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-08-07 17:37:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-08-13 13:26:15 +0200
commitb3edf85e0fe6ca03dc26e1bf531be82193bc9627 (patch)
tree62887e38b2f0b06ca8e74fffd126560b5b0c8049 /scripting
parentc78dd0a726b32d922a0d75a26a51d4c30612368c (diff)
warn on load when a document binds an event to a macro
a) treat shared/Scripts equivalently to document scripts This doesn't automatically warn/block running those scripts when used in a freshly loaded document on its own however because DocumentMacroMode::checkMacrosOnLoading will see at... if ( m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() ) that the document contains no macros and flip the allow macros flag to true so that potentially new uses of macros added by the user during the edit are allowed to run b) so, add an additional flag to indicate existence of use of macros in a document c) for odf import, set it when a script:event-listener tag is encountered d) for html import when registerScriptEvents or SwFormatINetFormat::SetMacroTable is called e) for doc import when Read_F_Macro or StoreMacroCmds is called as well for good measure f) for xls import when registerScriptEvent or ScMacroInfo::SetMacro is called g) for oox import when VbaProject::attachMacros is called Change-Id: Ic1203d8ec7dfc217aa217135033ae9db2888e19b Reviewed-on: https://gerrit.libreoffice.org/77131 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/protocolhandler/scripthandler.cxx55
1 files changed, 22 insertions, 33 deletions
diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx
index db3808799111..965827bbde6e 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -132,42 +132,32 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
{
try
{
- css::uno::Reference<css::uri::XUriReferenceFactory> urifac(
- css::uri::UriReferenceFactory::create(m_xContext));
- css::uno::Reference<css::uri::XVndSunStarScriptUrlReference> uri(
- urifac->parse(aURL.Complete), css::uno::UNO_QUERY_THROW);
- auto const loc = uri->getParameter("location");
- bool bIsDocumentScript = loc == "document";
-
- if ( bIsDocumentScript )
- {
- // obtain the component for our security check
- Reference< XEmbeddedScripts > xDocumentScripts;
- if ( getScriptInvocation() )
- xDocumentScripts.set( m_xScriptInvocation->getScriptContainer(), UNO_SET_THROW );
+ // obtain the component for our security check
+ Reference< XEmbeddedScripts > xDocumentScripts;
+ if ( getScriptInvocation() )
+ xDocumentScripts.set( m_xScriptInvocation->getScriptContainer(), UNO_SET_THROW );
- OSL_ENSURE( xDocumentScripts.is(), "ScriptProtocolHandler::dispatchWithNotification: can't do the security check!" );
- if ( !xDocumentScripts.is() || !xDocumentScripts->getAllowMacroExecution() )
+ OSL_ENSURE( xDocumentScripts.is(), "ScriptProtocolHandler::dispatchWithNotification: can't do the security check!" );
+ if ( !xDocumentScripts.is() || !xDocumentScripts->getAllowMacroExecution() )
+ {
+ if ( xListener.is() )
{
- if ( xListener.is() )
+ css::frame::DispatchResultEvent aEvent(
+ static_cast< ::cppu::OWeakObject* >( this ),
+ css::frame::DispatchResultState::FAILURE,
+ invokeResult );
+ try
+ {
+ xListener->dispatchFinished( aEvent ) ;
+ }
+ catch(const RuntimeException &)
{
- css::frame::DispatchResultEvent aEvent(
- static_cast< ::cppu::OWeakObject* >( this ),
- css::frame::DispatchResultState::FAILURE,
- invokeResult );
- try
- {
- xListener->dispatchFinished( aEvent ) ;
- }
- catch(const RuntimeException &)
- {
- TOOLS_WARN_EXCEPTION("scripting",
- "ScriptProtocolHandler::dispatchWithNotification: caught RuntimeException"
- "while dispatchFinished with failure of the execution");
- }
+ TOOLS_WARN_EXCEPTION("scripting",
+ "ScriptProtocolHandler::dispatchWithNotification: caught RuntimeException"
+ "while dispatchFinished with failure of the execution");
}
- return;
}
+ return;
}
// Creates a ScriptProvider ( if one is not created already )
@@ -204,8 +194,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
// attempt to protect the document against the script tampering with its Undo Context
std::unique_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
- if ( bIsDocumentScript )
- pUndoGuard.reset( new ::framework::DocumentUndoGuard( m_xScriptInvocation ) );
+ pUndoGuard.reset( new ::framework::DocumentUndoGuard( m_xScriptInvocation ) );
bSuccess = false;
while ( !bSuccess )