diff options
Diffstat (limited to 'vbahelper/source/msforms')
40 files changed, 4304 insertions, 0 deletions
diff --git a/vbahelper/source/msforms/makefile.mk b/vbahelper/source/msforms/makefile.mk new file mode 100644 index 000000000000..1d550c8409c2 --- /dev/null +++ b/vbahelper/source/msforms/makefile.mk @@ -0,0 +1,79 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.45 $ +# +# 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. +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=vbahelper +TARGET=msforms + +ENABLE_EXCEPTIONS=TRUE +VISIBILITY_HIDDEN=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +SLOFILES=\ + $(SLO)$/vbacontrol.obj \ + $(SLO)$/vbacontrols.obj \ + $(SLO)$/vbabutton.obj \ + $(SLO)$/vbacombobox.obj \ + $(SLO)$/vbalabel.obj \ + $(SLO)$/vbatextbox.obj \ + $(SLO)$/vbaradiobutton.obj \ + $(SLO)$/vbalistbox.obj \ + $(SLO)$/vbatogglebutton.obj \ + $(SLO)$/vbacheckbox.obj \ + $(SLO)$/vbaframe.obj \ + $(SLO)$/vbascrollbar.obj \ + $(SLO)$/vbaprogressbar.obj \ + $(SLO)$/vbamultipage.obj \ + $(SLO)$/vbalistcontrolhelper.obj \ + $(SLO)$/vbaspinbutton.obj \ + $(SLO)$/vbaimage.obj \ + $(SLO)$/vbapages.obj \ + $(SLO)$/vbauserform.obj \ + $(SLO)$/service.obj \ + +# #FIXME vbapropvalue needs to move to vbahelper + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + +ALLTAR : \ + $(MISC)$/$(TARGET).don \ + +$(SLOFILES) : $(MISC)$/$(TARGET).don + +$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb + +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@ + echo $@ + diff --git a/vbahelper/source/msforms/service.cxx b/vbahelper/source/msforms/service.cxx new file mode 100644 index 000000000000..395256bcf61a --- /dev/null +++ b/vbahelper/source/msforms/service.cxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: service.cxx,v $ + * $Revision: 1.4 $ + * + * 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 "cppuhelper/implementationentry.hxx" +#include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "com/sun/star/registry/XRegistryKey.hpp" +#include "comphelper/servicedecl.hxx" + +// ============================================================================= +// component exports +// ============================================================================= +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace sdecl = comphelper::service_decl; + +// reference service helper(s) +namespace controlprovider +{ +extern sdecl::ServiceDecl const serviceDecl; +} + +namespace userform +{ +extern sdecl::ServiceDecl const serviceDecl; +} + +extern "C" +{ + SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) + { + OSL_TRACE("In component_getImplementationEnv"); + *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 ) + { + OSL_TRACE("In component_getFactory for %s", pImplName ); + void* pRet = component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey, controlprovider::serviceDecl, userform::serviceDecl ); + OSL_TRACE("Ret is 0x%x", pRet); + return pRet; + } +} diff --git a/vbahelper/source/msforms/vbabutton.cxx b/vbahelper/source/msforms/vbabutton.cxx new file mode 100644 index 000000000000..4c21c70c88b5 --- /dev/null +++ b/vbahelper/source/msforms/vbabutton.cxx @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbabutton.cxx,v $ + * $Revision: 1.3 $ + * + * 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 "vbabutton.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); +ScVbaButton::ScVbaButton( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ +} + +// Attributes +rtl::OUString SAL_CALL +ScVbaButton::getCaption() throw (css::uno::RuntimeException) +{ + rtl::OUString Label; + m_xProps->getPropertyValue( LABEL ) >>= Label; + return Label; +} + +void SAL_CALL +ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) +{ + m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); +} + +rtl::OUString& +ScVbaButton::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaButton") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaButton::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Button" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbabutton.hxx b/vbahelper/source/msforms/vbabutton.hxx new file mode 100644 index 000000000000..48dda8ba7bdb --- /dev/null +++ b/vbahelper/source/msforms/vbabutton.hxx @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbabutton.hxx,v $ + * $Revision: 1.3 $ + * + * 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 SC_VBA_BUTTON_HXX +#define SC_VBA_BUTTON_HXX +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XButton.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XButton > ButtonImpl_BASE; + +class ScVbaButton : public ButtonImpl_BASE +{ +public: + ScVbaButton( 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 ); + // Attributes + virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; +#endif //SC_VBA_BUTTON_HXX diff --git a/vbahelper/source/msforms/vbacheckbox.cxx b/vbahelper/source/msforms/vbacheckbox.cxx new file mode 100644 index 000000000000..769899462976 --- /dev/null +++ b/vbahelper/source/msforms/vbacheckbox.cxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include "vbacheckbox.hxx" +#include <vbahelper/helperdecl.hxx> +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); +const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") ); +ScVbaCheckbox::ScVbaCheckbox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : CheckBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ +} + +// Attributes +rtl::OUString SAL_CALL +ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException) +{ + rtl::OUString Label; + m_xProps->getPropertyValue( LABEL ) >>= Label; + return Label; +} + +void SAL_CALL +ScVbaCheckbox::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) +{ + m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); +} + +uno::Any SAL_CALL +ScVbaCheckbox::getValue() throw (css::uno::RuntimeException) +{ + sal_Int16 nValue = -1; + m_xProps->getPropertyValue( STATE ) >>= nValue; + if( nValue != 0 ) + nValue = -1; +// return uno::makeAny( nValue ); +// I must be missing something MSO says value should be -1 if selected, 0 if not +// selected + return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False ); +} + +void SAL_CALL +ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException) +{ + sal_Int16 nValue = 0; + sal_Bool bValue = false; + if( _value >>= nValue ) + { + if( nValue == -1) + nValue = 1; + } + else if ( _value >>= bValue ) + { + if ( bValue ) + nValue = 1; + } + m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) ); +} +rtl::OUString& +ScVbaCheckbox::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCheckbox") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaCheckbox::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.CheckBox" ) ); + } + return aServiceNames; +} + diff --git a/vbahelper/source/msforms/vbacheckbox.hxx b/vbahelper/source/msforms/vbacheckbox.hxx new file mode 100644 index 000000000000..f3374db0119c --- /dev/null +++ b/vbahelper/source/msforms/vbacheckbox.hxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef SC_VBA_CHECKBOX_HXX +#define SC_VBA_CHECKBOX_HXX +#include <cppuhelper/implbase2.hxx> +#include <ooo/vba/msforms/XRadioButton.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > CheckBoxImpl_BASE; + +class ScVbaCheckbox : public CheckBoxImpl_BASE +{ +public: + ScVbaCheckbox( 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 ); + // Attributes + virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + 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"); } + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; + +#endif //SC_VBA_CHECKBOX_HXX diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx new file mode 100644 index 000000000000..1d1f87915b6d --- /dev/null +++ b/vbahelper/source/msforms/vbacombobox.cxx @@ -0,0 +1,183 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbacombobox.cxx,v $ + * $Revision: 1.4 $ + * + * 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 "vbacombobox.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +//SelectedItems list of integer indexes +//StringItemList list of items + +const static rtl::OUString TEXT( RTL_CONSTASCII_USTRINGPARAM("Text") ); +const static rtl::OUString SELECTEDITEMS( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ); +const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ); +const static rtl::OUString CONTROLSOURCEPROP( RTL_CONSTASCII_USTRINGPARAM("DataFieldProperty") ); + +ScVbaComboBox::ScVbaComboBox( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialogType ) : ComboBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialogType( bDialogType ) +{ + mpListHelper.reset( new ListControlHelper( m_xProps ) ); + // grab the default value property name + m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName; +} + +// Attributes + + +// Value, [read] e.g. getValue returns the value of ooo Text propery e.g. the value in +// the drop down +uno::Any SAL_CALL +ScVbaComboBox::getValue() throw (uno::RuntimeException) +{ + return m_xProps->getPropertyValue( sSourceName ); +} + +void SAL_CALL +ScVbaComboBox::setListIndex( const uno::Any& _value ) throw (uno::RuntimeException) +{ + sal_Int16 nIndex = 0; + if( _value >>= nIndex ) + { + 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 ) ); + } + } +} + +uno::Any SAL_CALL +ScVbaComboBox::getListIndex() throw (uno::RuntimeException) +{ + uno::Sequence< rtl::OUString > sItems; + m_xProps->getPropertyValue( ITEMS ) >>= sItems; + // should really return the item that has focus regardless of + // it been selected + if ( sItems.getLength() > 0 ) + { + rtl::OUString sText = getText(); + sal_Int32 nLen = sItems.getLength(); + for ( sal_Int32 index = 0; sText.getLength() && index < nLen; ++index ) + { + if ( sItems[ index ].equals( sText ) ) + { + OSL_TRACE("getListIndex returning %d", index ); + return uno::makeAny( index ); + } + + } + } + OSL_TRACE("getListIndex returning %d", -1 ); + return uno::makeAny( sal_Int32( -1 ) ); +} + +// Value, [write]e.g. setValue sets the value in the drop down, and if the value is one +// of the values in the list then the selection is also set +void SAL_CALL +ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException) +{ + m_xProps->setPropertyValue( sSourceName, _value ); +} + +// see Value + +::rtl::OUString SAL_CALL +ScVbaComboBox::getText() throw (uno::RuntimeException) +{ + rtl::OUString result; + getValue() >>= result; + return result; +} + +void SAL_CALL +ScVbaComboBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException) +{ + setValue( uno::makeAny( _text ) ); // seems the same +} + +// Methods +void SAL_CALL +ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException) +{ + mpListHelper->AddItem( pvargItem, pvargIndex ); +} + +void SAL_CALL +ScVbaComboBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException) + { + mpListHelper->removeItem( index ); +} + +void SAL_CALL +ScVbaComboBox::Clear( ) throw (uno::RuntimeException) + { + mpListHelper->Clear(); + } + +void SAL_CALL +ScVbaComboBox::setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException) +{ + ScVbaControl::setRowSource( _rowsource ); + mpListHelper->setRowSource( _rowsource ); + } + +sal_Int32 SAL_CALL +ScVbaComboBox::getListCount() throw (uno::RuntimeException) +{ + return mpListHelper->getListCount(); +} + +uno::Any SAL_CALL +ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException) +{ + return mpListHelper->List( pvargIndex, pvarColumn ); + } + +rtl::OUString& +ScVbaComboBox::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaComboBox") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaComboBox::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ComboBox" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx new file mode 100644 index 000000000000..66b1a9abe408 --- /dev/null +++ b/vbahelper/source/msforms/vbacombobox.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbacombobox.hxx,v $ + * $Revision: 1.4 $ + * + * 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 SC_VBA_COMBOBOX_HXX +#define SC_VBA_COMBOBOX_HXX +#include <cppuhelper/implbase2.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/script/XDefaultProperty.hpp> +#include <ooo/vba/msforms/XComboBox.hpp> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +#include "vbacontrol.hxx" +#include "vbalistcontrolhelper.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper2<ScVbaControl, ov::msforms::XComboBox, css::script::XDefaultProperty > ComboBoxImpl_BASE; +class ScVbaComboBox : public ComboBoxImpl_BASE +{ + std::auto_ptr< ListControlHelper > mpListHelper; + rtl::OUString sSourceName; + rtl::OUString msDftPropName; + bool mbDialogType; + +public: + ScVbaComboBox( 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, bool bDialogType = false ); + + // Attributes + virtual css::uno::Any SAL_CALL getListIndex() throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getListCount() throw (css::uno::RuntimeException); + virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) throw (css::uno::RuntimeException); + 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); + virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException); + virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException); + + // Methods + virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException); + virtual void SAL_CALL removeItem( const css::uno::Any& index ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Clear( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException); + // XControl + 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"); } + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; + +#endif // diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx new file mode 100644 index 000000000000..c0169f7a490c --- /dev/null +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -0,0 +1,539 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbacontrol.cxx,v $ + * $Revision: 1.3 $ + * + * 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 <com/sun/star/form/FormComponentType.hpp> +#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/lang/XEventListener.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/view/XControlAccess.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/form/binding/XBindableValue.hpp> +#include <com/sun/star/form/binding/XListEntrySink.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <ooo/vba/XControlProvider.hpp> +#ifdef VBA_OOBUILD_HACK +#include <svtools/bindablecontrolhelper.hxx> +#endif +#include"vbacontrol.hxx" +#include"vbacombobox.hxx" +#include "vbabutton.hxx" +#include "vbalabel.hxx" +#include "vbatextbox.hxx" +#include "vbaradiobutton.hxx" +#include "vbalistbox.hxx" +#include "vbatogglebutton.hxx" +#include "vbacheckbox.hxx" +#include "vbaframe.hxx" +#include "vbascrollbar.hxx" +#include "vbaprogressbar.hxx" +#include "vbamultipage.hxx" +#include "vbaspinbutton.hxx" +#include "vbaimage.hxx" +#include <vbahelper/helperdecl.hxx> + + +using namespace com::sun::star; +using namespace ooo::vba; + +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() ) + { + // would seem to be a Userform control + uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY_THROW ); + xWinPeer = xControl->getPeer(); + return xWinPeer; + } + // form control + xControlModel.set( xControlShape->getControl(), uno::UNO_QUERY_THROW ); + + uno::Reference< view::XControlAccess > xControlAccess( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); + try + { + uno::Reference< awt::XControl > xControl( xControlAccess->getControl( xControlModel ), uno::UNO_QUERY ); + xWinPeer = xControl->getPeer(); + } + catch( uno::Exception ) + { + throw uno::RuntimeException( rtl::OUString::createFromAscii( "The Control does not exsit" ), + uno::Reference< uno::XInterface >() ); + } + return xWinPeer; +} + +//ScVbaControlListener +class ScVbaControlListener: public cppu::WeakImplHelper1< lang::XEventListener > +{ +private: + ScVbaControl *pControl; +public: + ScVbaControlListener( ScVbaControl *pTmpControl ); + virtual ~ScVbaControlListener(); + virtual void SAL_CALL disposing( const lang::EventObject& rEventObject ) throw( uno::RuntimeException ); +}; + +ScVbaControlListener::ScVbaControlListener( ScVbaControl *pTmpControl ): pControl( pTmpControl ) +{ +} + +ScVbaControlListener::~ScVbaControlListener() +{ +} + +void SAL_CALL +ScVbaControlListener::disposing( const lang::EventObject& ) throw( uno::RuntimeException ) +{ + if( pControl ) + { + pControl->removeResouce(); + pControl = NULL; + } +} + +//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 ) +{ + //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 ); + else if ( xUserFormControl.is() ) // userform control + m_xProps.set( xUserFormControl->getModel(), uno::UNO_QUERY_THROW ); +} + +ScVbaControl::~ScVbaControl() +{ + if( m_xControl.is() ) +{ + uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW ); + xComponent->removeEventListener( m_xEventListener ); +} +} + +void +ScVbaControl::setGeometryHelper( AbstractGeometryAttributes* pHelper ) +{ + mpGeometryHelper.reset( pHelper ); +} + +void ScVbaControl::removeResouce() throw( uno::RuntimeException ) +{ + uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW ); + xComponent->removeEventListener( m_xEventListener ); + m_xControl= NULL; + m_xProps = NULL; +} + +//In design model has different behavior +sal_Bool SAL_CALL ScVbaControl::getEnabled() throw (uno::RuntimeException) +{ + uno::Any aValue = m_xProps->getPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ) ); + sal_Bool bRet = false; + aValue >>= bRet; + return bRet; +} + +void SAL_CALL ScVbaControl::setEnabled( sal_Bool bVisible ) throw (uno::RuntimeException) +{ + uno::Any aValue( bVisible ); + m_xProps->setPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ), aValue); + +} + +sal_Bool SAL_CALL ScVbaControl::getVisible() throw (uno::RuntimeException) +{ + sal_Bool bVisible( sal_True ); + m_xProps->getPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableVisible" ) )) >>= bVisible; + return bVisible; +} + +void SAL_CALL ScVbaControl::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException) +{ + uno::Any aValue( bVisible ); + m_xProps->setPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableVisible" ) ), aValue); +} +double SAL_CALL ScVbaControl::getHeight() throw (uno::RuntimeException) +{ + return mpGeometryHelper->getHeight(); +} +void SAL_CALL ScVbaControl::setHeight( double _height ) throw (uno::RuntimeException) +{ + mpGeometryHelper->setHeight( _height ); +} + +double SAL_CALL ScVbaControl::getWidth() throw (uno::RuntimeException) +{ + return mpGeometryHelper->getWidth(); +} +void SAL_CALL ScVbaControl::setWidth( double _width ) throw (uno::RuntimeException) +{ + mpGeometryHelper->setWidth( _width ); +} + +double SAL_CALL +ScVbaControl::getLeft() throw (uno::RuntimeException) +{ + return mpGeometryHelper->getLeft(); +} + +void SAL_CALL +ScVbaControl::setLeft( double _left ) throw (uno::RuntimeException) +{ + mpGeometryHelper->setLeft( _left ); + +} + +double SAL_CALL +ScVbaControl::getTop() throw (uno::RuntimeException) +{ + return mpGeometryHelper->getTop(); +} + +void SAL_CALL +ScVbaControl::setTop( double _top ) throw (uno::RuntimeException) +{ + mpGeometryHelper->setTop( _top ); +} + +uno::Reference< uno::XInterface > SAL_CALL +ScVbaControl::getObject() throw (uno::RuntimeException) +{ + uno::Reference< msforms::XControl > xRet( this ); + return xRet; +} + +void SAL_CALL ScVbaControl::SetFocus() throw (uno::RuntimeException) +{ + uno::Reference< awt::XWindow > xWin( m_xControl, uno::UNO_QUERY_THROW ); + xWin->setFocus(); +} + +rtl::OUString SAL_CALL +ScVbaControl::getControlSource() throw (uno::RuntimeException) +{ +// #FIXME I *hate* having these upstream differences +// but this is necessary until I manage to upstream other +// dependant parts +#ifdef VBA_OOBUILD_HACK + rtl::OUString sControlSource; + uno::Reference< form::binding::XBindableValue > xBindable( m_xProps, uno::UNO_QUERY ); + if ( xBindable.is() ) + { + try + { + uno::Reference< lang::XMultiServiceFactory > xFac( m_xModel, uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellAddressConversion" ))), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xProps( xBindable->getValueBinding(), uno::UNO_QUERY_THROW ); + table::CellAddress aAddress; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BoundCell") ) ) >>= aAddress; + xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address") ), uno::makeAny( aAddress ) ); + xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sControlSource; + } + catch( uno::Exception& ) + { + } + } + return sControlSource; +#else + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getControlSource not supported") ), uno::Reference< uno::XInterface >()); // not supported +#endif +} + +void SAL_CALL +ScVbaControl::setControlSource( const rtl::OUString& _controlsource ) throw (uno::RuntimeException) +{ +#ifdef VBA_OOBUILD_HACK + rtl::OUString sEmpty; + svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, _controlsource, sEmpty ); +#else + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setControlSource not supported ") ).concat( _controlsource ), uno::Reference< uno::XInterface >()); // not supported +#endif +} + +rtl::OUString SAL_CALL +ScVbaControl::getRowSource() throw (uno::RuntimeException) +{ +#ifdef VBA_OOBUILD_HACK + rtl::OUString sRowSource; + uno::Reference< form::binding::XListEntrySink > xListSink( m_xProps, uno::UNO_QUERY ); + if ( xListSink.is() ) + { + try + { + uno::Reference< lang::XMultiServiceFactory > xFac( m_xModel, uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellRangeAddressConversion" ))), uno::UNO_QUERY ); + + uno::Reference< beans::XPropertySet > xProps( xListSink->getListEntrySource(), uno::UNO_QUERY_THROW ); + table::CellRangeAddress aAddress; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CellRange") ) ) >>= aAddress; + xConvertor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Address")), uno::makeAny( aAddress ) ); + xConvertor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("XL_A1_Representation") ) ) >>= sRowSource; + } + catch( uno::Exception& ) + { + } + } + return sRowSource; +#else + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getRowSource not supported") ), uno::Reference< uno::XInterface >()); // not supported +#endif +} + +void SAL_CALL +ScVbaControl::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException) +{ +#ifdef VBA_OOBUILD_HACK + rtl::OUString sEmpty; + svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, sEmpty, _rowsource ); +#else + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setRowSource not supported ") ).concat( _rowsource ), uno::Reference< uno::XInterface >()); // not supported +#endif +} + +rtl::OUString SAL_CALL +ScVbaControl::getName() throw (uno::RuntimeException) +{ + rtl::OUString sName; + m_xProps->getPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName; + return sName; + +} + +void SAL_CALL +ScVbaControl::setName( const rtl::OUString& _name ) throw (uno::RuntimeException) +{ + m_xProps->setPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), uno::makeAny( _name ) ); + } + +rtl::OUString SAL_CALL +ScVbaControl::getControlTipText() throw (css::uno::RuntimeException) +{ + rtl::OUString sName; + m_xProps->getPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) ) ) >>= sName; + return sName; +} + +void SAL_CALL +ScVbaControl::setControlTipText( const rtl::OUString& rsToolTip ) throw (css::uno::RuntimeException) +{ + m_xProps->setPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) ), uno::makeAny( rsToolTip ) ); +} +//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 ) +{ +} + +ScVbaControl* ScVbaControlFactory::createControl() throw (uno::RuntimeException) +{ + return createControl( m_xModel ); +} +ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException) +{ + uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ); + if ( xControlShape.is() ) // form controls + return createControl( xControlShape, xParent ); + uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY ); + 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) +{ + uno::Reference< beans::XPropertySet > xProps( xControlShape->getControl(), uno::UNO_QUERY_THROW ); + sal_Int32 nClassId = -1; + const static rtl::OUString sClassId( RTL_CONSTASCII_USTRINGPARAM("ClassId") ); + xProps->getPropertyValue( sClassId ) >>= nClassId; + uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess + 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 ) ) ); + 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::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: + return new ScVbaListBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + case form::FormComponentType::SPINBUTTON: + return new ScVbaSpinButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) ); + 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 >() ); + } +} + +ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XControl >& xControl, const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xProps( xControl->getModel(), uno::UNO_QUERY_THROW ); + uno::Reference< lang::XServiceInfo > xServiceInfo( xProps, uno::UNO_QUERY_THROW ); + 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 ) ); + 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 ) ); + 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") ) ) ) + { + sal_Bool bToggle = sal_False; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toggle") ) ) >>= bToggle; + if ( bToggle ) + pControl = new ScVbaToggleButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + else + pControl = new ScVbaButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) ); + } + 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 ) ); + 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 ) ); + 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 ) ); + 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 ) ); + 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 ) ); + 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 ) ); + 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 ); + 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 + throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() ); + return pControl; +} + +rtl::OUString& +ScVbaControl::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControl") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaControl::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Control" ) ); + } + return aServiceNames; +} + + + +typedef cppu::WeakImplHelper1< XControlProvider > ControlProvider_BASE; +class ControlProviderImpl : public ControlProvider_BASE +{ + uno::Reference< uno::XComponentContext > m_xCtx; +public: + ControlProviderImpl( const uno::Reference< uno::XComponentContext >& xCtx ) : m_xCtx( xCtx ) {} + virtual uno::Reference< msforms::XControl > SAL_CALL createControl( const uno::Reference< drawing::XControlShape >& xControl, const uno::Reference< frame::XModel >& xDocOwner ) throw (uno::RuntimeException); + 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 +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() ) + { + ScVbaControlFactory controlFactory( m_xCtx, xControlShape, xDocOwner ); + xControlToReturn.set( controlFactory.createControl( xDocOwner ) ); + } + return xControlToReturn; + +} +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() ) + { + + ScVbaControlFactory controlFactory( m_xCtx, xControl, xDocOwner ); + xControlToReturn.set( controlFactory.createControl( xDialog->getModel() ) ); + ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xControlToReturn.get() ); + pControl->setGeometryHelper( new UserFormGeometryHelper( m_xCtx, xControl ) ); + } + return xControlToReturn; +} + +namespace controlprovider +{ +namespace sdecl = comphelper::service_decl; +sdecl::class_<ControlProviderImpl, sdecl::with_args<false> > serviceImpl; +extern sdecl::ServiceDecl const serviceDecl( + serviceImpl, + "ControlProviderImpl", + "ooo.vba.ControlProvider" ); +} + + diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx new file mode 100644 index 000000000000..15be1211d0b6 --- /dev/null +++ b/vbahelper/source/msforms/vbacontrol.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbacontrol.hxx,v $ + * $Revision: 1.3 $ + * + * 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 SC_VBA_CONTROL_HXX +#define SC_VBA_CONTROL_HXX + +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/script/XDefaultProperty.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XWindowPeer.hpp> +#include <ooo/vba/msforms/XControl.hpp> + +#include <vbahelper/vbahelper.hxx> +#include <vbahelper/vbahelperinterface.hxx> +#include <memory> + +//typedef ::cppu::WeakImplHelper1< ov::msforms::XControl > ControlImpl_BASE; +typedef InheritedHelperInterfaceImpl1< ov::msforms::XControl > ControlImpl_BASE; + +class ScVbaControl : public ControlImpl_BASE +{ +private: + com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener; +protected: + 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); +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 ); + virtual ~ScVbaControl(); + // This class will own the helper, so make sure it is allocated from + // the heap + void setGeometryHelper( ov::AbstractGeometryAttributes* pHelper ); + // XControl + virtual sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException); + virtual void SAL_CALL setEnabled( sal_Bool _enabled ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException); + virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException); + virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException); + virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException); + virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException); + 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 css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException); + virtual rtl::OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException); + virtual void SAL_CALL setControlSource( const rtl::OUString& _controlsource ) throw (css::uno::RuntimeException); + virtual rtl::OUString SAL_CALL getRowSource() throw (css::uno::RuntimeException); + virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException); + virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); + 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); + //remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape + virtual void removeResouce() throw( css::uno::RuntimeException ); + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; + + +class ScVbaControlFactory +{ +public: + ScVbaControlFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel ); + ScVbaControl* createControl() throw ( css::uno::RuntimeException ); + ScVbaControl* createControl( const css::uno::Reference< css::uno::XInterface >& xParent ) throw ( css::uno::RuntimeException ); +private: + ScVbaControl* createControl( const css::uno::Reference< css::awt::XControl >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException ); + ScVbaControl* createControl( const css::uno::Reference< css::drawing::XControlShape >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException ); + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::uno::XInterface > m_xControl; + css::uno::Reference< css::frame::XModel > m_xModel; +}; + +#endif//SC_VBA_CONTROL_HXX diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx new file mode 100644 index 000000000000..ccef1419c5d2 --- /dev/null +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -0,0 +1,232 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * 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 "vbacontrols.hxx" +#include <cppuhelper/implbase2.hxx> +#include <com/sun/star/awt/XControlContainer.hpp> +#include <ooo/vba//XControlProvider.hpp> +#include <hash_map> + +using namespace com::sun::star; +using namespace ooo::vba; + + +typedef ::cppu::WeakImplHelper2< container::XNameAccess, container::XIndexAccess > ArrayWrapImpl; + +typedef std::hash_map< rtl::OUString, sal_Int32, ::rtl::OUStringHash, + ::std::equal_to< ::rtl::OUString > > ControlIndexMap; +typedef std::vector< uno::Reference< awt::XControl > > ControlVec; + +class ControlArrayWrapper : public ArrayWrapImpl +{ + uno::Reference< awt::XControlContainer > mxDialog; + uno::Sequence< ::rtl::OUString > msNames; + ControlVec mControls; + ControlIndexMap mIndices; + + rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl ) + { + uno::Reference< beans::XPropertySet > xProp( xCtrl->getModel(), uno::UNO_QUERY ); + rtl::OUString sName; + xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName; + return sName; + } + +public: + + ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog ) + { + 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 ) + { + uno::Reference< awt::XControl > xCtrl = sXControls[ i ]; + msNames[ i ] = getControlName( xCtrl ); + mControls.push_back( xCtrl ); + mIndices[ msNames[ i ] ] = i; + } + } + + // XElementAccess + virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) + { + return awt::XControl::static_type(0); + } + + virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) + { + return ( mControls.size() > 0 ); + } + + // XNameAcess + virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) + { + if ( !hasByName( aName ) ) + throw container::NoSuchElementException(); + return getByIndex( mIndices[ aName ] ); + } + + virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException) + { + return msNames; + } + + virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException) + { + ControlIndexMap::iterator it = mIndices.find( aName ); + return it != mIndices.end(); + } + + // XElementAccess + virtual ::sal_Int32 SAL_CALL getCount( ) throw (css::uno::RuntimeException) + { + return mControls.size(); + } + + virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) + { + if ( Index < 0 || Index >= static_cast< sal_Int32 >( mControls.size() ) ) + throw lang::IndexOutOfBoundsException(); + return uno::makeAny( mControls[ Index ] ); + } +}; + + +class ControlsEnumWrapper : public EnumerationHelper_BASE +{ + uno::Reference<XHelperInterface > m_xParent; + uno::Reference<uno::XComponentContext > m_xContext; + uno::Reference<container::XIndexAccess > m_xIndexAccess; + uno::Reference<awt::XControl > m_xDlg; + sal_Int32 nIndex; + +public: + + ControlsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< awt::XControl >& xDlg ) : m_xParent( xParent ), m_xContext( xContext), m_xIndexAccess( xIndexAccess ), m_xDlg( xDlg ), nIndex( 0 ) {} + + virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) + { + return ( nIndex < m_xIndexAccess->getCount() ); + } + + virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) + { + if ( nIndex < m_xIndexAccess->getCount() ) + { + uno::Reference< frame::XModel > xModel; + uno::Reference< awt::XControl > xControl; + m_xIndexAccess->getByIndex( nIndex++ ) >>= xControl; + + uno::Reference<lang::XMultiComponentFactory > xServiceManager( m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); + uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), m_xContext ), uno::UNO_QUERY_THROW ); + + uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, m_xDlg, xModel ) ); + return uno::makeAny( xVBAControl ); + } + throw container::NoSuchElementException(); + } + +}; + + +uno::Reference<container::XIndexAccess > +lcl_controlsWrapper( const uno::Reference< awt::XControl >& xDlg ) +{ + return new ControlArrayWrapper( xDlg ); +} + +ScVbaControls::ScVbaControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, + const css::uno::Reference< awt::XControl >& xDialog ) + : ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ) +{ + mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); +} + +uno::Reference< container::XEnumeration > +ScVbaControls::createEnumeration() throw (uno::RuntimeException) +{ + uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog ) ); + if ( !xEnum.is() ) + throw uno::RuntimeException(); + return xEnum; +} + +uno::Any +ScVbaControls::createCollectionObject( const css::uno::Any& aSource ) +{ + // Create control from awt::XControl + uno::Reference< awt::XControl > xControl; + aSource >>= xControl; + uno::Reference< frame::XModel > xModel; + uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); + uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW ); + + uno::Reference< msforms::XControl > xVBAControl( xControlProvider->createUserformControl( xControl, mxDialog, xModel ) ); + + return uno::makeAny( xVBAControl ); +} + +void SAL_CALL +ScVbaControls::Move( double cx, double cy ) throw (uno::RuntimeException) +{ + uno::Reference< container::XEnumeration > xEnum( createEnumeration() ); + while ( xEnum->hasMoreElements() ) + { + uno::Reference< msforms::XControl > xControl( xEnum->nextElement(), uno::UNO_QUERY_THROW ); + xControl->setLeft( xControl->getLeft() + cx ); + xControl->setTop( xControl->getTop() + cy ); + } +} + +uno::Type +ScVbaControls::getElementType() throw (uno::RuntimeException) +{ + return ooo::vba::msforms::XControl::static_type(0); +} +rtl::OUString& +ScVbaControls::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaControls") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaControls::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Controls" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx new file mode 100644 index 000000000000..3b5bddd80379 --- /dev/null +++ b/vbahelper/source/msforms/vbacontrols.hxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * 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 SC_VBA_CONTROLS_HXX +#define SC_VBA_CONTROLS_HXX + +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XControls.hpp> +#include <com/sun/star/awt/XControl.hpp> + +#include <vbahelper/vbacollectionimpl.hxx> +#include <vbahelper/vbahelper.hxx> + +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); + // 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); + + // ScVbaCollectionBaseImpl + virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); + +}; +#endif //SC_VBA_OLEOBJECTS_HXX + diff --git a/vbahelper/source/msforms/vbaframe.cxx b/vbahelper/source/msforms/vbaframe.cxx new file mode 100644 index 000000000000..24f8884e4d3b --- /dev/null +++ b/vbahelper/source/msforms/vbaframe.cxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include "vbaframe.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); +ScVbaFrame::ScVbaFrame( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ +} + +// Attributes +rtl::OUString SAL_CALL +ScVbaFrame::getCaption() throw (css::uno::RuntimeException) +{ + rtl::OUString Label; + m_xProps->getPropertyValue( LABEL ) >>= Label; + return Label; +} + +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 +ScVbaFrame::getValue() throw (css::uno::RuntimeException) +{ + return uno::makeAny( getCaption() ); +} + +void SAL_CALL +ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException) +{ + rtl::OUString sCaption; + _value >>= sCaption; + setCaption( sCaption ); +} + +rtl::OUString& +ScVbaFrame::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFrame") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaFrame::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/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx new file mode 100644 index 000000000000..071b5b09d028 --- /dev/null +++ b/vbahelper/source/msforms/vbaframe.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef SC_VBA_FRAME_HXX +#define SC_VBA_FRAME_HXX +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XLabel.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XLabel > FrameImpl_BASE; + +class ScVbaFrame : public FrameImpl_BASE +{ +public: + ScVbaFrame( 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 ); + // Attributes + 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); + virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; +#endif //SC_VBA_LABEL_HXX diff --git a/vbahelper/source/msforms/vbaimage.cxx b/vbahelper/source/msforms/vbaimage.cxx new file mode 100644 index 000000000000..7e6cd34c191e --- /dev/null +++ b/vbahelper/source/msforms/vbaimage.cxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * 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 "vbaimage.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); +ScVbaImage::ScVbaImage( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ImageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ +} + +rtl::OUString& +ScVbaImage::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaImage") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaImage::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Image" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbaimage.hxx b/vbahelper/source/msforms/vbaimage.hxx new file mode 100644 index 000000000000..0fe6b8bda148 --- /dev/null +++ b/vbahelper/source/msforms/vbaimage.hxx @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * 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 SC_VBA_IMAGE_HXX +#define SC_VBA_IMAGE_HXX +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XImage.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XImage > ImageImpl_BASE; + +class ScVbaImage : public ImageImpl_BASE +{ +public: + ScVbaImage( 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 ); + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; +#endif //SC_VBA_IMAGE_HXX diff --git a/vbahelper/source/msforms/vbalabel.cxx b/vbahelper/source/msforms/vbalabel.cxx new file mode 100644 index 000000000000..0a7614ee4eb0 --- /dev/null +++ b/vbahelper/source/msforms/vbalabel.cxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbalabel.cxx,v $ + * $Revision: 1.3 $ + * + * 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 "vbalabel.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); +ScVbaLabel::ScVbaLabel( const css::uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : LabelImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ +} + +// Attributes +rtl::OUString SAL_CALL +ScVbaLabel::getCaption() throw (css::uno::RuntimeException) +{ + rtl::OUString Label; + m_xProps->getPropertyValue( LABEL ) >>= Label; + return Label; +} + +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 +ScVbaLabel::getValue() throw (css::uno::RuntimeException) +{ + return uno::makeAny( getCaption() ); +} + +void SAL_CALL +ScVbaLabel::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException) +{ + rtl::OUString sCaption; + _value >>= sCaption; + setCaption( sCaption ); +} + + +rtl::OUString& +ScVbaLabel::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaLabel") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaLabel::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Label" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbalabel.hxx b/vbahelper/source/msforms/vbalabel.hxx new file mode 100644 index 000000000000..e390f3e3f0ed --- /dev/null +++ b/vbahelper/source/msforms/vbalabel.hxx @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbalabel.hxx,v $ + * $Revision: 1.3 $ + * + * 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 SC_VBA_LABEL_HXX +#define SC_VBA_LABEL_HXX +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XLabel.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> +#include <cppuhelper/implbase2.hxx> + +typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XLabel, css::script::XDefaultProperty > LabelImpl_BASE; + +class ScVbaLabel : public LabelImpl_BASE +{ +public: + ScVbaLabel( 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 ); + // Attributes + 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); + virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) 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"); } +}; +#endif //SC_VBA_LABEL_HXX diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx new file mode 100644 index 000000000000..184f1387aaed --- /dev/null +++ b/vbahelper/source/msforms/vbalistbox.cxx @@ -0,0 +1,290 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbalistbox.cxx,v $ + * $Revision: 1.4 $ + * + * 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 <com/sun/star/form/validation/XValidatableFormComponent.hpp> + +#include "vbalistbox.hxx" +#include <vector> +#include <comphelper/anytostring.hxx> +#include <com/sun/star/script/ArrayWrapper.hpp> + +using namespace com::sun::star; +using namespace ooo::vba; + +const static rtl::OUString TEXT( RTL_CONSTASCII_USTRINGPARAM("Text") ); +const static rtl::OUString SELECTEDITEMS( RTL_CONSTASCII_USTRINGPARAM("SelectedItems") ); +const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ); + + +ScVbaListBox::ScVbaListBox( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< css::uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : ListBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ + mpListHelper.reset( new ListControlHelper( m_xProps ) ); +} + +// Attributes +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 ) ); +} + +uno::Any SAL_CALL +ScVbaListBox::getListIndex() throw (uno::RuntimeException) +{ + uno::Sequence< sal_Int16 > sSelection; + m_xProps->getPropertyValue( SELECTEDITEMS ) >>= sSelection; + if ( sSelection.getLength() == 0 ) + return uno::Any( sal_Int32( -1 ) ); + return uno::Any( sSelection[ 0 ] ); +} + +uno::Any SAL_CALL +ScVbaListBox::getValue() throw (uno::RuntimeException) +{ + uno::Sequence< sal_Int16 > sSelection; + uno::Sequence< rtl::OUString > sItems; + 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 >() ); + uno::Any aRet; + if ( sSelection.getLength() ) + aRet = uno::makeAny( sItems[ sSelection[ 0 ] ] ); + return aRet; +} + +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 >() ); + } + rtl::OUString sValue = getAnyAsString( _value ); + uno::Sequence< rtl::OUString > sList; + m_xProps->getPropertyValue( ITEMS ) >>= sList; + uno::Sequence< sal_Int16 > nList; + sal_Int16 nLength = static_cast<sal_Int16>( sList.getLength() ); + sal_Int16 nValue = -1; + sal_Int16 i = 0; + for( i = 0; i < nLength; i++ ) + { + if( sList[i].equals( sValue ) ) + { + nValue = i; + break; + } + } + if( nValue == -1 ) + throw uno::RuntimeException( rtl::OUString::createFromAscii( + "Attribute use invalid." ), uno::Reference< uno::XInterface >() ); + + uno::Sequence< sal_Int16 > nSelectedIndices(1); + nSelectedIndices[ 0 ] = nValue; + m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nSelectedIndices ) ); + m_xProps->setPropertyValue( TEXT, uno::makeAny( sValue ) ); +} + +::rtl::OUString SAL_CALL +ScVbaListBox::getText() throw (uno::RuntimeException) +{ + rtl::OUString result; + getValue() >>= result; + return result; +} + +void SAL_CALL +ScVbaListBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException) +{ + setValue( uno::makeAny( _text ) ); // seems the same +} + +sal_Bool 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; +} + +void SAL_CALL +ScVbaListBox::setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException) +{ + m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ), uno::makeAny( _multiselect ) ); +} + +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 + 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 >() ); + m_nIndex = nIndex; + return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) ); +} + +// Methods +void SAL_CALL +ScVbaListBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException) +{ + mpListHelper->AddItem( pvargItem, pvargIndex ); + } + +void SAL_CALL +ScVbaListBox::removeItem( const uno::Any& index ) throw (uno::RuntimeException) +{ + mpListHelper->removeItem( index ); +} + +void SAL_CALL +ScVbaListBox::Clear( ) throw (uno::RuntimeException) +{ + mpListHelper->Clear(); +} + +// this is called when something like the following vba code is used +// to set the selected state of particular entries in the Listbox +// ListBox1.Selected( 3 ) = false +//PropListener +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 >() ); + uno::Sequence< sal_Int16 > nList; + m_xProps->getPropertyValue( SELECTEDITEMS ) >>= nList; + sal_Int16 nLength = static_cast<sal_Int16>( nList.getLength() ); + sal_Int16 nIndex = m_nIndex; + for( sal_Int16 i = 0; i < nLength; i++ ) + { + if( nList[i] == nIndex ) + { + if( bValue ) + return; + else + { + for( ; i < nLength - 1; i++ ) + { + nList[i] = nList[i + 1]; + } + nList.realloc( nLength - 1 ); + //m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) ); + m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nList ) ); + return; + } + } + } + if( bValue ) + { + if( getMultiSelect() ) + { + nList.realloc( nLength + 1 ); + nList[nLength] = nIndex; + } + else + { + nList.realloc( 1 ); + nList[0] = nIndex; + } + //m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) ); + m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nList ) ); + } +} + +// this is called when something like the following vba code is used +// to determine the selected state of particular entries in the Listbox +// msgbox ListBox1.Selected( 3 ) + +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 ) + return uno::makeAny( sal_True ); + } + + return uno::makeAny( sal_False ); +} + +void SAL_CALL +ScVbaListBox::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException) +{ + ScVbaControl::setRowSource( _rowsource ); + mpListHelper->setRowSource( _rowsource ); +} + +sal_Int32 SAL_CALL +ScVbaListBox::getListCount() throw (uno::RuntimeException) +{ + return mpListHelper->getListCount(); +} + +uno::Any SAL_CALL +ScVbaListBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn ) throw (uno::RuntimeException) +{ + return mpListHelper->List( pvargIndex, pvarColumn ); +} + +rtl::OUString& +ScVbaListBox::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaListBox") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaListBox::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ScVbaListBox" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbalistbox.hxx b/vbahelper/source/msforms/vbalistbox.hxx new file mode 100644 index 000000000000..e653338d82d9 --- /dev/null +++ b/vbahelper/source/msforms/vbalistbox.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbalistbox.hxx,v $ + * $Revision: 1.3 $ + * + * 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 SC_VBA_LISTBOX_HXX +#define SC_VBA_LISTBOX_HXX +#include <cppuhelper/implbase2.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/script/XDefaultProperty.hpp> +#include <ooo/vba/msforms/XListBox.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbapropvalue.hxx> +#include "vbalistcontrolhelper.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper2<ScVbaControl, ov::msforms::XListBox, css::script::XDefaultProperty > ListBoxImpl_BASE; +class ScVbaListBox : public ListBoxImpl_BASE + ,public PropListener +{ + std::auto_ptr< ListControlHelper > mpListHelper; + rtl::OUString sSourceName; + rtl::OUString msDftPropName; + + sal_Int16 m_nIndex; + +public: + ScVbaListBox( 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 ); + + // Attributes + virtual css::uno::Any SAL_CALL getListIndex() throw (css::uno::RuntimeException); + virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getListCount() throw (css::uno::RuntimeException); + 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); + 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 css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException); + + // Methods + virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException); + virtual void SAL_CALL removeItem( const css::uno::Any& index ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Clear( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException); + // XControl + 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"); } + + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); + + //PropListener + virtual void setValueEvent( const css::uno::Any& value ); + virtual css::uno::Any getValueEvent(); + + +}; + +#endif // diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.cxx b/vbahelper/source/msforms/vbalistcontrolhelper.cxx new file mode 100644 index 000000000000..76763b42039e --- /dev/null +++ b/vbahelper/source/msforms/vbalistcontrolhelper.cxx @@ -0,0 +1,146 @@ +#include <vbalistcontrolhelper.hxx> +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + +const static rtl::OUString ITEMS( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ); + +void SAL_CALL +ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex ) throw (uno::RuntimeException) +{ + if ( pvargItem.hasValue() ) + { + uno::Sequence< rtl::OUString > sList; + m_xProps->getPropertyValue( ITEMS ) >>= sList; + + sal_Int32 nIndex = sList.getLength(); + + if ( pvargIndex.hasValue() ) + pvargIndex >>= nIndex; + + rtl::OUString sString = getAnyAsString( pvargItem ); + + // 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; + } + else + { + // just copy those elements above the one to be inserted + std::vector< rtl::OUString > sVec; + // reserve just the amount we need to copy + sVec.reserve( sList.getLength() - nIndex ); + + // point at first element to copy + rtl::OUString* pString = sList.getArray() + nIndex; + const rtl::OUString* pEndString = sList.getArray() + sList.getLength(); + // insert the new element + sVec.push_back( sString ); + // copy elements + for ( ; pString != pEndString; ++pString ) + sVec.push_back( *pString ); + + sList.realloc( sList.getLength() + 1 ); + + // point at first element to be overwritten + pString = sList.getArray() + nIndex; + pEndString = sList.getArray() + sList.getLength(); + std::vector< rtl::OUString >::iterator it = sVec.begin(); + for ( ; pString != pEndString; ++pString, ++it) + *pString = *it; + // + } + + m_xProps->setPropertyValue( ITEMS, uno::makeAny( sList ) ); + + } +} + +void SAL_CALL +ListControlHelper::removeItem( const uno::Any& index ) throw (uno::RuntimeException) +{ + sal_Int32 nIndex = 0; + // for int index + if ( index >>= nIndex ) + { + 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 > () ); + if( sList.hasElements() ) + { + if( sList.getLength() == 1 ) + { + Clear(); + return; + } + for( sal_Int32 i = nIndex; i < ( sList.getLength()-1 ); i++ ) + { + sList[i] = sList[i+1]; + } + sList.realloc( sList.getLength() - 1 ); + } + + m_xProps->setPropertyValue( ITEMS, uno::makeAny( sList ) ); + } +} + +void SAL_CALL +ListControlHelper::Clear( ) throw (uno::RuntimeException) +{ + // urk, setValue doesn't seem to work !! + //setValue( uno::makeAny( sal_Int16() ) ); + m_xProps->setPropertyValue( ITEMS, uno::makeAny( uno::Sequence< rtl::OUString >() ) ); +} + +void SAL_CALL +ListControlHelper::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException) +{ + if ( _rowsource.getLength() == 0 ) + Clear(); +} + +sal_Int32 SAL_CALL +ListControlHelper::getListCount() throw (uno::RuntimeException) +{ + uno::Sequence< rtl::OUString > sList; + m_xProps->getPropertyValue( ITEMS ) >>= sList; + return sList.getLength(); +} + +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; +} diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.hxx b/vbahelper/source/msforms/vbalistcontrolhelper.hxx new file mode 100644 index 000000000000..d56729da17e6 --- /dev/null +++ b/vbahelper/source/msforms/vbalistcontrolhelper.hxx @@ -0,0 +1,20 @@ +#ifndef SC_VBA_LISTCONTROLHELPER +#define SC_VBA_LISTCONTROLHELPER + +#include <vbahelper/vbahelper.hxx> + +class ListControlHelper +{ + css::uno::Reference< css::beans::XPropertySet > m_xProps; + +public: + ListControlHelper( const css::uno::Reference< css::beans::XPropertySet >& rxControl ) : m_xProps( rxControl ){} + virtual ~ListControlHelper() {} + virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException); + virtual void SAL_CALL removeItem( const css::uno::Any& index ) throw (css::uno::RuntimeException); + virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getListCount() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Clear( ) throw (css::uno::RuntimeException); +}; +#endif diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx new file mode 100644 index 000000000000..69410dbadc64 --- /dev/null +++ b/vbahelper/source/msforms/vbamultipage.cxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include "vbamultipage.hxx" +#include <ooo/vba/XCollection.hpp> +#include "vbapages.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + +// uno servicename com.sun.star.awt.UnoControlProgressBarMode +const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ); +const rtl::OUString SVALUEMAX( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") ); +const rtl::OUString SSTEP( RTL_CONSTASCII_USTRINGPARAM("Step") ); + +typedef cppu::WeakImplHelper1< container::XIndexAccess > PagesImpl_Base; +class PagesImpl : public PagesImpl_Base +{ + sal_Int32 mnPages; +public: + PagesImpl( sal_Int32 nPages ) : mnPages( nPages ) {} + virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException) { return mnPages; } + virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, ::uno::RuntimeException) + { + if ( Index < 0 || Index > mnPages ) + throw lang::IndexOutOfBoundsException(); + return uno::makeAny( uno::Reference< uno::XInterface >() ); + } + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException) + { + // no Pages object yet #FIXME + //return msforms::XPage::static_type(0); + return uno::XInterface::static_type(0); + } + virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) + { + return ( mnPages > 0 ); + } +}; +uno::Reference< container::XIndexAccess > +ScVbaMultiPage::getPages( sal_Int32 nPages ) +{ + return new PagesImpl( nPages ); +} + +ScVbaMultiPage::ScVbaMultiPage( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, const uno::Reference< uno::XInterface >& xDialog ) : MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ + mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW ); + // set dialog step to value of multipage pseudo model + setValue(getValue()); +} + +// Attributes +sal_Int32 SAL_CALL +ScVbaMultiPage::getValue() throw (css::uno::RuntimeException) +{ + sal_Int32 nValue = 0; + m_xProps->getPropertyValue( SVALUE ) >>= nValue; + return nValue; +} + +void SAL_CALL +ScVbaMultiPage::setValue( const sal_Int32 _value ) throw (::com::sun::star::uno::RuntimeException) +{ + // track change in dialog ( dialog value is 1 based, 0 is a special value ) + m_xProps->setPropertyValue( SVALUE, uno::makeAny( _value ) ); + mxDialogProps->setPropertyValue( SSTEP, uno::makeAny( _value + 1) ); +} + + +rtl::OUString& +ScVbaMultiPage::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMultiPage") ); + return sImplName; +} + +uno::Any SAL_CALL +ScVbaMultiPage::Pages( const uno::Any& index ) throw (uno::RuntimeException) +{ + sal_Int32 nValue = 0; + m_xProps->getPropertyValue( SVALUEMAX ) >>= nValue; + uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, getPages( nValue ) ) ); + if ( !index.hasValue() ) + return uno::makeAny( xColl ); + return xColl->Item( uno::makeAny( index ), uno::Any() ); +} + +uno::Sequence< rtl::OUString > +ScVbaMultiPage::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.MultiPage" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbamultipage.hxx b/vbahelper/source/msforms/vbamultipage.hxx new file mode 100644 index 000000000000..b0214f684dbc --- /dev/null +++ b/vbahelper/source/msforms/vbamultipage.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef SC_VBA_MULTIPAGE_HXX +#define SC_VBA_MULTIPAGE_HXX +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XMultiPage.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> +//#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase1.hxx> + +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XMultiPage > MultiPageImpl_BASE; + +class ScVbaMultiPage : public MultiPageImpl_BASE +{ + css::uno::Reference< css::container::XIndexAccess > getPages( sal_Int32 nPages ); + css::uno::Reference< css::beans::XPropertySet > mxDialogProps; +public: + ScVbaMultiPage( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper, const css::uno::Reference< css::uno::XInterface >& xDialog ); + // Attributes + virtual sal_Int32 SAL_CALL getValue() throw (css::uno::RuntimeException); + virtual void SAL_CALL setValue( sal_Int32 _value ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Pages( const css::uno::Any& index ) 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"); } +}; +#endif //SC_VBA_LABEL_HXX diff --git a/vbahelper/source/msforms/vbapages.cxx b/vbahelper/source/msforms/vbapages.cxx new file mode 100644 index 000000000000..af06cffb75ae --- /dev/null +++ b/vbahelper/source/msforms/vbapages.cxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include "vbapages.hxx" + +using namespace ::ooo::vba; +using namespace ::com::sun::star; + +ScVbaPages::ScVbaPages( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xPages ) throw( lang::IllegalArgumentException ) : ScVbaPages_BASE( xParent, xContext, xPages ) +{ +} + +uno::Type SAL_CALL +ScVbaPages::getElementType() throw (uno::RuntimeException) +{ + // return msforms::XPage::static_type(0); + return uno::XInterface::static_type(0); +} + +uno::Any +ScVbaPages::createCollectionObject( const css::uno::Any& aSource ) +{ + return aSource; +} + +rtl::OUString& +ScVbaPages::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPages") ); + return sImplName; +} + +uno::Reference< container::XEnumeration > SAL_CALL +ScVbaPages::createEnumeration() throw (uno::RuntimeException) +{ + return uno::Reference< container::XEnumeration >(); +} + +uno::Sequence< rtl::OUString > +ScVbaPages::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msform.Pages" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbapages.hxx b/vbahelper/source/msforms/vbapages.hxx new file mode 100644 index 000000000000..b61e21bb0019 --- /dev/null +++ b/vbahelper/source/msforms/vbapages.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef SC_VBA_PAGES_HXX +#define SC_VBA_PAGES_HXX + +#include <ooo/vba/office/MsoShapeType.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <ooo/vba/msforms/XPages.hpp> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase1.hxx> + +#include <vbahelper/vbacollectionimpl.hxx> +typedef CollTestImplHelper< +ov::msforms::XPages > ScVbaPages_BASE; + +class ScVbaPages : public ScVbaPages_BASE +{ +protected: + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +public: + ScVbaPages( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xPages ) throw ( css::lang::IllegalArgumentException ); + virtual ~ScVbaPages() {} + // 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); + // ScVbaPages_BASE + virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); + +}; +#endif//SC_VBA_SHAPE_HXX diff --git a/vbahelper/source/msforms/vbaprogressbar.cxx b/vbahelper/source/msforms/vbaprogressbar.cxx new file mode 100644 index 000000000000..27f425f9b808 --- /dev/null +++ b/vbahelper/source/msforms/vbaprogressbar.cxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include "vbaprogressbar.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + +// uno servicename com.sun.star.awt.UnoControlProgressBarMode +const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") ); + +ScVbaProgressBar::ScVbaProgressBar( 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 ) : ProgressBarImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ +} + +// Attributes +uno::Any SAL_CALL +ScVbaProgressBar::getValue() throw (css::uno::RuntimeException) +{ + return m_xProps->getPropertyValue( SVALUE ); +} + +void SAL_CALL +ScVbaProgressBar::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException) +{ + m_xProps->setPropertyValue( SVALUE, _value ); +} + +rtl::OUString& +ScVbaProgressBar::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaProgressBar") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaProgressBar::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.Label" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbaprogressbar.hxx b/vbahelper/source/msforms/vbaprogressbar.hxx new file mode 100644 index 000000000000..86cbae4e89a0 --- /dev/null +++ b/vbahelper/source/msforms/vbaprogressbar.hxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef SC_VBA_PROGRESSBAR_HXX +#define SC_VBA_PROGRESSBAR_HXX +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XProgressBar.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> +#include <cppuhelper/implbase2.hxx> + +typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XProgressBar, css::script::XDefaultProperty > ProgressBarImpl_BASE; + +class ScVbaProgressBar : public ProgressBarImpl_BASE +{ +public: + ScVbaProgressBar( 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 ); + // Attributes + 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); + //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"); } +}; +#endif //SC_VBA_LABEL_HXX diff --git a/vbahelper/source/msforms/vbaradiobutton.cxx b/vbahelper/source/msforms/vbaradiobutton.cxx new file mode 100644 index 000000000000..3ce00bfd862b --- /dev/null +++ b/vbahelper/source/msforms/vbaradiobutton.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbaradiobutton.cxx,v $ + * $Revision: 1.3 $ + * + * 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 "vbaradiobutton.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); +const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") ); +ScVbaRadioButton::ScVbaRadioButton( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : RadioButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ +} + +// Attributes +rtl::OUString SAL_CALL +ScVbaRadioButton::getCaption() throw (css::uno::RuntimeException) +{ + rtl::OUString Label; + m_xProps->getPropertyValue( LABEL ) >>= Label; + return Label; +} + +void SAL_CALL +ScVbaRadioButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) +{ + m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); +} + +uno::Any SAL_CALL +ScVbaRadioButton::getValue() throw (css::uno::RuntimeException) +{ + sal_Int16 nValue = -1; + m_xProps->getPropertyValue( STATE ) >>= nValue; + if( nValue != 0 ) + nValue = -1; +// return uno::makeAny( nValue ); +// I must be missing something MSO says value should be -1 if selected, 0 if not +// selected + return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False ); + +} + +void SAL_CALL +ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException) +{ + sal_Int16 nValue = 0; + sal_Bool bValue = sal_False; + if( _value >>= nValue ) + { + if( nValue == -1) + nValue = 1; + } + else if ( _value >>= bValue ) + { + if ( bValue ) + nValue = 1; + } + m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) ); +} + +rtl::OUString& +ScVbaRadioButton::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaRadioButton") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaRadioButton::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.RadioButton" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbaradiobutton.hxx b/vbahelper/source/msforms/vbaradiobutton.hxx new file mode 100644 index 000000000000..b13b1260ea8c --- /dev/null +++ b/vbahelper/source/msforms/vbaradiobutton.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbaradiobutton.hxx,v $ + * $Revision: 1.3 $ + * + * 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 SC_VBA_RADIOBUTTON_HXX +#define SC_VBA_RADIOBUTTON_HXX +#include <ooo/vba/msforms/XRadioButton.hpp> +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> +#include <cppuhelper/implbase2.hxx> + +typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > RadioButtonImpl_BASE; + +class ScVbaRadioButton : public RadioButtonImpl_BASE +{ +public: + ScVbaRadioButton( 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 ); + // Attributes + virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); + virtual void SAL_CALL setValue(const com::sun::star::uno::Any&) 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"); } + +}; +#endif //SC_VBA_RADIOBUTTON_HXX diff --git a/vbahelper/source/msforms/vbascrollbar.cxx b/vbahelper/source/msforms/vbascrollbar.cxx new file mode 100644 index 000000000000..3da3230a8761 --- /dev/null +++ b/vbahelper/source/msforms/vbascrollbar.cxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include "vbascrollbar.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +const static rtl::OUString LARGECHANGE( RTL_CONSTASCII_USTRINGPARAM("BlockIncrement") ); +const static rtl::OUString SMALLCHANGE( RTL_CONSTASCII_USTRINGPARAM("LineIncrement") ); +const static rtl::OUString ORIENTATION( RTL_CONSTASCII_USTRINGPARAM("Orientation") ); +const static rtl::OUString SCROLLVALUE( RTL_CONSTASCII_USTRINGPARAM("ScrollValue") ); +const static rtl::OUString SCROLLMAX( RTL_CONSTASCII_USTRINGPARAM("ScrollValueMax") ); +const static rtl::OUString SCROLLMIN( RTL_CONSTASCII_USTRINGPARAM("ScrollValueMin") ); + +ScVbaScrollBar::ScVbaScrollBar( const css::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 ) : ScrollBarImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ +} + +// Attributes +uno::Any SAL_CALL +ScVbaScrollBar::getValue() throw (css::uno::RuntimeException) +{ + return m_xProps->getPropertyValue( SCROLLVALUE ); +} + +void SAL_CALL +ScVbaScrollBar::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException) +{ + m_xProps->setPropertyValue( SCROLLVALUE, _value ); +} + +::sal_Int32 SAL_CALL +ScVbaScrollBar::getMax() throw (uno::RuntimeException) +{ + sal_Int32 nMax = 0; + m_xProps->getPropertyValue( SCROLLMAX ) >>= nMax; + return nMax; +} + +void SAL_CALL +ScVbaScrollBar::setMax( sal_Int32 nVal ) throw (uno::RuntimeException) +{ + m_xProps->setPropertyValue( SCROLLMAX, uno::makeAny( nVal ) ); +} + +::sal_Int32 SAL_CALL +ScVbaScrollBar::getMin() throw (uno::RuntimeException) +{ + sal_Int32 nVal = 0; + m_xProps->getPropertyValue( SCROLLMIN ) >>= nVal; + return nVal; +} + +void SAL_CALL +ScVbaScrollBar::setMin( sal_Int32 nVal ) throw (uno::RuntimeException) +{ + m_xProps->setPropertyValue( SCROLLMIN, uno::makeAny( nVal ) ); +} + +void SAL_CALL +ScVbaScrollBar::setLargeChange( ::sal_Int32 _largechange ) throw (uno::RuntimeException) +{ + m_xProps->setPropertyValue( LARGECHANGE, uno::makeAny( _largechange ) ); +} + +::sal_Int32 SAL_CALL +ScVbaScrollBar::getLargeChange() throw (uno::RuntimeException) +{ + sal_Int32 nVal = 0; + m_xProps->getPropertyValue( LARGECHANGE ) >>= nVal; + return nVal; +} + +::sal_Int32 SAL_CALL +ScVbaScrollBar::getSmallChange() throw (uno::RuntimeException) +{ + sal_Int32 nSmallChange = 0; + m_xProps->getPropertyValue( SMALLCHANGE ) >>= nSmallChange; + return nSmallChange; +} + +void SAL_CALL +ScVbaScrollBar::setSmallChange( ::sal_Int32 _smallchange ) throw (uno::RuntimeException) +{ + m_xProps->setPropertyValue( SMALLCHANGE, uno::makeAny( _smallchange ) ); +} + +rtl::OUString& +ScVbaScrollBar::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaScrollBar") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaScrollBar::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/vbascrollbar.hxx b/vbahelper/source/msforms/vbascrollbar.hxx new file mode 100644 index 000000000000..459f610a71f8 --- /dev/null +++ b/vbahelper/source/msforms/vbascrollbar.hxx @@ -0,0 +1,66 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef SC_VBA_SCROLLBAR_HXX +#define SC_VBA_SCROLLBAR_HXX +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XScrollBar.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XScrollBar > ScrollBarImpl_BASE; + +class ScVbaScrollBar : public ScrollBarImpl_BASE +{ +public: + ScVbaScrollBar( 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 ); + // Attributes + 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); + virtual ::sal_Int32 SAL_CALL getMax() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMax( ::sal_Int32 _max ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getMin() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMin( ::sal_Int32 _min ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getLargeChange() throw (css::uno::RuntimeException); + virtual void SAL_CALL setLargeChange( ::sal_Int32 _largechange ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getSmallChange() throw (css::uno::RuntimeException); + virtual void SAL_CALL setSmallChange( ::sal_Int32 _smallchange ) throw (css::uno::RuntimeException); + + + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; +#endif //SC_VBA_LABEL_HXX diff --git a/vbahelper/source/msforms/vbaspinbutton.cxx b/vbahelper/source/msforms/vbaspinbutton.cxx new file mode 100644 index 000000000000..c9da8cf8827c --- /dev/null +++ b/vbahelper/source/msforms/vbaspinbutton.cxx @@ -0,0 +1,109 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include "vbaspinbutton.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +const static rtl::OUString ORIENTATION( RTL_CONSTASCII_USTRINGPARAM("Orientation") ); +const static rtl::OUString SPINVALUE( RTL_CONSTASCII_USTRINGPARAM("SpinValue") ); +const static rtl::OUString SPINMAX( RTL_CONSTASCII_USTRINGPARAM("SpinValueMax") ); +const static rtl::OUString SPINMIN( RTL_CONSTASCII_USTRINGPARAM("SpinValueMin") ); + +ScVbaSpinButton::ScVbaSpinButton( const css::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 ) : SpinButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ +} + +// Attributes +uno::Any SAL_CALL +ScVbaSpinButton::getValue() throw (css::uno::RuntimeException) +{ + return m_xProps->getPropertyValue( SPINVALUE ); +} + +void SAL_CALL +ScVbaSpinButton::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::RuntimeException) +{ + m_xProps->setPropertyValue( SPINVALUE, _value ); +} + +::sal_Int32 SAL_CALL +ScVbaSpinButton::getMax() throw (uno::RuntimeException) +{ + sal_Int32 nMax = 0; + m_xProps->getPropertyValue( SPINMAX ) >>= nMax; + return nMax; +} + +void SAL_CALL +ScVbaSpinButton::setMax( sal_Int32 nVal ) throw (uno::RuntimeException) +{ + m_xProps->setPropertyValue( SPINMAX, uno::makeAny( nVal ) ); +} + +::sal_Int32 SAL_CALL +ScVbaSpinButton::getMin() throw (uno::RuntimeException) +{ + sal_Int32 nVal = 0; + m_xProps->getPropertyValue( SPINMIN ) >>= nVal; + return nVal; +} + +void SAL_CALL +ScVbaSpinButton::setMin( sal_Int32 nVal ) throw (uno::RuntimeException) +{ + m_xProps->setPropertyValue( SPINMIN, uno::makeAny( nVal ) ); +} + +rtl::OUString& +ScVbaSpinButton::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaSpinButton") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaSpinButton::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/vbaspinbutton.hxx b/vbahelper/source/msforms/vbaspinbutton.hxx new file mode 100644 index 000000000000..8f1d6e3d4dc9 --- /dev/null +++ b/vbahelper/source/msforms/vbaspinbutton.hxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef SC_VBA_SPINBUTTON_HXX +#define SC_VBA_SPINBUTTON_HXX +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XSpinButton.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XSpinButton > SpinButtonImpl_BASE; + +class ScVbaSpinButton : public SpinButtonImpl_BASE +{ +public: + ScVbaSpinButton( 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 ); + // Attributes + 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); + virtual ::sal_Int32 SAL_CALL getMax() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMax( ::sal_Int32 _max ) throw (css::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getMin() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMin( ::sal_Int32 _min ) throw (css::uno::RuntimeException); + + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; +#endif //SC_VBA_SPINBUTTON_HXX diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx new file mode 100644 index 000000000000..f6574550c0c9 --- /dev/null +++ b/vbahelper/source/msforms/vbatextbox.cxx @@ -0,0 +1,137 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbatextbox.cxx,v $ + * $Revision: 1.3 $ + * + * 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 <com/sun/star/text/XTextRange.hpp> + +#include "vbatextbox.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + + +ScVbaTextBox::ScVbaTextBox( 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, bool bDialog ) : TextBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialog( bDialog ) +{ +} + +// Attributes +uno::Any SAL_CALL +ScVbaTextBox::getValue() throw (css::uno::RuntimeException) +{ + return uno::makeAny( getText() ); +} + +void SAL_CALL +ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException) +{ + rtl::OUString sVal = getAnyAsString( _value ); + setText( sVal ); +} + +//getString() will cause some imfo lose. +rtl::OUString SAL_CALL +ScVbaTextBox::getText() throw (css::uno::RuntimeException) +{ + uno::Any aValue; + aValue = m_xProps->getPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ) ); + rtl::OUString sString; + aValue >>= sString; + return sString; +} + +void SAL_CALL +ScVbaTextBox::setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException) +{ + if ( !mbDialog ) + { + 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 ) ); +} + +sal_Int32 SAL_CALL +ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException) +{ + uno::Any aValue; + aValue = m_xProps->getPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ) ); + sal_Int32 nMaxLength = 0; + aValue >>= nMaxLength; + return nMaxLength; +} + +void SAL_CALL +ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException) +{ + uno::Any aValue( _maxlength ); + m_xProps->setPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ), aValue); +} + +sal_Bool SAL_CALL +ScVbaTextBox::getMultiline() throw (css::uno::RuntimeException) +{ + uno::Any aValue; + aValue = m_xProps->getPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ) ); + sal_Bool bRet = false; + aValue >>= bRet; + return bRet; +} + +void SAL_CALL +ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException) +{ + uno::Any aValue( _multiline ); + m_xProps->setPropertyValue + (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue); +} + +rtl::OUString& +ScVbaTextBox::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaTextBox") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaTextBox::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.TextBox" ) ); + } + return aServiceNames; +} diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx new file mode 100644 index 000000000000..ac2d8e789d46 --- /dev/null +++ b/vbahelper/source/msforms/vbatextbox.hxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbatextbox.hxx,v $ + * $Revision: 1.3 $ + * + * 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 SC_VBA_TEXTBOX_HXX +#define SC_VBA_TEXTBOX_HXX +#include <cppuhelper/implbase2.hxx> +#include <ooo/vba/msforms/XTextBox.hpp> +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XTextBox, css::script::XDefaultProperty > TextBoxImpl_BASE; + +class ScVbaTextBox : public TextBoxImpl_BASE +{ + bool mbDialog; +public: + ScVbaTextBox( 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, bool bDialog = false ); + // Attributes + 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); + 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_Int32 SAL_CALL getMaxLength() throw (css::uno::RuntimeException); + virtual void SAL_CALL setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException); + 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"); } + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; +#endif //SC_VBA_TEXTBOX_HXX diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx new file mode 100644 index 000000000000..d49b2e89affe --- /dev/null +++ b/vbahelper/source/msforms/vbatogglebutton.cxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include "vbatogglebutton.hxx" +#include <vector> + +using namespace com::sun::star; +using namespace ooo::vba; + + +const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); +const static rtl::OUString TOGGLE( RTL_CONSTASCII_USTRINGPARAM("Toggle") ); +const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") ); +ScVbaToggleButton::ScVbaToggleButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : ToggleButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ) +{ + OSL_TRACE("ScVbaToggleButton(ctor)"); + m_xProps->setPropertyValue( TOGGLE, uno::makeAny( sal_True ) ); +} + +ScVbaToggleButton::~ScVbaToggleButton() +{ + OSL_TRACE("~ScVbaToggleButton(dtor)"); +} + +// Attributes +rtl::OUString SAL_CALL +ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException) +{ + rtl::OUString Label; + m_xProps->getPropertyValue( LABEL ) >>= Label; + return Label; +} + +void SAL_CALL +ScVbaToggleButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) +{ + m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); +} + +uno::Any SAL_CALL +ScVbaToggleButton::getValue() throw (uno::RuntimeException) +{ + sal_Int16 nState = 0; + m_xProps->getPropertyValue( STATE ) >>= nState; + 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; + OSL_TRACE( "nState - %d", nState ); + nState = ( nState == -1 ) ? 1 : 0; + OSL_TRACE( "nState - %d", nState ); + m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) ); +} + +rtl::OUString& +ScVbaToggleButton::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaToggleButton::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ToggleButton" ) ); + } + return aServiceNames; +} + diff --git a/vbahelper/source/msforms/vbatogglebutton.hxx b/vbahelper/source/msforms/vbatogglebutton.hxx new file mode 100644 index 000000000000..1932d514cce9 --- /dev/null +++ b/vbahelper/source/msforms/vbatogglebutton.hxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef SC_VBA_TOGGLEBUTTON_HXX +#define SC_VBA_TOGGLEBUTTON_HXX +#include <cppuhelper/implbase2.hxx> +#include <ooo/vba/msforms/XToggleButton.hpp> + +#include "vbacontrol.hxx" +#include <vbahelper/vbahelper.hxx> + +typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XToggleButton, css::script::XDefaultProperty > ToggleButtonImpl_BASE; + +class ScVbaToggleButton : public ToggleButtonImpl_BASE +{ + rtl::OUString msDftPropName; +public: + ScVbaToggleButton( 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 ); + ~ScVbaToggleButton(); + // Attributes + 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); + + virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); + virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) 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"); } +}; +#endif //SC_VBA_TOGGLEBUTTON_HXX diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx new file mode 100644 index 000000000000..2a1885c0b528 --- /dev/null +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -0,0 +1,227 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include <vbahelper/helperdecl.hxx> +#include "vbauserform.hxx" +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/beans/PropertyConcept.hpp> +#include <basic/sbx.hxx> +#include <basic/sbstar.hxx> +#include <basic/sbmeth.hxx> +#include "vbacontrols.hxx" + +using namespace ::ooo::vba; +using namespace ::com::sun::star; + +// some little notes +// XDialog implementation has the following interesting bits +// a Controls property ( which is an array of the container controls ) +// each item in the controls array is a XControl, where the model is +// basically a property bag +// additionally the XDialog instance has itself a model +// this model has a ControlModels ( array of models ) property +// the models in ControlModels can be accessed by name +// also the XDialog is a XControl ( to access the model above + +ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) throw ( lang::IllegalArgumentException ) : ScVbaUserForm_BASE( getXSomethingFromArgs< XHelperInterface >( aArgs, 0 ), xContext, getXSomethingFromArgs< uno::XInterface >( aArgs, 1 ), getXSomethingFromArgs< frame::XModel >( aArgs, 2 ), static_cast< ooo::vba::AbstractGeometryAttributes* >(0) ), mbDispose( true ) +{ + m_xDialog.set( m_xControl, uno::UNO_QUERY_THROW ); + 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 ) ); +} + +ScVbaUserForm::~ScVbaUserForm() +{ +} + +void SAL_CALL +ScVbaUserForm::Show( ) throw (uno::RuntimeException) +{ + OSL_TRACE("ScVbaUserForm::Show( )"); + short aRet = 0; + mbDispose = true; + if ( m_xDialog.is() ) + aRet = m_xDialog->execute(); + OSL_TRACE("ScVbaUserForm::Show() execute returned %d", aRet); + if ( mbDispose ) + { + try + { + uno::Reference< lang::XComponent > xComp( m_xDialog, uno::UNO_QUERY_THROW ); + m_xDialog = NULL; + xComp->dispose(); + mbDispose = false; + } + catch( uno::Exception& ) + { + } + } +} + +rtl::OUString SAL_CALL +ScVbaUserForm::getCaption() throw (::com::sun::star::uno::RuntimeException) +{ + rtl::OUString sCaption; + m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ) ) >>= sCaption; + return sCaption; +} +void +ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) +{ + m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) ); +} + +void SAL_CALL +ScVbaUserForm::Hide( ) throw (uno::RuntimeException) +{ + mbDispose = false; // hide not dispose + if ( m_xDialog.is() ) + m_xDialog->endExecute(); +} + +void SAL_CALL +ScVbaUserForm::RePaint( ) throw (uno::RuntimeException) +{ + // do nothing +} + +void SAL_CALL +ScVbaUserForm::UnloadObject( ) throw (uno::RuntimeException) +{ + mbDispose = true; + if ( m_xDialog.is() ) + m_xDialog->endExecute(); +} + +rtl::OUString& +ScVbaUserForm::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaUserForm") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaUserForm::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.UserForm" ) ); + } + return aServiceNames; +} + +uno::Reference< beans::XIntrospectionAccess > SAL_CALL +ScVbaUserForm::getIntrospection( ) throw (uno::RuntimeException) +{ + return uno::Reference< beans::XIntrospectionAccess >(); +} + +uno::Any SAL_CALL +ScVbaUserForm::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) +{ + throw uno::RuntimeException(); // unsupported operation +} + +void SAL_CALL +ScVbaUserForm::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException) +{ + uno::Any aObject = getValue( aPropertyName ); + // The Object *must* support XDefaultProperty here because getValue will + // only return properties that are Objects ( e.g. controls ) + // e.g. Userform1.aControl = something + // 'aControl' has to support XDefaultProperty to make sense here + uno::Reference< script::XDefaultProperty > xDfltProp( aObject, uno::UNO_QUERY_THROW ); + rtl::OUString aDfltPropName = xDfltProp->getDefaultPropertyName(); + uno::Reference< beans::XIntrospectionAccess > xUnoAccess( getIntrospectionAccess( aObject ) ); + uno::Reference< beans::XPropertySet > xPropSet( xUnoAccess->queryAdapter( ::getCppuType( (const uno::Reference< beans::XPropertySet > *)0 ) ), uno::UNO_QUERY_THROW ); + xPropSet->setPropertyValue( aDfltPropName, aValue ); +} + +uno::Any SAL_CALL +ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW ); + uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW ); + uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName ); + ScVbaControlFactory aFac( mxContext, xControl, m_xModel ); + uno::Reference< msforms::XControl > xVBAControl( aFac.createControl( xDialogControl->getModel() ) ); + ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() ); + pControl->setGeometryHelper( new UserFormGeometryHelper( mxContext, xControl ) ); + return uno::makeAny( xVBAControl ); +} + +::sal_Bool SAL_CALL +ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException) +{ + return sal_False; +} +uno::Any SAL_CALL +ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException) +{ + uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW ); + uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) ); + if ( index.hasValue() ) + return uno::makeAny( xControls->Item( index, uno::Any() ) ); + return uno::makeAny( xControls ); +} + +::sal_Bool SAL_CALL +ScVbaUserForm::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException) +{ + uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY ); + 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; + } + return sal_False; +} + +namespace userform +{ +namespace sdecl = comphelper::service_decl; +sdecl::vba_service_class_<ScVbaUserForm, sdecl::with_args<true> > serviceImpl; +extern sdecl::ServiceDecl const serviceDecl( + serviceImpl, + "ScVbaUserForm", + "ooo.vba.msforms.UserForm" ); +} + diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx new file mode 100644 index 000000000000..be93dc78eaa9 --- /dev/null +++ b/vbahelper/source/msforms/vbauserform.hxx @@ -0,0 +1,77 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * + * $Revision$ + * + * last change: $Author$ $Date$ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef SC_VBA_USERFORM_HXX +#define SC_VBA_USERFORM_HXX + +#include <cppuhelper/implbase1.hxx> +#include <ooo/vba/msforms/XUserForm.hpp> +#include <com/sun/star/awt/XDialog.hpp> +#include <com/sun/star/frame/XModel.hpp> + +#include <vbahelper/vbahelperinterface.hxx> +#include "vbacontrol.hxx" + +//typedef InheritedHelperInterfaceImpl1< ov::msforms::XUserForm > ScVbaUserForm_BASE; +typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XUserForm > ScVbaUserForm_BASE; + +class ScVbaUserForm : public ScVbaUserForm_BASE +{ +private: + css::uno::Reference< css::awt::XDialog > m_xDialog; + bool mbDispose; +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(); + // XUserForm + virtual void SAL_CALL RePaint( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL Show( ) throw (css::uno::RuntimeException); + // XIntrospection + virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException); + virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCaption() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL Hide( ) throw (css::uno::RuntimeException); + virtual void SAL_CALL UnloadObject( ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& index ) throw (css::uno::RuntimeException); + //XHelperInterface + virtual rtl::OUString& getServiceImplName(); + virtual css::uno::Sequence<rtl::OUString> getServiceNames(); +}; +#endif |