diff options
Diffstat (limited to 'vbahelper/source/msforms')
-rw-r--r-- | vbahelper/source/msforms/makefile.mk | 1 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbacontrol.cxx | 34 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbacontrol.hxx | 7 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbacontrols.cxx | 199 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbacontrols.hxx | 7 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbasystemaxcontrol.cxx | 101 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbasystemaxcontrol.hxx | 58 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbauserform.cxx | 4 |
8 files changed, 392 insertions, 19 deletions
diff --git a/vbahelper/source/msforms/makefile.mk b/vbahelper/source/msforms/makefile.mk index 7c61e4302b7f..5fce64649dcb 100644 --- a/vbahelper/source/msforms/makefile.mk +++ b/vbahelper/source/msforms/makefile.mk @@ -58,6 +58,7 @@ SLOFILES=\ $(SLO)$/vbamultipage.obj \ $(SLO)$/vbalistcontrolhelper.obj \ $(SLO)$/vbaspinbutton.obj \ + $(SLO)$/vbasystemaxcontrol.obj \ $(SLO)$/vbaimage.obj \ $(SLO)$/vbapages.obj \ $(SLO)$/vbauserform.obj \ diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index 2ff12b145824..82b68bbd5be7 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -57,6 +57,7 @@ #include "vbaprogressbar.hxx" #include "vbamultipage.hxx" #include "vbaspinbutton.hxx" +#include "vbasystemaxcontrol.hxx" #include "vbaimage.hxx" #include <vbahelper/helperdecl.hxx> @@ -254,6 +255,22 @@ void SAL_CALL ScVbaControl::SetFocus() throw (uno::RuntimeException) xWin->setFocus(); } +void SAL_CALL ScVbaControl::Move( double Left, double Top, const uno::Any& Width, const uno::Any& Height ) + throw ( uno::RuntimeException ) +{ + double nWidth = 0.0; + double nHeight = 0.0; + + setLeft( Left ); + setTop( Top ); + + if ( Width >>= nWidth ) + setWidth( nWidth ); + + if ( Height >>= nHeight ) + setHeight( nHeight ); +} + rtl::OUString SAL_CALL ScVbaControl::getControlSource() throw (uno::RuntimeException) { @@ -368,6 +385,20 @@ ScVbaControl::setControlTipText( const rtl::OUString& rsToolTip ) throw (css::un m_xProps->setPropertyValue (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) ), uno::makeAny( rsToolTip ) ); } + +::rtl::OUString SAL_CALL ScVbaControl::getTag() + throw (css::uno::RuntimeException) +{ + return m_aControlTag; +} + +void SAL_CALL ScVbaControl::setTag( const ::rtl::OUString& aTag ) + throw (css::uno::RuntimeException) +{ + m_aControlTag = aTag; +} + + //ScVbaControlFactory ScVbaControlFactory::ScVbaControlFactory( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel ): m_xContext( xContext ), m_xControl( xControl ), m_xModel( xModel ) @@ -383,7 +414,6 @@ ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XIn if ( !xControl.is() ) throw uno::RuntimeException(); // really we should be more informative return createControl( xControl, xParent ); - } ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< uno::XInterface >& /*xParent*/ ) throw (uno::RuntimeException) @@ -456,6 +486,8 @@ ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XCo pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) ) pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) ) + pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() ); return pControl; diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx index 1a8ed063548b..992fbd94a8c5 100644 --- a/vbahelper/source/msforms/vbacontrol.hxx +++ b/vbahelper/source/msforms/vbacontrol.hxx @@ -48,6 +48,10 @@ class ScVbaControl : public ControlImpl_BASE private: com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener; protected: + // awt control has nothing similar to Tag property of Mso controls, + // whether it is necessary is another question + ::rtl::OUString m_aControlTag; + std::auto_ptr< ov::AbstractGeometryAttributes > mpGeometryHelper; css::uno::Reference< css::beans::XPropertySet > m_xProps; css::uno::Reference< css::uno::XInterface > m_xControl; @@ -75,6 +79,7 @@ public: virtual double SAL_CALL getTop() throw (css::uno::RuntimeException); virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException); virtual void SAL_CALL SetFocus( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Move( double Left, double Top, const ::com::sun::star::uno::Any& Width, const ::com::sun::star::uno::Any& Height ) throw (::com::sun::star::uno::RuntimeException); virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException); virtual rtl::OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException); @@ -85,6 +90,8 @@ public: virtual void SAL_CALL setName( const rtl::OUString& _name ) throw (css::uno::RuntimeException); virtual rtl::OUString SAL_CALL getControlTipText() throw (css::uno::RuntimeException); virtual void SAL_CALL setControlTipText( const rtl::OUString& ) throw (css::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTag() throw (css::uno::RuntimeException); + virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException); //remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape virtual void removeResouce() throw( css::uno::RuntimeException ); //XHelperInterface diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 48ef83d60aa6..8d01687ef905 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -25,9 +25,14 @@ * ************************************************************************/ +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/lang/WrappedTargetException.hpp> + #include "vbacontrols.hxx" #include <cppuhelper/implbase2.hxx> -#include <com/sun/star/awt/XControlContainer.hpp> #include <ooo/vba//XControlProvider.hpp> #include <hash_map> @@ -48,31 +53,55 @@ class ControlArrayWrapper : public ArrayWrapImpl ControlVec mControls; ControlIndexMap mIndices; - rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl ) +private: + void SetArrayElementTo( const uno::Reference< awt::XControl >& xCtrl, sal_Int32 nIndex = -1 ) { - uno::Reference< beans::XPropertySet > xProp( xCtrl->getModel(), uno::UNO_QUERY ); - rtl::OUString sName; - xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName; - return sName; + // initialize the element with specified index to the control + if ( xCtrl.is() ) + { + if ( nIndex == -1 ) + nIndex = msNames.getLength(); + + if ( nIndex >= msNames.getLength() ) + msNames.realloc( nIndex ); + + msNames[ nIndex ] = getControlName( xCtrl ); + mControls.push_back( xCtrl ); + mIndices[ msNames[ nIndex ] ] = nIndex; + } } public: - ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog ) { - mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); - uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls(); + try + { + mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls(); - msNames.realloc( sXControls.getLength() ); - for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i ) + msNames.realloc( sXControls.getLength() ); + for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i ) + SetArrayElementTo( sXControls[ i ], i ); + } + catch( uno::Exception& ) { - uno::Reference< awt::XControl > xCtrl = sXControls[ i ]; - msNames[ i ] = getControlName( xCtrl ); - mControls.push_back( xCtrl ); - mIndices[ msNames[ i ] ] = i; + // accept the case when the dialog already does not exist + // in this case the wrapper should work in dummy mode } } + static rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl ) + { + if ( !xCtrl.is() ) + throw uno::RuntimeException(); + + uno::Reference< beans::XPropertySet > xProp( xCtrl->getModel(), uno::UNO_QUERY_THROW ); + rtl::OUString sName; + xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName; + return sName; + } + + // XElementAccess virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { @@ -165,7 +194,7 @@ ScVbaControls::ScVbaControls( const uno::Reference< XHelperInterface >& xParent, const css::uno::Reference< awt::XControl >& xDialog ) : ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ) { - mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); + mxDialog.set( xDialog, uno::UNO_QUERY ); } uno::Reference< container::XEnumeration > @@ -204,6 +233,144 @@ ScVbaControls::Move( double cx, double cy ) throw (uno::RuntimeException) } } +uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& StringKey, const uno::Any& /*Before*/, const uno::Any& /*After*/ ) + throw (uno::RuntimeException) +{ + uno::Any aResult; + ::rtl::OUString aComServiceName; + + try + { + if ( !mxDialog.is() ) + throw uno::RuntimeException(); + + uno::Reference< awt::XControl > xNewControl; + uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW ); + + uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW ); + + Object >>= aComServiceName; + + // TODO: Support Before and After? + ::rtl::OUString aNewName; + StringKey >>= aNewName; + if ( !aNewName.getLength() ) + { + aNewName = aComServiceName; + if ( !aNewName.getLength() ) + aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) ); + + sal_Int32 nInd = 0; + while( xDialogContainer->hasByName( aNewName ) && nInd < SAL_MAX_INT32 ) + { + aNewName = aComServiceName; + aNewName += ::rtl::OUString::valueOf( nInd ); + } + } + + if ( aComServiceName.getLength() ) + { + uno::Reference< awt::XControlModel > xNewModel( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW ); + + + xDialogContainer->insertByName( aNewName, uno::makeAny( xNewModel ) ); + uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW ); + xNewControl = xControlContainer->getControl( aNewName ); + + try + { + uno::Reference< script::XInvocation > xControlInvoke( xNewControl, uno::UNO_QUERY_THROW ); + + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] <<= aComServiceName; + uno::Sequence< sal_Int16 > aOutIDDummy; + uno::Sequence< uno::Any > aOutDummy; + xControlInvoke->invoke( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SOAddAXControl" ) ), aArgs, aOutIDDummy, aOutDummy ); + } + catch( uno::Exception& ) + { + xDialogContainer->removeByName( aNewName ); + throw; + } + } + + if ( xNewControl.is() ) + { + UpdateCollectionIndex( lcl_controlsWrapper( mxDialog ) ); + aResult <<= xNewControl; + aResult = createCollectionObject( aResult ); + } + else + throw uno::RuntimeException(); + } + catch( uno::RuntimeException& ) + { + throw; + } + catch( uno::Exception& e ) + { + throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( e ) ); + } + + return aResult; +} + +void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex ) + throw (uno::RuntimeException) +{ + ::rtl::OUString aControlName; + sal_Int32 nIndex = -1; + + try + { + if ( !mxDialog.is() ) + throw uno::RuntimeException(); + + uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW ); + uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW ); + + if ( !( ( StringKeyOrIndex >>= aControlName ) && aControlName.getLength() ) + && !( ( StringKeyOrIndex >>= nIndex ) && nIndex >= 0 && nIndex < m_xIndexAccess->getCount() ) ) + throw uno::RuntimeException(); + + uno::Reference< awt::XControl > xControl; + if ( aControlName.getLength() ) + { + uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW ); + xControl = xControlContainer->getControl( aControlName ); + } + else + { + m_xIndexAccess->getByIndex( nIndex ) >>= xControl; + } + + if ( !xControl.is() ) + throw uno::RuntimeException(); + + if ( !aControlName.getLength() ) + aControlName = ControlArrayWrapper::getControlName( xControl ); + + xDialogContainer->removeByName( aControlName ); + xControl->dispose(); + } + catch( uno::RuntimeException& ) + { + // the exceptions are not rethrown, impossibility to find or remove the control is currently not reported + // since in most cases it means just that the controls is already not there, the VBA seems to do it in the same way + + // throw; + } + catch( uno::Exception& e ) + { + // throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), + // uno::Reference< uno::XInterface >(), + // uno::makeAny( e ) ); + } +} + + uno::Type ScVbaControls::getElementType() throw (uno::RuntimeException) { diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx index 804133dbddfa..a72506609531 100644 --- a/vbahelper/source/msforms/vbacontrols.hxx +++ b/vbahelper/source/msforms/vbacontrols.hxx @@ -39,14 +39,19 @@ typedef CollTestImplHelper< ov::msforms::XControls > ControlsImpl_BASE; class ScVbaControls : public ControlsImpl_BASE { css::uno::Reference< css::awt::XControl > mxDialog; + protected: virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); + public: ScVbaControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::awt::XControl >& xDialog ); // XControls - virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL Add( const ::com::sun::star::uno::Any& Object, const ::com::sun::star::uno::Any& StringKey, const ::com::sun::star::uno::Any& Before, const ::com::sun::star::uno::Any& After ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL Remove( const ::com::sun::star::uno::Any& StringKeyOrIndex ) throw (::com::sun::star::uno::RuntimeException); + // XEnumerationAccess virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); diff --git a/vbahelper/source/msforms/vbasystemaxcontrol.cxx b/vbahelper/source/msforms/vbasystemaxcontrol.cxx new file mode 100644 index 000000000000..ed2fc70164ac --- /dev/null +++ b/vbahelper/source/msforms/vbasystemaxcontrol.cxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "vbasystemaxcontrol.hxx" + +using namespace com::sun::star; +using namespace ooo::vba; + +//---------------------------------------------------------- +VbaSystemAXControl::VbaSystemAXControl( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) +: SystemAXControlImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +, m_xControlInvocation( xControl, uno::UNO_QUERY_THROW ) +{ +} + +//---------------------------------------------------------- +uno::Reference< beans::XIntrospectionAccess > SAL_CALL VbaSystemAXControl::getIntrospection() + throw ( uno::RuntimeException ) +{ + return m_xControlInvocation->getIntrospection(); +} + +//---------------------------------------------------------- +uno::Any SAL_CALL VbaSystemAXControl::invoke( const ::rtl::OUString& aFunctionName, const uno::Sequence< uno::Any >& aParams, uno::Sequence< ::sal_Int16 >& aOutParamIndex, uno::Sequence< uno::Any >& aOutParam ) + throw ( lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException ) +{ + return m_xControlInvocation->invoke( aFunctionName, aParams, aOutParamIndex, aOutParam ); +} + +//---------------------------------------------------------- +void SAL_CALL VbaSystemAXControl::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) + throw ( beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException ) +{ + m_xControlInvocation->setValue( aPropertyName, aValue ); +} + +//---------------------------------------------------------- +uno::Any SAL_CALL VbaSystemAXControl::getValue( const ::rtl::OUString& aPropertyName ) + throw ( beans::UnknownPropertyException, uno::RuntimeException ) +{ + return m_xControlInvocation->getValue( aPropertyName ); +} + +//---------------------------------------------------------- +::sal_Bool SAL_CALL VbaSystemAXControl::hasMethod( const ::rtl::OUString& aName ) + throw ( uno::RuntimeException ) +{ + return m_xControlInvocation->hasMethod( aName ); +} + +//---------------------------------------------------------- +::sal_Bool SAL_CALL VbaSystemAXControl::hasProperty( const ::rtl::OUString& aName ) + throw ( uno::RuntimeException ) +{ + return m_xControlInvocation->hasProperty( aName ); +} + +//---------------------------------------------------------- +rtl::OUString& +VbaSystemAXControl::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM( "VbaSystemAXControl" ) ); + return sImplName; +} + +//---------------------------------------------------------- +uno::Sequence< rtl::OUString > +VbaSystemAXControl::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.msforms.Frame" ) ); + } + return aServiceNames; +} + diff --git a/vbahelper/source/msforms/vbasystemaxcontrol.hxx b/vbahelper/source/msforms/vbasystemaxcontrol.hxx new file mode 100644 index 000000000000..bffe5b99c4f1 --- /dev/null +++ b/vbahelper/source/msforms/vbasystemaxcontrol.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef VBA_SYSTEMAXCONTROL_HXX +#define VBA_SYSTEMAXCONTROL_HXX + +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/script/XInvocation.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper1< ScVbaControl, css::script::XInvocation > SystemAXControlImpl_BASE; + +class VbaSystemAXControl : public SystemAXControlImpl_BASE +{ + css::uno::Reference< css::script::XInvocation > m_xControlInvocation; + +public: + VbaSystemAXControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ); + + // XInvocation + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< ::sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException ); + virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw ( ::com::sun::star::uno::RuntimeException ); + virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw ( ::com::sun::star::uno::RuntimeException ); + + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; + +#endif diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index 1ce403fc19c3..2a4cecfc2338 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -185,7 +185,9 @@ ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::Runtime uno::Any SAL_CALL ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException) { - uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW ); + // if the dialog already closed we should do nothing, but the VBA will call methods of the Controls objects + // thus we have to provide a dummy object in this case + uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY ); uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) ); if ( index.hasValue() ) return uno::makeAny( xControls->Item( index, uno::Any() ) ); |