diff options
author | Carsten Driesner <cd@openoffice.org> | 2011-02-07 13:06:08 +0100 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2011-02-07 13:06:08 +0100 |
commit | bebf85efd10e676c8a9409c6ebd98a6e767d16f0 (patch) | |
tree | ab9f9265bb021e5eb6fc357e79234bba20bc4b8f /scripting/source/protocolhandler | |
parent | e4ee5496696455f7ef6657c15696f36d3da78659 (diff) | |
parent | a1a2a5a68046e75aba3dfd6ba06083a314f12182 (diff) |
removetooltypes01: Rebase to DEV300m99
Diffstat (limited to 'scripting/source/protocolhandler')
-rw-r--r-- | scripting/source/protocolhandler/makefile.mk | 1 | ||||
-rw-r--r-- | scripting/source/protocolhandler/scripthandler.cxx | 41 |
2 files changed, 14 insertions, 28 deletions
diff --git a/scripting/source/protocolhandler/makefile.mk b/scripting/source/protocolhandler/makefile.mk index ec69c00b209d..5a2e92bbbac3 100644 --- a/scripting/source/protocolhandler/makefile.mk +++ b/scripting/source/protocolhandler/makefile.mk @@ -45,6 +45,7 @@ SHL1TARGET= $(TARGET)$(DLLPOSTFIX) SHL1STDLIBS= \ $(SFXLIB) \ + $(FWELIB) \ $(CPPULIB) \ $(CPPUHELPERLIB) \ $(VCLLIB) \ diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index 52b626dc5884..b1268ada4998 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -49,10 +49,12 @@ #include <sfx2/frame.hxx> #include <sfx2/sfxdlg.hxx> #include <vcl/abstdlg.hxx> +#include <tools/diagnose_ex.h> #include <cppuhelper/factory.hxx> #include <cppuhelper/exc_hlp.hxx> #include <util/util.hxx> +#include <framework/documentundoguard.hxx> #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uri/XUriReference.hpp" @@ -69,7 +71,6 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::script; using namespace ::com::sun::star::script::provider; using namespace ::com::sun::star::document; -using namespace ::scripting_util; namespace scripting_protocolhandler { @@ -97,8 +98,7 @@ void SAL_CALL ScriptProtocolHandler::initialize( throw RuntimeException( temp, Reference< XInterface >() ); } - validateXRef( m_xFactory, - "ScriptProtocolHandler::initialize: No Service Manager available" ); + ENSURE_OR_THROW( m_xFactory.is(), "ScriptProtocolHandler::initialize: No Service Manager available" ); m_bInitialised = true; } @@ -162,7 +162,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( { try { - bool bIsDocumentScript = ( aURL.Complete.indexOf( ::rtl::OUString::createFromAscii( "document" ) ) !=-1 ); + bool bIsDocumentScript = ( aURL.Complete.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "document" ) ) !=-1 ); // TODO: isn't this somewhat strange? This should be a test for a location=document parameter, shouldn't it? if ( bIsDocumentScript ) @@ -182,7 +182,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( Reference< provider::XScript > xFunc = m_xScriptProvider->getScript( aURL.Complete ); - validateXRef( xFunc, + ENSURE_OR_THROW( xFunc.is(), "ScriptProtocolHandler::dispatchWithNotification: validate xFunc - unable to obtain XScript interface" ); @@ -207,6 +207,11 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( } } + // attempt to protect the document against the script tampering with its Undo Context + ::std::auto_ptr< ::framework::DocumentUndoGuard > pUndoGuard; + if ( bIsDocumentScript ) + pUndoGuard.reset( new ::framework::DocumentUndoGuard( m_xScriptInvocation ) ); + bSuccess = sal_False; while ( !bSuccess ) { @@ -248,16 +253,6 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( bCaughtException = sal_True; } -#ifdef _DEBUG - catch ( ... ) - { - ::rtl::OUString reason = ::rtl::OUString::createFromAscii( - "ScriptProtocolHandler::dispatch: caught unknown exception" ); - - invokeResult <<= reason; - } -#endif - } else { @@ -358,13 +353,11 @@ ScriptProtocolHandler::getScriptInvocation() return m_xScriptInvocation.is(); } -void -ScriptProtocolHandler::createScriptProvider() +void ScriptProtocolHandler::createScriptProvider() { if ( m_xScriptProvider.is() ) - { return; - } + try { // first, ask the component supporting the XScriptInvocationContext interface @@ -397,6 +390,7 @@ ScriptProtocolHandler::createScriptProvider() m_xScriptProvider = xSPS->getScriptProvider(); } + // if nothing of this is successful, use the master script provider if ( !m_xScriptProvider.is() ) { Reference< XPropertySet > xProps( m_xFactory, UNO_QUERY_THROW ); @@ -430,15 +424,6 @@ ScriptProtocolHandler::createScriptProvider() ::rtl::OUString temp = OUSTR( "ScriptProtocolHandler::createScriptProvider: " ); throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); } -#ifdef _DEBUG - catch ( ... ) - { - throw RuntimeException( - OUSTR( "ScriptProtocolHandler::createScriptProvider: UnknownException: " ), - Reference< XInterface > () ); - } -#endif - } ScriptProtocolHandler::ScriptProtocolHandler( |