From 9551bf5a1ee5c9275a26f8ec4021e0b7f5665176 Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 10 Sep 2010 13:10:07 +0200 Subject: sb129: #i113189# change UNO components to use passive registration --- scripting/source/protocolhandler/exports.dxp | 1 - scripting/source/protocolhandler/makefile.mk | 8 +++++ .../protocolhandler/protocolhandler.component | 34 ++++++++++++++++++++++ scripting/source/protocolhandler/scripthandler.cxx | 21 ------------- 4 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 scripting/source/protocolhandler/protocolhandler.component (limited to 'scripting/source/protocolhandler') diff --git a/scripting/source/protocolhandler/exports.dxp b/scripting/source/protocolhandler/exports.dxp index 9630d7e06768..f0e1c69934bc 100644 --- a/scripting/source/protocolhandler/exports.dxp +++ b/scripting/source/protocolhandler/exports.dxp @@ -1,3 +1,2 @@ component_getImplementationEnvironment -component_writeInfo component_getFactory diff --git a/scripting/source/protocolhandler/makefile.mk b/scripting/source/protocolhandler/makefile.mk index c782c1a188f5..ec69c00b209d 100644 --- a/scripting/source/protocolhandler/makefile.mk +++ b/scripting/source/protocolhandler/makefile.mk @@ -61,3 +61,11 @@ DEF1EXPORTFILE= exports.dxp # --- Targets ------------------------------------------------------ .INCLUDE : target.mk + +ALLTAR : $(MISC)/protocolhandler.component + +$(MISC)/protocolhandler.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt protocolhandler.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt protocolhandler.component diff --git a/scripting/source/protocolhandler/protocolhandler.component b/scripting/source/protocolhandler/protocolhandler.component new file mode 100644 index 000000000000..db177a896ca4 --- /dev/null +++ b/scripting/source/protocolhandler/protocolhandler.component @@ -0,0 +1,34 @@ + + + + + + + + diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index 1e6adb6e7804..4e81426d7d53 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -537,27 +537,6 @@ extern "C" *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; } - sal_Bool SAL_CALL component_writeInfo( void * pServiceManager , - void * pRegistryKey ) - { - (void)pServiceManager; - - Reference< css::registry::XRegistryKey > xKey( - reinterpret_cast< css::registry::XRegistryKey* >( pRegistryKey ) ) ; - - ::rtl::OUString aStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); - aStr += - ::scripting_protocolhandler::ScriptProtocolHandler::impl_getStaticImplementationName(); - - aStr += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES" ) ); - Reference< css::registry::XRegistryKey > xNewKey = xKey->createKey( aStr ); - xNewKey->createKey( - ::rtl::OUString::createFromAscii( ::scripting_protocolhandler::MYSERVICENAME ) - ); - - return sal_True; - } - void* SAL_CALL component_getFactory( const sal_Char * pImplementationName , void * pServiceManager , void * pRegistryKey ) -- cgit From af22075998a021d23ec1b266433f239d3200c35d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 4 Nov 2010 10:36:00 +0100 Subject: undoapi: attempt to fix broken Undo contexts after executing a script --- scripting/source/protocolhandler/makefile.mk | 1 + scripting/source/protocolhandler/scripthandler.cxx | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'scripting/source/protocolhandler') 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 4e81426d7d53..7c24b98e5a71 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uri/XUriReference.hpp" @@ -207,6 +208,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 ) { -- cgit From 9d30af3dab07e35b3a02218a693ebd349803d495 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 4 Nov 2010 10:36:15 +0100 Subject: undoapi: replace validateXRef with UNO_QUERY/SET_THROW resp. ENSURE_OR_THROW --- scripting/source/protocolhandler/scripthandler.cxx | 35 +++++----------------- 1 file changed, 7 insertions(+), 28 deletions(-) (limited to 'scripting/source/protocolhandler') diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index 7c24b98e5a71..e9d12be12b5e 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -70,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 { @@ -98,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; } @@ -163,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 ) @@ -183,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" ); @@ -254,16 +253,6 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( bCaughtException = TRUE; } -#ifdef _DEBUG - catch ( ... ) - { - ::rtl::OUString reason = ::rtl::OUString::createFromAscii( - "ScriptProtocolHandler::dispatch: caught unknown exception" ); - - invokeResult <<= reason; - } -#endif - } else { @@ -364,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 @@ -403,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 ); @@ -436,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( -- cgit From 6fb2b3e423f5725752f10b5d8931535b6d2afaa0 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Fri, 14 Jan 2011 16:07:01 +0100 Subject: removetooltypes01: #i112600# remove tooltypes from scripting --- scripting/source/protocolhandler/scripthandler.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripting/source/protocolhandler') diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index 4e81426d7d53..52b626dc5884 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -155,7 +155,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( sal_Bool bSuccess = sal_False; Any invokeResult; - bool bCaughtException = FALSE; + bool bCaughtException = sal_False; Any aException; if ( m_bInitialised ) @@ -246,7 +246,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( invokeResult <<= reason.concat( aException.getValueTypeName() ).concat( e.Message ); - bCaughtException = TRUE; + bCaughtException = sal_True; } #ifdef _DEBUG catch ( ... ) -- cgit