diff options
Diffstat (limited to 'vbahelper/source/msforms')
39 files changed, 631 insertions, 161 deletions
diff --git a/vbahelper/source/msforms/service.cxx b/vbahelper/source/msforms/service.cxx index 01e6014a37..432552254b 100644 --- a/vbahelper/source/msforms/service.cxx +++ b/vbahelper/source/msforms/service.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -57,6 +58,16 @@ 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"); + + // Component registration + return component_writeInfoHelper( pServiceManager, pRegistryKey, + controlprovider::serviceDecl, userform::serviceDecl ); + } + SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) @@ -68,3 +79,5 @@ extern "C" return pRet; } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbabutton.cxx b/vbahelper/source/msforms/vbabutton.cxx index ed93d0b6e7..69e4733c5d 100644 --- a/vbahelper/source/msforms/vbabutton.cxx +++ b/vbahelper/source/msforms/vbabutton.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -69,3 +70,5 @@ ScVbaButton::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbabutton.hxx b/vbahelper/source/msforms/vbabutton.hxx index 0596c0bd28..1a01d69165 100644 --- a/vbahelper/source/msforms/vbabutton.hxx +++ b/vbahelper/source/msforms/vbabutton.hxx @@ -47,3 +47,5 @@ public: virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; #endif //SC_VBA_BUTTON_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbacheckbox.cxx b/vbahelper/source/msforms/vbacheckbox.cxx index 15175f0e0f..fea0853b68 100644 --- a/vbahelper/source/msforms/vbacheckbox.cxx +++ b/vbahelper/source/msforms/vbacheckbox.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -70,6 +71,8 @@ void SAL_CALL ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException) { sal_Int16 nValue = 0; + sal_Int16 nOldValue = 0; + m_xProps->getPropertyValue( STATE ) >>= nOldValue; sal_Bool bValue = false; if( _value >>= nValue ) { @@ -82,6 +85,8 @@ ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeExcept nValue = 1; } m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) ); + if ( nValue != nOldValue ) + fireClickEvent(); } rtl::OUString& ScVbaCheckbox::getServiceImplName() @@ -102,3 +107,4 @@ ScVbaCheckbox::getServiceNames() return aServiceNames; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbacheckbox.hxx b/vbahelper/source/msforms/vbacheckbox.hxx index d3922d84a9..2c306486b0 100644 --- a/vbahelper/source/msforms/vbacheckbox.hxx +++ b/vbahelper/source/msforms/vbacheckbox.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -44,10 +45,12 @@ public: virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); // XDefaultProperty - rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } + rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; #endif //SC_VBA_CHECKBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx index 4dfbf2908a..d0446bca77 100644 --- a/vbahelper/source/msforms/vbacombobox.cxx +++ b/vbahelper/source/msforms/vbacombobox.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,6 +27,9 @@ ************************************************************************/ #include "vbacombobox.hxx" #include <vector> +#include <filter/msfilter/msvbahelper.hxx> +#include <basic/sbstar.hxx> +#include <basic/sbmod.hxx> using namespace com::sun::star; using namespace ooo::vba; @@ -63,12 +67,18 @@ ScVbaComboBox::setListIndex( const uno::Any& _value ) throw (uno::RuntimeExcepti sal_Int16 nIndex = 0; if( _value >>= nIndex ) { + sal_Int32 nOldIndex = -1; + getListIndex() >>= nOldIndex; uno::Sequence< rtl::OUString > sItems; m_xProps->getPropertyValue( ITEMS ) >>= sItems; if( ( nIndex >= 0 ) && ( sItems.getLength() > nIndex ) ) { rtl::OUString sText = sItems[ nIndex ]; m_xProps->setPropertyValue( TEXT, uno::makeAny( sText ) ); + + // fire the _Change event + if( nOldIndex != nIndex ) + fireClickEvent(); } } } @@ -103,7 +113,38 @@ ScVbaComboBox::getListIndex() throw (uno::RuntimeException) void SAL_CALL ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException) { - m_xProps->setPropertyValue( sSourceName, _value ); + rtl::OUString sOldValue, sNewValue; + getValue() >>= sOldValue; + + uno::Any aConverted = _value; + uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext ); + try + { + aConverted = xConverter.is() ? xConverter->convertTo( _value, getCppuType( static_cast< const rtl::OUString* >(0) ) ) : aConverted; + } + catch( const uno::Exception& /*ex*/ ) + { + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid value" ) ), uno::Reference< uno::XInterface >() ); + } + + m_xProps->setPropertyValue( sSourceName, aConverted ); + + aConverted >>= sNewValue; + if ( sNewValue != sOldValue ) + { + // If the new value is in current list, we should fire click event, otherwise fire the change event. + sal_Int32 nListIndex = -1; + getListIndex() >>= nListIndex; + sal_Bool bIsInList = ( nListIndex >= 0 ); + if ( bIsInList ) + { + fireClickEvent(); + } + else + { + fireChangeEvent(); + } + } } // see Value @@ -178,3 +219,5 @@ ScVbaComboBox::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx index e7e86a00fd..77a546e678 100644 --- a/vbahelper/source/msforms/vbacombobox.hxx +++ b/vbahelper/source/msforms/vbacombobox.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -68,10 +69,12 @@ public: virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException); // XDefaultProperty - ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } + ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; #endif // + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index 28f6d7f61c..6b14bed48e 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -1,7 +1,8 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * 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 @@ -28,6 +29,7 @@ #include <com/sun/star/awt/XControlModel.hpp> #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/awt/XActionListener.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/drawing/XControlShape.hpp> @@ -39,6 +41,9 @@ #include <com/sun/star/form/binding/XListEntrySink.hpp> #include <com/sun/star/table/CellAddress.hpp> #include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/script/XScriptListener.hpp> +#include <com/sun/star/document/XCodeNameQuery.hpp> +#include <com/sun/star/form/XChangeListener.hpp> #include <ooo/vba/XControlProvider.hpp> #ifdef VBA_OOBUILD_HACK #include <svtools/bindablecontrolhelper.hxx> @@ -65,15 +70,15 @@ using namespace com::sun::star; using namespace ooo::vba; -uno::Reference< css::awt::XWindowPeer > +uno::Reference< css::awt::XWindowPeer > ScVbaControl::getWindowPeer() throw (uno::RuntimeException) { uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ); uno::Reference< awt::XControlModel > xControlModel; uno::Reference< css::awt::XWindowPeer > xWinPeer; - if ( !xControlShape.is() ) - { + if ( !xControlShape.is() ) + { // would seem to be a Userform control uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY_THROW ); xWinPeer = xControl->getPeer(); @@ -90,7 +95,7 @@ ScVbaControl::getWindowPeer() throw (uno::RuntimeException) } catch( uno::Exception ) { - throw uno::RuntimeException( rtl::OUString::createFromAscii( "The Control does not exsit" ), + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The Control does not exsit")), uno::Reference< uno::XInterface >() ); } return xWinPeer; @@ -127,21 +132,30 @@ ScVbaControlListener::disposing( const lang::EventObject& ) throw( uno::RuntimeE //ScVbaControl -ScVbaControl::ScVbaControl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< ::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ControlImpl_BASE( xParent, xContext ), m_xControl( xControl ), m_xModel( xModel ) +ScVbaControl::ScVbaControl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< ::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ControlImpl_BASE( xParent, xContext ), bIsDialog(false), m_xControl( xControl ), m_xModel( xModel ) { //add listener m_xEventListener.set( new ScVbaControlListener( this ) ); setGeometryHelper( pGeomHelper ); uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW ); xComponent->addEventListener( m_xEventListener ); - + //init m_xProps uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ) ; uno::Reference< awt::XControl> xUserFormControl( m_xControl, uno::UNO_QUERY ) ; if ( xControlShape.is() ) // form control + { m_xProps.set( xControlShape->getControl(), uno::UNO_QUERY_THROW ); + rtl::OUString sDefaultControl; + m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultControl") ) ) >>= sDefaultControl; + uno::Reference< lang::XMultiComponentFactory > xMFac( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); + m_xEmptyFormControl.set( xMFac->createInstanceWithContext( sDefaultControl, mxContext ), uno::UNO_QUERY_THROW ); + } else if ( xUserFormControl.is() ) // userform control + { m_xProps.set( xUserFormControl->getModel(), uno::UNO_QUERY_THROW ); + bIsDialog = true; + } } ScVbaControl::~ScVbaControl() @@ -153,7 +167,7 @@ ScVbaControl::~ScVbaControl() } } -void +void ScVbaControl::setGeometryHelper( AbstractGeometryAttributes* pHelper ) { mpGeometryHelper.reset( pHelper ); @@ -227,6 +241,7 @@ void SAL_CALL ScVbaControl::setLeft( double _left ) throw (uno::RuntimeException) { mpGeometryHelper->setLeft( _left ); + } double SAL_CALL @@ -248,7 +263,7 @@ ScVbaControl::getObject() throw (uno::RuntimeException) return xRet; } -void SAL_CALL ScVbaControl::SetFocus() throw (uno::RuntimeException) +void SAL_CALL ScVbaControl::SetFocus() throw (uno::RuntimeException) { uno::Reference< awt::XWindow > xWin( m_xControl, uno::UNO_QUERY_THROW ); xWin->setFocus(); @@ -270,7 +285,7 @@ void SAL_CALL ScVbaControl::Move( double Left, double Top, const uno::Any& Width setHeight( nHeight ); } -rtl::OUString SAL_CALL +rtl::OUString SAL_CALL ScVbaControl::getControlSource() throw (uno::RuntimeException) { // #FIXME I *hate* having these upstream differences @@ -293,7 +308,7 @@ ScVbaControl::getControlSource() throw (uno::RuntimeException) } catch( uno::Exception& ) { - } + } } return sControlSource; #else @@ -301,7 +316,7 @@ ScVbaControl::getControlSource() throw (uno::RuntimeException) #endif } -void SAL_CALL +void SAL_CALL ScVbaControl::setControlSource( const rtl::OUString& _controlsource ) throw (uno::RuntimeException) { #ifdef VBA_OOBUILD_HACK @@ -312,7 +327,7 @@ ScVbaControl::setControlSource( const rtl::OUString& _controlsource ) throw (uno #endif } -rtl::OUString SAL_CALL +rtl::OUString SAL_CALL ScVbaControl::getRowSource() throw (uno::RuntimeException) { #ifdef VBA_OOBUILD_HACK @@ -333,7 +348,7 @@ ScVbaControl::getRowSource() throw (uno::RuntimeException) } catch( uno::Exception& ) { - } + } } return sRowSource; #else @@ -341,7 +356,7 @@ ScVbaControl::getRowSource() throw (uno::RuntimeException) #endif } -void SAL_CALL +void SAL_CALL ScVbaControl::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException) { #ifdef VBA_OOBUILD_HACK @@ -352,7 +367,7 @@ ScVbaControl::setRowSource( const rtl::OUString& _rowsource ) throw (uno::Runtim #endif } -rtl::OUString SAL_CALL +rtl::OUString SAL_CALL ScVbaControl::getName() throw (uno::RuntimeException) { rtl::OUString sName; @@ -369,7 +384,7 @@ ScVbaControl::setName( const rtl::OUString& _name ) throw (uno::RuntimeException (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), uno::makeAny( _name ) ); } -rtl::OUString SAL_CALL +rtl::OUString SAL_CALL ScVbaControl::getControlTipText() throw (css::uno::RuntimeException) { rtl::OUString sName; @@ -378,7 +393,7 @@ ScVbaControl::getControlTipText() throw (css::uno::RuntimeException) return sName; } -void SAL_CALL +void SAL_CALL ScVbaControl::setControlTipText( const rtl::OUString& rsToolTip ) throw (css::uno::RuntimeException) { m_xProps->setPropertyValue @@ -397,6 +412,85 @@ void SAL_CALL ScVbaControl::setTag( const ::rtl::OUString& aTag ) m_aControlTag = aTag; } +::sal_Int32 SAL_CALL ScVbaControl::getForeColor() throw (::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nForeColor = -1; + m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextColor" ) ) ) >>= nForeColor; + return OORGBToXLRGB( nForeColor ); +} + +void SAL_CALL ScVbaControl::setForeColor( ::sal_Int32 _forecolor ) throw (::com::sun::star::uno::RuntimeException) +{ + m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextColor" ) ), uno::makeAny( XLRGBToOORGB( _forecolor ) ) ); +} + +void ScVbaControl::fireEvent( script::ScriptEvent& evt ) +{ + uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); + uno::Reference< script::XScriptListener > xScriptListener( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.EventListener" ) ), mxContext ), uno::UNO_QUERY_THROW ); + + uno::Reference< beans::XPropertySet > xProps( xScriptListener, uno::UNO_QUERY_THROW ); + xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ), uno::makeAny( m_xModel ) ); + + // handling for sheet control + uno::Reference< msforms::XControl > xThisControl( this ); + try + { + evt.Arguments.realloc( 1 ); + lang::EventObject aEvt; + + uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ) ; + uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY ) ; + + if ( xControlShape.is() ) + { + evt.Source = xControlShape; + aEvt.Source = m_xEmptyFormControl; + // Set up proper scriptcode + uno::Reference< lang::XMultiServiceFactory > xDocFac( m_xModel, uno::UNO_QUERY_THROW ); + uno::Reference< document::XCodeNameQuery > xNameQuery( xDocFac->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooo.vba.VBACodeNameProvider")) ), uno::UNO_QUERY_THROW ); + uno::Reference< uno::XInterface > xIf( xControlShape->getControl(), uno::UNO_QUERY_THROW ); + evt.ScriptCode = xNameQuery->getCodeNameForObject( xIf ); + evt.Arguments[ 0 ] = uno::makeAny( aEvt ); + xScriptListener->firing( evt ); + } + else + { + if ( xControl.is() ) // normal control ( from dialog/userform ) + { + // #FIXME We should probably store a reference to the + // parent dialog/userform here ( other wise the name of + // dialog could be changed and we won't be aware of it. + // ( OTOH this is probably an unlikely scenario ) + evt.Source = xThisControl; + aEvt.Source = xControl; + evt.ScriptCode = m_sLibraryAndCodeName; + evt.Arguments[ 0 ] = uno::makeAny( aEvt ); + xScriptListener->firing( evt ); + } + } + } + catch( uno::Exception& e ) + { + } +} +void ScVbaControl::fireChangeEvent() +{ + script::ScriptEvent evt; + evt.ScriptType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VBAInterop") ); + evt.ListenerType = form::XChangeListener::static_type(0); + evt.MethodName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("changed") ); + fireEvent( evt ); +} + +void ScVbaControl::fireClickEvent() +{ + script::ScriptEvent evt; + evt.ScriptType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VBAInterop") ); + evt.ListenerType = awt::XActionListener::static_type(0); + evt.MethodName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("actionPerformed") ); + fireEvent( evt ); +} //ScVbaControlFactory @@ -422,16 +516,25 @@ ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing:: const static rtl::OUString sClassId( RTL_CONSTASCII_USTRINGPARAM("ClassId") ); xProps->getPropertyValue( sClassId ) >>= nClassId; uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess + sal_Bool bToggle = sal_False; switch( nClassId ) { case form::FormComponentType::COMBOBOX: return new ScVbaComboBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); case form::FormComponentType::COMMANDBUTTON: - return new ScVbaButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toggle") ) ) >>= bToggle; + if ( bToggle ) + return new ScVbaToggleButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + else + return new ScVbaButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + case form::FormComponentType::FIXEDTEXT: return new ScVbaLabel( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); case form::FormComponentType::TEXTFIELD: return new ScVbaTextBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + case form::FormComponentType::CHECKBOX: + return new ScVbaCheckbox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); case form::FormComponentType::RADIOBUTTON: return new ScVbaRadioButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); case form::FormComponentType::LISTBOX: @@ -441,8 +544,8 @@ ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing:: case form::FormComponentType::IMAGECONTROL: return new ScVbaImage( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); default: - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Donot support this Control Type." ), uno::Reference< uno::XInterface >() ); + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Donot support this Control Type." )), uno::Reference< uno::XInterface >() ); } } @@ -453,9 +556,9 @@ ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XCo ScVbaControl* pControl = NULL; uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) ) - pControl = new ScVbaCheckbox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaCheckbox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) ) - pControl = new ScVbaRadioButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaRadioButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) ) pControl = new ScVbaTextBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) ) @@ -470,36 +573,41 @@ ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XCo else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) ) pControl = new ScVbaComboBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) - pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) ) - pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) ) - pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) ) - pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) - pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) ) - pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) ) - pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent ); + pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent ); + // #FIXME implement a page control + else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoPageModel") ) ) ) + pControl = new ScVbaControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoFrameModel") ) ) ) + pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); 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 ) ); + 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 ) ); + 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 >() ); + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unsupported control ")), uno::Reference< uno::XInterface >() ); return pControl; } -rtl::OUString& +rtl::OUString& ScVbaControl::getServiceImplName() { static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControl") ); return sImplName; } -uno::Sequence< rtl::OUString > +uno::Sequence< rtl::OUString > ScVbaControl::getServiceNames() { static uno::Sequence< rtl::OUString > aServiceNames; @@ -523,25 +631,25 @@ public: virtual uno::Reference< msforms::XControl > SAL_CALL createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException); }; -uno::Reference< msforms::XControl > SAL_CALL +uno::Reference< msforms::XControl > SAL_CALL ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException) { uno::Reference< msforms::XControl > xControlToReturn; - if ( xControlShape.is() ) + if ( xControlShape.is() ) { ScVbaControlFactory controlFactory( m_xCtx, xControlShape, xDocOwner ); xControlToReturn.set( controlFactory.createControl( xDocOwner ) ); } return xControlToReturn; - + } -uno::Reference< msforms::XControl > SAL_CALL +uno::Reference< msforms::XControl > SAL_CALL ControlProviderImpl::createUserformControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< awt::XControl >& xDialog, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException) { uno::Reference< msforms::XControl > xControlToReturn; - if ( xControl.is() && xDialog.is() ) - { - + if ( xControl.is() && xDialog.is() ) + { + ScVbaControlFactory controlFactory( m_xCtx, xControl, xDocOwner ); xControlToReturn.set( controlFactory.createControl( xDialog->getModel() ) ); ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xControlToReturn.get() ); @@ -561,3 +669,4 @@ extern sdecl::ServiceDecl const serviceDecl( } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx index d2631c761e..ed7004a1e4 100644 --- a/vbahelper/source/msforms/vbacontrol.hxx +++ b/vbahelper/source/msforms/vbacontrol.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,6 +35,7 @@ #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XWindowPeer.hpp> +#include <com/sun/star/script/ScriptEvent.hpp> #include <ooo/vba/msforms/XControl.hpp> #include <vbahelper/vbahelper.hxx> @@ -47,17 +49,23 @@ class ScVbaControl : public ControlImpl_BASE { private: com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener; + com::sun::star::uno::Reference< com::sun::star::awt::XControl > m_xEmptyFormControl; protected: // awt control has nothing similar to Tag property of Mso controls, // whether it is necessary is another question ::rtl::OUString m_aControlTag; + bool bIsDialog; + rtl::OUString m_sLibraryAndCodeName; std::auto_ptr< ov::AbstractGeometryAttributes > mpGeometryHelper; css::uno::Reference< css::beans::XPropertySet > m_xProps; css::uno::Reference< css::uno::XInterface > m_xControl; css::uno::Reference< css::frame::XModel > m_xModel; virtual css::uno::Reference< css::awt::XWindowPeer > getWindowPeer() throw (css::uno::RuntimeException); + void fireChangeEvent(); + void fireClickEvent(); + void fireEvent( css::script::ScriptEvent& evt ); public: ScVbaControl( 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* pHelper ); @@ -65,6 +73,10 @@ public: // This class will own the helper, so make sure it is allocated from // the heap void setGeometryHelper( ov::AbstractGeometryAttributes* pHelper ); + // sets the name of the associated library ( used for UserForm controls ) + void setLibraryAndCodeName( const rtl::OUString& sLibCodeName ) { m_sLibraryAndCodeName = sLibCodeName; } + rtl::OUString getLibraryAndCodeName() { return m_sLibraryAndCodeName; } + // XControl virtual sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException); virtual void SAL_CALL setEnabled( sal_Bool _enabled ) throw (css::uno::RuntimeException); @@ -94,6 +106,8 @@ public: 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 ); + virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setForeColor( ::sal_Int32 _forecolor ) throw (::com::sun::star::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); @@ -115,3 +129,5 @@ private: }; #endif//SC_VBA_CONTROL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 78c8b25885..55bc5b8c36 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -70,7 +71,19 @@ private: mIndices[ msNames[ nIndex ] ] = nIndex; } } - + void getNestedControls( ControlVec& vControls, uno::Reference< awt::XControlContainer >& xContainer ) + { + uno::Sequence< uno::Reference< awt::XControl > > aControls = xContainer->getControls(); + const uno::Reference< awt::XControl >* pCtrl = aControls.getConstArray(); + const uno::Reference< awt::XControl >* pCtrlsEnd = pCtrl + aControls.getLength(); + for ( ; pCtrl < pCtrlsEnd; ++pCtrl ) + { + uno::Reference< awt::XControlContainer > xC( *pCtrl, uno::UNO_QUERY ); + vControls.push_back( *pCtrl ); + if ( xC.is() ) + getNestedControls( vControls, xC ); + } + } public: ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog ) { @@ -394,3 +407,5 @@ ScVbaControls::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx index a050415c9b..cbbb4fcafe 100644 --- a/vbahelper/source/msforms/vbacontrols.hxx +++ b/vbahelper/source/msforms/vbacontrols.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -62,3 +63,4 @@ public: }; #endif //SC_VBA_OLEOBJECTS_HXX +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbaframe.cxx b/vbahelper/source/msforms/vbaframe.cxx index 3c202f1e58..09d3b3c7fb 100644 --- a/vbahelper/source/msforms/vbaframe.cxx +++ b/vbahelper/source/msforms/vbaframe.cxx @@ -1,7 +1,8 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * 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 @@ -37,7 +38,7 @@ ScVbaFrame::ScVbaFrame( const uno::Reference< XHelperInterface >& xParent, const } // Attributes -rtl::OUString SAL_CALL +rtl::OUString SAL_CALL ScVbaFrame::getCaption() throw (css::uno::RuntimeException) { rtl::OUString Label; @@ -45,34 +46,58 @@ ScVbaFrame::getCaption() throw (css::uno::RuntimeException) return Label; } -void SAL_CALL +void SAL_CALL ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) { m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); } -uno::Any SAL_CALL +uno::Any SAL_CALL ScVbaFrame::getValue() throw (css::uno::RuntimeException) { return uno::makeAny( getCaption() ); } -void SAL_CALL +void SAL_CALL ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException) { rtl::OUString sCaption; _value >>= sCaption; - setCaption( sCaption ); + setCaption( sCaption ); +} + +::sal_Int32 SAL_CALL ScVbaFrame::getForeColor() throw (::com::sun::star::uno::RuntimeException) +{ + return 0; } -rtl::OUString& +void SAL_CALL ScVbaFrame::setForeColor( ::sal_Int32 /*_forecolor*/ ) throw (::com::sun::star::uno::RuntimeException) +{ + return; +} + + +rtl::OUString SAL_CALL +ScVbaFrame::getAccelerator() throw (css::uno::RuntimeException) +{ + //FIXME: seems not support? + return rtl::OUString(); +} + +void SAL_CALL +ScVbaFrame::setAccelerator( const rtl::OUString& /*_accelerator*/ ) throw (::com::sun::star::uno::RuntimeException) +{ + //FIXME: seems not support? +} + +rtl::OUString& ScVbaFrame::getServiceImplName() { static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFrame") ); return sImplName; } -uno::Sequence< rtl::OUString > +uno::Sequence< rtl::OUString > ScVbaFrame::getServiceNames() { static uno::Sequence< rtl::OUString > aServiceNames; @@ -83,3 +108,5 @@ ScVbaFrame::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx index c55a41bf08..9b2c77252f 100644 --- a/vbahelper/source/msforms/vbaframe.hxx +++ b/vbahelper/source/msforms/vbaframe.hxx @@ -1,7 +1,8 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * 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 @@ -43,8 +44,16 @@ public: virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + + virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setForeColor( ::sal_Int32 _forecolor ) throw (::com::sun::star::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getAccelerator() throw (css::uno::RuntimeException); + virtual void SAL_CALL setAccelerator( const rtl::OUString& _accelerator ) throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; #endif //SC_VBA_LABEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbalabel.cxx b/vbahelper/source/msforms/vbalabel.cxx index 5fb6ebeabb..29c8dfa834 100644 --- a/vbahelper/source/msforms/vbalabel.cxx +++ b/vbahelper/source/msforms/vbalabel.cxx @@ -1,7 +1,8 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * 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 @@ -37,7 +38,7 @@ ScVbaLabel::ScVbaLabel( const css::uno::Reference< XHelperInterface >& xParent, } // Attributes -rtl::OUString SAL_CALL +rtl::OUString SAL_CALL ScVbaLabel::getCaption() throw (css::uno::RuntimeException) { rtl::OUString Label; @@ -45,34 +46,46 @@ ScVbaLabel::getCaption() throw (css::uno::RuntimeException) return Label; } -void SAL_CALL +void SAL_CALL ScVbaLabel::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) { m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); } -uno::Any SAL_CALL +uno::Any SAL_CALL ScVbaLabel::getValue() throw (css::uno::RuntimeException) { return uno::makeAny( getCaption() ); } -void SAL_CALL +void SAL_CALL ScVbaLabel::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException) { rtl::OUString sCaption; _value >>= sCaption; - setCaption( sCaption ); + setCaption( sCaption ); } +rtl::OUString SAL_CALL +ScVbaLabel::getAccelerator() throw (css::uno::RuntimeException) +{ + //FIXME: seems not support? + return rtl::OUString(); +} -rtl::OUString& +void SAL_CALL +ScVbaLabel::setAccelerator( const rtl::OUString& /*_accelerator*/ ) throw (::com::sun::star::uno::RuntimeException) +{ + //FIXME: seems not support? +} + +rtl::OUString& ScVbaLabel::getServiceImplName() { static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaLabel") ); return sImplName; } -uno::Sequence< rtl::OUString > +uno::Sequence< rtl::OUString > ScVbaLabel::getServiceNames() { static uno::Sequence< rtl::OUString > aServiceNames; @@ -83,3 +96,5 @@ ScVbaLabel::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbalabel.hxx b/vbahelper/source/msforms/vbalabel.hxx index fd6b1c199f..3619c06e15 100644 --- a/vbahelper/source/msforms/vbalabel.hxx +++ b/vbahelper/source/msforms/vbalabel.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -44,10 +45,14 @@ public: virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual rtl::OUString SAL_CALL getAccelerator() throw (css::uno::RuntimeException); + virtual void SAL_CALL setAccelerator( const rtl::OUString& _accelerator ) throw (css::uno::RuntimeException); //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); // XDefaultProperty - rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } + rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } }; #endif //SC_VBA_LABEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx index 8538fc29bc..a29c1312ee 100644 --- a/vbahelper/source/msforms/vbalistbox.cxx +++ b/vbahelper/source/msforms/vbalistbox.cxx @@ -1,7 +1,8 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * 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 @@ -45,16 +46,16 @@ ScVbaListBox::ScVbaListBox( const uno::Reference< XHelperInterface >& xParent, c } // Attributes -void SAL_CALL +void SAL_CALL ScVbaListBox::setListIndex( const uno::Any& _value ) throw (uno::RuntimeException) { sal_Int32 nIndex = 0; _value >>= nIndex; uno::Reference< XPropValue > xPropVal( Selected( nIndex ), uno::UNO_QUERY_THROW ); - xPropVal->setValue( uno::makeAny( sal_True ) ); + xPropVal->setValue( uno::makeAny( sal_True ) ); } -uno::Any SAL_CALL +uno::Any SAL_CALL ScVbaListBox::getListIndex() throw (uno::RuntimeException) { uno::Sequence< sal_Int16 > sSelection; @@ -64,7 +65,7 @@ ScVbaListBox::getListIndex() throw (uno::RuntimeException) return uno::Any( sSelection[ 0 ] ); } -uno::Any SAL_CALL +uno::Any SAL_CALL ScVbaListBox::getValue() throw (uno::RuntimeException) { uno::Sequence< sal_Int16 > sSelection; @@ -72,21 +73,21 @@ ScVbaListBox::getValue() throw (uno::RuntimeException) m_xProps->getPropertyValue( SELECTEDITEMS ) >>= sSelection; m_xProps->getPropertyValue( ITEMS ) >>= sItems; if( getMultiSelect() ) - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Attribute use invalid." ), uno::Reference< uno::XInterface >() ); + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Attribute use invalid." )), uno::Reference< uno::XInterface >() ); uno::Any aRet; if ( sSelection.getLength() ) - aRet = uno::makeAny( sItems[ sSelection[ 0 ] ] ); + aRet = uno::makeAny( sItems[ sSelection[ 0 ] ] ); return aRet; } -void SAL_CALL +void SAL_CALL ScVbaListBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException) { if( getMultiSelect() ) - { - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Attribute use invalid." ), uno::Reference< uno::XInterface >() ); + { + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Attribute use invalid." )), uno::Reference< uno::XInterface >() ); } rtl::OUString sValue = getAnyAsString( _value ); uno::Sequence< rtl::OUString > sList; @@ -99,21 +100,25 @@ ScVbaListBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException) { if( sList[i].equals( sValue ) ) { - nValue = i; + nValue = i; break; } } if( nValue == -1 ) - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Attribute use invalid." ), uno::Reference< uno::XInterface >() ); + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Attribute use invalid." )), uno::Reference< uno::XInterface >() ); uno::Sequence< sal_Int16 > nSelectedIndices(1); + uno::Sequence< sal_Int16 > nOldSelectedIndices; + m_xProps->getPropertyValue( SELECTEDITEMS ) >>= nOldSelectedIndices; nSelectedIndices[ 0 ] = nValue; - m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nSelectedIndices ) ); - m_xProps->setPropertyValue( TEXT, uno::makeAny( sValue ) ); + m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nSelectedIndices ) ); + if ( nSelectedIndices != nOldSelectedIndices ) + fireClickEvent(); + //m_xProps->setPropertyValue( TEXT, uno::makeAny( sValue ) ); } -::rtl::OUString SAL_CALL +::rtl::OUString SAL_CALL ScVbaListBox::getText() throw (uno::RuntimeException) { rtl::OUString result; @@ -121,56 +126,58 @@ ScVbaListBox::getText() throw (uno::RuntimeException) return result; } -void SAL_CALL +void SAL_CALL ScVbaListBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException) { setValue( uno::makeAny( _text ) ); // seems the same } -sal_Bool SAL_CALL +sal_Int32 SAL_CALL ScVbaListBox::getMultiSelect() throw (css::uno::RuntimeException) { sal_Bool bMultiSelect = sal_False; m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ) ) >>= bMultiSelect; - return bMultiSelect; + return bMultiSelect ? 1 : 0 ; } -void SAL_CALL -ScVbaListBox::setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException) +void SAL_CALL +ScVbaListBox::setMultiSelect( sal_Int32 _multiselect ) throw (css::uno::RuntimeException) { - m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ), uno::makeAny( _multiselect ) ); + sal_Bool bMultiSelect = _multiselect == 1 ? 1 : 0; + m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ), uno::makeAny( bMultiSelect ) ); } -css::uno::Any SAL_CALL + +css::uno::Any SAL_CALL ScVbaListBox::Selected( sal_Int32 index ) throw (css::uno::RuntimeException) { uno::Sequence< rtl::OUString > sList; m_xProps->getPropertyValue( ITEMS ) >>= sList; sal_Int16 nLength = static_cast< sal_Int16 >( sList.getLength() ); // no choice but to do a horror cast as internally - // the indices are but sal_Int16 + // the indices are but sal_Int16 sal_Int16 nIndex = static_cast< sal_Int16 >( index ); if( nIndex < 0 || nIndex >= nLength ) - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Error Number." ), uno::Reference< uno::XInterface >() ); + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Error Number." )), uno::Reference< uno::XInterface >() ); m_nIndex = nIndex; return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) ); } // Methods -void SAL_CALL +void SAL_CALL ScVbaListBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException) { mpListHelper->AddItem( pvargItem, pvargIndex ); } -void SAL_CALL +void SAL_CALL ScVbaListBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException) { mpListHelper->removeItem( index ); } -void SAL_CALL +void SAL_CALL ScVbaListBox::Clear( ) throw (uno::RuntimeException) { mpListHelper->Clear(); @@ -180,13 +187,13 @@ ScVbaListBox::Clear( ) throw (uno::RuntimeException) // to set the selected state of particular entries in the Listbox // ListBox1.Selected( 3 ) = false //PropListener -void +void ScVbaListBox::setValueEvent( const uno::Any& value ) { sal_Bool bValue = sal_False; if( !(value >>= bValue) ) - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Invalid type\n. need boolean." ), uno::Reference< uno::XInterface >() ); + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Invalid type\n. need boolean." )), uno::Reference< uno::XInterface >() ); uno::Sequence< sal_Int16 > nList; m_xProps->getPropertyValue( SELECTEDITEMS ) >>= nList; sal_Int16 nLength = static_cast<sal_Int16>( nList.getLength() ); @@ -205,6 +212,7 @@ ScVbaListBox::setValueEvent( const uno::Any& value ) } nList.realloc( nLength - 1 ); //m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) ); + fireClickEvent(); m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nList ) ); return; } @@ -223,6 +231,7 @@ ScVbaListBox::setValueEvent( const uno::Any& value ) nList[0] = nIndex; } //m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) ); + fireClickEvent(); m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nList ) ); } } @@ -231,14 +240,14 @@ ScVbaListBox::setValueEvent( const uno::Any& value ) // to determine the selected state of particular entries in the Listbox // msgbox ListBox1.Selected( 3 ) -css::uno::Any +css::uno::Any ScVbaListBox::getValueEvent() { uno::Sequence< sal_Int16 > nList; m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectedItems" ) ) ) >>= nList; sal_Int32 nLength = nList.getLength(); sal_Int32 nIndex = m_nIndex; - + for( sal_Int32 i = 0; i < nLength; i++ ) { if( nList[i] == nIndex ) @@ -261,20 +270,20 @@ ScVbaListBox::getListCount() throw (uno::RuntimeException) return mpListHelper->getListCount(); } -uno::Any SAL_CALL +uno::Any SAL_CALL ScVbaListBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException) { return mpListHelper->List( pvargIndex, pvarColumn ); } -rtl::OUString& +rtl::OUString& ScVbaListBox::getServiceImplName() { static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaListBox") ); return sImplName; } -uno::Sequence< rtl::OUString > +uno::Sequence< rtl::OUString > ScVbaListBox::getServiceNames() { static uno::Sequence< rtl::OUString > aServiceNames; @@ -285,3 +294,5 @@ ScVbaListBox::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbalistbox.hxx b/vbahelper/source/msforms/vbalistbox.hxx index 01c53d1b0f..a35f100f4b 100644 --- a/vbahelper/source/msforms/vbalistbox.hxx +++ b/vbahelper/source/msforms/vbalistbox.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -58,8 +59,8 @@ public: virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException); virtual rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException); virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getMultiSelect() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getMultiSelect() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMultiSelect( ::sal_Int32 _multiselect ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException); // Methods @@ -71,7 +72,7 @@ public: virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException); // XDefaultProperty - rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } + rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } //XHelperInterface virtual rtl::OUString& getServiceImplName(); @@ -85,3 +86,5 @@ public: }; #endif // + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.cxx b/vbahelper/source/msforms/vbalistcontrolhelper.cxx index 36683ae6f7..696b52bfb4 100644 --- a/vbahelper/source/msforms/vbalistcontrolhelper.cxx +++ b/vbahelper/source/msforms/vbalistcontrolhelper.cxx @@ -1,12 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include <vbalistcontrolhelper.hxx> #include <vector> +#include <vbahelper/vbapropvalue.hxx> using namespace com::sun::star; using namespace ooo::vba; const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ); -void SAL_CALL +class ListPropListener : public PropListener +{ +private: + uno::Reference< beans::XPropertySet > m_xProps; + uno::Any m_pvargIndex; + uno::Any m_pvarColumn; + +public: + ListPropListener( const uno::Reference< beans::XPropertySet >& xProps, const uno::Any& pvargIndex, const uno::Any& pvarColumn ); + virtual void setValueEvent( const css::uno::Any& value ); + virtual css::uno::Any getValueEvent(); +}; + +ListPropListener::ListPropListener( const uno::Reference< beans::XPropertySet >& xProps, const uno::Any& pvargIndex, const uno::Any& pvarColumn ) : m_xProps( xProps ), m_pvargIndex( pvargIndex ), m_pvarColumn( pvarColumn ) +{ +} + +void ListPropListener::setValueEvent( const uno::Any& value ) +{ + if( m_pvargIndex.hasValue() || m_pvarColumn.hasValue() ) + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Bad argument" )), uno::Reference< uno::XInterface >() ); + + m_xProps->setPropertyValue( ITEMS, value ); +} + +uno::Any ListPropListener::getValueEvent() +{ + uno::Sequence< rtl::OUString > sList; + m_xProps->getPropertyValue( ITEMS ) >>= sList; + sal_Int16 nLength = static_cast< sal_Int16 >( sList.getLength() ); + uno::Any aRet; + if ( m_pvargIndex.hasValue() ) + { + sal_Int16 nIndex = -1; + m_pvargIndex >>= nIndex; + if( nIndex < 0 || nIndex >= nLength ) + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Bad row Index" )), uno::Reference< uno::XInterface >() ); + aRet <<= sList[ nIndex ]; + } + else if ( m_pvarColumn.hasValue() ) // pvarColumn on its own would be bad + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Bad column Index" )), uno::Reference< uno::XInterface >() ); + else // List() ( e.g. no args ) + { + uno::Sequence< uno::Sequence< rtl::OUString > > sReturnArray( nLength ); + for ( sal_Int32 i = 0; i < nLength; ++i ) + { + sReturnArray[ i ].realloc( 10 ); + sReturnArray[ i ][ 0 ] = sList[ i ]; + } + aRet = uno::makeAny( sReturnArray ); + } + return aRet; +} + +void SAL_CALL ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException) { if ( pvargItem.hasValue() ) @@ -21,13 +80,13 @@ ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargInde rtl::OUString sString = getAnyAsString( pvargItem ); - // if no index specified or item is to be appended to end of + // if no index specified or item is to be appended to end of // list just realloc the array and set the last item if ( nIndex == sList.getLength() ) { sal_Int32 nOldSize = sList.getLength(); sList.realloc( nOldSize + 1 ); - sList[ nOldSize ] = sString; + sList[ nOldSize ] = sString; } else { @@ -41,10 +100,10 @@ ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargInde const rtl::OUString* pEndString = sList.getArray() + sList.getLength(); // insert the new element sVec.push_back( sString ); - // copy elements + // copy elements for ( ; pString != pEndString; ++pString ) sVec.push_back( *pString ); - + sList.realloc( sList.getLength() + 1 ); // point at first element to be overwritten @@ -52,16 +111,16 @@ ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargInde pEndString = sList.getArray() + sList.getLength(); std::vector< rtl::OUString >::iterator it = sVec.begin(); for ( ; pString != pEndString; ++pString, ++it) - *pString = *it; + *pString = *it; // } m_xProps->setPropertyValue( ITEMS, uno::makeAny( sList ) ); - + } } -void SAL_CALL +void SAL_CALL ListControlHelper::removeItem( const uno::Any& index ) throw (uno::RuntimeException) { sal_Int32 nIndex = 0; @@ -71,7 +130,7 @@ ListControlHelper::removeItem( const uno::Any& index ) throw (uno::RuntimeExcept uno::Sequence< rtl::OUString > sList; m_xProps->getPropertyValue( ITEMS ) >>= sList; if( nIndex < 0 || nIndex > ( sList.getLength() - 1 ) ) - throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid index" ), uno::Reference< uno::XInterface > () ); + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid index")), uno::Reference< uno::XInterface > () ); if( sList.hasElements() ) { if( sList.getLength() == 1 ) @@ -90,7 +149,7 @@ ListControlHelper::removeItem( const uno::Any& index ) throw (uno::RuntimeExcept } } -void SAL_CALL +void SAL_CALL ListControlHelper::Clear( ) throw (uno::RuntimeException) { // urk, setValue doesn't seem to work !! @@ -113,34 +172,10 @@ ListControlHelper::getListCount() throw (uno::RuntimeException) return sList.getLength(); } -uno::Any SAL_CALL +uno::Any SAL_CALL ListControlHelper::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException) { - uno::Sequence< rtl::OUString > sList; - m_xProps->getPropertyValue( ITEMS ) >>= sList; - sal_Int16 nLength = static_cast< sal_Int16 >( sList.getLength() ); - uno::Any aRet; - if ( pvargIndex.hasValue() ) - { - sal_Int16 nIndex = -1; - pvargIndex >>= nIndex; - if( nIndex < 0 || nIndex >= nLength ) - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Bad row Index" ), uno::Reference< uno::XInterface >() ); - aRet <<= sList[ nIndex ]; - } - else if ( pvarColumn.hasValue() ) // pvarColumn on its own would be bad - throw uno::RuntimeException( rtl::OUString::createFromAscii( - "Bad column Index" ), uno::Reference< uno::XInterface >() ); - else // List() ( e.g. no args ) - { - uno::Sequence< uno::Sequence< rtl::OUString > > sReturnArray( nLength ); - for ( sal_Int32 i = 0; i < nLength; ++i ) - { - sReturnArray[ i ].realloc( 10 ); - sReturnArray[ i ][ 0 ] = sList[ i ]; - } - aRet = uno::makeAny( sReturnArray ); - } - return aRet; + return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( new ListPropListener( m_xProps, pvargIndex, pvarColumn ) ) ) ); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.hxx b/vbahelper/source/msforms/vbalistcontrolhelper.hxx index 6b332ab9d8..82ac338765 100644 --- a/vbahelper/source/msforms/vbalistcontrolhelper.hxx +++ b/vbahelper/source/msforms/vbalistcontrolhelper.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #ifndef SC_VBA_LISTCONTROLHELPER #define SC_VBA_LISTCONTROLHELPER @@ -18,3 +19,5 @@ public: virtual void SAL_CALL Clear( ) throw (css::uno::RuntimeException); }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx index 4cdf220aa6..c3ca653dc9 100644 --- a/vbahelper/source/msforms/vbamultipage.cxx +++ b/vbahelper/source/msforms/vbamultipage.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,6 +29,7 @@ #include <ooo/vba/XCollection.hpp> #include "vbapages.hxx" #include <vector> +#include <com/sun/star/container/XNameContainer.hpp> using namespace com::sun::star; using namespace ooo::vba; @@ -122,3 +124,5 @@ ScVbaMultiPage::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbamultipage.hxx b/vbahelper/source/msforms/vbamultipage.hxx index 75c0da0bb1..0113b8ea91 100644 --- a/vbahelper/source/msforms/vbamultipage.hxx +++ b/vbahelper/source/msforms/vbamultipage.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -52,6 +53,8 @@ public: virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); // XDefaultProperty - rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } + rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } }; #endif //SC_VBA_LABEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbapages.cxx b/vbahelper/source/msforms/vbapages.cxx index 95e2e715b4..7f6b2d5be8 100644 --- a/vbahelper/source/msforms/vbapages.cxx +++ b/vbahelper/source/msforms/vbapages.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -70,3 +71,5 @@ ScVbaPages::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbapages.hxx b/vbahelper/source/msforms/vbapages.hxx index 7914f5bd6f..f19c6120f4 100644 --- a/vbahelper/source/msforms/vbapages.hxx +++ b/vbahelper/source/msforms/vbapages.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -54,3 +55,5 @@ public: }; #endif//SC_VBA_SHAPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbaprogressbar.cxx b/vbahelper/source/msforms/vbaprogressbar.cxx index 3ffe96d5c6..80b05467ce 100644 --- a/vbahelper/source/msforms/vbaprogressbar.cxx +++ b/vbahelper/source/msforms/vbaprogressbar.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -68,3 +69,5 @@ ScVbaProgressBar::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbaprogressbar.hxx b/vbahelper/source/msforms/vbaprogressbar.hxx index a4d4270f96..e022bd9f52 100644 --- a/vbahelper/source/msforms/vbaprogressbar.hxx +++ b/vbahelper/source/msforms/vbaprogressbar.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -46,6 +47,8 @@ public: virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); // XDefaultProperty - rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } + rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } }; #endif //SC_VBA_LABEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbaradiobutton.cxx b/vbahelper/source/msforms/vbaradiobutton.cxx index 3853f380d9..aa08851902 100644 --- a/vbahelper/source/msforms/vbaradiobutton.cxx +++ b/vbahelper/source/msforms/vbaradiobutton.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -70,6 +71,9 @@ void SAL_CALL ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException) { sal_Int16 nValue = 0; + sal_Int16 nOldValue = 0; + m_xProps->getPropertyValue( STATE ) >>= nOldValue; + sal_Bool bValue = sal_False; if( _value >>= nValue ) { @@ -82,6 +86,15 @@ ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExceptio nValue = 1; } m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) ); + if ( nValue != nOldValue ) + { + fireChangeEvent(); + // In Excel, only when the radio button is checked, the click event is fired. + if ( nValue != 0 ) + { + fireClickEvent(); + } + } } rtl::OUString& @@ -102,3 +115,5 @@ ScVbaRadioButton::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbaradiobutton.hxx b/vbahelper/source/msforms/vbaradiobutton.hxx index 576cde6709..0bcbb33f15 100644 --- a/vbahelper/source/msforms/vbaradiobutton.hxx +++ b/vbahelper/source/msforms/vbaradiobutton.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -46,7 +47,9 @@ public: virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); // XDefaultProperty - rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } + rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } }; #endif //SC_VBA_RADIOBUTTON_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbascrollbar.cxx b/vbahelper/source/msforms/vbascrollbar.cxx index 1c37e61bb9..0cf4e6c963 100644 --- a/vbahelper/source/msforms/vbascrollbar.cxx +++ b/vbahelper/source/msforms/vbascrollbar.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -129,3 +130,5 @@ ScVbaScrollBar::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbascrollbar.hxx b/vbahelper/source/msforms/vbascrollbar.hxx index 8543fe081b..de36b51398 100644 --- a/vbahelper/source/msforms/vbascrollbar.hxx +++ b/vbahelper/source/msforms/vbascrollbar.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -56,3 +57,5 @@ public: virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; #endif //SC_VBA_LABEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbaspinbutton.cxx b/vbahelper/source/msforms/vbaspinbutton.cxx index fbb7961aaf..42f025a45f 100644 --- a/vbahelper/source/msforms/vbaspinbutton.cxx +++ b/vbahelper/source/msforms/vbaspinbutton.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -99,3 +100,5 @@ ScVbaSpinButton::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbaspinbutton.hxx b/vbahelper/source/msforms/vbaspinbutton.hxx index cd6aaf7ce2..66d2b906ef 100644 --- a/vbahelper/source/msforms/vbaspinbutton.hxx +++ b/vbahelper/source/msforms/vbaspinbutton.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -51,3 +52,5 @@ public: virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; #endif //SC_VBA_SPINBUTTON_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbasystemaxcontrol.cxx b/vbahelper/source/msforms/vbasystemaxcontrol.cxx index 227338d7f6..171986ac6c 100755 --- a/vbahelper/source/msforms/vbasystemaxcontrol.cxx +++ b/vbahelper/source/msforms/vbasystemaxcontrol.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -99,3 +100,4 @@ VbaSystemAXControl::getServiceNames() return aServiceNames; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbasystemaxcontrol.hxx b/vbahelper/source/msforms/vbasystemaxcontrol.hxx index 5bc23f44b2..45bcb3a630 100755 --- a/vbahelper/source/msforms/vbasystemaxcontrol.hxx +++ b/vbahelper/source/msforms/vbasystemaxcontrol.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -56,3 +57,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx index 730f24c961..3fc94c7a17 100644 --- a/vbahelper/source/msforms/vbatextbox.cxx +++ b/vbahelper/source/msforms/vbatextbox.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -67,13 +68,20 @@ ScVbaTextBox::getText() throw (css::uno::RuntimeException) void SAL_CALL ScVbaTextBox::setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException) { + rtl::OUString sOldText = getText(); + if ( !mbDialog ) { - uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW ); - xTextRange->setString( _text ); -} + uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW ); + xTextRange->setString( _text ); + } else m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ), uno::makeAny( _text ) ); + + if ( _text != sOldText ) + { + fireChangeEvent(); + } } sal_Int32 SAL_CALL @@ -90,7 +98,8 @@ ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException) void SAL_CALL ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException) { - uno::Any aValue( _maxlength ); + sal_Int16 _maxlength16 = static_cast<sal_Int16> (_maxlength); + uno::Any aValue( _maxlength16 ); m_xProps->setPropertyValue (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ), aValue); } @@ -132,3 +141,5 @@ ScVbaTextBox::getServiceNames() } return aServiceNames; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx index 58d22f45e9..548ae2ab47 100644 --- a/vbahelper/source/msforms/vbatextbox.hxx +++ b/vbahelper/source/msforms/vbatextbox.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -48,9 +49,11 @@ public: virtual sal_Bool SAL_CALL getMultiline() throw (css::uno::RuntimeException); virtual void SAL_CALL setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException); // XDefaultProperty - rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } + rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } //XHelperInterface virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; #endif //SC_VBA_TEXTBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx index d16fab90e4..297e30c103 100644 --- a/vbahelper/source/msforms/vbatogglebutton.cxx +++ b/vbahelper/source/msforms/vbatogglebutton.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -68,17 +69,34 @@ ScVbaToggleButton::getValue() throw (uno::RuntimeException) return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) ); } + void SAL_CALL ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException) { sal_Int16 nState = 0; - _value >>= nState; + if (_value.getValueTypeClass() == uno::TypeClass_BOOLEAN) + { + sal_Bool bValue; + _value >>= bValue; + nState = static_cast< sal_Int16 >(bValue); + } + else if (_value.getValueTypeClass() == uno::TypeClass_BYTE) + { + sal_Int8 nValue; + _value >>= nValue; + nState = ( nValue == 1) ? 1 : 0; + } + else + { + _value >>= nState; OSL_TRACE( "nState - %d", nState ); - nState = ( nState == -1 ) ? 1 : 0; + nState = ( nState == -1 ) ? 1 : 0; OSL_TRACE( "nState - %d", nState ); + } m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) ); } + rtl::OUString& ScVbaToggleButton::getServiceImplName() { @@ -98,3 +116,4 @@ ScVbaToggleButton::getServiceNames() return aServiceNames; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbatogglebutton.hxx b/vbahelper/source/msforms/vbatogglebutton.hxx index 8950a1ff09..540069de3d 100644 --- a/vbahelper/source/msforms/vbatogglebutton.hxx +++ b/vbahelper/source/msforms/vbatogglebutton.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -50,6 +51,8 @@ public: virtual rtl::OUString& getServiceImplName(); virtual css::uno::Sequence<rtl::OUString> getServiceNames(); // XDefaultProperty - rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); } + rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } }; #endif //SC_VBA_TOGGLEBUTTON_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index 3db05ee747..2e7dc0984d 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -55,6 +56,8 @@ ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Refer uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW ); m_xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW ); setGeometryHelper( new UserFormGeometryHelper( xContext, xControl ) ); + if ( aArgs.getLength() >= 4 ) + aArgs[ 3 ] >>= m_sLibName; } ScVbaUserForm::~ScVbaUserForm() @@ -66,8 +69,7 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException) { OSL_TRACE("ScVbaUserForm::Show( )"); short aRet = 0; - mbDispose = true; - + mbDispose = true; if ( m_xDialog.is() ) { // try to center dialog on model window @@ -125,6 +127,24 @@ ScVbaUserForm::Hide( ) throw (uno::RuntimeException) m_xDialog->endExecute(); } +sal_Bool SAL_CALL ScVbaUserForm::getVisible() throw (uno::RuntimeException) +{ + uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer(), uno::UNO_QUERY_THROW ); + return xWindow2->isVisible(); +} + +void SAL_CALL ScVbaUserForm::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException) +{ + if ( bVisible ) + { + Show(); + } + else + { + Hide(); + } +} + void SAL_CALL ScVbaUserForm::RePaint( ) throw (uno::RuntimeException) { @@ -190,6 +210,30 @@ ScVbaUserForm::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& a } } +uno::Reference< awt::XControl > +ScVbaUserForm::nestedSearch( const rtl::OUString& aPropertyName, uno::Reference< awt::XControlContainer >& xContainer ) +{ + uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName ); + if ( !xControl.is() ) + { + uno::Sequence< uno::Reference< awt::XControl > > aControls = xContainer->getControls(); + const uno::Reference< awt::XControl >* pCtrl = aControls.getConstArray(); + const uno::Reference< awt::XControl >* pCtrlsEnd = pCtrl + aControls.getLength(); + + for ( ; pCtrl < pCtrlsEnd; ++pCtrl ) + { + uno::Reference< awt::XControlContainer > xC( *pCtrl, uno::UNO_QUERY ); + if ( xC.is() ) + { + xControl.set( nestedSearch( aPropertyName, xC ) ); + if ( xControl.is() ) + break; + } + } + } + return xControl; +} + uno::Any SAL_CALL ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException) { @@ -238,10 +282,14 @@ ScVbaUserForm::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeEx OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is() ); if ( xControl.is() ) { - uno::Reference< container::XNameAccess > xNameAccess( xControl->getModel(), uno::UNO_QUERY_THROW ); - sal_Bool bRes = xNameAccess->hasByName( aName ); - OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is(), bRes ); - return bRes; + uno::Reference< beans::XPropertySet > xDlgProps( xControl->getModel(), uno::UNO_QUERY ); + if ( xDlgProps.is() ) + { + uno::Reference< container::XNameContainer > xAllChildren( xDlgProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllDialogChildren")) ), uno::UNO_QUERY_THROW ); + sal_Bool bRes = xAllChildren->hasByName( aName ); + OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xAllChildren.is(), bRes ); + return bRes; + } } return sal_False; } @@ -256,3 +304,4 @@ extern sdecl::ServiceDecl const serviceDecl( "ooo.vba.msforms.UserForm" ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx index 463a3cba3b..625d1fae02 100644 --- a/vbahelper/source/msforms/vbauserform.hxx +++ b/vbahelper/source/msforms/vbauserform.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,6 +31,7 @@ #include <cppuhelper/implbase1.hxx> #include <ooo/vba/msforms/XUserForm.hpp> #include <com/sun/star/awt/XDialog.hpp> +#include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/frame/XModel.hpp> #include <vbahelper/vbahelperinterface.hxx> @@ -43,10 +45,14 @@ class ScVbaUserForm : public ScVbaUserForm_BASE private: css::uno::Reference< css::awt::XDialog > m_xDialog; bool mbDispose; + rtl::OUString m_sLibName; protected: public: ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException ); virtual ~ScVbaUserForm(); + static css::uno::Reference< css::awt::XControl > nestedSearch( const rtl::OUString& aPropertyName, css::uno::Reference< css::awt::XControlContainer >& xContainer ); + virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException); // XUserForm virtual void SAL_CALL RePaint( ) throw (css::uno::RuntimeException); virtual void SAL_CALL Show( ) throw (css::uno::RuntimeException); @@ -67,3 +73,5 @@ public: virtual css::uno::Sequence<rtl::OUString> getServiceNames(); }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |