From cfafac74a31475087a8a90d629cd4e68a5320266 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 27 Aug 2010 12:13:59 +0200 Subject: tabcontrol: #i113362# impl tabcontrol in awt --- scripting/source/dlgprov/DialogModelProvider.cxx | 196 +++++++++++++++++++++++ scripting/source/dlgprov/DialogModelProvider.hxx | 92 +++++++++++ scripting/source/dlgprov/dlgprov.cxx | 158 +++++++++++------- scripting/source/dlgprov/dlgprov.hxx | 7 + scripting/source/dlgprov/makefile.mk | 1 + 5 files changed, 394 insertions(+), 60 deletions(-) create mode 100644 scripting/source/dlgprov/DialogModelProvider.cxx create mode 100644 scripting/source/dlgprov/DialogModelProvider.hxx (limited to 'scripting/source') diff --git a/scripting/source/dlgprov/DialogModelProvider.cxx b/scripting/source/dlgprov/DialogModelProvider.cxx new file mode 100644 index 000000000000..fe8da6e511d7 --- /dev/null +++ b/scripting/source/dlgprov/DialogModelProvider.cxx @@ -0,0 +1,196 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_scripting.hxx" + +#include "DialogModelProvider.hxx" +#include "dlgprov.hxx" +#include +#include + + +// component helper namespace +namespace comp_DialogModelProvider { + +namespace css = ::com::sun::star; +using namespace ::com::sun::star; +using namespace awt; +using namespace lang; +using namespace uno; +using namespace script; +using namespace beans; + + +// component and service helper functions: +::rtl::OUString SAL_CALL _getImplementationName(); +css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames(); +css::uno::Reference< css::uno::XInterface > SAL_CALL _create( css::uno::Reference< css::uno::XComponentContext > const & context ); + +} // closing component helper namespace + + + +/// anonymous implementation namespace +namespace dlgprov { + +namespace css = ::com::sun::star; +using namespace ::com::sun::star; +using namespace awt; +using namespace lang; +using namespace uno; +using namespace script; +using namespace beans; + + +DialogModelProvider::DialogModelProvider(Reference< XComponentContext > const & context) : + m_xContext(context) +{} + +// lang::XInitialization: +void SAL_CALL DialogModelProvider::initialize(const css::uno::Sequence< uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception) +{ + if ( aArguments.getLength() == 1 ) + { + ::rtl::OUString sURL; + if ( !( aArguments[ 0 ] >>= sURL )) + throw css::lang::IllegalArgumentException(); + // Try any other URL with SimpleFileAccess + Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager(), UNO_QUERY_THROW ); + Reference< ucb::XSimpleFileAccess > xSFI = + Reference< ucb::XSimpleFileAccess >( xSMgr->createInstanceWithContext + ( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), m_xContext ), UNO_QUERY ); + + try + { + Reference< io::XInputStream > xInput = xSFI->openFileRead( sURL ); + Reference< resource::XStringResourceManager > xStringResourceManager; + if ( xInput.is() ) + { + xStringResourceManager = dlgprov::lcl_getStringResourceManager(m_xContext,sURL); + Any aDialogSourceURLAny; + aDialogSourceURLAny <<= sURL; + + m_xDialogModel.set( dlgprov::lcl_createDialogModel( m_xContext,xInput , xStringResourceManager, aDialogSourceURLAny ), UNO_QUERY_THROW); + m_xDialogModelProp.set(m_xDialogModel, UNO_QUERY_THROW); + } + } + catch( Exception& ) + {} + //m_sURL = sURL; + } +} + +// container::XElementAccess: +uno::Type SAL_CALL DialogModelProvider::getElementType() throw (css::uno::RuntimeException) +{ + return m_xDialogModel->getElementType(); +} + +::sal_Bool SAL_CALL DialogModelProvider::hasElements() throw (css::uno::RuntimeException) +{ + return m_xDialogModel->hasElements(); +} + +// container::XNameAccess: +uno::Any SAL_CALL DialogModelProvider::getByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException) +{ + return m_xDialogModel->getByName(aName); +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL DialogModelProvider::getElementNames() throw (css::uno::RuntimeException) +{ + return m_xDialogModel->getElementNames(); +} + +::sal_Bool SAL_CALL DialogModelProvider::hasByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException) +{ + return m_xDialogModel->hasByName(aName); +} + +// container::XNameReplace: +void SAL_CALL DialogModelProvider::replaceByName(const ::rtl::OUString & aName, const uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException) +{ + m_xDialogModel->replaceByName(aName,aElement); +} + +// container::XNameContainer: +void SAL_CALL DialogModelProvider::insertByName(const ::rtl::OUString & aName, const uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException) +{ + m_xDialogModel->insertByName(aName,aElement); +} + +void SAL_CALL DialogModelProvider::removeByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException) +{ + m_xDialogModel->removeByName(aName); +} +uno::Reference< beans::XPropertySetInfo > SAL_CALL DialogModelProvider::getPropertySetInfo( ) throw (uno::RuntimeException) +{ + return m_xDialogModelProp->getPropertySetInfo(); +} +void SAL_CALL DialogModelProvider::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +uno::Any SAL_CALL DialogModelProvider::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return m_xDialogModelProp->getPropertyValue(PropertyName); +} +void SAL_CALL DialogModelProvider::addPropertyChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +void SAL_CALL DialogModelProvider::removePropertyChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +void SAL_CALL DialogModelProvider::addVetoableChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +void SAL_CALL DialogModelProvider::removeVetoableChangeListener( const ::rtl::OUString& ,const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ +} + +// com.sun.star.uno.XServiceInfo: +::rtl::OUString SAL_CALL DialogModelProvider::getImplementationName() throw (css::uno::RuntimeException) +{ + return comp_DialogModelProvider::_getImplementationName(); +} + +::sal_Bool SAL_CALL DialogModelProvider::supportsService(::rtl::OUString const & serviceName) throw (css::uno::RuntimeException) +{ + css::uno::Sequence< ::rtl::OUString > serviceNames = comp_DialogModelProvider::_getSupportedServiceNames(); + for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) { + if (serviceNames[i] == serviceName) + return sal_True; + } + return sal_False; +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL DialogModelProvider::getSupportedServiceNames() throw (css::uno::RuntimeException) +{ + return comp_DialogModelProvider::_getSupportedServiceNames(); +} + +} // closing anonymous implementation namespace + diff --git a/scripting/source/dlgprov/DialogModelProvider.hxx b/scripting/source/dlgprov/DialogModelProvider.hxx new file mode 100644 index 000000000000..bc74dfe661dd --- /dev/null +++ b/scripting/source/dlgprov/DialogModelProvider.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "sal/config.h" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase4.hxx" +#include "com/sun/star/lang/XInitialization.hpp" +#include "com/sun/star/container/XNameContainer.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" + +/// anonymous implementation namespace +namespace dlgprov{ + +namespace css = ::com::sun::star; + +class DialogModelProvider: + public ::cppu::WeakImplHelper4< + css::lang::XInitialization, + css::container::XNameContainer, + css::beans::XPropertySet, + css::lang::XServiceInfo> +{ +public: + explicit DialogModelProvider(css::uno::Reference< css::uno::XComponentContext > const & context); +private: + // ::com::sun::star::lang::XInitialization: + virtual void SAL_CALL initialize(const css::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception); + + // ::com::sun::star::container::XElementAccess: + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException); + + // ::com::sun::star::container::XNameAccess: + virtual ::com::sun::star::uno::Any SAL_CALL getByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException); + virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException); + + // ::com::sun::star::container::XNameReplace: + virtual void SAL_CALL replaceByName(const ::rtl::OUString & aName, const ::com::sun::star::uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException); + + // ::com::sun::star::container::XNameContainer: + virtual void SAL_CALL insertByName(const ::rtl::OUString & aName, const ::com::sun::star::uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException); + virtual void SAL_CALL removeByName(const ::rtl::OUString & Name) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException); + + // ::com::sun::star::lang::XServiceInfo: + virtual ::rtl::OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (css::uno::RuntimeException); + virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: + DialogModelProvider(const DialogModelProvider &); // not defined + DialogModelProvider& operator=(const DialogModelProvider &); // not defined + + // destructor is private and will be called indirectly by the release call virtual ~DialogModelProvider() {} + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::container::XNameContainer> m_xDialogModel; + css::uno::Reference< css::beans::XPropertySet> m_xDialogModelProp; +}; +} // closing anonymous implementation namespace diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx index aa6c6cfb966a..131b69cbf384 100644 --- a/scripting/source/dlgprov/dlgprov.cxx +++ b/scripting/source/dlgprov/dlgprov.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_scripting.hxx" +#include "DialogModelProvider.hxx" #include "dlgprov.hxx" #include "dlgevtatt.hxx" #include @@ -60,20 +61,103 @@ #include using namespace ::com::sun::star; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::script; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::document; +using namespace awt; +using namespace lang; +using namespace uno; +using namespace script; +using namespace beans; +using namespace document; using namespace ::sf_misc; +// component helper namespace +namespace comp_DialogModelProvider +{ + + ::rtl::OUString SAL_CALL _getImplementationName() + { + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogModelProvider")); + } + + uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames() + { + uno::Sequence< ::rtl::OUString > s(1); + s[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDialogModelProvider")); + return s; + } + + uno::Reference< uno::XInterface > SAL_CALL _create(const uno::Reference< uno::XComponentContext > & context) SAL_THROW((uno::Exception)) + { + return static_cast< ::cppu::OWeakObject * >(new dlgprov::DialogModelProvider(context)); + } +} // closing component helper namespace //......................................................................... namespace dlgprov { //......................................................................... static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAscii( "ResourceResolver" ); + + Reference< resource::XStringResourceManager > lcl_getStringResourceManager(const Reference< XComponentContext >& i_xContext,const ::rtl::OUString& i_sURL) + { + INetURLObject aInetObj( i_sURL ); + ::rtl::OUString aDlgName = aInetObj.GetBase(); + aInetObj.removeSegment(); + ::rtl::OUString aDlgLocation = aInetObj.GetMainURL( INetURLObject::NO_DECODE ); + bool bReadOnly = true; + ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); + ::rtl::OUString aComment; + + Sequence aArgs( 6 ); + aArgs[0] <<= aDlgLocation; + aArgs[1] <<= bReadOnly; + aArgs[2] <<= aLocale; + aArgs[3] <<= aDlgName; + aArgs[4] <<= aComment; + + Reference< task::XInteractionHandler > xDummyHandler; + aArgs[5] <<= xDummyHandler; + Reference< XMultiComponentFactory > xSMgr_( i_xContext->getServiceManager(), UNO_QUERY_THROW ); + // TODO: Ctor + Reference< resource::XStringResourceManager > xStringResourceManager( xSMgr_->createInstanceWithContext + ( ::rtl::OUString::createFromAscii( "com.sun.star.resource.StringResourceWithLocation" ), + i_xContext ), UNO_QUERY ); + if( xStringResourceManager.is() ) + { + Reference< XInitialization > xInit( xStringResourceManager, UNO_QUERY ); + if( xInit.is() ) + xInit->initialize( aArgs ); + } + return xStringResourceManager; + } + Reference< container::XNameContainer > lcl_createControlModel(const Reference< XComponentContext >& i_xContext) + { + Reference< XMultiComponentFactory > xSMgr_( i_xContext->getServiceManager(), UNO_QUERY_THROW ); + Reference< container::XNameContainer > xControlModel( xSMgr_->createInstanceWithContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ), i_xContext ), UNO_QUERY_THROW ); + return xControlModel; + } + Reference< container::XNameContainer > lcl_createDialogModel( const Reference< XComponentContext >& i_xContext, + const Reference< io::XInputStream >& xInput, + const Reference< resource::XStringResourceManager >& xStringResourceManager, + const Any &aDialogSourceURL) throw ( Exception ) + { + Reference< container::XNameContainer > xDialogModel( lcl_createControlModel(i_xContext) ); + + ::rtl::OUString aDlgSrcUrlPropName( RTL_CONSTASCII_USTRINGPARAM( "DialogSourceURL" ) ); + Reference< beans::XPropertySet > xDlgPropSet( xDialogModel, UNO_QUERY ); + xDlgPropSet->setPropertyValue( aDlgSrcUrlPropName, aDialogSourceURL ); + + ::xmlscript::importDialogModel( xInput, xDialogModel, i_xContext ); + // Set resource property + if( xStringResourceManager.is() ) + { + Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY ); + Any aStringResourceManagerAny; + aStringResourceManagerAny <<= xStringResourceManager; + xDlgPSet->setPropertyValue( aResourceResolverPropName, aStringResourceManagerAny ); + } + + return xDialogModel; + } // ============================================================================= // component operations // ============================================================================= @@ -173,9 +257,7 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs Reference< container::XNameContainer > DialogProviderImpl::createControlModel() throw ( Exception ) { - Reference< XMultiComponentFactory > xSMgr_( m_xContext->getServiceManager(), UNO_QUERY_THROW ); - Reference< container::XNameContainer > xControlModel( xSMgr_->createInstanceWithContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ), m_xContext ), UNO_QUERY_THROW ); - return xControlModel; + return lcl_createControlModel(m_xContext); } Reference< container::XNameContainer > DialogProviderImpl::createDialogModel( @@ -183,23 +265,9 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs const Reference< resource::XStringResourceManager >& xStringResourceManager, const Any &aDialogSourceURL) throw ( Exception ) { - Reference< container::XNameContainer > xDialogModel( createControlModel() ); - - ::rtl::OUString aDlgSrcUrlPropName( RTL_CONSTASCII_USTRINGPARAM( "DialogSourceURL" ) ); - Reference< beans::XPropertySet > xDlgPropSet( xDialogModel, UNO_QUERY ); - xDlgPropSet->setPropertyValue( aDlgSrcUrlPropName, aDialogSourceURL ); - ::xmlscript::importDialogModel( xInput, xDialogModel, m_xContext ); - // Set resource property - if( xStringResourceManager.is() ) - { - Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY ); - Any aStringResourceManagerAny; - aStringResourceManagerAny <<= xStringResourceManager; - xDlgPSet->setPropertyValue( aResourceResolverPropName, aStringResourceManagerAny ); - } - return xDialogModel; + return lcl_createDialogModel(m_xContext,xInput,xStringResourceManager,aDialogSourceURL); } Reference< XControlModel > DialogProviderImpl::createDialogModelForBasic() throw ( Exception ) @@ -280,8 +348,8 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs bSingleDialog = true; // Try any other URL with SimpleFileAccess - Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSFI = - Reference< ::com::sun::star::ucb::XSimpleFileAccess >( xSMgr->createInstanceWithContext + Reference< ucb::XSimpleFileAccess > xSFI = + Reference< ucb::XSimpleFileAccess >( xSMgr->createInstanceWithContext ( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), m_xContext ), UNO_QUERY ); try @@ -412,34 +480,7 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs Reference< resource::XStringResourceManager > xStringResourceManager; if( bSingleDialog ) { - INetURLObject aInetObj( aURL ); - ::rtl::OUString aDlgName = aInetObj.GetBase(); - aInetObj.removeSegment(); - ::rtl::OUString aDlgLocation = aInetObj.GetMainURL( INetURLObject::NO_DECODE ); - bool bReadOnly = true; - ::com::sun ::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); - ::rtl::OUString aComment; - - Sequence aArgs( 6 ); - aArgs[0] <<= aDlgLocation; - aArgs[1] <<= bReadOnly; - aArgs[2] <<= aLocale; - aArgs[3] <<= aDlgName; - aArgs[4] <<= aComment; - - Reference< task::XInteractionHandler > xDummyHandler; - aArgs[5] <<= xDummyHandler; - Reference< XMultiComponentFactory > xSMgr_( m_xContext->getServiceManager(), UNO_QUERY_THROW ); - // TODO: Ctor - xStringResourceManager = Reference< resource::XStringResourceManager >( xSMgr_->createInstanceWithContext - ( ::rtl::OUString::createFromAscii( "com.sun.star.resource.StringResourceWithLocation" ), - m_xContext ), UNO_QUERY ); - if( xStringResourceManager.is() ) - { - Reference< XInitialization > xInit( xStringResourceManager, UNO_QUERY ); - if( xInit.is() ) - xInit->initialize( aArgs ); - } + xStringResourceManager = lcl_getStringResourceManager(m_xContext,aURL); } else if( xDialogLib.is() ) { @@ -769,7 +810,7 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs Reference< XWindow > DialogProviderImpl::createContainerWindow( const ::rtl::OUString& URL, const ::rtl::OUString& WindowType, const Reference< XWindowPeer >& xParent, const Reference< XInterface >& xHandler ) - throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) + throw (lang::IllegalArgumentException, RuntimeException) { (void)WindowType; // for future use if( !xParent.is() ) @@ -799,11 +840,8 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs static struct ::cppu::ImplementationEntry s_component_entries [] = { - { - create_DialogProviderImpl, getImplementationName_DialogProviderImpl, - getSupportedServiceNames_DialogProviderImpl, ::cppu::createSingleComponentFactory, - 0, 0 - }, + {create_DialogProviderImpl, getImplementationName_DialogProviderImpl,getSupportedServiceNames_DialogProviderImpl, ::cppu::createSingleComponentFactory,0, 0}, + { &comp_DialogModelProvider::_create,&comp_DialogModelProvider::_getImplementationName,&comp_DialogModelProvider::_getSupportedServiceNames,&::cppu::createSingleComponentFactory, 0, 0 }, { 0, 0, 0, 0, 0, 0 } }; diff --git a/scripting/source/dlgprov/dlgprov.hxx b/scripting/source/dlgprov/dlgprov.hxx index f55239ff13e8..1b2eabba9442 100644 --- a/scripting/source/dlgprov/dlgprov.hxx +++ b/scripting/source/dlgprov/dlgprov.hxx @@ -61,6 +61,13 @@ namespace dlgprov // ============================================================================= // class DialogProviderImpl // ============================================================================= + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createControlModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext); + ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > lcl_getStringResourceManager(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,const ::rtl::OUString& i_sURL); + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createDialogModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput, + const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager, + const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception ); typedef ::cppu::WeakImplHelper4< ::com::sun::star::lang::XServiceInfo, diff --git a/scripting/source/dlgprov/makefile.mk b/scripting/source/dlgprov/makefile.mk index 6c8ec298c760..60352f15c924 100644 --- a/scripting/source/dlgprov/makefile.mk +++ b/scripting/source/dlgprov/makefile.mk @@ -41,6 +41,7 @@ DLLPRE = SLOFILES= \ $(SLO)$/dlgprov.obj \ + $(SLO)$/DialogModelProvider.obj \ $(SLO)$/dlgevtatt.obj SHL1TARGET= $(TARGET)$(DLLPOSTFIX).uno -- cgit 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/basprov/basprov.component | 37 +++++++++++++ scripting/source/basprov/basprov.cxx | 7 --- scripting/source/basprov/makefile.mk | 8 +++ scripting/source/dlgprov/dlgprov.component | 36 +++++++++++++ scripting/source/dlgprov/dlgprov.cxx | 7 --- scripting/source/dlgprov/makefile.mk | 8 +++ scripting/source/protocolhandler/exports.dxp | 1 - scripting/source/protocolhandler/makefile.mk | 8 +++ .../protocolhandler/protocolhandler.component | 34 ++++++++++++ scripting/source/protocolhandler/scripthandler.cxx | 21 -------- scripting/source/provider/MasterScriptProvider.cxx | 36 ------------- scripting/source/provider/exports.dxp | 1 - scripting/source/pyprov/mailmerge.component | 37 +++++++++++++ scripting/source/pyprov/makefile.mk | 14 +++++ scripting/source/pyprov/pythonscript.component | 35 ++++++++++++ .../source/runtimemgr/ScriptRuntimeManager.cxx | 62 ---------------------- scripting/source/runtimemgr/exports.dxp | 1 - scripting/source/storage/exports.dxp | 1 - scripting/source/stringresource/makefile.mk | 8 +++ .../source/stringresource/stringresource.component | 40 ++++++++++++++ scripting/source/stringresource/stringresource.cxx | 7 --- scripting/source/vbaevents/makefile.mk | 8 +++ scripting/source/vbaevents/service.cxx | 10 ---- scripting/source/vbaevents/vbaevents.component | 37 +++++++++++++ 24 files changed, 310 insertions(+), 154 deletions(-) create mode 100644 scripting/source/basprov/basprov.component create mode 100644 scripting/source/dlgprov/dlgprov.component create mode 100644 scripting/source/protocolhandler/protocolhandler.component create mode 100644 scripting/source/pyprov/mailmerge.component create mode 100644 scripting/source/pyprov/pythonscript.component create mode 100644 scripting/source/stringresource/stringresource.component mode change 100644 => 100755 scripting/source/vbaevents/makefile.mk create mode 100644 scripting/source/vbaevents/vbaevents.component (limited to 'scripting/source') diff --git a/scripting/source/basprov/basprov.component b/scripting/source/basprov/basprov.component new file mode 100644 index 000000000000..528ab6544e1e --- /dev/null +++ b/scripting/source/basprov/basprov.component @@ -0,0 +1,37 @@ + + + + + + + + + + + diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx index abd61f6c1285..72d53793a69a 100644 --- a/scripting/source/basprov/basprov.cxx +++ b/scripting/source/basprov/basprov.cxx @@ -589,13 +589,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) - { - return ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, ::basprov::s_component_entries ); - } - SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) diff --git a/scripting/source/basprov/makefile.mk b/scripting/source/basprov/makefile.mk index 5001e5db288e..c98f961e6bd3 100644 --- a/scripting/source/basprov/makefile.mk +++ b/scripting/source/basprov/makefile.mk @@ -71,3 +71,11 @@ SHL1LIBS=$(SLB)$/$(TARGET).lib # --- Targets ------------------------------------------------------ .INCLUDE : target.mk + +ALLTAR : $(MISC)/basprov.component + +$(MISC)/basprov.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + basprov.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt basprov.component diff --git a/scripting/source/dlgprov/dlgprov.component b/scripting/source/dlgprov/dlgprov.component new file mode 100644 index 000000000000..f7ceed336cf6 --- /dev/null +++ b/scripting/source/dlgprov/dlgprov.component @@ -0,0 +1,36 @@ + + + + + + + + + + diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx index 0fc0778c71d9..ffa128381d39 100644 --- a/scripting/source/dlgprov/dlgprov.cxx +++ b/scripting/source/dlgprov/dlgprov.cxx @@ -853,13 +853,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - sal_Bool SAL_CALL component_writeInfo( - lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) - { - return ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, ::dlgprov::s_component_entries ); - } - void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) diff --git a/scripting/source/dlgprov/makefile.mk b/scripting/source/dlgprov/makefile.mk index 6c8ec298c760..111dca58edc2 100644 --- a/scripting/source/dlgprov/makefile.mk +++ b/scripting/source/dlgprov/makefile.mk @@ -80,3 +80,11 @@ $(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@ echo $@ + +ALLTAR : $(MISC)/dlgprov.component + +$(MISC)/dlgprov.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + dlgprov.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt dlgprov.component 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 ) diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx index dbade7172e6e..94ea78f80c73 100755 --- a/scripting/source/provider/MasterScriptProvider.cxx +++ b/scripting/source/provider/MasterScriptProvider.cxx @@ -981,42 +981,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - /** - * This function creates an implementation section in the registry and another subkey - * - * for each supported service. - * @param pServiceManager the service manager - * @param pRegistryKey the registry key - */ - SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - lang::XMultiServiceFactory * pServiceManager, - registry::XRegistryKey * pRegistryKey ) - { - if (::cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, - ::scripting_runtimemgr::s_entries )) - { - try - { - // MasterScriptProviderFactory Mangager singleton - registry::XRegistryKey * pKey = - reinterpret_cast< registry::XRegistryKey * >(pRegistryKey); - - Reference< registry::XRegistryKey >xKey = pKey->createKey( - OUSTR("com.sun.star.script.provider.MasterScriptProviderFactory/UNO/SINGLETONS/com.sun.star.script.provider.theMasterScriptProviderFactory")); - xKey->setStringValue( OUSTR("com.sun.star.script.provider.MasterScriptProviderFactory") ); - // BrowseNodeFactory Mangager singleton - xKey = pKey->createKey( - OUSTR("com.sun.star.script.browse.BrowseNodeFactory/UNO/SINGLETONS/com.sun.star.script.browse.theBrowseNodeFactory")); - xKey->setStringValue( OUSTR("com.sun.star.script.browse.BrowseNodeFactory") ); - return sal_True; - } - catch (Exception &) - { - } - } - return sal_False; - } - /** * This function is called to get service factories for an implementation. * diff --git a/scripting/source/provider/exports.dxp b/scripting/source/provider/exports.dxp index 9630d7e06768..f0e1c69934bc 100644 --- a/scripting/source/provider/exports.dxp +++ b/scripting/source/provider/exports.dxp @@ -1,3 +1,2 @@ component_getImplementationEnvironment -component_writeInfo component_getFactory diff --git a/scripting/source/pyprov/mailmerge.component b/scripting/source/pyprov/mailmerge.component new file mode 100644 index 000000000000..dd6a65e9a1ce --- /dev/null +++ b/scripting/source/pyprov/mailmerge.component @@ -0,0 +1,37 @@ + + + + + + + + + + + diff --git a/scripting/source/pyprov/makefile.mk b/scripting/source/pyprov/makefile.mk index 3c0278595181..42c161adbbc8 100644 --- a/scripting/source/pyprov/makefile.mk +++ b/scripting/source/pyprov/makefile.mk @@ -47,3 +47,17 @@ $(DLLDEST)$/%.py: %.py cp $? $@ .INCLUDE : target.mk + +ALLTAR : $(MISC)/mailmerge.component $(MISC)/pythonscript.component + +$(MISC)/mailmerge.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + mailmerge.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_PYTHON)mailmerge' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt mailmerge.component + +$(MISC)/pythonscript.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt pythonscript.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_PYTHON)pythonscript' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt pythonscript.component diff --git a/scripting/source/pyprov/pythonscript.component b/scripting/source/pyprov/pythonscript.component new file mode 100644 index 000000000000..08f895097203 --- /dev/null +++ b/scripting/source/pyprov/pythonscript.component @@ -0,0 +1,35 @@ + + + + + + + + + diff --git a/scripting/source/runtimemgr/ScriptRuntimeManager.cxx b/scripting/source/runtimemgr/ScriptRuntimeManager.cxx index 48f21367e762..4780d58acc88 100755 --- a/scripting/source/runtimemgr/ScriptRuntimeManager.cxx +++ b/scripting/source/runtimemgr/ScriptRuntimeManager.cxx @@ -485,68 +485,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - /** - * This function creates an implementation section in the registry and another subkey - * - * for each supported service. - * @param pServiceManager the service manager - * @param pRegistryKey the registry key - */ - sal_Bool SAL_CALL component_writeInfo( lang::XMultiServiceFactory * pServiceManager, - registry::XRegistryKey * pRegistryKey ) - { - if (::cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, - ::scripting_runtimemgr::s_entries )) - { - try - { - // register RuntimeManager singleton - - registry::XRegistryKey * pKey = - reinterpret_cast< registry::XRegistryKey * >(pRegistryKey); - - Reference< registry::XRegistryKey > xKey( - pKey->createKey( - - OUSTR("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeManager/UNO/SINGLETONS/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeManager"))); - xKey->setStringValue( OUSTR("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeManager") ); - - // ScriptStorage Mangaer singleton - - xKey = pKey->createKey( - OUSTR("drafts.com.sun.star.script.framework.storage.ScriptStorageManager/UNO/SINGLETONS/drafts.com.sun.star.script.framework.storage.theScriptStorageManager")); - xKey->setStringValue( OUSTR("drafts.com.sun.star.script.framework.storage.ScriptStorageManager") ); - // Singleton entries are not handled by the setup process - // below is the only alternative at the momement which - // is to programmatically do this. - - // "Java" Runtime singleton entry - - xKey = pKey->createKey( - OUSTR("com.sun.star.scripting.runtime.java.ScriptRuntimeForJava$_ScriptRuntimeForJava/UNO/SINGLETONS/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeForJava")); - xKey->setStringValue( OUSTR("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeForJava") ); - - // "JavaScript" Runtime singleton entry - - xKey = pKey->createKey( - OUSTR("com.sun.star.scripting.runtime.javascript.ScriptRuntimeForJavaScript$_ScriptRuntimeForJavaScript/UNO/SINGLETONS/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeForJavaScript")); - xKey->setStringValue( OUSTR("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeForJavaScript") ); - - // "BeanShell" Runtime singleton entry - - xKey = pKey->createKey( - OUSTR("com.sun.star.scripting.runtime.beanshell.ScriptRuntimeForBeanShell$_ScriptRuntimeForBeanShell/UNO/SINGLETONS/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeForBeanShell")); - xKey->setStringValue( OUSTR("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeForBeanShell") ); - - return sal_True; - } - catch (Exception & exc) - { - } - } - return sal_False; - } - /** * This function is called to get service factories for an implementation. * diff --git a/scripting/source/runtimemgr/exports.dxp b/scripting/source/runtimemgr/exports.dxp index 9630d7e06768..f0e1c69934bc 100644 --- a/scripting/source/runtimemgr/exports.dxp +++ b/scripting/source/runtimemgr/exports.dxp @@ -1,3 +1,2 @@ component_getImplementationEnvironment -component_writeInfo component_getFactory diff --git a/scripting/source/storage/exports.dxp b/scripting/source/storage/exports.dxp index 9630d7e06768..f0e1c69934bc 100644 --- a/scripting/source/storage/exports.dxp +++ b/scripting/source/storage/exports.dxp @@ -1,3 +1,2 @@ component_getImplementationEnvironment -component_writeInfo component_getFactory diff --git a/scripting/source/stringresource/makefile.mk b/scripting/source/stringresource/makefile.mk index dfc2d1979190..71f8ee39e748 100644 --- a/scripting/source/stringresource/makefile.mk +++ b/scripting/source/stringresource/makefile.mk @@ -60,3 +60,11 @@ SHL1LIBS=$(SLB)$/$(TARGET).lib # --- Targets ------------------------------------------------------ .INCLUDE : target.mk + +ALLTAR : $(MISC)/stringresource.component + +$(MISC)/stringresource.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt stringresource.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt stringresource.component diff --git a/scripting/source/stringresource/stringresource.component b/scripting/source/stringresource/stringresource.component new file mode 100644 index 000000000000..6d64d9553945 --- /dev/null +++ b/scripting/source/stringresource/stringresource.component @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx index 58b6c21b522f..0c0e9dd454ca 100644 --- a/scripting/source/stringresource/stringresource.cxx +++ b/scripting/source/stringresource/stringresource.cxx @@ -3080,13 +3080,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - sal_Bool SAL_CALL component_writeInfo( - lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) - { - return ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, ::stringresource::s_component_entries ); - } - void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) diff --git a/scripting/source/vbaevents/makefile.mk b/scripting/source/vbaevents/makefile.mk old mode 100644 new mode 100755 index 1946c61d1e0b..287bbe2b052b --- a/scripting/source/vbaevents/makefile.mk +++ b/scripting/source/vbaevents/makefile.mk @@ -91,3 +91,11 @@ $(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@ echo $@ + +ALLTAR : $(MISC)/vbaevents.component + +$(MISC)/vbaevents.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + vbaevents.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt vbaevents.component diff --git a/scripting/source/vbaevents/service.cxx b/scripting/source/vbaevents/service.cxx index 9f38acb7e2a6..a6d4b287cfd6 100755 --- a/scripting/source/vbaevents/service.cxx +++ b/scripting/source/vbaevents/service.cxx @@ -110,16 +110,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) - { - OSL_TRACE("In component_writeInfo"); - if ( ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, s_component_entries ) ) - return sal_True; - return sal_False; - } - SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) diff --git a/scripting/source/vbaevents/vbaevents.component b/scripting/source/vbaevents/vbaevents.component new file mode 100644 index 000000000000..e8cbf3d88ff7 --- /dev/null +++ b/scripting/source/vbaevents/vbaevents.component @@ -0,0 +1,37 @@ + + + + + + + + + + + -- cgit From 60a9e05910a3083130b88a61cd36745af5e1128d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 14 Sep 2010 11:02:43 +0200 Subject: dba34a: #i113403# reset m_documentBasicManager to NULL when it dies --- scripting/source/basprov/basscript.cxx | 22 ++++++++++++++++++++++ scripting/source/basprov/basscript.hxx | 6 +++++- scripting/source/basprov/makefile.mk | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'scripting/source') diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx index c6de155e3ed0..24bba1e7bff6 100644 --- a/scripting/source/basprov/basscript.cxx +++ b/scripting/source/basprov/basscript.cxx @@ -80,11 +80,33 @@ namespace basprov ,m_documentBasicManager( &documentBasicManager ) ,m_xDocumentScriptContext( documentScriptContext ) { + StartListening( *m_documentBasicManager ); } // ----------------------------------------------------------------------------- BasicScriptImpl::~BasicScriptImpl() { + if ( m_documentBasicManager ) + EndListening( *m_documentBasicManager ); + } + + // ----------------------------------------------------------------------------- + // SfxListener + // ----------------------------------------------------------------------------- + void BasicScriptImpl::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) + { + if ( &rBC != m_documentBasicManager ) + { + OSL_ENSURE( false, "BasicScriptImpl::Notify: where does this come from?" ); + // not interested in + return; + } + const SfxSimpleHint* pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint ); + if ( pSimpleHint && ( pSimpleHint->GetId() == SFX_HINT_DYING ) ) + { + m_documentBasicManager = NULL; + EndListening( rBC ); // prevent multiple notifications + } } // ----------------------------------------------------------------------------- diff --git a/scripting/source/basprov/basscript.hxx b/scripting/source/basprov/basscript.hxx index 4a3d6f1ab61d..772a9166cde3 100644 --- a/scripting/source/basprov/basscript.hxx +++ b/scripting/source/basprov/basscript.hxx @@ -32,6 +32,7 @@ #include #include #include +#include class BasicManager; @@ -49,7 +50,7 @@ namespace basprov ::com::sun::star::script::provider::XScript > BasicScriptImpl_BASE; - class BasicScriptImpl : public BasicScriptImpl_BASE + class BasicScriptImpl : public BasicScriptImpl_BASE, public SfxListener { private: SbMethodRef m_xMethod; @@ -80,6 +81,9 @@ namespace basprov ::com::sun::star::script::provider::ScriptFrameworkErrorException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException ); + + // SfxListener + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); }; //......................................................................... diff --git a/scripting/source/basprov/makefile.mk b/scripting/source/basprov/makefile.mk index 5001e5db288e..0340419e2a69 100644 --- a/scripting/source/basprov/makefile.mk +++ b/scripting/source/basprov/makefile.mk @@ -58,6 +58,7 @@ SHL1STDLIBS= \ $(SFX2LIB) \ $(BASICLIB) \ $(VCLLIB) \ + $(SVLLIB) \ $(TOOLSLIB) \ $(UCBHELPERLIB) \ $(COMPHELPERLIB) \ -- 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') 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/inc/util/util.hxx | 15 -- scripting/source/protocolhandler/scripthandler.cxx | 35 +---- scripting/source/provider/ActiveMSPList.cxx | 1 - scripting/source/provider/MasterScriptProvider.cxx | 8 +- scripting/source/provider/ProviderCache.cxx | 17 +-- scripting/source/provider/ScriptImpl.cxx | 8 +- scripting/source/provider/ScriptingContext.cxx | 5 +- .../source/runtimemgr/ScriptNameResolverImpl.cxx | 71 +++------ .../source/runtimemgr/ScriptRuntimeManager.cxx | 61 +++----- scripting/source/runtimemgr/StorageBridge.cxx | 32 +--- .../source/storage/ScriptMetadataImporter.cxx | 29 +--- scripting/source/storage/ScriptSecurityManager.cxx | 162 ++++++--------------- scripting/source/storage/ScriptStorage.cxx | 67 +++------ scripting/source/storage/ScriptStorageManager.cxx | 53 +++---- 14 files changed, 153 insertions(+), 411 deletions(-) (limited to 'scripting/source') diff --git a/scripting/source/inc/util/util.hxx b/scripting/source/inc/util/util.hxx index 27e5c19ccc91..a07d66452e0d 100644 --- a/scripting/source/inc/util/util.hxx +++ b/scripting/source/inc/util/util.hxx @@ -29,21 +29,6 @@ #ifndef _COM_SUN_STAR_SCRIPTING_UTIL_UTIL_HXX_ #define _COM_SUN_STAR_SCRIPTING_UTIL_UTIL_HXX_ -#include -#include - #define OUSTR(x) ::rtl::OUString( ::rtl::OUString::createFromAscii(x) ) -namespace scripting_util -{ - inline void validateXRef(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRef, const sal_Char* Msg) throw (::com::sun::star::uno::RuntimeException) - { - OSL_ENSURE( xRef.is(), Msg ); - - if(!xRef.is()) - { - throw ::com::sun::star::uno::RuntimeException(OUSTR(Msg), ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >()); - } - } -} #endif //_COM_SUN_STAR_SCRIPTING_UTIL_UTIL_HXX_ 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( diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx index 3c6206d8d051..bbabbb21405c 100644 --- a/scripting/source/provider/ActiveMSPList.cxx +++ b/scripting/source/provider/ActiveMSPList.cxx @@ -49,7 +49,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::script; -using namespace ::scripting_util; using namespace ::sf_misc; namespace func_provider diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx index 94ea78f80c73..33d371e3d51b 100755 --- a/scripting/source/provider/MasterScriptProvider.cxx +++ b/scripting/source/provider/MasterScriptProvider.cxx @@ -33,6 +33,8 @@ #include #include #include +#include + #include #include #include @@ -60,7 +62,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::script; using namespace ::com::sun::star::document; using namespace ::sf_misc; -using namespace ::scripting_util; namespace func_provider { @@ -95,10 +96,9 @@ MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext > m_xContext( xContext ), m_bIsValid( false ), m_bInitialised( false ), m_bIsPkgMSP( false ), m_pPCache( 0 ) { - validateXRef( m_xContext, "MasterScriptProvider::MasterScriptProvider: No context available\n" ); + ENSURE_OR_THROW( m_xContext.is(), "MasterScriptProvider::MasterScriptProvider: No context available\n" ); m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, - "MasterScriptProvider::MasterScriptProvider: No service manager available\n" ); + ENSURE_OR_THROW( m_xMgr.is(), "MasterScriptProvider::MasterScriptProvider: No service manager available\n" ); m_bIsValid = true; } diff --git a/scripting/source/provider/ProviderCache.cxx b/scripting/source/provider/ProviderCache.cxx index 5d3350f635e3..bea38a67a8f1 100644 --- a/scripting/source/provider/ProviderCache.cxx +++ b/scripting/source/provider/ProviderCache.cxx @@ -29,6 +29,7 @@ #include "precompiled_scripting.hxx" #include #include +#include #include #include @@ -39,7 +40,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::script; -using namespace ::scripting_util; namespace func_provider { @@ -51,7 +51,7 @@ ProviderCache::ProviderCache( const Reference< XComponentContext >& xContext, co // will use createContentEnumeration m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, "ProviderCache::ProviderCache() failed to obtain ServiceManager" ); + ENSURE_OR_THROW( m_xMgr.is(), "ProviderCache::ProviderCache() failed to obtain ServiceManager" ); populateCache(); } @@ -64,7 +64,7 @@ ProviderCache::ProviderCache( const Reference< XComponentContext >& xContext, co // will use createContentEnumeration m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, "ProviderCache::ProviderCache() failed to obtain ServiceManager" ); + ENSURE_OR_THROW( m_xMgr.is(), "ProviderCache::ProviderCache() failed to obtain ServiceManager" ); populateCache(); } @@ -163,14 +163,8 @@ ProviderCache::populateCache() throw ( RuntimeException ) while ( xEnum->hasMoreElements() ) { - Reference< lang::XSingleComponentFactory > factory; - if ( sal_False == ( xEnum->nextElement() >>= factory ) ) - { - throw new RuntimeException( ::rtl::OUString::createFromAscii( " error extracting XSingleComponentFactory from Content enumeration. " ), Reference< XInterface >() ); - } - validateXRef( factory, "ProviderCache::populateCache() invalid factory" ); + Reference< lang::XSingleComponentFactory > factory( xEnum->nextElement(), UNO_QUERY_THROW ); Reference< lang::XServiceInfo > xServiceInfo( factory, UNO_QUERY_THROW ); - validateXRef( xServiceInfo, "ProviderCache::populateCache() failed to get XServiceInfo from factory" ); Sequence< ::rtl::OUString > serviceNames = xServiceInfo->getSupportedServiceNames(); @@ -207,9 +201,8 @@ ProviderCache::createProvider( ProviderDetails& details ) throw ( RuntimeExcepti { try { - details.provider = Reference< provider::XScriptProvider >( + details.provider.set( details.factory->createInstanceWithArgumentsAndContext( m_Sctx, m_xContext ), UNO_QUERY_THROW ); - validateXRef( details.provider, "ProviderCache::createProvider, failed to create provider"); } catch ( RuntimeException& e ) { diff --git a/scripting/source/provider/ScriptImpl.cxx b/scripting/source/provider/ScriptImpl.cxx index f5b93a802138..08d548e3461c 100644 --- a/scripting/source/provider/ScriptImpl.cxx +++ b/scripting/source/provider/ScriptImpl.cxx @@ -46,15 +46,11 @@ ScriptImpl::ScriptImpl( const Reference< runtime::XScriptInvocation > & runtimeMgr, const ::rtl::OUString& scriptURI ) throw ( RuntimeException ) : - m_XScriptingContext( scriptingContext ), - m_RunTimeManager( runtimeMgr ), + m_XScriptingContext( scriptingContext, UNO_SET_THROW ), + m_RunTimeManager( runtimeMgr, UNO_SET_THROW ), m_ScriptURI( scriptURI ) { OSL_TRACE( "\n" ); - validateXRef( m_XScriptingContext, - "ScriptImpl::ScriptImpl: No XScriptingContext\n" ); - validateXRef( m_RunTimeManager, - "ScriptImpl::ScriptImpl: No XScriptInvocation\n" ); } //************************************************************************* diff --git a/scripting/source/provider/ScriptingContext.cxx b/scripting/source/provider/ScriptingContext.cxx index 08a27a19562f..0394bd3653d1 100755 --- a/scripting/source/provider/ScriptingContext.cxx +++ b/scripting/source/provider/ScriptingContext.cxx @@ -55,13 +55,10 @@ namespace func_provider //************************************************************************* ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xContext ) : //ScriptingContextImpl_BASE( GetMutex()), OPropertyContainer( GetBroadcastHelper() ), - m_xContext( xContext ) + m_xContext( xContext, UNO_SET_THROW ) { OSL_TRACE( "< ScriptingContext ctor called >\n" ); - validateXRef( m_xContext, - "ScriptingContext::ScriptingContext: No context available\n" ); - Any nullAny; scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = diff --git a/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx b/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx index 48b960c6c9aa..8dafab0e8d4c 100644 --- a/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx +++ b/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx @@ -70,13 +70,11 @@ static ::std::vector< sal_Int32 >* m_pSearchIDs = NULL; //************************************************************************* ScriptNameResolverImpl::ScriptNameResolverImpl( const Reference< XComponentContext > & xContext ) : - m_xContext( xContext ) + m_xContext( xContext, UNO_SET_THROW ) { OSL_TRACE( "< ScriptNameResolverImpl ctor called >\n" ); validateXRef( m_xContext, "ScriptNameResolverImpl::ScriptNameResolverImpl: invalid context" ); - m_xMultiComFac = m_xContext->getServiceManager(); - - validateXRef( m_xMultiComFac, "ScriptNameResolverImpl::ScriptNameResolverImpl: invalid XMultiComponentFactory " ); + m_xMultiComFac.set( m_xContext->getServiceManager(), UNO_SET_THROW ); if( !m_pSearchIDs ) { @@ -220,11 +218,13 @@ throw ( lang::IllegalArgumentException, script::CannotConvertException, RuntimeE OUString temp = OUSTR( "ScriptNameResolverImpl::resolve: " ); throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); } - Reference< XInterface > xInterface = m_xMultiComFac->createInstanceWithContext( - ::rtl::OUString::createFromAscii( - "com.sun.star.ucb.SimpleFileAccess" ), m_xContext ); - validateXRef( xInterface, - "ScriptProvider::initialise: cannot get SimpleFileAccess Service\n" ); + Reference< XInterface > xInterface( + m_xMultiComFac->createInstanceWithContext( + ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), + m_xContext + ), + UNO_SET_THROW + ); Reference < ucb::XSimpleFileAccess > xSimpleFileAccess = Reference < ucb::XSimpleFileAccess > ( xInterface, UNO_QUERY_THROW ); @@ -236,15 +236,8 @@ throw ( lang::IllegalArgumentException, script::CannotConvertException, RuntimeE try { // need to get the ScriptStorageManager - Any a = m_xContext->getValueByName( - scriptingConstantsPool.SCRIPTSTORAGEMANAGER_SERVICE ); - if ( sal_False == ( a >>= xScriptStorageMgr ) ) - { - OUString temp = OUSTR( "ScriptNameResolverImpl::resolve: failed to get ScriptStorageManager" ); - throw RuntimeException( temp, Reference< XInterface >() ); - // need to throw - } - validateXRef( xScriptStorageMgr, "Cannot get ScriptStorageManager" ); + xScriptStorageMgr.set( m_xContext->getValueByName( + scriptingConstantsPool.SCRIPTSTORAGEMANAGER_SERVICE ), UNO_QUERY_THROW ); filesysScriptStorageID = xScriptStorageMgr->createScriptStorageWithURI( xSimpleFileAccess, filesysURL ); @@ -364,20 +357,12 @@ throw ( lang::IllegalArgumentException, script::CannotConvertException, RuntimeE if( filesysScriptStorageID > 2 ) { // get the filesys storage and dispose of it - Reference< XInterface > xScriptStorage = - xScriptStorageMgr->getScriptStorage( filesysScriptStorageID ); - validateXRef( xScriptStorage, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Storage service" ); + Reference< XInterface > xScriptStorage( xScriptStorageMgr->getScriptStorage( filesysScriptStorageID ), UNO_SET_THROW ); Reference< storage::XScriptInfoAccess > xScriptInfoAccess = Reference< storage::XScriptInfoAccess > ( xScriptStorage, UNO_QUERY_THROW ); - validateXRef( xScriptInfoAccess, - "ScriptNameResolverImpl::resolveURIFromStorageID: cannot get XScriptInfoAccess" ); Sequence< Reference< storage::XScriptInfo > > results = xScriptInfoAccess->getAllImplementations( ); - Reference < lang::XEventListener > xEL_ScriptStorageMgr = - Reference< lang::XEventListener > - ( xScriptStorageMgr ,UNO_QUERY_THROW ); - validateXRef( xEL_ScriptStorageMgr, "ScriptNameResolverImpl::resolve: can't get ScriptStorageManager XEventListener interface when trying to dispose of filesystem storage" ); + Reference < lang::XEventListener > xEL_ScriptStorageMgr(( xScriptStorageMgr ,UNO_QUERY_THROW ); lang::EventObject event( results[ 0 ] ); xEL_ScriptStorageMgr->disposing( event ); } @@ -447,9 +432,7 @@ SAL_THROW ( ( lang::IllegalArgumentException, css::security::AccessControlExcept throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); } } - Reference< storage::XScriptInfoAccess > storage = getStorageInstance( sid, permissionURI ); - validateXRef( storage, - "ScriptNameResolverImpl::resolveURIFromStorageID: cannot get XScriptInfoAccess" ); + Reference< storage::XScriptInfoAccess > storage( getStorageInstance( sid, permissionURI ), UNO_SET_THROW ); Sequence< Reference< storage::XScriptInfo > > results = storage->getImplementations( scriptURI ); @@ -516,22 +499,10 @@ const ::rtl::OUString & permissionURI ) SAL_THROW ( ( RuntimeException, css::sec Reference< storage::XScriptInfoAccess > xScriptInfoAccess; try { - Reference< XInterface > xInterface; - - Any a = m_xContext->getValueByName( - OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ); - if ( sal_False == ( a >>= xInterface ) ) - { - throw RuntimeException( - OUSTR( "ScriptNameResolverImpl::getStorageInstance: could not obtain ScriptStorageManager singleton" ), - Reference< XInterface >() ); - } - validateXRef( xInterface, - "ScriptNameResolverImpl::getStorageInstance: cannot get Storage service" ); + Reference< XInterface > xInterface( m_xContext->getValueByName( + OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ), UNO_QUERY_THROW ); // check that we have permissions for this storage Reference< dcsssf::security::XScriptSecurity > xScriptSecurity( xInterface, UNO_QUERY_THROW ); - validateXRef( xScriptSecurity, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Security service" ); scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = scripting_constants::ScriptingConstantsPool::instance(); // if we dealing with a document storage (ie. not user or share @@ -546,14 +517,8 @@ const ::rtl::OUString & permissionURI ) SAL_THROW ( ( RuntimeException, css::sec OSL_TRACE( "ScriptNameResolverImpl::getStorageInstance: got execute permission for ID=%d", sid ); } Reference< storage::XScriptStorageManager > xScriptStorageManager( xInterface, UNO_QUERY_THROW ); - validateXRef( xScriptStorageManager, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Storage Manager service" ); - Reference< XInterface > xScriptStorage = - xScriptStorageManager->getScriptStorage( sid ); - validateXRef( xScriptStorage, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Storage service" ); - xScriptInfoAccess = Reference< - storage::XScriptInfoAccess > ( xScriptStorage, UNO_QUERY_THROW ); + Reference< XInterface > xScriptStorage( ScriptStorageManager->getScriptStorage( sid ), UNO_SET_THROW ); + xScriptInfoAccess.set( xScriptStorage, UNO_QUERY_THROW ); } catch ( lang::IllegalArgumentException & e ) { diff --git a/scripting/source/runtimemgr/ScriptRuntimeManager.cxx b/scripting/source/runtimemgr/ScriptRuntimeManager.cxx index 4780d58acc88..79a44bebce7d 100755 --- a/scripting/source/runtimemgr/ScriptRuntimeManager.cxx +++ b/scripting/source/runtimemgr/ScriptRuntimeManager.cxx @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -68,14 +69,10 @@ static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceNam // ScriptRuntimeManager Constructor ScriptRuntimeManager::ScriptRuntimeManager( const Reference< XComponentContext > & xContext ) : - m_xContext( xContext ) + m_xContext( xContext, UNO_SET_THROW ) { OSL_TRACE( "< ScriptRuntimeManager ctor called >\n" ); - validateXRef( m_xContext, - "ScriptRuntimeManager::ScriptRuntimeManager: invalid context" ); - m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, - "ScriptRuntimeManager::ScriptRuntimeManager: cannot get ServiceManager" ); + m_xMgr.set( m_xContext->getServiceManager(), UNO_SET_THROW ); s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); // test //scripting_securitymgr::ScriptSecurityManager ssm(xContext); @@ -106,22 +103,12 @@ throw( RuntimeException ) Reference< storage::XScriptInfo > sinfo = Reference< storage::XScriptInfo >( scriptInfo, UNO_QUERY_THROW ); - OUStringBuffer *buf = new OUStringBuffer(80); - buf->appendAscii("/singletons/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeFor"); - buf->append(sinfo->getLanguage()); + OUStringBuffer* buf( 80 ); + buf.appendAscii("/singletons/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeFor"); + buf.append(sinfo->getLanguage()); - Any a = m_xContext->getValueByName(buf->makeStringAndClear()); - - if ( sal_False == ( a >>= xInterface ) ) - { - throw RuntimeException( - sinfo->getLanguage().concat( OUSTR( " runtime support is not installed for this language" ) ), - Reference< XInterface >() ); - } - validateXRef( xInterface, - "ScriptRuntimeManager::GetScriptRuntime: cannot get appropriate ScriptRuntime Service" - ); - xScriptInvocation = Reference< runtime::XScriptInvocation >( xInterface, UNO_QUERY_THROW ); + xInterface.set( m_xContext->getValueByName( buf.makeStringAndClear() ), UNO_QUERY_THROW ); + xScriptInvocation.set( xInterface, UNO_QUERY_THROW ); } catch ( Exception & e ) { @@ -143,13 +130,14 @@ throw( RuntimeException ) try { - Reference< XInterface > xInterface = m_xMgr->createInstanceWithContext( - OUString::createFromAscii( - "drafts.com.sun.star.script.framework.runtime.DefaultScriptNameResolver" ), - m_xContext ); - validateXRef( xInterface, - "ScriptRuntimeManager::GetScriptRuntime: cannot get instance of DefaultScriptNameResolver" ); - xScriptNameResolver = Reference< runtime::XScriptNameResolver >( xInterface, UNO_QUERY_THROW ); + Reference< XInterface > xInterface( + m_xMgr->createInstanceWithContext( + OUString::createFromAscii("drafts.com.sun.star.script.framework.runtime.DefaultScriptNameResolver" ), + m_xContext + ), + UNO_SET_THROW + ); + xScriptNameResolver.set( xInterface, UNO_QUERY_THROW ); } catch ( Exception & e ) { @@ -182,9 +170,8 @@ Any SAL_CALL ScriptRuntimeManager::invoke( try { - Reference< storage::XScriptInfo > resolvedScript = resolve( scriptURI, - resolvedCtx ); - validateXRef( resolvedScript, "ScriptRuntimeManager::invoke: No resolvedURI" ); + Reference< storage::XScriptInfo > resolvedScript = resolve( scriptURI, resolvedCtx ); + ENSURE_OR_THROW( resolvedScript.is(), "ScriptRuntimeManager::invoke: No resolvedURI" ); Reference< beans::XPropertySet > xPropSetResolvedCtx; if ( sal_False == ( resolvedCtx >>= xPropSetResolvedCtx ) ) @@ -216,7 +203,7 @@ Any SAL_CALL ScriptRuntimeManager::invoke( Reference< runtime::XScriptInvocation > xScriptInvocation = getScriptRuntime( resolvedScript ); - validateXRef( xScriptInvocation, + ENSURE_OR_THROW( xScriptInvocation.is(), "ScriptRuntimeManager::invoke: cannot get instance of language specific runtime." ); // the scriptURI is currently passed to the language-dept runtime but @@ -232,13 +219,7 @@ Any SAL_CALL ScriptRuntimeManager::invoke( { Any a = m_xContext->getValueByName( scriptingConstantsPool.SCRIPTSTORAGEMANAGER_SERVICE ); - Reference < lang::XEventListener > xEL_ScriptStorageManager; - if ( sal_False == ( a >>= xEL_ScriptStorageManager ) ) - { - throw RuntimeException( OUSTR( "ScriptRuntimeManager::invoke: can't get ScriptStorageManager XEventListener interface when trying to dispose of filesystem storage" ), - Reference< XInterface > () ); - } - validateXRef( xEL_ScriptStorageManager, "Cannot get XEventListener from ScriptStorageManager" ); + Reference < lang::XEventListener > xEL_ScriptStorageManager( a, UNO_QUERY_THROW ); lang::EventObject event(resolvedScript); xEL_ScriptStorageManager->disposing( event ); } @@ -310,7 +291,7 @@ throw( lang::IllegalArgumentException, script::CannotConvertException, RuntimeEx Reference< storage::XScriptInfo > resolvedURI; Reference< runtime::XScriptNameResolver > xScriptNameResolver = getScriptNameResolver(); - validateXRef( xScriptNameResolver, + ENSURE_OR_THROW( xScriptNameResolver.is(), "ScriptRuntimeManager::resolve: No ScriptNameResolver" ); try diff --git a/scripting/source/runtimemgr/StorageBridge.cxx b/scripting/source/runtimemgr/StorageBridge.cxx index d1915afba9e5..1e15cf808870 100644 --- a/scripting/source/runtimemgr/StorageBridge.cxx +++ b/scripting/source/runtimemgr/StorageBridge.cxx @@ -54,9 +54,8 @@ const int STORAGEPROXY = 0; //************************************************************************* // StorageBridge Constructor StorageBridge::StorageBridge( const Reference< XComponentContext >& xContext, - sal_Int32 sid ) : m_xContext( xContext ), m_sid( sid ) + sal_Int32 sid ) : m_xContext( xContext, UNO_SET_THROW ), m_sid( sid ) { - validateXRef( m_xContext, "StorageBridge::StorageBridge: invalid context" ); try { initStorage(); @@ -74,31 +73,12 @@ StorageBridge::initStorage() throw ( ::com::sun::star::uno::RuntimeException ) { try { - Reference< lang::XMultiComponentFactory > xMultiComFac = - m_xContext->getServiceManager(); - validateXRef( xMultiComFac, - "StorageBridge::StorageBridge: cannot get multicomponentfactory from multiservice factory" ); - Reference< XInterface > temp; - - Any a = m_xContext->getValueByName( - OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ); - if ( sal_False == ( a >>= temp ) ) - { - throw RuntimeException( - OUSTR( "StorageBridge::StorageBridge: could not obtain ScriptStorageManager singleton" ), - Reference< XInterface >() ); - } - validateXRef( temp, - "StorageBridge::StorageBridge: cannot get Storage service" ); + Reference< lang::XMultiComponentFactory > xMultiComFac( m_xContext->getServiceManager(), UNO_SET_THROW ); + Reference< XInterface > temp( m_xContext->getValueByName( + OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ), UNO_QUERY_THROW ); Reference< storage::XScriptStorageManager > xScriptStorageManager( temp, UNO_QUERY_THROW ); - validateXRef( xScriptStorageManager, - "StorageBridge::StorageBridge: cannot get Script Storage Manager service" ); - Reference< XInterface > xScriptStorage = - xScriptStorageManager->getScriptStorage( m_sid ); - validateXRef( xScriptStorage, - "StorageBridge::StorageBridge: cannot get Script Storage service" ); - m_xScriptInfoAccess = - Reference< storage::XScriptInfoAccess > ( xScriptStorage, UNO_QUERY_THROW ); + Reference< XInterface > xScriptStorage( xScriptStorageManager->getScriptStorage( m_sid ), UNO_SET_THROW ); + m_xScriptInfoAccess.set( xScriptStorage, UNO_QUERY_THROW ); } catch ( RuntimeException & re ) { diff --git a/scripting/source/storage/ScriptMetadataImporter.cxx b/scripting/source/storage/ScriptMetadataImporter.cxx index 64dd87b2546b..96faf6e9c1f4 100644 --- a/scripting/source/storage/ScriptMetadataImporter.cxx +++ b/scripting/source/storage/ScriptMetadataImporter.cxx @@ -38,7 +38,7 @@ #include #include - +#include #include @@ -82,31 +82,14 @@ void ScriptMetadataImporter::parseMetaData( ms_parcelURI = parcelURI; //Get the parser service - validateXRef( m_xContext, + ENSURE_OR_THROW( m_xContext.is(), "ScriptMetadataImporter::parseMetaData: No context available" ); - Reference< lang::XMultiComponentFactory > xMgr = - m_xContext->getServiceManager(); - - validateXRef( xMgr, - "ScriptMetadataImporter::parseMetaData: No service manager available" ); - - Reference< XInterface > xInterface = xMgr->createInstanceWithContext( - OUString::createFromAscii( "com.sun.star.xml.sax.Parser" ), m_xContext ); + Reference< lang::XMultiComponentFactory > xMgr( m_xContext->getServiceManager(), UNO_SET_THROW ); - validateXRef( xInterface, "ScriptMetadataImporter::parseMetaData: cannot get SAX Parser" ); - Reference< xml::sax::XParser > xParser; - try - { - xParser.set( xInterface ,UNO_QUERY_THROW ); - } - catch (RuntimeException & re ) - { - OUString msg = OUString::createFromAscii( - "ScriptMetadata:Importer::parserMetaData cannot get XParser" ); - msg.concat( re.Message ); - throw RuntimeException( msg, Reference< XInterface > () ); - } + Reference< xml::sax::XParser > xParser( + xMgr->createInstanceWithContext( OUString::createFromAscii( "com.sun.star.xml.sax.Parser" ), m_xContext ), + UNO_QUERY_THROW ); // xxx todo: error handler, entity resolver omitted // This class is the document handler for the parser diff --git a/scripting/source/storage/ScriptSecurityManager.cxx b/scripting/source/storage/ScriptSecurityManager.cxx index 3fde4e466974..fbe6f41b4663 100755 --- a/scripting/source/storage/ScriptSecurityManager.cxx +++ b/scripting/source/storage/ScriptSecurityManager.cxx @@ -47,7 +47,7 @@ #include "ScriptSecurityManager.hxx" #include #include - +#include using namespace ::rtl; using namespace ::osl; @@ -85,28 +85,15 @@ static const int ADD_TO_PATH = 2; // ScriptSecurityManager Constructor ScriptSecurityManager::ScriptSecurityManager( const Reference< XComponentContext > & xContext ) throw ( RuntimeException ) - : m_xContext( xContext) + : m_xContext( xContext, UNO_SET_THROW ) { OSL_TRACE( "< ScriptSecurityManager ctor called >\n" ); - validateXRef( m_xContext, - "ScriptSecurityManager::ScriptSecurityManager: invalid context" ); // get the service manager from the context - Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); - validateXRef( xMgr, - "ScriptSecurityManager::ScriptSecurityManager: cannot get ServiceManager" ); + Reference< lang::XMultiComponentFactory > xMgr( m_xContext->getServiceManager(), UNO_SET_THROW ); // create an instance of the ConfigurationProvider - Reference< XInterface > xInterface = xMgr->createInstanceWithContext( - s_configProv, m_xContext ); - validateXRef( xInterface, - "ScriptSecurityManager::ScriptSecurityManager: cannot get ConfigurationProvider" ); - // create an instance of the ConfigurationAccess for accessing the - // scripting security settings - m_xConfigProvFactory = Reference < lang::XMultiServiceFactory > ( xInterface, UNO_QUERY ); - validateXRef( m_xConfigProvFactory, - "ScriptSecurityManager::ScriptSecurityManager: cannot get XMultiServiceFactory interface from ConfigurationProvider" ); - + m_xConfigProvFactory.set( xMgr->createInstanceWithContext( s_configProv, m_xContext ), UNO_QUERY_THROW ); } void ScriptSecurityManager::addScriptStorage( rtl::OUString scriptStorageURL, @@ -131,35 +118,6 @@ throw ( RuntimeException ) //need to check if storage has any scripts try { - /* need to replace this with something better, now logical names are - * gone - - Reference< XInterface > xInterface; - Any a = m_xContext->getValueByName( - OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ); - if ( sal_False == ( a >>= xInterface ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager::addScriptStorage: could not obtain ScriptStorageManager singleton" ), - Reference< XInterface >() ); - } - validateXRef( xInterface, - "ScriptSecurityManager::addScriptStorage: cannot get Storage service" ); - Reference< storage::XScriptStorageManager > xScriptStorageManager( - xInterface, UNO_QUERY_THROW ); - Reference< XInterface > xScriptStorage = - xScriptStorageManager->getScriptStorage( storageID ); - validateXRef( xScriptStorage, - "ScriptNameResolverImpl::getStorageInstance: cannot get Script Storage service" ); - Reference< storage::XScriptInfoAccess > xScriptInfoAccess = - Reference< storage::XScriptInfoAccess > ( xScriptStorage, - UNO_QUERY_THROW ); - Sequence< ::rtl::OUString > logicalNames = xScriptInfoAccess->getScriptLogicalNames(); - if( !logicalNames.getLength() ) // we have no logical names - { - return; - } */ - // we have some scripts so read config & decide on that basis // Setup flags: m_runMacroSetting, m_warning, m_confirmationRequired, readConfiguration(); @@ -317,17 +275,12 @@ throw ( RuntimeException ) short result; try { - Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); - validateXRef( xMgr, - "ScriptSecurityManager::executeDialog: cannot get ServiceManager" ); - Reference< XInterface > xInterface = - xMgr->createInstanceWithArgumentsAndContext( s_securityDialog, - aArgs, m_xContext ); - validateXRef( xInterface, "ScriptSecurityManager::executeDialog: Can't create SecurityDialog" ); - Reference< awt::XDialog > xDialog( xInterface, UNO_QUERY_THROW ); + Reference< lang::XMultiComponentFactory > xMgr( m_xContext->getServiceManager(), UNO_SET_THROW ); + Reference< awt::XDialog > xDialog( + xMgr->createInstanceWithArgumentsAndContext( s_securityDialog, aArgs, m_xContext ), + UNO_QUERY_THROW ); result = xDialog->execute(); - Reference< lang::XComponent > xComponent( xInterface, UNO_QUERY_THROW ); - validateXRef( xInterface, "ScriptSecurityManager::executeDialog: Can't get XComponent to dispose dialog" ); + Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY_THROW ); xComponent->dispose(); } catch ( RuntimeException & rte ) @@ -410,31 +363,20 @@ void ScriptSecurityManager::removePermissionSettings ( ::rtl::OUString & scriptS void ScriptSecurityManager::readConfiguration() throw ( RuntimeException) { - Reference< XInterface > xInterface; try { - beans::PropertyValue configPath; - configPath.Name = ::rtl::OUString::createFromAscii( "nodepath" ); - configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Common/Security/Scripting" ); - Sequence < Any > aargs( 1 ); - aargs[ 0 ] <<= configPath; - validateXRef( m_xConfigProvFactory, - "ScriptSecurityManager::readConfiguration: ConfigProviderFactory no longer valid!" ); - xInterface = m_xConfigProvFactory->createInstanceWithArguments( s_configAccess, - aargs ); - validateXRef( xInterface, - "ScriptSecurityManager::readConfiguration: cannot get ConfigurationAccess" ); - // get the XPropertySet interface from the ConfigurationAccess service - Reference < beans::XPropertySet > xPropSet( xInterface, UNO_QUERY ); - Any value; - - value=xPropSet->getPropertyValue( OUSTR( "Confirmation" ) ); - if ( sal_False == ( value >>= m_confirmationRequired ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager:readConfiguration: can't get Confirmation setting" ), - Reference< XInterface > () ); - } + beans::PropertyValue configPath; + configPath.Name = ::rtl::OUString::createFromAscii( "nodepath" ); + configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Common/Security/Scripting" ); + Sequence < Any > aargs( 1 ); + aargs[ 0 ] <<= configPath; + ENSURE_OR_THROW( m_xConfigProvFactory.is(), + "ScriptSecurityManager::readConfiguration: ConfigProviderFactory no longer valid!" ); + // get the XPropertySet interface from the ConfigurationAccess service + Reference < beans::XPropertySet > xPropSet( m_xConfigProvFactory->createInstanceWithArguments( s_configAccess, aargs ), UNO_QUERY_THROW ); + + m_confirmationRequired = sal_True; + OSL_VERIFY( xPropSet->getPropertyValue( OUSTR( "Confirmation" ) ) >>= m_confirmationRequired ); if ( m_confirmationRequired == sal_True ) { OSL_TRACE( "ScriptSecurityManager:readConfiguration: confirmation is true" ); @@ -443,13 +385,10 @@ void ScriptSecurityManager::readConfiguration() { OSL_TRACE( "ScriptSecurityManager:readConfiguration: confirmation is false" ); } - value=xPropSet->getPropertyValue( OUSTR( "Warning" ) ); - if ( sal_False == ( value >>= m_warning ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager:readConfiguration: can't get Warning setting" ), - Reference< XInterface > () ); - } + + m_warning = true; + OSL_VERIFY( xPropSet->getPropertyValue( OUSTR( "Warning" ) ) >>= m_warning ); + if ( m_warning == sal_True ) { OSL_TRACE( "ScriptSecurityManager:readConfiguration: warning is true" ); @@ -458,21 +397,13 @@ void ScriptSecurityManager::readConfiguration() { OSL_TRACE( "ScriptSecurityManager:readConfiguration: warning is false" ); } - value=xPropSet->getPropertyValue( OUSTR( "OfficeBasic" ) ); - if ( sal_False == ( value >>= m_runMacroSetting ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager:readConfiguration: can't get OfficeBasic setting" ), - Reference< XInterface > () ); - } + + m_runMacroSetting = sal_True; + OSL_VERIFY( xPropSet->getPropertyValue( OUSTR( "OfficeBasic" ) ) >>= m_runMacroSetting ); OSL_TRACE( "ScriptSecurityManager:readConfiguration: OfficeBasic = %d", m_runMacroSetting ); - value=xPropSet->getPropertyValue( OUSTR( "SecureURL" ) ); - if ( sal_False == ( value >>= m_secureURL ) ) - { - throw RuntimeException( - OUSTR( "ScriptSecurityManager:readConfiguration: can't get SecureURL setting" ), - Reference< XInterface > () ); - } + + m_secureURL = ::rtl::OUString(); + OSL_VERIFY( xPropSet->getPropertyValue( OUSTR( "SecureURL" ) ) >>= m_secureURL ); } catch ( beans::UnknownPropertyException & upe ) { @@ -508,18 +439,14 @@ void ScriptSecurityManager::readConfiguration() int length = m_secureURL.getLength(); // PathSubstitution needed to interpret variables found in config - Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); - validateXRef( xMgr, - "ScriptSecurityManager::readConfiguration: cannot get XMultiComponentFactory" ); - xInterface = xMgr->createInstanceWithContext( - ::rtl::OUString::createFromAscii( - "com.sun.star.util.PathSubstitution"), m_xContext); - validateXRef( xInterface, - "ScriptSecurityManager::readConfiguration: cannot get ConfigurationProvider" ); + Reference< lang::XMultiComponentFactory > xMgr( m_xContext->getServiceManager(), UNO_SET_THROW ); + Reference< XInterface > xInterface = ); Reference< util::XStringSubstitution > xStringSubstitution( - xInterface, UNO_QUERY); - validateXRef( xStringSubstitution, - "ScriptSecurityManager::readConfiguration: cannot get ConfigurationProvider" ); + xMgr->createInstanceWithContext( + ::rtl::OUString::createFromAscii( "com.sun.star.util.PathSubstitution" ), m_xContext + ), + UNO_QUERY_THROW + ); for( int i = 0; i < length; i++ ) { OSL_TRACE( "ScriptSecurityManager:readConfiguration path = %s", @@ -552,16 +479,9 @@ throw ( RuntimeException ) configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Common/Security/Scripting" ); Sequence < Any > aargs( 1 ); aargs[ 0 ] <<= configPath; - Reference< XInterface > xInterface = m_xConfigProvFactory->createInstanceWithArguments( s_configUpdate, - aargs ); - validateXRef( xInterface, - "ScriptSecurityManager::addToSecurePaths: ScriptSecurityManager: cannot get ConfigurationUpdateAccess" ); - Reference < container::XNameReplace > xNameReplace( xInterface, UNO_QUERY ); - validateXRef( xNameReplace, - "ScriptSecurityManager::addToSecurePaths: ScriptSecurityManager: cannot get XNameReplace" ); - Reference < util::XChangesBatch > xChangesBatch( xInterface, UNO_QUERY ); - validateXRef( xChangesBatch, - "ScriptSecurityManager::addToSecurePaths: cannot get XChangesBatch" ); + Reference < container::XNameReplace > xNameReplace( + m_xConfigProvFactory->createInstanceWithArguments( s_configUpdate, aargs ), UNO_QUERY_THROW ); + Reference < util::XChangesBatch > xChangesBatch( xNameReplace, UNO_QUERY_THROW ); OSL_TRACE( "--->ScriptSecurityManager::addToSecurePaths: after if stuff" ); Reference < beans::XPropertySet > xPropSet( xInterface, UNO_QUERY ); diff --git a/scripting/source/storage/ScriptStorage.cxx b/scripting/source/storage/ScriptStorage.cxx index 7315e9d35dd5..e4ea5f231f47 100644 --- a/scripting/source/storage/ScriptStorage.cxx +++ b/scripting/source/storage/ScriptStorage.cxx @@ -84,16 +84,11 @@ const sal_uInt16 NUMBER_STORAGE_INITIALIZE_ARGS = 3; ScriptStorage::ScriptStorage( const Reference < XComponentContext > & xContext ) throw ( RuntimeException ) - : m_xContext( xContext ), m_bInitialised( false ) + : m_xContext( xContext, UNO_SET_THROW ), m_bInitialised( false ) { OSL_TRACE( "< ScriptStorage ctor called >\n" ); - validateXRef( m_xContext, - "ScriptStorage::ScriptStorage : cannot get component context" ); - - m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, - "ScriptStorage::ScriptStorage : cannot get service manager" ); + m_xMgr.set( m_xContext->getServiceManager(), UNO_SET_THROW ); if( !mh_scriptLangs ) { @@ -101,47 +96,30 @@ throw ( RuntimeException ) if( !mh_scriptLangs ) { mh_scriptLangs = new ScriptLanguages_hash(); - Reference< XInterface > xInterface = - m_xMgr->createInstanceWithContext( - OUString::createFromAscii( - "com.sun.star.configuration.ConfigurationProvider" ) - , m_xContext ); - validateXRef( xInterface, - "ScriptStorage::ScriptStorage: cannot get ConfigurationProvider" ); + Reference< lang::XMultiServiceFactory > xConfigProvFactory( + m_xMgr->createInstanceWithContext( OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ), m_xContext ), + UNO_QUERY_THROW ); // create an instance of the ConfigurationAccess for accessing the // scripting runtime settings - Reference< lang::XMultiServiceFactory > xConfigProvFactory = - Reference < lang::XMultiServiceFactory > - ( xInterface, UNO_QUERY_THROW ); - validateXRef( xConfigProvFactory, - "ScriptStorage::ScriptStorage: cannot get XMultiServiceFactory interface from ConfigurationProvider" ); beans::PropertyValue configPath; configPath.Name = ::rtl::OUString::createFromAscii( "nodepath" ); configPath.Value <<= ::rtl::OUString::createFromAscii( "org.openoffice.Office.Scripting/ScriptRuntimes" ); Sequence < Any > aargs( 1 ); aargs[ 0 ] <<= configPath; - xInterface = xConfigProvFactory->createInstanceWithArguments( - OUString::createFromAscii( - "com.sun.star.configuration.ConfigurationAccess"), - aargs ); - validateXRef( xInterface, - "ScriptStorage::ScriptStorage: cannot get ConfigurationAccess" ); - Reference< container::XNameAccess > xNameAccess = - Reference < container::XNameAccess > ( xInterface, - UNO_QUERY_THROW ); - validateXRef( xNameAccess, - "ScriptStorage::ScriptStorage: cannot get ConfigurationAccess" ); + Reference< container::XNameAccess > xNameAccess( + xConfigProvFactory->createInstanceWithArguments( + OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ), + aargs + ), + UNO_QUERY_THROW ); + Sequence< OUString > names = xNameAccess->getElementNames(); for( int i = 0 ; i < names.getLength() ; i++ ) { OSL_TRACE( "Getting propertyset for Lang=%s", ::rtl::OUStringToOString( names[i], RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - Reference< beans::XPropertySet > xPropSet = - Reference< beans::XPropertySet >( xNameAccess->getByName(names[i]), - UNO_QUERY_THROW ); - validateXRef( xPropSet, - "ScriptStorage::ScriptStorage: cannot get XPropertySet for name" ); + Reference< beans::XPropertySet > xPropSet( xNameAccess->getByName( names[i] ), UNO_QUERY_THROW ); Any aProp = xPropSet->getPropertyValue( OUString::createFromAscii( "SupportedFileExtensions") ); Sequence< OUString > extns; @@ -285,9 +263,7 @@ throw ( RuntimeException, Exception ) OUString xStringUri(m_stringUri); ScriptMetadataImporter* SMI = new ScriptMetadataImporter( m_xContext ); - Reference< xml::sax::XExtendedDocumentHandler > xSMI( SMI ); - - validateXRef( xSMI, "ScriptStorage::create: failed to obtain valid XExtendedDocumentHandler" ); + Reference< xml::sax::XExtendedDocumentHandler > xSMI( SMI, UNO_SET_THROW ); xStringUri = xStringUri.concat( ::rtl::OUString::createFromAscii( SCRIPT_DIR ) ); @@ -587,15 +563,14 @@ throw ( RuntimeException ) "/parcel.xml" ) ), RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - Reference< XInterface > xInterface = + xHandler.set( m_xMgr->createInstanceWithContext( - OUString::createFromAscii( "com.sun.star.xml.sax.Writer" ), - m_xContext ); - validateXRef( xInterface, "ScriptStorage::save: cannot get sax.Writer" ); - xHandler = Reference( - xInterface, UNO_QUERY_THROW ); - xSource = Reference< io::XActiveDataSource >( - xHandler, UNO_QUERY_THROW ); + OUString::createFromAscii( "com.sun.star.xml.sax.Writer" ), + m_xContext + ), + UNO_QUERY_THROW + ); + xSource.set( xHandler, UNO_QUERY_THROW ); xSource->setOutputStream( xOS ); writeMetadataHeader( xHandler ); diff --git a/scripting/source/storage/ScriptStorageManager.cxx b/scripting/source/storage/ScriptStorageManager.cxx index 77ca5a45dd15..424f2752bc47 100644 --- a/scripting/source/storage/ScriptStorageManager.cxx +++ b/scripting/source/storage/ScriptStorageManager.cxx @@ -45,6 +45,7 @@ #include "ScriptStorageManager.hxx" #include #include +#include using namespace ::rtl; using namespace ::com::sun::star; @@ -70,32 +71,19 @@ static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceNam // ScriptStorageManager Constructor ScriptStorageManager::ScriptStorageManager( const Reference< XComponentContext > & xContext ) SAL_THROW ( ( RuntimeException ) ) - : m_xContext( xContext ), m_count( 0 ), m_securityMgr( xContext ) + : m_xContext( xContext, UNO_SET_THROW ), m_count( 0 ), m_securityMgr( xContext ) { OSL_TRACE( "< ScriptStorageManager ctor called >\n" ); //s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); - validateXRef( m_xContext, - "ScriptStorageManager::ScriptStorageManager : cannot get component context" ); - - m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, - "ScriptStorageManager::ScriptStorageManager : cannot get service manager" ); + m_xMgr.set( m_xContext->getServiceManager(), UNO_SET_THROW ); try { // obtain the macro expander singleton to use in determining the // location of the application script storage - Any aAny = m_xContext->getValueByName( OUString::createFromAscii( - "/singletons/com.sun.star.util.theMacroExpander" ) ); - Reference< util::XMacroExpander > xME; - if ( sal_False == ( aAny >>= xME ) ) - { - throw RuntimeException( - OUSTR( "ScriptStorageManager::ScriptStorageManager: can't get XMacroExpander" ), - Reference< XInterface >() ); - } - validateXRef( xME, "ScriptStorageManager constructor: can't get MacroExpander" ); + Reference< util::XMacroExpander > xME( m_xContext->getValueByName( OUString::createFromAscii( + "/singletons/com.sun.star.util.theMacroExpander" ) ), UNO_QUERY_THROW ); OUString base = OUString::createFromAscii( SAL_CONFIGFILE( "${$BRAND_BASE_DIR/program/bootstrap" ) ); @@ -126,12 +114,13 @@ SAL_THROW ( ( RuntimeException ) ) { try { - Reference< XInterface > xInterface = + Reference< ucb::XSimpleFileAccess > xSFA( m_xMgr->createInstanceWithContext( - OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), m_xContext ); - validateXRef( xInterface, - "ScriptStorageManager constructor: can't get SimpleFileAccess XInterface" ); - Reference< ucb::XSimpleFileAccess > xSFA( xInterface, UNO_QUERY_THROW ); + OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), + m_xContext + ), + UNO_QUERY_THROW + ); setupAnyStorage( xSFA, xME->expandMacros( storageStr ), appStr ); } @@ -168,13 +157,14 @@ SAL_THROW ( ( RuntimeException ) ) ::rtl::OUStringToOString( storageStr, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - Reference< XInterface > xInterface = + Reference< XInterface > xInterface( m_xMgr->createInstanceWithArgumentsAndContext( - OUString::createFromAscii( - "drafts.com.sun.star.script.framework.storage.ScriptStorage" ), - aArgs, m_xContext ); - - validateXRef( xInterface, "ScriptStorageManager:: setupAnyStorage: Can't create ScriptStorage for share" ); + OUString::createFromAscii( "drafts.com.sun.star.script.framework.storage.ScriptStorage" ), + aArgs, + m_xContext + ), + UNO_QUERY_THROW + ); // and place it in the hash_map. Increment the counter m_ScriptStorageMap[ m_count++ ] = xInterface; @@ -215,8 +205,7 @@ ScriptStorageManager::createScriptStorage( throw ( RuntimeException ) { OSL_TRACE( "** ==> ScriptStorageManager in createScriptingStorage\n" ); - validateXRef( xSFA, - "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); + ENSURE_OR_THROW( xSFA.is(), "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); return setupAnyStorage( xSFA, ::rtl::OUString::createFromAscii( "" ), ::rtl::OUString::createFromAscii( "" ) ); @@ -229,7 +218,7 @@ ScriptStorageManager::createScriptStorageWithURI( throw ( RuntimeException ) { OSL_TRACE( "** ==> ScriptStorageManager in createScriptingStorageWithURI\n" ); - validateXRef( xSFA, "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); + ENSURE_OR_THROW( xSFA.is(), "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); // related to issue 11866 // warning dialog gets launched when adding binding to script in doc @@ -313,7 +302,7 @@ throw( RuntimeException ) OUSTR( "ScriptStorageManager::getScriptStorage: invalid storage ID" ), Reference< XInterface >() ); } - validateXRef( itr->second, + ENSURE_OR_THROW( itr->second.is(), "ScriptStorageManager::getScriptStorage: Cannot get ScriptStorage from ScriptStorageHash" ); return itr->second; } -- 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/basprov/basmethnode.cxx | 2 +- scripting/source/basprov/basmodnode.cxx | 4 ++-- scripting/source/basprov/basprov.cxx | 2 +- scripting/source/basprov/basscript.cxx | 6 +++--- scripting/source/protocolhandler/scripthandler.cxx | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'scripting/source') diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx index f27b612ce9cb..c4bc6f872834 100644 --- a/scripting/source/basprov/basmethnode.cxx +++ b/scripting/source/basprov/basmethnode.cxx @@ -218,7 +218,7 @@ namespace basprov if ( aFunctionName == BASPROV_PROPERTY_EDITABLE ) { ::rtl::OUString sDocURL, sLibName, sModName; - USHORT nLine1 = 0, nLine2; + sal_uInt16 nLine1 = 0, nLine2; if ( !m_bIsAppScript ) { diff --git a/scripting/source/basprov/basmodnode.cxx b/scripting/source/basprov/basmodnode.cxx index fe6ed69fccab..dc9d98acab64 100644 --- a/scripting/source/basprov/basmodnode.cxx +++ b/scripting/source/basprov/basmodnode.cxx @@ -100,7 +100,7 @@ namespace basprov sal_Int32 nRealCount = 0; for ( sal_Int32 i = 0; i < nCount; ++i ) { - SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< USHORT >( i ) ) ); + SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< sal_uInt16 >( i ) ) ); if ( pMethod && !pMethod->IsHidden() ) ++nRealCount; } @@ -110,7 +110,7 @@ namespace basprov sal_Int32 iTarget = 0; for ( sal_Int32 i = 0; i < nCount; ++i ) { - SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< USHORT >( i ) ) ); + SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< sal_uInt16 >( i ) ) ); if ( pMethod && !pMethod->IsHidden() ) pChildNodes[iTarget++] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( m_xContext, m_sScriptingContext, pMethod, m_bIsAppScript ) ); } diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx index ed6c9d7e6a5b..db697dfb807f 100644 --- a/scripting/source/basprov/basprov.cxx +++ b/scripting/source/basprov/basprov.cxx @@ -396,7 +396,7 @@ namespace basprov StarBASIC* pBasic = pBasicMgr->GetLib( aLibrary ); if ( !pBasic ) { - USHORT nId = pBasicMgr->GetLibId( aLibrary ); + sal_uInt16 nId = pBasicMgr->GetLibId( aLibrary ); if ( nId != LIB_NOTFOUND ) { pBasicMgr->LoadLib( nId ); diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx index 24bba1e7bff6..3006ba82e554 100644 --- a/scripting/source/basprov/basscript.cxx +++ b/scripting/source/basprov/basscript.cxx @@ -136,7 +136,7 @@ namespace basprov if ( pInfo ) { sal_Int32 nSbxOptional = 0; - USHORT n = 1; + sal_uInt16 n = 1; for ( const SbxParamInfo* pParamInfo = pInfo->GetParam( n ); pParamInfo; pParamInfo = pInfo->GetParam( ++n ) ) { if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != 0 ) @@ -169,7 +169,7 @@ namespace basprov { SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT ); unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), pParams[i] ); - xSbxParams->Put( xSbxVar, static_cast< USHORT >( i ) + 1 ); + xSbxParams->Put( xSbxVar, static_cast< sal_uInt16 >( i ) + 1 ); // Enable passing by ref if ( xSbxVar->GetType() != SbxVARIANT ) @@ -205,7 +205,7 @@ namespace basprov if ( pInfo_ ) { OutParamMap aOutParamMap; - for ( USHORT n = 1, nCount = xSbxParams->Count(); n < nCount; ++n ) + for ( sal_uInt16 n = 1, nCount = xSbxParams->Count(); n < nCount; ++n ) { const SbxParamInfo* pParamInfo = pInfo_->GetParam( n ); if ( pParamInfo && ( pParamInfo->eType & SbxBYREF ) != 0 ) 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 From 1d1e3298ae77049be883769273c440dedeaeae7d Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 28 Jan 2011 13:54:12 +0100 Subject: CWS gnumake3: more fixes for problems caused by crappy vbahelper headers --- scripting/source/dlgprov/makefile.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'scripting/source') diff --git a/scripting/source/dlgprov/makefile.mk b/scripting/source/dlgprov/makefile.mk index 111dca58edc2..b5de27bbce13 100644 --- a/scripting/source/dlgprov/makefile.mk +++ b/scripting/source/dlgprov/makefile.mk @@ -58,6 +58,7 @@ SHL1STDLIBS= \ $(CPPUHELPERLIB) \ $(COMPHELPERLIB) \ $(UCBHELPERLIB) \ + $(VBAHELPERLIB) \ $(CPPULIB) \ $(BASICLIB) \ $(SALLIB) -- cgit From 6d8c5d706723968e36f194c99134b83ed44e8c41 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 28 Jan 2011 13:59:35 +0100 Subject: CWS gnumake3: kill ENABLE_VBA --- scripting/source/vbaevents/makefile.mk | 5 ----- 1 file changed, 5 deletions(-) (limited to 'scripting/source') diff --git a/scripting/source/vbaevents/makefile.mk b/scripting/source/vbaevents/makefile.mk index 287bbe2b052b..aa4c416da96b 100755 --- a/scripting/source/vbaevents/makefile.mk +++ b/scripting/source/vbaevents/makefile.mk @@ -33,11 +33,6 @@ PRJ=..$/.. PRJNAME=scripting TARGET=vbaevents -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vbaevents..." -.ENDIF - VISIBILITY_HIDDEN=TRUE NO_BSYMBOLIC= TRUE ENABLE_EXCEPTIONS=TRUE -- cgit From fcc66077e2176b8bfc0908034eefefcf0f3bcf3d Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Tue, 15 Mar 2011 00:23:23 -0500 Subject: sligh mis-merge... was corrected during the m98 iteration, reported here. --- scripting/source/vbaevents/eventhelper.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripting/source') diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index b9ee8b3216c4..f6884cedfbe7 100755 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -1027,8 +1027,8 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce OSL_TRACE("*** trying to invoke %s ", rtl::OUStringToOString( sToResolve, RTL_TEXTENCODING_UTF8 ).getStr() ); - ooo::vba::VBAMacroResolvedInfo aMacroResolvedInfo = ooo::vba::resolveVBAMacro( mpShell, sToResolve ); - if ( aMacroResolvedInfo.IsResolved() ) + ooo::vba::MacroResolvedInfo aMacroResolvedInfo = ooo::vba::resolveVBAMacro( mpShell, sToResolve ); + if ( aMacroResolvedInfo.mbFound ) { if (! txInfo->ApproveRule(evt, txInfo->pPara) ) @@ -1047,7 +1047,7 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce // call basic event handlers for event // create script url - rtl::OUString url = aMacroResolvedInfo.ResolvedMacro(); + rtl::OUString url = aMacroResolvedInfo.msResolvedMacro; OSL_TRACE("resolved script = %s", rtl::OUStringToOString( url, -- cgit From c703f03e506d6fd8c0d8e8fde6608a8b4cbab021 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Tue, 15 Mar 2011 11:52:49 +0100 Subject: Fix build in scripting --- scripting/source/dlgprov/DialogModelProvider.cxx | 3 ++- scripting/source/dlgprov/dlgprov.cxx | 23 +++++++++++------------ scripting/source/dlgprov/dlgprov.hxx | 1 + 3 files changed, 14 insertions(+), 13 deletions(-) (limited to 'scripting/source') diff --git a/scripting/source/dlgprov/DialogModelProvider.cxx b/scripting/source/dlgprov/DialogModelProvider.cxx index fe8da6e511d7..462aaa1d95d7 100755 --- a/scripting/source/dlgprov/DialogModelProvider.cxx +++ b/scripting/source/dlgprov/DialogModelProvider.cxx @@ -94,7 +94,8 @@ void SAL_CALL DialogModelProvider::initialize(const css::uno::Sequence< uno::Any Any aDialogSourceURLAny; aDialogSourceURLAny <<= sURL; - m_xDialogModel.set( dlgprov::lcl_createDialogModel( m_xContext,xInput , xStringResourceManager, aDialogSourceURLAny ), UNO_QUERY_THROW); + Reference< frame::XModel > xModel; + m_xDialogModel.set( dlgprov::lcl_createDialogModel( m_xContext, xInput , xModel, xStringResourceManager, aDialogSourceURLAny ), UNO_QUERY_THROW); m_xDialogModelProp.set(m_xDialogModel, UNO_QUERY_THROW); } } diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx index c847a4a152db..fc2f5aab953e 100755 --- a/scripting/source/dlgprov/dlgprov.cxx +++ b/scripting/source/dlgprov/dlgprov.cxx @@ -138,6 +138,7 @@ static ::rtl::OUString aResourceResolverPropName(RTL_CONSTASCII_USTRINGPARAM("Re } Reference< container::XNameContainer > lcl_createDialogModel( const Reference< XComponentContext >& i_xContext, const Reference< io::XInputStream >& xInput, + const Reference< frame::XModel >& xModel, const Reference< resource::XStringResourceManager >& xStringResourceManager, const Any &aDialogSourceURL) throw ( Exception ) { @@ -147,7 +148,15 @@ static ::rtl::OUString aResourceResolverPropName(RTL_CONSTASCII_USTRINGPARAM("Re Reference< beans::XPropertySet > xDlgPropSet( xDialogModel, UNO_QUERY ); xDlgPropSet->setPropertyValue( aDlgSrcUrlPropName, aDialogSourceURL ); - ::xmlscript::importDialogModel( xInput, xDialogModel, i_xContext ); + // #TODO we really need to detect the source of the Dialog, is it + // the dialog. E.g. if the dialog was created from basic ( then we just + // can't tell where its from ) + // If we are happy to always substitute the form model for the awt + // one then maybe the presence of a document model is enough to trigger + // swapping out the models ( or perhaps we only want to do this + // for vba mode ) there are a number of feasible and valid possibilities + ::xmlscript::importDialogModel( xInput, xDialogModel, i_xContext, xModel ); + // Set resource property if( xStringResourceManager.is() ) { @@ -266,17 +275,7 @@ static ::rtl::OUString aResourceResolverPropName(RTL_CONSTASCII_USTRINGPARAM("Re const Reference< resource::XStringResourceManager >& xStringResourceManager, const Any &aDialogSourceURL) throw ( Exception ) { - - - // #TODO we really need to detect the source of the Dialog, is it - // the dialog. E.g. if the dialog was created from basic ( then we just - // can't tell where its from ) - // If we are happy to always substitute the form model for the awt - // one then maybe the presence of a document model is enough to trigger - // swapping out the models ( or perhaps we only want to do this - // for vba mode ) there are a number of feasible and valid possibilities - ::xmlscript::importDialogModel( xInput, xDialogModel, m_xContext, m_xModel ); - return lcl_createDialogModel(m_xContext,xInput,xStringResourceManager,aDialogSourceURL); + return lcl_createDialogModel(m_xContext,xInput,m_xModel,xStringResourceManager,aDialogSourceURL); } Reference< XControlModel > DialogProviderImpl::createDialogModelForBasic() throw ( Exception ) diff --git a/scripting/source/dlgprov/dlgprov.hxx b/scripting/source/dlgprov/dlgprov.hxx index 2545961a3d5e..773cfe9647f4 100755 --- a/scripting/source/dlgprov/dlgprov.hxx +++ b/scripting/source/dlgprov/dlgprov.hxx @@ -67,6 +67,7 @@ namespace dlgprov ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createDialogModel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel, const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager, const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception ); -- cgit