summaryrefslogtreecommitdiff
path: root/vbahelper/source/msforms
diff options
context:
space:
mode:
Diffstat (limited to 'vbahelper/source/msforms')
-rw-r--r--vbahelper/source/msforms/service.cxx70
-rw-r--r--vbahelper/source/msforms/vbabutton.cxx122
-rw-r--r--vbahelper/source/msforms/vbabutton.hxx59
-rw-r--r--vbahelper/source/msforms/vbacheckbox.cxx111
-rw-r--r--vbahelper/source/msforms/vbacheckbox.hxx54
-rw-r--r--vbahelper/source/msforms/vbacombobox.cxx260
-rw-r--r--vbahelper/source/msforms/vbacombobox.hxx91
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx550
-rw-r--r--vbahelper/source/msforms/vbacontrol.hxx126
-rw-r--r--vbahelper/source/msforms/vbacontrols.cxx500
-rw-r--r--vbahelper/source/msforms/vbacontrols.hxx71
-rw-r--r--vbahelper/source/msforms/vbaframe.cxx106
-rw-r--r--vbahelper/source/msforms/vbaframe.hxx65
-rw-r--r--vbahelper/source/msforms/vbaimage.cxx56
-rw-r--r--vbahelper/source/msforms/vbaimage.hxx45
-rw-r--r--vbahelper/source/msforms/vbalabel.cxx90
-rw-r--r--vbahelper/source/msforms/vbalabel.hxx54
-rw-r--r--vbahelper/source/msforms/vbalistbox.cxx292
-rw-r--r--vbahelper/source/msforms/vbalistbox.hxx88
-rw-r--r--vbahelper/source/msforms/vbalistcontrolhelper.cxx146
-rw-r--r--vbahelper/source/msforms/vbalistcontrolhelper.hxx20
-rw-r--r--vbahelper/source/msforms/vbamultipage.cxx131
-rw-r--r--vbahelper/source/msforms/vbamultipage.hxx64
-rwxr-xr-xvbahelper/source/msforms/vbanewfont.cxx160
-rwxr-xr-xvbahelper/source/msforms/vbanewfont.hxx73
-rw-r--r--vbahelper/source/msforms/vbapages.cxx72
-rw-r--r--vbahelper/source/msforms/vbapages.hxx56
-rw-r--r--vbahelper/source/msforms/vbaprogressbar.cxx70
-rw-r--r--vbahelper/source/msforms/vbaprogressbar.hxx51
-rw-r--r--vbahelper/source/msforms/vbaradiobutton.cxx110
-rw-r--r--vbahelper/source/msforms/vbaradiobutton.hxx53
-rw-r--r--vbahelper/source/msforms/vbascrollbar.cxx131
-rw-r--r--vbahelper/source/msforms/vbascrollbar.hxx58
-rw-r--r--vbahelper/source/msforms/vbaspinbutton.cxx101
-rw-r--r--vbahelper/source/msforms/vbaspinbutton.hxx53
-rwxr-xr-xvbahelper/source/msforms/vbasystemaxcontrol.cxx101
-rwxr-xr-xvbahelper/source/msforms/vbasystemaxcontrol.hxx58
-rw-r--r--vbahelper/source/msforms/vbatextbox.cxx163
-rw-r--r--vbahelper/source/msforms/vbatextbox.hxx62
-rw-r--r--vbahelper/source/msforms/vbatogglebutton.cxx151
-rw-r--r--vbahelper/source/msforms/vbatogglebutton.hxx65
-rw-r--r--vbahelper/source/msforms/vbauserform.cxx272
-rw-r--r--vbahelper/source/msforms/vbauserform.hxx73
43 files changed, 5104 insertions, 0 deletions
diff --git a/vbahelper/source/msforms/service.cxx b/vbahelper/source/msforms/service.cxx
new file mode 100644
index 000000000000..152517be3958
--- /dev/null
+++ b/vbahelper/source/msforms/service.cxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "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 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..775a05cbb5b5
--- /dev/null
+++ b/vbahelper/source/msforms/vbabutton.cxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbabutton.hxx"
+#include "vbanewfont.hxx"
+
+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 ) );
+}
+
+sal_Bool SAL_CALL ScVbaButton::getAutoSize() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaButton::getCancel() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaButton::getDefault() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaButton::getBackColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaButton::getForeColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+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..93a55e1bf73a
--- /dev/null
+++ b/vbahelper/source/msforms/vbabutton.hxx
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_BUTTON_HXX
+#define SC_VBA_BUTTON_HXX
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/msforms/XCommandButton.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XCommandButton > 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);
+ virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() 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..329586cf6b27
--- /dev/null
+++ b/vbahelper/source/msforms/vbacheckbox.cxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbacheckbox.hxx"
+#include "vbanewfont.hxx"
+#include <vbahelper/helperdecl.hxx>
+
+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 ) );
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+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..59e4d7e75e49
--- /dev/null
+++ b/vbahelper/source/msforms/vbacheckbox.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_CHECKBOX_HXX
+#define SC_VBA_CHECKBOX_HXX
+#include <cppuhelper/implbase2.hxx>
+#include <ooo/vba/msforms/XCheckBox.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper2< ScVbaControl, ov::msforms::XCheckBox, 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);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() 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..9a75fa5cbaa1
--- /dev/null
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -0,0 +1,260 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbacombobox.hxx"
+#include "vbanewfont.hxx"
+#include <ooo/vba/msforms/fmStyle.hpp>
+#include <ooo/vba/msforms/fmDropButtonStyle.hpp>
+#include <ooo/vba/msforms/fmDragBehavior.hpp>
+#include <ooo/vba/msforms/fmEnterFieldBehavior.hpp>
+#include <ooo/vba/msforms/fmListStyle.hpp>
+#include <ooo/vba/msforms/fmTextAlign.hpp>
+
+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 ) );
+ try
+ {
+ // grab the default value property name
+ m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ if( sSourceName.getLength() == 0 )
+ sSourceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) );
+}
+
+// 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)
+{
+ // booleans are converted to uppercase strings
+ m_xProps->setPropertyValue( sSourceName, uno::Any( extractStringFromAny( _value, ::rtl::OUString(), true ) ) );
+}
+
+// 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 );
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmStyle::fmStyleDropDownCombo;
+}
+
+void SAL_CALL ScVbaComboBox::setStyle( sal_Int32 /*nStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getDropButtonStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmDropButtonStyle::fmDropButtonStyleArrow;
+}
+
+void SAL_CALL ScVbaComboBox::setDropButtonStyle( sal_Int32 /*nDropButtonStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getDragBehavior() throw (uno::RuntimeException)
+{
+ return msforms::fmDragBehavior::fmDragBehaviorDisabled;
+}
+
+void SAL_CALL ScVbaComboBox::setDragBehavior( sal_Int32 /*nDragBehavior*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getEnterFieldBehavior() throw (uno::RuntimeException)
+{
+ return msforms::fmEnterFieldBehavior::fmEnterFieldBehaviorSelectAll;
+}
+
+void SAL_CALL ScVbaComboBox::setEnterFieldBehavior( sal_Int32 /*nEnterFieldBehavior*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getListStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmListStyle::fmListStylePlain;
+}
+
+void SAL_CALL ScVbaComboBox::setListStyle( sal_Int32 /*nListStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getTextAlign() throw (uno::RuntimeException)
+{
+ return msforms::fmTextAlign::fmTextAlignLeft;
+}
+
+void SAL_CALL ScVbaComboBox::setTextAlign( sal_Int32 /*nTextAlign*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getTextLength() throw (uno::RuntimeException)
+{
+ return getText().getLength();
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaComboBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+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..c73b617a743b
--- /dev/null
+++ b/vbahelper/source/msforms/vbacombobox.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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);
+ virtual sal_Int32 SAL_CALL getStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStyle( sal_Int32 nStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDropButtonStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDropButtonStyle( sal_Int32 nDropButtonStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDragBehavior() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDragBehavior( sal_Int32 nDragBehavior ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getEnterFieldBehavior() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setEnterFieldBehavior( sal_Int32 nEnterFieldBehavior ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getListStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setListStyle( sal_Int32 nListStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTextAlign() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTextAlign( sal_Int32 nTextAlign ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() 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..780191885049
--- /dev/null
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -0,0 +1,550 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <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 "vbasystemaxcontrol.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();
+}
+
+void SAL_CALL ScVbaControl::Move( double Left, double Top, const uno::Any& Width, const uno::Any& Height )
+ throw ( uno::RuntimeException )
+{
+ double nWidth = 0.0;
+ double nHeight = 0.0;
+
+ setLeft( Left );
+ setTop( Top );
+
+ if ( Width >>= nWidth )
+ setWidth( nWidth );
+
+ if ( Height >>= nHeight )
+ setHeight( nHeight );
+}
+
+rtl::OUString SAL_CALL
+ScVbaControl::getControlSource() throw (uno::RuntimeException)
+{
+// #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 ) );
+}
+
+::rtl::OUString SAL_CALL ScVbaControl::getTag()
+ throw (css::uno::RuntimeException)
+{
+ return m_aControlTag;
+}
+
+void SAL_CALL ScVbaControl::setTag( const ::rtl::OUString& aTag )
+ throw (css::uno::RuntimeException)
+{
+ m_aControlTag = aTag;
+}
+
+sal_Int32 SAL_CALL ScVbaControl::getTabIndex() throw (uno::RuntimeException)
+{
+ return 1;
+}
+
+void SAL_CALL ScVbaControl::setTabIndex( sal_Int32 /*nTabIndex*/ ) throw (uno::RuntimeException)
+{
+}
+
+//ScVbaControlFactory
+
+/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createShapeControl(
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< drawing::XControlShape >& xControlShape,
+ const uno::Reference< frame::XModel >& xModel ) 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
+ uno::Reference< drawing::XShape > xShape( xControlShape, uno::UNO_QUERY_THROW );
+ ::std::auto_ptr< ConcreteXShapeGeometryAttributes > xGeoHelper( new ConcreteXShapeGeometryAttributes( xContext, xShape ) );
+
+ switch( nClassId )
+ {
+ case form::FormComponentType::COMBOBOX:
+ return new ScVbaComboBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+ case form::FormComponentType::COMMANDBUTTON:
+ return new ScVbaButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+ case form::FormComponentType::FIXEDTEXT:
+ return new ScVbaLabel( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+ case form::FormComponentType::TEXTFIELD:
+ return new ScVbaTextBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+ case form::FormComponentType::RADIOBUTTON:
+ return new ScVbaRadioButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+ case form::FormComponentType::LISTBOX:
+ return new ScVbaListBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+ case form::FormComponentType::SPINBUTTON:
+ return new ScVbaSpinButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+ case form::FormComponentType::IMAGECONTROL:
+ return new ScVbaImage( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+ }
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() );
+}
+
+/*static*/ uno::Reference< msforms::XControl > ScVbaControlFactory::createUserformControl(
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< awt::XControl >& xControl,
+ const uno::Reference< awt::XControl >& xDialog,
+ const uno::Reference< frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( xControl->getModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< lang::XServiceInfo > xServiceInfo( xProps, uno::UNO_QUERY_THROW );
+ uno::Reference< msforms::XControl > xVBAControl;
+ uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess
+ ::std::auto_ptr< UserFormGeometryHelper > xGeoHelper( new UserFormGeometryHelper( xContext, xControl, fOffsetX, fOffsetY ) );
+
+ if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) )
+ xVBAControl.set( new ScVbaCheckbox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) )
+ xVBAControl.set( new ScVbaRadioButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) )
+ xVBAControl.set( new ScVbaTextBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), 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 )
+ xVBAControl.set( new ScVbaToggleButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else
+ xVBAControl.set( new ScVbaButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ }
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) )
+ xVBAControl.set( new ScVbaComboBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), true ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) )
+ xVBAControl.set( new ScVbaListBox( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) )
+ xVBAControl.set( new ScVbaLabel( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) )
+ xVBAControl.set( new ScVbaImage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) )
+ xVBAControl.set( new ScVbaProgressBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) )
+ xVBAControl.set( new ScVbaFrame( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) )
+ xVBAControl.set( new ScVbaScrollBar( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) )
+ xVBAControl.set( new ScVbaMultiPage( xVbaParent, xContext, xControl, xModel, xGeoHelper.release(), xDialog ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) )
+ xVBAControl.set( new ScVbaSpinButton( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) )
+ xVBAControl.set( new VbaSystemAXControl( xVbaParent, xContext, xControl, xModel, xGeoHelper.release() ) );
+
+ if( xVBAControl.is() )
+ return xVBAControl;
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control." ), uno::Reference< uno::XInterface >() );
+}
+
+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);
+};
+
+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() )
+ xControlToReturn = ScVbaControlFactory::createShapeControl( m_xCtx, xControlShape, xDocOwner );
+ 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..e421f919b6a4
--- /dev/null
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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;
+//template SAL_DLLPUBLIC_IMPORT InheritedHelperInterfaceImpl1< ov::msforms::XControl >;
+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:
+ // awt control has nothing similar to Tag property of Mso controls,
+ // whether it is necessary is another question
+ ::rtl::OUString m_aControlTag;
+
+ std::auto_ptr< ov::AbstractGeometryAttributes > mpGeometryHelper;
+ css::uno::Reference< css::beans::XPropertySet > m_xProps;
+ css::uno::Reference< css::uno::XInterface > m_xControl;
+ 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 void SAL_CALL Move( double Left, double Top, const ::com::sun::star::uno::Any& Width, const ::com::sun::star::uno::Any& Height ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException);
+ 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);
+ virtual ::rtl::OUString SAL_CALL getTag() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) 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:
+ static css::uno::Reference< ov::msforms::XControl > createShapeControl(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::drawing::XControlShape >& xControlShape,
+ const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+
+ static css::uno::Reference< ov::msforms::XControl > createUserformControl(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::awt::XControl >& xControl,
+ const css::uno::Reference< css::awt::XControl >& xDialog,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) throw (css::uno::RuntimeException);
+
+private:
+ ScVbaControlFactory();
+ ~ScVbaControlFactory();
+};
+
+#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..7411f7ad9463
--- /dev/null
+++ b/vbahelper/source/msforms/vbacontrols.cxx
@@ -0,0 +1,500 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+
+#include "vbacontrols.hxx"
+#include "vbacontrol.hxx"
+#include <cppuhelper/implbase2.hxx>
+#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;
+
+private:
+ void SetArrayElementTo( const uno::Reference< awt::XControl >& xCtrl, sal_Int32 nIndex = -1 )
+ {
+ // initialize the element with specified index to the control
+ if ( xCtrl.is() )
+ {
+ if ( nIndex == -1 )
+ nIndex = msNames.getLength();
+
+ if ( nIndex >= msNames.getLength() )
+ msNames.realloc( nIndex );
+
+ msNames[ nIndex ] = getControlName( xCtrl );
+ mControls.push_back( xCtrl );
+ mIndices[ msNames[ nIndex ] ] = nIndex;
+ }
+ }
+
+public:
+ ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog )
+ {
+ try
+ {
+ mxDialog.set( xDialog, uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls();
+
+ msNames.realloc( sXControls.getLength() );
+ for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i )
+ SetArrayElementTo( sXControls[ i ], i );
+ }
+ catch( uno::Exception& )
+ {
+ // accept the case when the dialog already does not exist
+ // in this case the wrapper should work in dummy mode
+ }
+ }
+
+ static rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl )
+ {
+ if ( !xCtrl.is() )
+ throw uno::RuntimeException();
+
+ uno::Reference< beans::XPropertySet > xProp( xCtrl->getModel(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName;
+ xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName;
+ return sName;
+ }
+
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
+ {
+ 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;
+ uno::Reference< frame::XModel > m_xModel;
+ double mfOffsetX;
+ double mfOffsetY;
+ 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,
+ const uno::Reference< frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) :
+ m_xParent( xParent ),
+ m_xContext( xContext),
+ m_xIndexAccess( xIndexAccess ),
+ m_xDlg( xDlg ),
+ m_xModel( xModel ),
+ mfOffsetX( fOffsetX ),
+ mfOffsetY( fOffsetY ),
+ 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< awt::XControl > xControl;
+ m_xIndexAccess->getByIndex( nIndex++ ) >>= xControl;
+
+ uno::Reference< msforms::XControl > xVBAControl;
+ if ( xControl.is() && m_xDlg.is() )
+ xVBAControl = ScVbaControlFactory::createUserformControl( m_xContext, xControl, m_xDlg, m_xModel, mfOffsetX, mfOffsetY );
+ 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,
+ const uno::Reference< frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY ) :
+ ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ),
+ mxDialog( xDialog ),
+ mxModel( xModel ),
+ mfOffsetX( fOffsetX ),
+ mfOffsetY( fOffsetY )
+{
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaControls::createEnumeration() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog, mxModel, mfOffsetX, mfOffsetY ) );
+ 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, uno::UNO_QUERY_THROW );
+ uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, mxDialog, mxModel, mfOffsetX, mfOffsetY );
+ return uno::Any( 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::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& StringKey, const uno::Any& /*Before*/, const uno::Any& /*After*/ )
+ throw (uno::RuntimeException)
+{
+ uno::Any aResult;
+ ::rtl::OUString aComServiceName;
+
+ try
+ {
+ if ( !mxDialog.is() )
+ throw uno::RuntimeException();
+
+ uno::Reference< awt::XControl > xNewControl;
+ uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW );
+
+ uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW );
+
+ Object >>= aComServiceName;
+
+ // TODO: Support Before and After?
+ ::rtl::OUString aNewName;
+ StringKey >>= aNewName;
+ if ( !aNewName.getLength() )
+ {
+ aNewName = aComServiceName;
+ if ( !aNewName.getLength() )
+ aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) );
+
+ sal_Int32 nInd = 0;
+ while( xDialogContainer->hasByName( aNewName ) && (nInd < SAL_MAX_INT32) )
+ {
+ aNewName = aComServiceName;
+ aNewName += ::rtl::OUString::valueOf( nInd++ );
+ }
+ }
+
+ double fDefWidth = 72.0, fDefHeight = 18.0;
+ if ( aComServiceName.getLength() )
+ {
+ // create a UNO control model based on the passed control type
+ uno::Reference< awt::XControlModel > xNewModel;
+ bool bFontSupport = false;
+ bool bNativeAX = false;
+ if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CommandButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 24.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Label.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Image.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 72.0;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CheckBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 108.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.OptionButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 108.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.TextBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ListBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ComboBox.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dropdown" ) ), uno::Any( true ) );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ToggleButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Toggle" ) ), uno::Any( true ) );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Frame.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 216.0; fDefHeight = 144.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.SpinButton.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlSpinButtonModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 12.75; fDefHeight = 25.5;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ScrollBar.1" ) ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 12.75; fDefHeight = 63.8;
+ }
+ else
+ {
+ xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bNativeAX = true;
+ }
+
+ // need to set a few font properties to get rid of the default DONT_KNOW values
+ if( bFontSupport )
+ {
+ uno::Reference< beans::XPropertySet > xModelProps( xNewModel, uno::UNO_QUERY_THROW );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ), uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Tahoma" ) ) ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ), uno::Any( float( 8.0 ) ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ), uno::Any( awt::FontWeight::NORMAL ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ), uno::Any( awt::FontSlant_NONE ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ), uno::Any( awt::FontUnderline::NONE ) );
+ xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ), uno::Any( awt::FontStrikeout::NONE ) );
+ }
+
+ xDialogContainer->insertByName( aNewName, uno::makeAny( xNewModel ) );
+ uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW );
+ xNewControl = xControlContainer->getControl( aNewName );
+
+ if( bNativeAX ) try
+ {
+ uno::Reference< script::XInvocation > xControlInvoke( xNewControl, uno::UNO_QUERY_THROW );
+
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[0] <<= aComServiceName;
+ uno::Sequence< sal_Int16 > aOutIDDummy;
+ uno::Sequence< uno::Any > aOutDummy;
+ xControlInvoke->invoke( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SOAddAXControl" ) ), aArgs, aOutIDDummy, aOutDummy );
+ }
+ catch( uno::Exception& )
+ {
+ xDialogContainer->removeByName( aNewName );
+ throw;
+ }
+ }
+
+ if ( xNewControl.is() )
+ {
+ UpdateCollectionIndex( lcl_controlsWrapper( mxDialog ) );
+ aResult <<= xNewControl;
+ aResult = createCollectionObject( aResult );
+ uno::Reference< msforms::XControl > xVBAControl( aResult, uno::UNO_QUERY_THROW );
+ if( fDefWidth > 0.0 )
+ xVBAControl->setWidth( fDefWidth );
+ if( fDefHeight > 0.0 )
+ xVBAControl->setHeight( fDefHeight );
+ }
+ else
+ throw uno::RuntimeException();
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& e )
+ {
+ throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ),
+ uno::Reference< uno::XInterface >(),
+ uno::makeAny( e ) );
+ }
+
+ return aResult;
+}
+
+void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex )
+ throw (uno::RuntimeException)
+{
+ ::rtl::OUString aControlName;
+ sal_Int32 nIndex = -1;
+
+ try
+ {
+ if ( !mxDialog.is() )
+ throw uno::RuntimeException();
+
+ uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW );
+
+ if ( !( ( StringKeyOrIndex >>= aControlName ) && aControlName.getLength() )
+ && !( ( StringKeyOrIndex >>= nIndex ) && nIndex >= 0 && nIndex < m_xIndexAccess->getCount() ) )
+ throw uno::RuntimeException();
+
+ uno::Reference< awt::XControl > xControl;
+ if ( aControlName.getLength() )
+ {
+ uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW );
+ xControl = xControlContainer->getControl( aControlName );
+ }
+ else
+ {
+ m_xIndexAccess->getByIndex( nIndex ) >>= xControl;
+ }
+
+ if ( !xControl.is() )
+ throw uno::RuntimeException();
+
+ if ( !aControlName.getLength() )
+ aControlName = ControlArrayWrapper::getControlName( xControl );
+
+ xDialogContainer->removeByName( aControlName );
+ xControl->dispose();
+ }
+ catch( uno::RuntimeException& )
+ {
+ // the exceptions are not rethrown, impossibility to find or remove the control is currently not reported
+ // since in most cases it means just that the controls is already not there, the VBA seems to do it in the same way
+
+ // throw;
+ }
+ catch( uno::Exception& e )
+ {
+ // throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ),
+ // uno::Reference< uno::XInterface >(),
+ // uno::makeAny( e ) );
+ }
+}
+
+
+uno::Type
+ScVbaControls::getElementType() throw (uno::RuntimeException)
+{
+ return ooo::vba::msforms::XControl::static_type(0);
+}
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaControls, "ooo.vba.msforms.Controls" )
diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx
new file mode 100644
index 000000000000..4b4838a45a8e
--- /dev/null
+++ b/vbahelper/source/msforms/vbacontrols.hxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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
+{
+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,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ double fOffsetX, double fOffsetY );
+ // XControls
+ virtual void SAL_CALL Move( double cx, double cy ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Object, const css::uno::Any& StringKey, const css::uno::Any& Before, const css::uno::Any& After ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Remove( const css::uno::Any& StringKeyOrIndex ) 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 );
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ css::uno::Reference< css::awt::XControl > mxDialog;
+ css::uno::Reference< css::frame::XModel > mxModel;
+ double mfOffsetX;
+ double mfOffsetY;
+};
+
+#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..4a1fe6a58b49
--- /dev/null
+++ b/vbahelper/source/msforms/vbaframe.cxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbaframe.hxx"
+#include "vbanewfont.hxx"
+#include "vbacontrols.hxx"
+#include <ooo/vba/msforms/fmBorderStyle.hpp>
+#include <ooo/vba/msforms/fmSpecialEffect.hpp>
+
+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,
+ const css::uno::Reference< css::awt::XControl >& xDialog ) :
+ FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ),
+ mxDialog( xDialog )
+{
+}
+
+// XFrame 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 ) );
+}
+
+sal_Int32 SAL_CALL ScVbaFrame::getSpecialEffect() throw (uno::RuntimeException)
+{
+ return msforms::fmSpecialEffect::fmSpecialEffectEtched;
+}
+
+void SAL_CALL ScVbaFrame::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaFrame::getBorderStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmBorderStyle::fmBorderStyleNone;
+}
+
+void SAL_CALL ScVbaFrame::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaFrame::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+// XFrame methods
+
+uno::Any SAL_CALL ScVbaFrame::Controls( const uno::Any& rIndex ) throw (uno::RuntimeException)
+{
+ // horizontal anchor of frame children is inside border line (add one unit to compensate border line width)
+ double fOffsetX = mpGeometryHelper->getOffsetX() + getLeft() + 1.0;
+ // vertical anchor of frame children is inside border line (add half of text height and one unit to compensate border line width)
+ double fOffsetY = mpGeometryHelper->getOffsetY() + getTop() + (getFont()->getSize() / 2.0) + 1.0;
+
+ uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, mxDialog, m_xModel, fOffsetX, fOffsetY ) );
+ if( rIndex.hasValue() )
+ return uno::Any( xControls->Item( rIndex, uno::Any() ) );
+ return uno::Any( xControls );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaFrame, "ooo.vba.msforms.Frame" )
diff --git a/vbahelper/source/msforms/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx
new file mode 100644
index 000000000000..d76f31230bba
--- /dev/null
+++ b/vbahelper/source/msforms/vbaframe.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_FRAME_HXX
+#define SC_VBA_FRAME_HXX
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/msforms/XFrame.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper1< ScVbaControl, ov::msforms::XFrame > 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,
+ const css::uno::Reference< css::awt::XControl >& xDialog );
+
+ // XFrame 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 sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+ // XFrame methods
+ css::uno::Any SAL_CALL Controls( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+ //XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+private:
+ css::uno::Reference< css::awt::XControl > mxDialog;
+};
+#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..508f97824f51
--- /dev/null
+++ b/vbahelper/source/msforms/vbaimage.cxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "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..52012fc1fee3
--- /dev/null
+++ b/vbahelper/source/msforms/vbaimage.hxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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..d5aa1176e3d3
--- /dev/null
+++ b/vbahelper/source/msforms/vbalabel.cxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbalabel.hxx"
+#include "vbanewfont.hxx"
+
+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 );
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaLabel::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+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..2dcee186d58b
--- /dev/null
+++ b/vbahelper/source/msforms/vbalabel.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() 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..8829c8ae7256
--- /dev/null
+++ b/vbahelper/source/msforms/vbalistbox.cxx
@@ -0,0 +1,292 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbalistbox.hxx"
+#include "vbanewfont.hxx"
+#include <comphelper/anytostring.hxx>
+#include <com/sun/star/script/ArrayWrapper.hpp>
+#include <com/sun/star/form/validation/XValidatableFormComponent.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 );
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaListBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+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..7dbda1837cb0
--- /dev/null
+++ b/vbahelper/source/msforms/vbalistbox.hxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException);
+ 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..78590f0fd85b
--- /dev/null
+++ b/vbahelper/source/msforms/vbamultipage.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "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,
+ const uno::Reference< frame::XModel >& xModel,
+ AbstractGeometryAttributes* pGeomHelper,
+ const uno::Reference< awt::XControl >& xDialog ) :
+ MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+{
+ mxDialogProps.set( xDialog->getModel(), 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..328a71b61592
--- /dev/null
+++ b/vbahelper/source/msforms/vbamultipage.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ ov::AbstractGeometryAttributes* pGeomHelper,
+ const css::uno::Reference< css::awt::XControl >& 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/vbanewfont.cxx b/vbahelper/source/msforms/vbanewfont.cxx
new file mode 100755
index 000000000000..f487b4e6919c
--- /dev/null
+++ b/vbahelper/source/msforms/vbanewfont.cxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <vbanewfont.hxx>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+// ============================================================================
+
+VbaNewFont::VbaNewFont(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< beans::XPropertySet >& rxModelProps ) throw (uno::RuntimeException) :
+ VbaNewFont_BASE( rxParent, rxContext ),
+ mxProps( rxModelProps, uno::UNO_SET_THROW )
+{
+}
+
+// XNewFont attributes
+
+::rtl::OUString SAL_CALL VbaNewFont::getName() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ) );
+ return aAny.get< ::rtl::OUString >();
+}
+
+void SAL_CALL VbaNewFont::setName( const ::rtl::OUString& rName ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ),
+ uno::Any( rName ) );
+}
+
+double SAL_CALL VbaNewFont::getSize() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ) );
+ return aAny.get< float >();
+}
+
+void SAL_CALL VbaNewFont::setSize( double fSize ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ),
+ uno::Any( static_cast< float >( fSize ) ) );
+}
+
+sal_Int16 SAL_CALL VbaNewFont::getCharset() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ) );
+ return rtl_getBestWindowsCharsetFromTextEncoding( static_cast< rtl_TextEncoding >( aAny.get< sal_Int16 >() ) );
+}
+
+void SAL_CALL VbaNewFont::setCharset( sal_Int16 nCharset ) throw (uno::RuntimeException)
+{
+ rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
+ if( (0 <= nCharset) && (nCharset <= SAL_MAX_UINT8) )
+ eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( nCharset ) );
+ if( eFontEnc == RTL_TEXTENCODING_DONTKNOW )
+ throw uno::RuntimeException();
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontCharset" ) ),
+ uno::Any( static_cast< sal_Int16 >( eFontEnc ) ) );
+}
+
+sal_Int16 SAL_CALL VbaNewFont::getWeight() throw (uno::RuntimeException)
+{
+ return getBold() ? 700 : 400;
+}
+
+void SAL_CALL VbaNewFont::setWeight( sal_Int16 nWeight ) throw (uno::RuntimeException)
+{
+ setBold( nWeight >= 700 );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getBold() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ) );
+ return aAny.get< float >() > awt::FontWeight::NORMAL;
+}
+
+void SAL_CALL VbaNewFont::setBold( sal_Bool bBold ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ),
+ uno::Any( bBold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getItalic() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ) );
+ return aAny.get< awt::FontSlant >() != awt::FontSlant_NONE;
+}
+
+void SAL_CALL VbaNewFont::setItalic( sal_Bool bItalic ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ),
+ uno::Any( bItalic ? awt::FontSlant_ITALIC : awt::FontSlant_NONE ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getUnderline() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ) );
+ return aAny.get< sal_Int16 >() != awt::FontUnderline::NONE;
+}
+
+void SAL_CALL VbaNewFont::setUnderline( sal_Bool bUnderline ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ),
+ uno::Any( bUnderline ? awt::FontUnderline::SINGLE : awt::FontUnderline::NONE ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getStrikethrough() throw (uno::RuntimeException)
+{
+ uno::Any aAny = mxProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ) );
+ return aAny.get< sal_Int16 >() != awt::FontStrikeout::NONE;
+}
+
+void SAL_CALL VbaNewFont::setStrikethrough( sal_Bool bStrikethrough ) throw (uno::RuntimeException)
+{
+ mxProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ),
+ uno::Any( bStrikethrough ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( VbaNewFont, "ooo.vba.msforms.NewFont" )
+
+// ============================================================================
diff --git a/vbahelper/source/msforms/vbanewfont.hxx b/vbahelper/source/msforms/vbanewfont.hxx
new file mode 100755
index 000000000000..d59d5caa139c
--- /dev/null
+++ b/vbahelper/source/msforms/vbanewfont.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef VBAHELPER_MSFORMS_VBANEWFONT_HXX
+#define VBAHELPER_MSFORMS_VBANEWFONT_HXX
+
+#include <ooo/vba/msforms/XNewFont.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+// ============================================================================
+
+typedef InheritedHelperInterfaceImpl1< ov::msforms::XNewFont > VbaNewFont_BASE;
+
+class VbaNewFont : public VbaNewFont_BASE
+{
+public:
+ VbaNewFont(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::beans::XPropertySet >& rxModelProps ) throw (css::uno::RuntimeException);
+
+ // XNewFont attributes
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSize( double fSize ) throw (css::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getCharset() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCharset( sal_Int16 nCharset ) throw (css::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getWeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWeight( sal_Int16 nWeight ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBold() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBold( sal_Bool bBold ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getItalic() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setItalic( sal_Bool bItalic ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getUnderline() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setUnderline( sal_Bool bUnderline ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getStrikethrough() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStrikethrough( sal_Bool bStrikethrough ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ css::uno::Reference< css::beans::XPropertySet > mxProps;
+};
+
+// ============================================================================
+
+#endif
diff --git a/vbahelper/source/msforms/vbapages.cxx b/vbahelper/source/msforms/vbapages.cxx
new file mode 100644
index 000000000000..dd52a66a65cf
--- /dev/null
+++ b/vbahelper/source/msforms/vbapages.cxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "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..4bc743b1ee96
--- /dev/null
+++ b/vbahelper/source/msforms/vbapages.hxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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..716cdcc61583
--- /dev/null
+++ b/vbahelper/source/msforms/vbaprogressbar.cxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "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..13980f522ef4
--- /dev/null
+++ b/vbahelper/source/msforms/vbaprogressbar.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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..12ee1ad8ae41
--- /dev/null
+++ b/vbahelper/source/msforms/vbaradiobutton.cxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbaradiobutton.hxx"
+#include "vbanewfont.hxx"
+
+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 ) );
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaRadioButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+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..3da00eb0765e
--- /dev/null
+++ b/vbahelper/source/msforms/vbaradiobutton.hxx
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() 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..f208f5acdcf9
--- /dev/null
+++ b/vbahelper/source/msforms/vbascrollbar.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "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..8b4e122c0422
--- /dev/null
+++ b/vbahelper/source/msforms/vbascrollbar.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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..d536e0c41340
--- /dev/null
+++ b/vbahelper/source/msforms/vbaspinbutton.cxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "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..1c600a0aa156
--- /dev/null
+++ b/vbahelper/source/msforms/vbaspinbutton.hxx
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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/vbasystemaxcontrol.cxx b/vbahelper/source/msforms/vbasystemaxcontrol.cxx
new file mode 100755
index 000000000000..ed2fc70164ac
--- /dev/null
+++ b/vbahelper/source/msforms/vbasystemaxcontrol.cxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * ( a copy is included in the LICENSE file that accompanied this code ).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbasystemaxcontrol.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+//----------------------------------------------------------
+VbaSystemAXControl::VbaSystemAXControl( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper )
+: SystemAXControlImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+, m_xControlInvocation( xControl, uno::UNO_QUERY_THROW )
+{
+}
+
+//----------------------------------------------------------
+uno::Reference< beans::XIntrospectionAccess > SAL_CALL VbaSystemAXControl::getIntrospection()
+ throw ( uno::RuntimeException )
+{
+ return m_xControlInvocation->getIntrospection();
+}
+
+//----------------------------------------------------------
+uno::Any SAL_CALL VbaSystemAXControl::invoke( const ::rtl::OUString& aFunctionName, const uno::Sequence< uno::Any >& aParams, uno::Sequence< ::sal_Int16 >& aOutParamIndex, uno::Sequence< uno::Any >& aOutParam )
+ throw ( lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException )
+{
+ return m_xControlInvocation->invoke( aFunctionName, aParams, aOutParamIndex, aOutParam );
+}
+
+//----------------------------------------------------------
+void SAL_CALL VbaSystemAXControl::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw ( beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException )
+{
+ m_xControlInvocation->setValue( aPropertyName, aValue );
+}
+
+//----------------------------------------------------------
+uno::Any SAL_CALL VbaSystemAXControl::getValue( const ::rtl::OUString& aPropertyName )
+ throw ( beans::UnknownPropertyException, uno::RuntimeException )
+{
+ return m_xControlInvocation->getValue( aPropertyName );
+}
+
+//----------------------------------------------------------
+::sal_Bool SAL_CALL VbaSystemAXControl::hasMethod( const ::rtl::OUString& aName )
+ throw ( uno::RuntimeException )
+{
+ return m_xControlInvocation->hasMethod( aName );
+}
+
+//----------------------------------------------------------
+::sal_Bool SAL_CALL VbaSystemAXControl::hasProperty( const ::rtl::OUString& aName )
+ throw ( uno::RuntimeException )
+{
+ return m_xControlInvocation->hasProperty( aName );
+}
+
+//----------------------------------------------------------
+rtl::OUString&
+VbaSystemAXControl::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM( "VbaSystemAXControl" ) );
+ return sImplName;
+}
+
+//----------------------------------------------------------
+uno::Sequence< rtl::OUString >
+VbaSystemAXControl::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.msforms.Frame" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/vbahelper/source/msforms/vbasystemaxcontrol.hxx b/vbahelper/source/msforms/vbasystemaxcontrol.hxx
new file mode 100755
index 000000000000..bffe5b99c4f1
--- /dev/null
+++ b/vbahelper/source/msforms/vbasystemaxcontrol.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * ( a copy is included in the LICENSE file that accompanied this code ).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef VBA_SYSTEMAXCONTROL_HXX
+#define VBA_SYSTEMAXCONTROL_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/script/XInvocation.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper1< ScVbaControl, css::script::XInvocation > SystemAXControlImpl_BASE;
+
+class VbaSystemAXControl : public SystemAXControlImpl_BASE
+{
+ css::uno::Reference< css::script::XInvocation > m_xControlInvocation;
+
+public:
+ VbaSystemAXControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper );
+
+ // XInvocation
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw ( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< ::sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException );
+ virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw ( ::com::sun::star::uno::RuntimeException );
+ virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw ( ::com::sun::star::uno::RuntimeException );
+
+ //XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif
diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx
new file mode 100644
index 000000000000..b6aedcdceaf6
--- /dev/null
+++ b/vbahelper/source/msforms/vbatextbox.cxx
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbatextbox.hxx"
+#include "vbanewfont.hxx"
+#include <com/sun/star/text/XTextRange.hpp>
+#include <ooo/vba/msforms/fmBorderStyle.hpp>
+#include <ooo/vba/msforms/fmSpecialEffect.hpp>
+
+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)
+{
+ // booleans are converted to uppercase strings
+ rtl::OUString sVal = extractStringFromAny( _value, true );
+ 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);
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect() throw (uno::RuntimeException)
+{
+ return msforms::fmSpecialEffect::fmSpecialEffectSunken;
+}
+
+void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle() throw (uno::RuntimeException)
+{
+ return msforms::fmBorderStyle::fmBorderStyleNone;
+}
+
+void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getTextLength() throw (uno::RuntimeException)
+{
+ return getText().getLength();
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+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..586bceb607a0
--- /dev/null
+++ b/vbahelper/source/msforms/vbatextbox.hxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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);
+ virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() 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..d1a3b40d6eb7
--- /dev/null
+++ b/vbahelper/source/msforms/vbatogglebutton.cxx
@@ -0,0 +1,151 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbatogglebutton.hxx"
+#include "vbanewfont.hxx"
+
+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 ) );
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException)
+{
+ return new VbaNewFont( this, mxContext, m_xProps );
+}
+
+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..d2bf4c6b7f17
--- /dev/null
+++ b/vbahelper/source/msforms/vbatogglebutton.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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);
+ virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getCancel() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCancel( sal_Bool bCancel ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getDefault() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDefault( sal_Bool bDefault ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() 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..3eb799205389
--- /dev/null
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -0,0 +1,272 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <vbahelper/helperdecl.hxx>
+#include "vbauserform.hxx"
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/beans/PropertyConcept.hpp>
+#include <com/sun/star/util/MeasureUnit.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, 0.0, 0.0 ) );
+}
+
+ScVbaUserForm::~ScVbaUserForm()
+{
+}
+
+void SAL_CALL
+ScVbaUserForm::Show( ) throw (uno::RuntimeException)
+{
+ OSL_TRACE("ScVbaUserForm::Show( )");
+ short aRet = 0;
+ mbDispose = true;
+
+ if ( m_xDialog.is() )
+ {
+ // try to center dialog on model window
+ if( m_xModel.is() ) try
+ {
+ uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_SET_THROW );
+ uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
+ uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
+ awt::Rectangle aPosSize = xWindow->getPosSize(); // already in pixel
+
+ uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
+ uno::Reference< awt::XWindow > xControlWindow( xControl->getPeer(), uno::UNO_QUERY_THROW );
+ xControlWindow->setPosSize( (aPosSize.Width - getWidth()) / 2.0, (aPosSize.Height - getHeight()) / 2.0, 0, 0, awt::PosSize::POS );
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ 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 (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 (uno::RuntimeException)
+{
+ m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) );
+}
+
+double SAL_CALL ScVbaUserForm::getInnerWidth() throw (uno::RuntimeException)
+{
+ return mpGeometryHelper->getInnerWidth();
+}
+
+void SAL_CALL ScVbaUserForm::setInnerWidth( double fInnerWidth ) throw (uno::RuntimeException)
+{
+ mpGeometryHelper->setInnerWidth( fInnerWidth );
+}
+
+double SAL_CALL ScVbaUserForm::getInnerHeight() throw (uno::RuntimeException)
+{
+ return mpGeometryHelper->getInnerHeight();
+}
+
+void SAL_CALL ScVbaUserForm::setInnerHeight( double fInnerHeight ) throw (uno::RuntimeException)
+{
+ mpGeometryHelper->setInnerHeight( fInnerHeight );
+}
+
+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 );
+
+ // in case the dialog is already closed the VBA implementation should not throw exceptions
+ if ( aObject.hasValue() )
+ {
+ // 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::Any aResult;
+
+ // in case the dialog is already closed the VBA implementation should not throw exceptions
+ if ( m_xDialog.is() )
+ {
+ 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 );
+ if ( xControl.is() )
+ aResult <<= ScVbaControlFactory::createUserformControl( mxContext, xControl, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() );
+ }
+
+ return aResult;
+}
+
+::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)
+{
+ // if the dialog already closed we should do nothing, but the VBA will call methods of the Controls objects
+ // thus we have to provide a dummy object in this case
+ uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY );
+ uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() ) );
+ 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..1777a979b9f2
--- /dev/null
+++ b/vbahelper/source/msforms/vbauserform.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef 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);
+ 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 ::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 double SAL_CALL getInnerWidth() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInnerWidth( double fInnerWidth ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getInnerHeight() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInnerHeight( double fInnerHeight ) 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);
+ // 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 ::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);
+ //XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif