summaryrefslogtreecommitdiffstats
path: root/vbahelper/source/msforms
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vbahelper/source/msforms/vbabutton.cxx128
-rw-r--r--vbahelper/source/msforms/vbabutton.hxx55
-rw-r--r--vbahelper/source/msforms/vbacheckbox.cxx130
-rw-r--r--vbahelper/source/msforms/vbacheckbox.hxx55
-rw-r--r--vbahelper/source/msforms/vbacombobox.cxx306
-rw-r--r--vbahelper/source/msforms/vbacombobox.hxx90
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx800
-rw-r--r--vbahelper/source/msforms/vbacontrol.hxx142
-rw-r--r--vbahelper/source/msforms/vbacontrols.cxx493
-rw-r--r--vbahelper/source/msforms/vbacontrols.hxx63
-rw-r--r--vbahelper/source/msforms/vbaframe.cxx99
-rw-r--r--vbahelper/source/msforms/vbaframe.hxx63
-rw-r--r--vbahelper/source/msforms/vbaimage.cxx56
-rw-r--r--vbahelper/source/msforms/vbaimage.hxx41
-rw-r--r--vbahelper/source/msforms/vbalabel.cxx112
-rw-r--r--vbahelper/source/msforms/vbalabel.hxx54
-rw-r--r--vbahelper/source/msforms/vbalistbox.cxx275
-rw-r--r--vbahelper/source/msforms/vbalistbox.hxx81
-rw-r--r--vbahelper/source/msforms/vbalistcontrolhelper.cxx190
-rw-r--r--vbahelper/source/msforms/vbalistcontrolhelper.hxx47
-rw-r--r--vbahelper/source/msforms/vbamultipage.cxx117
-rw-r--r--vbahelper/source/msforms/vbamultipage.hxx54
-rw-r--r--vbahelper/source/msforms/vbanewfont.cxx132
-rw-r--r--vbahelper/source/msforms/vbanewfont.hxx57
-rw-r--r--vbahelper/source/msforms/vbapages.cxx64
-rw-r--r--vbahelper/source/msforms/vbapages.hxx45
-rw-r--r--vbahelper/source/msforms/vbaprogressbar.cxx61
-rw-r--r--vbahelper/source/msforms/vbaprogressbar.hxx48
-rw-r--r--vbahelper/source/msforms/vbaradiobutton.cxx110
-rw-r--r--vbahelper/source/msforms/vbaradiobutton.hxx48
-rw-r--r--vbahelper/source/msforms/vbascrollbar.cxx115
-rw-r--r--vbahelper/source/msforms/vbascrollbar.hxx55
-rw-r--r--vbahelper/source/msforms/vbaspinbutton.cxx87
-rw-r--r--vbahelper/source/msforms/vbaspinbutton.hxx47
-rw-r--r--vbahelper/source/msforms/vbasystemaxcontrol.cxx85
-rw-r--r--vbahelper/source/msforms/vbasystemaxcontrol.hxx52
-rw-r--r--vbahelper/source/msforms/vbatextbox.cxx183
-rw-r--r--vbahelper/source/msforms/vbatextbox.hxx67
-rw-r--r--vbahelper/source/msforms/vbatogglebutton.cxx164
-rw-r--r--vbahelper/source/msforms/vbatogglebutton.hxx61
-rw-r--r--vbahelper/source/msforms/vbauserform.cxx311
-rw-r--r--vbahelper/source/msforms/vbauserform.hxx72
42 files changed, 5315 insertions, 0 deletions
diff --git a/vbahelper/source/msforms/vbabutton.cxx b/vbahelper/source/msforms/vbabutton.cxx
new file mode 100644
index 000000000..38d5c9402
--- /dev/null
+++ b/vbahelper/source/msforms/vbabutton.cxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbabutton.hxx"
+#include "vbanewfont.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+VbaButton::VbaButton( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, std::unique_ptr<AbstractGeometryAttributes> pGeomHelper )
+ : ButtonImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+}
+
+// Attributes
+OUString SAL_CALL
+VbaButton::getCaption()
+{
+ OUString Label;
+ m_xProps->getPropertyValue( "Label" ) >>= Label;
+ return Label;
+}
+
+void SAL_CALL
+VbaButton::setCaption( const OUString& _caption )
+{
+ m_xProps->setPropertyValue( "Label", uno::Any( _caption ) );
+}
+
+sal_Bool SAL_CALL VbaButton::getAutoSize()
+{
+ return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL VbaButton::setAutoSize( sal_Bool bAutoSize )
+{
+ ScVbaControl::setAutoSize( bAutoSize );
+}
+
+sal_Bool SAL_CALL VbaButton::getLocked()
+{
+ return ScVbaControl::getLocked();
+}
+
+void SAL_CALL VbaButton::setLocked( sal_Bool bLocked )
+{
+ ScVbaControl::setLocked( bLocked );
+}
+
+sal_Bool SAL_CALL VbaButton::getCancel()
+{
+ return false;
+}
+
+void SAL_CALL VbaButton::setCancel( sal_Bool /*bCancel*/ )
+{
+ // #STUB
+}
+
+sal_Bool SAL_CALL VbaButton::getDefault()
+{
+ // #STUB
+ return false;
+}
+
+void SAL_CALL VbaButton::setDefault( sal_Bool /*bDefault*/ )
+{
+ // #STUB
+}
+
+sal_Int32 SAL_CALL VbaButton::getBackColor()
+{
+ return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL VbaButton::setBackColor( sal_Int32 nBackColor )
+{
+ ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Int32 SAL_CALL VbaButton::getForeColor()
+{
+ return ScVbaControl::getForeColor();
+}
+
+void SAL_CALL VbaButton::setForeColor( sal_Int32 /*nForeColor*/ )
+{
+ // #STUB
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL VbaButton::getFont()
+{
+ return new VbaNewFont( m_xProps );
+}
+
+OUString
+VbaButton::getServiceImplName()
+{
+ return "VbaButton";
+}
+
+uno::Sequence< OUString >
+VbaButton::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.Button"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbabutton.hxx b/vbahelper/source/msforms/vbabutton.hxx
new file mode 100644
index 000000000..ad2aed40d
--- /dev/null
+++ b/vbahelper/source/msforms/vbabutton.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBABUTTON_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBABUTTON_HXX
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XCommandButton.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< ScVbaControl, ov::msforms::XCommandButton > ButtonImpl_BASE;
+
+class VbaButton : public ButtonImpl_BASE
+{
+public:
+ VbaButton( 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+ // Attributes
+ virtual OUString SAL_CALL getCaption() override;
+ virtual void SAL_CALL setCaption( const OUString& _caption ) override;
+ virtual sal_Bool SAL_CALL getAutoSize() override;
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) override;
+ virtual sal_Bool SAL_CALL getCancel() override;
+ virtual void SAL_CALL setCancel( sal_Bool bCancel ) override;
+ virtual sal_Bool SAL_CALL getDefault() override;
+ virtual void SAL_CALL setDefault( sal_Bool bDefault ) override;
+ virtual sal_Int32 SAL_CALL getBackColor() override;
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) override;
+ virtual sal_Int32 SAL_CALL getForeColor() override;
+ virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) override;
+ virtual sal_Bool SAL_CALL getLocked() override;
+ virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) override;
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override;
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBABUTTON_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacheckbox.cxx b/vbahelper/source/msforms/vbacheckbox.cxx
new file mode 100644
index 000000000..13922a6de
--- /dev/null
+++ b/vbahelper/source/msforms/vbacheckbox.cxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbacheckbox.hxx"
+#include "vbanewfont.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
+ : CheckBoxImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+}
+
+// Attributes
+OUString SAL_CALL
+ScVbaCheckbox::getCaption()
+{
+ OUString Label;
+ m_xProps->getPropertyValue( "Label" ) >>= Label;
+ return Label;
+}
+
+void SAL_CALL
+ScVbaCheckbox::setCaption( const OUString& _caption )
+{
+ m_xProps->setPropertyValue( "Label", uno::Any( _caption ) );
+}
+
+uno::Any SAL_CALL
+ScVbaCheckbox::getValue()
+{
+ 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::Any( nValue == -1 );
+}
+
+void SAL_CALL
+ScVbaCheckbox::setValue( const uno::Any& _value )
+{
+ sal_Int16 nValue = 0;
+ sal_Int16 nOldValue = 0;
+ m_xProps->getPropertyValue( "State" ) >>= nOldValue;
+ if( !( _value >>= nValue ) )
+ {
+ bool bValue = false;
+ _value >>= bValue;
+ if ( bValue )
+ nValue = -1;
+ }
+
+ if( nValue == -1)
+ nValue = 1;
+ m_xProps->setPropertyValue( "State", uno::Any( nValue ) );
+ if ( nValue != nOldValue )
+ fireClickEvent();
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont()
+{
+ return new VbaNewFont( m_xProps );
+}
+
+OUString
+ScVbaCheckbox::getServiceImplName()
+{
+ return "ScVbaCheckbox";
+}
+
+uno::Sequence< OUString >
+ScVbaCheckbox::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.CheckBox"
+ };
+ return aServiceNames;
+}
+
+sal_Int32 SAL_CALL ScVbaCheckbox::getBackColor()
+{
+ return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaCheckbox::setBackColor( sal_Int32 nBackColor )
+{
+ ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Bool SAL_CALL ScVbaCheckbox::getAutoSize()
+{
+ return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaCheckbox::setAutoSize( sal_Bool bAutoSize )
+{
+ ScVbaControl::setAutoSize( bAutoSize );
+}
+
+sal_Bool SAL_CALL ScVbaCheckbox::getLocked()
+{
+ return ScVbaControl::getLocked();
+}
+
+void SAL_CALL ScVbaCheckbox::setLocked( sal_Bool bLocked )
+{
+ ScVbaControl::setLocked( bLocked );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacheckbox.hxx b/vbahelper/source/msforms/vbacheckbox.hxx
new file mode 100644
index 000000000..91de78eb5
--- /dev/null
+++ b/vbahelper/source/msforms/vbacheckbox.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACHECKBOX_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACHECKBOX_HXX
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XCheckBox.hpp>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+ // Attributes
+ virtual OUString SAL_CALL getCaption() override;
+ virtual void SAL_CALL setCaption( const OUString& _caption ) override;
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override;
+ virtual sal_Int32 SAL_CALL getBackColor() override;
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) override;
+ virtual sal_Bool SAL_CALL getAutoSize() override;
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) override;
+ virtual sal_Bool SAL_CALL getLocked() override;
+ virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) override;
+ // XDefaultProperty
+ OUString SAL_CALL getDefaultPropertyName( ) override { return "Value"; }
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACHECKBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx
new file mode 100644
index 000000000..16abb6d98
--- /dev/null
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -0,0 +1,306 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbacombobox.hxx"
+#include <comphelper/sequence.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>
+#include <sal/log.hxx>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+//SelectedItems list of integer indexes
+//StringItemList list of items
+
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
+ : ComboBoxImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+ mpListHelper.reset( new ListControlHelper( m_xProps ) );
+ try
+ {
+ // grab the default value property name
+ m_xProps->getPropertyValue( "DataFieldProperty" ) >>= sSourceName;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ if( sSourceName.isEmpty() )
+ sSourceName = "Text";
+}
+
+// Attributes
+
+
+// Value, [read] e.g. getValue returns the value of ooo Text property e.g. the value in
+// the drop down
+uno::Any SAL_CALL
+ScVbaComboBox::getValue()
+{
+ return m_xProps->getPropertyValue( sSourceName );
+}
+
+void SAL_CALL
+ScVbaComboBox::setListIndex( const uno::Any& _value )
+{
+ sal_Int16 nIndex = 0;
+ if( !(_value >>= nIndex) )
+ return;
+
+ sal_Int32 nOldIndex = -1;
+ getListIndex() >>= nOldIndex;
+ uno::Sequence< OUString > sItems;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sItems;
+ if( ( nIndex >= 0 ) && ( sItems.getLength() > nIndex ) )
+ {
+ OUString sText = sItems[ nIndex ];
+ m_xProps->setPropertyValue( "Text", uno::Any( sText ) );
+
+ // fire the _Change event
+ if( nOldIndex != nIndex )
+ fireClickEvent();
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaComboBox::getListIndex()
+{
+ uno::Sequence< OUString > sItems;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sItems;
+ // should really return the item that has focus regardless of
+ // it been selected
+ if ( sItems.hasElements() )
+ {
+ OUString sText = getText();
+ if (!sText.isEmpty())
+ {
+ sal_Int32 index = comphelper::findValue(sItems, sText);
+ if (index != -1)
+ {
+ SAL_INFO("vbahelper", "getListIndex returning " << index );
+ return uno::Any( index );
+ }
+ }
+ }
+ SAL_INFO("vbahelper", "getListIndex returning -1" );
+ return uno::Any( 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 )
+{
+ // booleans are converted to uppercase strings
+ OUString oldValue = extractStringFromAny( getValue(), OUString(), true );
+ m_xProps->setPropertyValue( sSourceName, uno::Any( extractStringFromAny( _value, OUString(), true ) ) );
+ OUString newValue = extractStringFromAny( getValue(), OUString(), true );
+ if ( oldValue != newValue )
+ {
+ sal_Int32 index = 0;
+ uno::Any aIndex = getListIndex();
+ aIndex >>= index;
+ if ( index < 0 )
+ fireChangeEvent();
+ else
+ fireClickEvent();
+ }
+}
+
+// see Value
+
+OUString SAL_CALL
+ScVbaComboBox::getText()
+{
+ OUString result;
+ getValue() >>= result;
+ return result;
+}
+
+void SAL_CALL
+ScVbaComboBox::setText( const OUString& _text )
+{
+ setValue( uno::Any( _text ) ); // seems the same
+}
+
+// Methods
+void SAL_CALL
+ScVbaComboBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex )
+{
+ mpListHelper->AddItem( pvargItem, pvargIndex );
+}
+
+void SAL_CALL
+ScVbaComboBox::removeItem( const uno::Any& index )
+{
+ mpListHelper->removeItem( index );
+}
+
+void SAL_CALL
+ScVbaComboBox::Clear( )
+{
+ mpListHelper->Clear();
+}
+
+void SAL_CALL
+ScVbaComboBox::setRowSource( const OUString& _rowsource )
+{
+ ScVbaControl::setRowSource( _rowsource );
+ mpListHelper->setRowSource( _rowsource );
+}
+
+sal_Int32 SAL_CALL
+ScVbaComboBox::getListCount()
+{
+ return mpListHelper->getListCount();
+}
+
+uno::Any SAL_CALL
+ScVbaComboBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn )
+{
+ return mpListHelper->List( pvargIndex, pvarColumn );
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getStyle()
+{
+ return msforms::fmStyle::fmStyleDropDownCombo;
+}
+
+void SAL_CALL ScVbaComboBox::setStyle( sal_Int32 /*nStyle*/ )
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getDropButtonStyle()
+{
+ return msforms::fmDropButtonStyle::fmDropButtonStyleArrow;
+}
+
+void SAL_CALL ScVbaComboBox::setDropButtonStyle( sal_Int32 /*nDropButtonStyle*/ )
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getDragBehavior()
+{
+ return msforms::fmDragBehavior::fmDragBehaviorDisabled;
+}
+
+void SAL_CALL ScVbaComboBox::setDragBehavior( sal_Int32 /*nDragBehavior*/ )
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getEnterFieldBehavior()
+{
+ return msforms::fmEnterFieldBehavior::fmEnterFieldBehaviorSelectAll;
+}
+
+void SAL_CALL ScVbaComboBox::setEnterFieldBehavior( sal_Int32 /*nEnterFieldBehavior*/ )
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getListStyle()
+{
+ return msforms::fmListStyle::fmListStylePlain;
+}
+
+void SAL_CALL ScVbaComboBox::setListStyle( sal_Int32 /*nListStyle*/ )
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getTextAlign()
+{
+ return msforms::fmTextAlign::fmTextAlignLeft;
+}
+
+void SAL_CALL ScVbaComboBox::setTextAlign( sal_Int32 /*nTextAlign*/ )
+{
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getTextLength()
+{
+ return getText().getLength();
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaComboBox::getFont()
+{
+ return new VbaNewFont( m_xProps );
+}
+
+OUString
+ScVbaComboBox::getServiceImplName()
+{
+ return "ScVbaComboBox";
+}
+
+sal_Int32 SAL_CALL ScVbaComboBox::getBackColor()
+{
+ return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaComboBox::setBackColor( sal_Int32 nBackColor )
+{
+ ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Bool SAL_CALL ScVbaComboBox::getAutoSize()
+{
+ return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaComboBox::setAutoSize( sal_Bool bAutoSize )
+{
+ ScVbaControl::setAutoSize( bAutoSize );
+}
+
+sal_Bool SAL_CALL ScVbaComboBox::getLocked()
+{
+ return ScVbaControl::getLocked();
+}
+
+void SAL_CALL ScVbaComboBox::setLocked( sal_Bool bLocked )
+{
+ ScVbaControl::setLocked( bLocked );
+}
+
+OUString SAL_CALL ScVbaComboBox::getLinkedCell()
+{
+ return ScVbaControl::getControlSource();
+}
+
+void SAL_CALL ScVbaComboBox::setLinkedCell( const OUString& _linkedcell )
+{
+ ScVbaControl::setControlSource( _linkedcell );
+}
+
+uno::Sequence< OUString >
+ScVbaComboBox::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.ComboBox"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx
new file mode 100644
index 000000000..feea8e52c
--- /dev/null
+++ b/vbahelper/source/msforms/vbacombobox.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACOMBOBOX_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACOMBOBOX_HXX
+#include <memory>
+#include <cppuhelper/implbase.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 <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include "vbacontrol.hxx"
+#include "vbalistcontrolhelper.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper<ScVbaControl, ov::msforms::XComboBox, css::script::XDefaultProperty > ComboBoxImpl_BASE;
+class ScVbaComboBox : public ComboBoxImpl_BASE
+{
+ std::unique_ptr< ListControlHelper > mpListHelper;
+ OUString sSourceName;
+
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+
+ // Attributes
+ virtual css::uno::Any SAL_CALL getListIndex() override;
+ virtual ::sal_Int32 SAL_CALL getListCount() override;
+ virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) override;
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
+ virtual OUString SAL_CALL getText() override;
+ virtual void SAL_CALL setText( const OUString& _text ) override;
+ virtual sal_Int32 SAL_CALL getStyle() override;
+ virtual void SAL_CALL setStyle( sal_Int32 nStyle ) override;
+ virtual sal_Int32 SAL_CALL getDropButtonStyle() override;
+ virtual void SAL_CALL setDropButtonStyle( sal_Int32 nDropButtonStyle ) override;
+ virtual sal_Int32 SAL_CALL getDragBehavior() override;
+ virtual void SAL_CALL setDragBehavior( sal_Int32 nDragBehavior ) override;
+ virtual sal_Int32 SAL_CALL getEnterFieldBehavior() override;
+ virtual void SAL_CALL setEnterFieldBehavior( sal_Int32 nEnterFieldBehavior ) override;
+ virtual sal_Int32 SAL_CALL getListStyle() override;
+ virtual void SAL_CALL setListStyle( sal_Int32 nListStyle ) override;
+ virtual sal_Int32 SAL_CALL getTextAlign() override;
+ virtual void SAL_CALL setTextAlign( sal_Int32 nTextAlign ) override;
+ virtual sal_Int32 SAL_CALL getTextLength() override;
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override;
+ virtual sal_Int32 SAL_CALL getBackColor() override;
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) override;
+ virtual sal_Bool SAL_CALL getAutoSize() override;
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) override;
+ virtual sal_Bool SAL_CALL getLocked() override;
+ virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) override;
+ virtual OUString SAL_CALL getLinkedCell() override;
+ virtual void SAL_CALL setLinkedCell( const OUString& _linkedcell ) override;
+
+ // Methods
+ virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) override;
+ virtual void SAL_CALL removeItem( const css::uno::Any& index ) override;
+ virtual void SAL_CALL Clear( ) override;
+ virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) override;
+ // XControl
+ virtual void SAL_CALL setRowSource( const OUString& _rowsource ) override;
+
+ // XDefaultProperty
+ OUString SAL_CALL getDefaultPropertyName( ) override { return "Value"; }
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
new file mode 100644
index 000000000..5cbea01a4
--- /dev/null
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -0,0 +1,800 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <memory>
+#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/XActionListener.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/view/XControlAccess.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 <com/sun/star/script/XScriptListener.hpp>
+#include <com/sun/star/document/XCodeNameQuery.hpp>
+#include <com/sun/star/form/XChangeListener.hpp>
+#include <ooo/vba/XControlProvider.hpp>
+#include <ooo/vba/msforms/fmMousePointer.hpp>
+#include <svtools/bindablecontrolhelper.hxx>
+#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 <toolkit/helper/vclunohelper.hxx>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <svx/svdobj.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+uno::Reference< css::awt::XWindowPeer >
+ScVbaControl::getWindowPeer()
+{
+ 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_SET_THROW );
+
+ uno::Reference< view::XControlAccess > xControlAccess( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ try
+ {
+ uno::Reference< awt::XControl > xControl = xControlAccess->getControl( xControlModel );
+ xWinPeer = xControl->getPeer();
+ }
+ catch(const uno::Exception&)
+ {
+ throw uno::RuntimeException( "The Control does not exist" );
+ }
+ return xWinPeer;
+}
+
+namespace {
+
+//ScVbaControlListener
+class ScVbaControlListener: public cppu::WeakImplHelper< lang::XEventListener >
+{
+private:
+ ScVbaControl *pControl;
+public:
+ explicit ScVbaControlListener( ScVbaControl *pTmpControl );
+
+ virtual void SAL_CALL disposing( const lang::EventObject& rEventObject ) override;
+};
+
+}
+
+ScVbaControlListener::ScVbaControlListener( ScVbaControl *pTmpControl ): pControl( pTmpControl )
+{
+}
+
+void SAL_CALL
+ScVbaControlListener::disposing( const lang::EventObject& )
+{
+ if( pControl )
+ {
+ pControl->removeResource();
+ pControl = nullptr;
+ }
+}
+
+//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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
+ : ControlImpl_BASE( xParent, xContext ), m_xControl( xControl ), m_xModel( xModel )
+{
+ //add listener
+ m_xEventListener.set( new ScVbaControlListener( this ) );
+ setGeometryHelper( std::move(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 );
+ OUString sDefaultControl;
+ m_xProps->getPropertyValue( "DefaultControl" ) >>= sDefaultControl;
+ uno::Reference< lang::XMultiComponentFactory > xMFac( mxContext->getServiceManager(), uno::UNO_SET_THROW );
+ m_xEmptyFormControl.set( xMFac->createInstanceWithContext( sDefaultControl, mxContext ), uno::UNO_QUERY_THROW );
+ }
+ else if ( xUserFormControl.is() ) // userform control
+ {
+ m_xProps.set( xUserFormControl->getModel(), uno::UNO_QUERY_THROW );
+ }
+}
+
+ScVbaControl::~ScVbaControl()
+{
+ if( m_xControl.is() )
+ {
+ uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
+ xComponent->removeEventListener( m_xEventListener );
+ }
+}
+
+void
+ScVbaControl::setGeometryHelper( std::unique_ptr<AbstractGeometryAttributes> pHelper )
+{
+ mpGeometryHelper = std::move( pHelper );
+}
+
+void ScVbaControl::removeResource()
+{
+ uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
+ xComponent->removeEventListener( m_xEventListener );
+ m_xControl= nullptr;
+ m_xProps = nullptr;
+}
+
+//In design model has different behavior
+sal_Bool SAL_CALL ScVbaControl::getEnabled()
+{
+ uno::Any aValue = m_xProps->getPropertyValue ( "Enabled" );
+ bool bRet = false;
+ aValue >>= bRet;
+ return bRet;
+}
+
+void SAL_CALL ScVbaControl::setEnabled( sal_Bool bVisible )
+{
+ uno::Any aValue( bVisible );
+ m_xProps->setPropertyValue( "Enabled" , aValue);
+
+}
+
+sal_Bool SAL_CALL ScVbaControl::getVisible()
+{
+ bool bVisible( true );
+ m_xProps->getPropertyValue ( "EnableVisible" ) >>= bVisible;
+ uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
+ if ( xControlShape.is() )
+ {
+ bool bEnableVisible = bVisible;
+ uno::Reference< beans::XPropertySet > xProps( m_xControl, uno::UNO_QUERY_THROW );
+ xProps->getPropertyValue ( "Visible" ) >>= bVisible;
+ bVisible = bVisible && bEnableVisible;
+ }
+ else
+ m_xProps->getPropertyValue ( "EnableVisible" ) >>= bVisible;
+ return bVisible;
+}
+
+void SAL_CALL ScVbaControl::setVisible( sal_Bool bVisible )
+{
+ uno::Any aValue( bVisible );
+ m_xProps->setPropertyValue( "EnableVisible" , aValue);
+ uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
+ if ( xControlShape.is() )
+ {
+ uno::Reference< beans::XPropertySet > xProps( m_xControl, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue ( "Visible", aValue );
+ }
+}
+double SAL_CALL ScVbaControl::getHeight()
+{
+ return mpGeometryHelper->getHeight();
+}
+void SAL_CALL ScVbaControl::setHeight( double _height )
+{
+ mpGeometryHelper->setHeight( _height );
+}
+
+double SAL_CALL ScVbaControl::getWidth()
+{
+ return mpGeometryHelper->getWidth();
+}
+void SAL_CALL ScVbaControl::setWidth( double _width )
+{
+ mpGeometryHelper->setWidth( _width );
+}
+
+double SAL_CALL
+ScVbaControl::getLeft()
+{
+ return mpGeometryHelper->getLeft();
+}
+
+void SAL_CALL
+ScVbaControl::setLeft( double _left )
+{
+ mpGeometryHelper->setLeft( _left );
+}
+
+double SAL_CALL
+ScVbaControl::getTop()
+{
+ return mpGeometryHelper->getTop();
+}
+
+void SAL_CALL
+ScVbaControl::setTop( double _top )
+{
+ mpGeometryHelper->setTop( _top );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL
+ScVbaControl::getObject()
+{
+ uno::Reference< msforms::XControl > xRet( this );
+ return xRet;
+}
+
+void SAL_CALL ScVbaControl::SetFocus()
+{
+ 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 )
+{
+ double nWidth = 0.0;
+ double nHeight = 0.0;
+
+ setLeft( Left );
+ setTop( Top );
+
+ if ( Width >>= nWidth )
+ setWidth( nWidth );
+
+ if ( Height >>= nHeight )
+ setHeight( nHeight );
+}
+
+OUString SAL_CALL
+ScVbaControl::getControlSource()
+{
+// #FIXME I *hate* having these upstream differences
+// but this is necessary until I manage to upstream other
+// dependent parts
+ 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( "com.sun.star.table.CellAddressConversion" ), uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProps( xBindable->getValueBinding(), uno::UNO_QUERY_THROW );
+ table::CellAddress aAddress;
+ xProps->getPropertyValue( "BoundCell" ) >>= aAddress;
+ xConvertor->setPropertyValue( "Address" , uno::Any( aAddress ) );
+ xConvertor->getPropertyValue( "XLA1Representation" ) >>= sControlSource;
+ }
+ catch(const uno::Exception&)
+ {
+ }
+ }
+ return sControlSource;
+}
+
+void SAL_CALL
+ScVbaControl::setControlSource( const OUString& _controlsource )
+{
+ // afaik this is only relevant for Excel documents ( and we need to set up a
+ // reference tab in case no Sheet is specified in "_controlsource"
+ // Can't use the active sheet either, code may of course access
+ uno::Reference< drawing::XDrawPagesSupplier > xSupplier( m_xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
+ sal_Int32 nLen = xIndex->getCount();
+ bool bMatched = false;
+ sal_Int16 nRefTab = 0;
+ for ( sal_Int32 index = 0; index < nLen; ++index )
+ {
+ try
+ {
+ uno::Reference< form::XFormsSupplier > xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
+ // get the www-standard container
+ uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
+ sal_Int32 nCntrls = xFormControls->getCount();
+ for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
+ {
+ uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
+ bMatched = ( m_xProps == xControl );
+ if ( bMatched )
+ {
+ nRefTab = index;
+ break;
+ }
+ }
+ }
+ catch( uno::Exception& ) {}
+ if ( bMatched )
+ break;
+ }
+
+ svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, _controlsource, "", sal_uInt16( nRefTab ) );
+}
+
+OUString SAL_CALL
+ScVbaControl::getRowSource()
+{
+ 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( "com.sun.star.table.CellRangeAddressConversion" ), uno::UNO_QUERY );
+
+ uno::Reference< beans::XPropertySet > xProps( xListSink->getListEntrySource(), uno::UNO_QUERY_THROW );
+ table::CellRangeAddress aAddress;
+ xProps->getPropertyValue( "CellRange" ) >>= aAddress;
+ xConvertor->setPropertyValue( "Address" , uno::Any( aAddress ) );
+ xConvertor->getPropertyValue( "XLA1Representation" ) >>= sRowSource;
+ }
+ catch(const uno::Exception&)
+ {
+ }
+ }
+ return sRowSource;
+}
+
+void SAL_CALL
+ScVbaControl::setRowSource( const OUString& _rowsource )
+{
+ svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, "", _rowsource );
+}
+
+OUString SAL_CALL
+ScVbaControl::getName()
+{
+ OUString sName;
+ m_xProps->getPropertyValue( "Name" ) >>= sName;
+ return sName;
+
+}
+
+void SAL_CALL
+ScVbaControl::setName( const OUString& _name )
+{
+ m_xProps->setPropertyValue( "Name" , uno::Any( _name ) );
+ }
+
+OUString SAL_CALL
+ScVbaControl::getControlTipText()
+{
+ OUString sName;
+ m_xProps->getPropertyValue( "HelpText" ) >>= sName;
+ return sName;
+}
+
+void SAL_CALL
+ScVbaControl::setControlTipText( const OUString& rsToolTip )
+{
+ m_xProps->setPropertyValue( "HelpText" , uno::Any( rsToolTip ) );
+}
+
+OUString SAL_CALL ScVbaControl::getTag()
+{
+ return m_aControlTag;
+}
+
+void SAL_CALL ScVbaControl::setTag( const OUString& aTag )
+{
+ m_aControlTag = aTag;
+}
+
+::sal_Int32 SAL_CALL ScVbaControl::getForeColor()
+{
+ Color nForeColor;
+ m_xProps->getPropertyValue( "TextColor" ) >>= nForeColor;
+ return OORGBToXLRGB( nForeColor );
+}
+
+namespace {
+
+struct PointerStyles
+{
+ tools::Long msoPointerStyle;
+ PointerStyle loPointStyle;
+};
+
+}
+
+// 1 -> 1 map of styles ( some dubious choices in there though )
+PointerStyles const styles[] = {
+ /// assuming pointer default is Arrow
+ { msforms::fmMousePointer::fmMousePointerDefault, PointerStyle::Arrow },
+ { msforms::fmMousePointer::fmMousePointerArrow, PointerStyle::Arrow },
+ { msforms::fmMousePointer::fmMousePointerCross, PointerStyle::Cross },
+ { msforms::fmMousePointer::fmMousePointerIBeam, PointerStyle::Text },
+ { msforms::fmMousePointer::fmMousePointerSizeNESW, PointerStyle::AutoScrollNSWE }, // #TODO not correct, need to check, need to find the right one
+ { msforms::fmMousePointer::fmMousePointerSizeNS, PointerStyle::AutoScrollNS },
+ { msforms::fmMousePointer::fmMousePointerSizeNWSE, PointerStyle::AutoScrollNSWE }, // #TODO not correct, need to check, need to find the right one
+ { msforms::fmMousePointer::fmMousePointerSizeWE, PointerStyle::AutoScrollWE },
+ { msforms::fmMousePointer::fmMousePointerUpArrow, PointerStyle::WindowNSize },
+ { msforms::fmMousePointer::fmMousePointerHourGlass, PointerStyle::Wait },
+ { msforms::fmMousePointer::fmMousePointerNoDrop, PointerStyle::NotAllowed },
+ { msforms::fmMousePointer::fmMousePointerAppStarting, PointerStyle::Wait },
+ { msforms::fmMousePointer::fmMousePointerHelp, PointerStyle::Help },
+ { msforms::fmMousePointer::fmMousePointerSizeAll, PointerStyle::Cross },
+ { msforms::fmMousePointer::fmMousePointerCustom, PointerStyle::Arrow }, // not supported I guess
+
+};
+
+static tools::Long lcl_loPointerToMsoPointer( PointerStyle eType )
+{
+ tools::Long nRet = msforms::fmMousePointer::fmMousePointerDefault;
+ for ( auto const & i: styles )
+ {
+ if ( i.loPointStyle == eType )
+ {
+ nRet = i.msoPointerStyle;
+ break;
+ }
+ }
+ return nRet;
+}
+
+static PointerStyle lcl_msoPointerToLOPointer( tools::Long msoPointerStyle )
+{
+ PointerStyle aPointer( PointerStyle::Arrow );
+ for ( auto const & i: styles )
+ {
+ if ( i.msoPointerStyle == msoPointerStyle )
+ {
+ aPointer = i.loPointStyle;
+ break;
+ }
+ }
+ return aPointer;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaControl::getMousePointer()
+{
+ return lcl_loPointerToMsoPointer(VCLUnoHelper::getMousePointer(getWindowPeer()));
+}
+
+void SAL_CALL
+ScVbaControl::setMousePointer( ::sal_Int32 _mousepointer )
+{
+ VCLUnoHelper::setMousePointer(getWindowPeer(), lcl_msoPointerToLOPointer(_mousepointer));
+}
+
+void SAL_CALL ScVbaControl::fireEvent( const script::ScriptEvent& rEvt )
+{
+ script::ScriptEvent evt( rEvt );
+ uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
+ uno::Reference< script::XScriptListener > xScriptListener( xServiceManager->createInstanceWithContext( "ooo.vba.EventListener" , mxContext ), uno::UNO_QUERY_THROW );
+
+ uno::Reference< beans::XPropertySet > xProps( xScriptListener, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( "Model" , uno::Any( m_xModel ) );
+
+ // handling for sheet control
+ uno::Reference< msforms::XControl > xThisControl( this );
+ try
+ {
+ evt.Arguments.realloc( 1 );
+ lang::EventObject aEvt;
+
+ uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ) ;
+ uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY ) ;
+
+ if ( xControlShape.is() )
+ {
+ evt.Source = xControlShape;
+ aEvt.Source = m_xEmptyFormControl;
+ // Set up proper scriptcode
+ uno::Reference< lang::XMultiServiceFactory > xDocFac( m_xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< document::XCodeNameQuery > xNameQuery( xDocFac->createInstance( "ooo.vba.VBACodeNameProvider" ), uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XInterface > xIf( xControlShape->getControl(), uno::UNO_QUERY_THROW );
+ evt.ScriptCode = xNameQuery->getCodeNameForObject( xIf );
+ // handle if we passed in our own arguments
+ if ( !rEvt.Arguments.hasElements() )
+ evt.Arguments.getArray()[ 0 ] <<= aEvt;
+ xScriptListener->firing( evt );
+ }
+ else
+ {
+ if ( xControl.is() ) // normal control ( from dialog/userform )
+ {
+ // #FIXME We should probably store a reference to the
+ // parent dialog/userform here (otherwise the name of
+ // dialog could be changed and we won't be aware of it.
+ // (OTOH this is probably an unlikely scenario)
+ evt.Source = xThisControl;
+ aEvt.Source = xControl;
+ evt.ScriptCode = m_sLibraryAndCodeName;
+ evt.Arguments.getArray()[ 0 ] <<= aEvt;
+ xScriptListener->firing( evt );
+ }
+ }
+ }
+ catch(const uno::Exception&)
+ {
+ }
+}
+void ScVbaControl::fireChangeEvent()
+{
+ script::ScriptEvent evt;
+ evt.ScriptType = "VBAInterop";
+ evt.ListenerType = cppu::UnoType<form::XChangeListener>::get();
+ evt.MethodName = "changed";
+ fireEvent( evt );
+}
+
+void ScVbaControl::fireClickEvent()
+{
+ script::ScriptEvent evt;
+ evt.ScriptType = "VBAInterop";
+ evt.ListenerType = cppu::UnoType<awt::XActionListener>::get();
+ evt.MethodName = "actionPerformed";
+ fireEvent( evt );
+}
+
+sal_Int32 SAL_CALL ScVbaControl::getTabIndex()
+{
+ return 1;
+}
+
+void SAL_CALL ScVbaControl::setTabIndex( sal_Int32 /*nTabIndex*/ )
+{
+}
+
+//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 )
+{
+ uno::Reference< beans::XPropertySet > xProps( xControlShape->getControl(), uno::UNO_QUERY_THROW );
+ sal_Int32 nClassId = -1;
+ xProps->getPropertyValue( "ClassId" ) >>= nClassId;
+ uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess
+ uno::Reference< drawing::XShape > xShape( xControlShape, uno::UNO_QUERY_THROW );
+ ::std::unique_ptr< ConcreteXShapeGeometryAttributes > xGeoHelper( new ConcreteXShapeGeometryAttributes( xShape ) );
+ switch( nClassId )
+ {
+ case form::FormComponentType::COMBOBOX:
+ return new ScVbaComboBox( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ case form::FormComponentType::COMMANDBUTTON:
+ {
+ bool bToggle = false;
+ xProps->getPropertyValue( "Toggle" ) >>= bToggle;
+ if ( bToggle )
+ return new ScVbaToggleButton( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ else
+ return new VbaButton( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ }
+ case form::FormComponentType::FIXEDTEXT:
+ return new ScVbaLabel( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ case form::FormComponentType::TEXTFIELD:
+ return new ScVbaTextBox( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ case form::FormComponentType::CHECKBOX:
+ return new ScVbaCheckbox( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ case form::FormComponentType::RADIOBUTTON:
+ return new ScVbaRadioButton( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ case form::FormComponentType::LISTBOX:
+ return new ScVbaListBox( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ case form::FormComponentType::SPINBUTTON:
+ return new ScVbaSpinButton( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ case form::FormComponentType::IMAGECONTROL:
+ return new ScVbaImage( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ case form::FormComponentType::SCROLLBAR:
+ return new ScVbaScrollBar( xVbaParent, xContext, xControlShape, xModel, std::move(xGeoHelper) );
+ }
+ throw uno::RuntimeException( "Unsupported control." );
+}
+
+/*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 )
+{
+ 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::unique_ptr< UserFormGeometryHelper > xGeoHelper( new UserFormGeometryHelper( xControl, fOffsetX, fOffsetY ) );
+
+ if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ) )
+ xVBAControl.set( new ScVbaCheckbox( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) )
+ xVBAControl.set( new ScVbaRadioButton( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlEditModel" ) )
+ xVBAControl.set( new ScVbaTextBox( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper), true ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlButtonModel" ) )
+ {
+ bool bToggle = false;
+ xProps->getPropertyValue( "Toggle" ) >>= bToggle;
+ if ( bToggle )
+ xVBAControl.set( new ScVbaToggleButton( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else
+ xVBAControl.set( new VbaButton( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ }
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlComboBoxModel" ) )
+ xVBAControl.set( new ScVbaComboBox( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlListBoxModel" ) )
+ xVBAControl.set( new ScVbaListBox( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
+ xVBAControl.set( new ScVbaLabel( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlImageControlModel" ) )
+ xVBAControl.set( new ScVbaImage( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlProgressBarModel" ) )
+ xVBAControl.set( new ScVbaProgressBar( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ) )
+ xVBAControl.set( new ScVbaFrame( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper), xDialog ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlScrollBarModel" ) )
+ xVBAControl.set( new ScVbaScrollBar( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoMultiPageModel" ) )
+ xVBAControl.set( new ScVbaMultiPage( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlSpinButtonModel" ) )
+ xVBAControl.set( new ScVbaSpinButton( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) )
+ xVBAControl.set( new VbaSystemAXControl( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ // #FIXME implement a page control
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoPageModel" ) )
+ xVBAControl.set( new ScVbaControl( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper) ) );
+ else if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoFrameModel" ) )
+ xVBAControl.set( new ScVbaFrame( xVbaParent, xContext, xControl, xModel, std::move(xGeoHelper), xDialog ) );
+ if( xVBAControl.is() )
+ return xVBAControl;
+ throw uno::RuntimeException( "Unsupported control." );
+}
+
+OUString
+ScVbaControl::getServiceImplName()
+{
+ return "ScVbaControl";
+}
+
+uno::Sequence< OUString >
+ScVbaControl::getServiceNames()
+{
+ return { "ooo.vba.excel.Control" };
+}
+
+sal_Int32 const nSysCols[] = { 0xC8D0D4, 0x0, 0x6A240A, 0x808080, 0xE4E4E4, 0xFFFFFF, 0x0, 0x0, 0x0, 0xFFFFFF, 0xE4E4E4, 0xE4E4E4, 0x808080, 0x6A240A, 0xFFFFFF, 0xE4E4E4, 0x808080, 0x808080, 0x0, 0xC8D0D4, 0xFFFFFF, 0x404040, 0xE4E4E4, 0x0, 0xE1FFFF };
+
+sal_Int32 ScVbaControl::getBackColor()
+{
+ sal_Int32 nBackColor = 0;
+ m_xProps->getPropertyValue( "BackgroundColor" ) >>= nBackColor;
+ return nBackColor;
+}
+
+void ScVbaControl::setBackColor( sal_Int32 nBackColor )
+{
+ auto const col = static_cast<sal_uInt32>(nBackColor);
+ if ( ( col >= sal_uInt32(0x80000000) ) &&
+ ( col <= sal_uInt32(0x80000000) + SAL_N_ELEMENTS(nSysCols) ) )
+ {
+ nBackColor = nSysCols[ col & 0x0FF];
+ }
+ m_xProps->setPropertyValue( "BackgroundColor" , uno::Any( XLRGBToOORGB( nBackColor ) ) );
+}
+
+bool ScVbaControl::getAutoSize() const
+{
+ bool bIsResizeEnabled = false;
+ uno::Reference< uno::XInterface > xIf( m_xControl, uno::UNO_SET_THROW );
+ SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xIf );
+ if ( pObj )
+ bIsResizeEnabled = !pObj->IsResizeProtect();
+ return bIsResizeEnabled;
+}
+
+// currently no implementation for this
+void ScVbaControl::setAutoSize( bool bAutoSize )
+{
+ uno::Reference< uno::XInterface > xIf( m_xControl, uno::UNO_SET_THROW );
+ SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xIf );
+ if ( pObj )
+ pObj->SetResizeProtect( !bAutoSize );
+}
+
+bool ScVbaControl::getLocked()
+{
+ bool bRes( false );
+ m_xProps->getPropertyValue( "ReadOnly" ) >>= bRes;
+ return bRes;
+}
+
+void ScVbaControl::setLocked( bool bLocked )
+{
+ m_xProps->setPropertyValue( "ReadOnly" , uno::Any( bLocked ) );
+}
+
+namespace {
+
+class ControlProviderImpl : public cppu::WeakImplHelper< XControlProvider, css::lang::XServiceInfo >
+{
+ uno::Reference< uno::XComponentContext > m_xCtx;
+public:
+ explicit 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 ) override;
+
+ // XServiceInfo
+ virtual sal_Bool SAL_CALL supportsService(const OUString& sServiceName) override;
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+};
+
+}
+
+// XServiceInfo
+sal_Bool ControlProviderImpl::supportsService(const OUString& sServiceName)
+{
+ return cppu::supportsService(this, sServiceName);
+}
+OUString ControlProviderImpl::getImplementationName()
+{
+ return "ControlProviderImpl";
+}
+css::uno::Sequence< OUString > ControlProviderImpl::getSupportedServiceNames()
+{
+ return { "ooo.vba.ControlProvider" };
+}
+
+uno::Reference< msforms::XControl > SAL_CALL
+ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< frame::XModel >& xDocOwner )
+{
+ uno::Reference< msforms::XControl > xControlToReturn;
+ if ( xControlShape.is() )
+ xControlToReturn = ScVbaControlFactory::createShapeControl( m_xCtx, xControlShape, xDocOwner );
+ return xControlToReturn;
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+ControlProviderImpl_get_implementation(
+ css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new ControlProviderImpl(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx
new file mode 100644
index 000000000..e96cd5fa9
--- /dev/null
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROL_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROL_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
+#include <com/sun/star/script/ScriptEvent.hpp>
+#include <ooo/vba/msforms/XControl.hpp>
+
+#include <vbahelper/vbahelper.hxx>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <memory>
+
+typedef InheritedHelperInterfaceWeakImpl< ov::msforms::XControl > ControlImpl_BASE;
+
+class ScVbaControl : public ControlImpl_BASE
+{
+private:
+ css::uno::Reference< css::lang::XEventListener > m_xEventListener;
+ css::uno::Reference< css::awt::XControl > m_xEmptyFormControl;
+protected:
+ // awt control has nothing similar to Tag property of Mso controls,
+ // whether it is necessary is another question
+ OUString m_aControlTag;
+
+ OUString m_sLibraryAndCodeName;
+ std::unique_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;
+
+ /// @throws css::uno::RuntimeException
+ css::uno::Reference< css::awt::XWindowPeer > getWindowPeer();
+ void fireChangeEvent();
+ void fireClickEvent();
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pHelper );
+ virtual ~ScVbaControl() override;
+ // This class will own the helper, so make sure it is allocated from
+ // the heap
+ void setGeometryHelper( std::unique_ptr<ov::AbstractGeometryAttributes> pHelper );
+ // sets the name of the associated library ( used for UserForm controls )
+ void setLibraryAndCodeName( const OUString& sLibCodeName ) { m_sLibraryAndCodeName = sLibCodeName; }
+
+ // XControl
+ virtual sal_Bool SAL_CALL getEnabled() override;
+ virtual void SAL_CALL setEnabled( sal_Bool _enabled ) override;
+ virtual sal_Bool SAL_CALL getVisible() override;
+ virtual void SAL_CALL setVisible( sal_Bool _visible ) override;
+ virtual double SAL_CALL getHeight() override;
+ virtual void SAL_CALL setHeight( double _height ) override;
+ virtual double SAL_CALL getWidth() override;
+ virtual void SAL_CALL setWidth( double _width ) override;
+ virtual double SAL_CALL getLeft() override;
+ virtual void SAL_CALL setLeft( double _left ) override;
+ virtual double SAL_CALL getTop() override;
+ virtual void SAL_CALL setTop( double _top ) override;
+ virtual void SAL_CALL SetFocus( ) override;
+ virtual void SAL_CALL Move( double Left, double Top, const css::uno::Any& Width, const css::uno::Any& Height ) override;
+ virtual void SAL_CALL fireEvent( const css::script::ScriptEvent& evt ) override;
+
+ virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() override;
+ virtual OUString SAL_CALL getControlSource() override;
+ virtual void SAL_CALL setControlSource( const OUString& _controlsource ) override;
+ virtual OUString SAL_CALL getRowSource() override;
+ virtual void SAL_CALL setRowSource( const OUString& _rowsource ) override;
+ virtual OUString SAL_CALL getName() override;
+ virtual void SAL_CALL setName( const OUString& _name ) override;
+ virtual OUString SAL_CALL getControlTipText() override;
+ virtual void SAL_CALL setControlTipText( const OUString& ) override;
+ virtual OUString SAL_CALL getTag() override;
+ virtual void SAL_CALL setTag( const OUString& aTag ) override;
+ virtual sal_Int32 SAL_CALL getTabIndex() override;
+ virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) override;
+ virtual ::sal_Int32 SAL_CALL getMousePointer() override;
+ virtual void SAL_CALL setMousePointer( ::sal_Int32 _mousepointer ) override;
+ //remove resource because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
+ /// @throws css::uno::RuntimeException
+ void removeResource();
+ /// @throws css::uno::RuntimeException
+ virtual ::sal_Int32 SAL_CALL getForeColor();
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+ //General helper methods for properties (may or may not be relevant for all
+ //controls)
+ /// @throws css::uno::RuntimeException
+ sal_Int32 getBackColor();
+ /// @throws css::uno::RuntimeException
+ void setBackColor( sal_Int32 nBackColor );
+ /// @throws css::uno::RuntimeException
+ bool getAutoSize() const;
+ /// @throws css::uno::RuntimeException
+ void setAutoSize( bool bAutoSize );
+ /// @throws css::uno::RuntimeException
+ bool getLocked();
+ /// @throws css::uno::RuntimeException
+ void setLocked( bool bAutoSize );
+};
+
+
+namespace ScVbaControlFactory
+{
+ /// @throws css::uno::RuntimeException
+ 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 );
+
+ /// @throws css::uno::RuntimeException
+ 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 );
+}
+
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx
new file mode 100644
index 000000000..a1dc6b6ee
--- /dev/null
+++ b/vbahelper/source/msforms/vbacontrols.cxx
@@ -0,0 +1,493 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#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/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include "vbacontrols.hxx"
+#include "vbacontrol.hxx"
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <o3tl/safeint.hxx>
+#include <unordered_map>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+typedef std::unordered_map< OUString, sal_Int32 > ControlIndexMap;
+
+namespace {
+
+class ControlArrayWrapper : public ::cppu::WeakImplHelper< container::XNameAccess, container::XIndexAccess >
+{
+ uno::Reference< awt::XControlContainer > mxDialog;
+ uno::Sequence< OUString > msNames;
+ std::vector< uno::Reference< awt::XControl > > mControls;
+ ControlIndexMap mIndices;
+
+private:
+ void SetArrayElementTo( const uno::Reference< awt::XControl >& xCtrl, sal_Int32 nIndex )
+ {
+ // 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.getArray()[ nIndex ] = getControlName( xCtrl );
+ mControls.push_back( xCtrl );
+ mIndices[ msNames[ nIndex ] ] = nIndex;
+ }
+ }
+public:
+ explicit 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 (const uno::Exception&)
+ {
+ // accept the case when the dialog already does not exist
+ // in this case the wrapper should work in dummy mode
+ }
+ }
+
+ static 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 );
+ OUString sName;
+ xProp->getPropertyValue( "Name" ) >>= sName;
+ return sName;
+ }
+
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) override
+ {
+ return cppu::UnoType<awt::XControl>::get();
+ }
+
+ virtual sal_Bool SAL_CALL hasElements( ) override
+ {
+ return ( !mControls.empty() );
+ }
+
+ // XNameAccess
+ virtual uno::Any SAL_CALL getByName( const OUString& aName ) override
+ {
+ if ( !hasByName( aName ) )
+ throw container::NoSuchElementException();
+ return getByIndex( mIndices[ aName ] );
+ }
+
+ virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) override
+ {
+ return msNames;
+ }
+
+ virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override
+ {
+ ControlIndexMap::iterator it = mIndices.find( aName );
+ return it != mIndices.end();
+ }
+
+ // XElementAccess
+ virtual ::sal_Int32 SAL_CALL getCount( ) override
+ {
+ return mControls.size();
+ }
+
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
+ {
+ if ( Index < 0 || o3tl::make_unsigned(Index) >= mControls.size() )
+ throw lang::IndexOutOfBoundsException();
+ return uno::Any( mControls[ Index ] );
+ }
+};
+
+
+class ControlsEnumWrapper : public EnumerationHelper_BASE
+{
+ 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< 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_xContext( xContext),
+ m_xIndexAccess( xIndexAccess ),
+ m_xDlg( xDlg ),
+ m_xModel( xModel ),
+ mfOffsetX( fOffsetX ),
+ mfOffsetY( fOffsetY ),
+ nIndex( 0 ) {}
+
+ virtual sal_Bool SAL_CALL hasMoreElements( ) override
+ {
+ return ( nIndex < m_xIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) override
+ {
+ 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::Any( xVBAControl );
+ }
+ throw container::NoSuchElementException();
+ }
+
+};
+
+}
+
+static 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()
+{
+ uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( 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 )
+{
+ 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*/ )
+{
+ uno::Any aResult;
+ 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?
+ OUString aNewName;
+ StringKey >>= aNewName;
+ if ( aNewName.isEmpty() )
+ {
+ aNewName = aComServiceName;
+ if ( aNewName.isEmpty() )
+ aNewName = "Control";
+
+ sal_Int32 nInd = 0;
+ while( xDialogContainer->hasByName( aNewName ) && (nInd < SAL_MAX_INT32) )
+ {
+ aNewName = aComServiceName + OUString::number( nInd++ );
+ }
+ }
+
+ double fDefWidth = 72.0, fDefHeight = 18.0;
+ if ( !aComServiceName.isEmpty() )
+ {
+ // create a UNO control model based on the passed control type
+ uno::Reference< awt::XControlModel > xNewModel;
+ bool bFontSupport = false;
+ bool bNativeAX = false;
+ if( aComServiceName.equalsIgnoreAsciiCase( "Forms.CommandButton.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlButtonModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 24.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.Label.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlFixedTextModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.Image.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlImageControlModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 72.0;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.CheckBox.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlCheckBoxModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 108.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.OptionButton.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlRadioButtonModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 108.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.TextBox.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlEditModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.ListBox.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlListBoxModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.ComboBox.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlComboBoxModel" ), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( "Dropdown" , uno::Any( true ) );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.ToggleButton.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlButtonModel" ), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( "Toggle" , uno::Any( true ) );
+ fDefWidth = 72.0; fDefHeight = 18.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.Frame.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlGroupBoxModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 216.0; fDefHeight = 144.0;
+ bFontSupport = true;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.SpinButton.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlSpinButtonModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 12.75; fDefHeight = 25.5;
+ }
+ else if( aComServiceName.equalsIgnoreAsciiCase( "Forms.ScrollBar.1" ) )
+ {
+ xNewModel.set( xModelFactory->createInstance( "com.sun.star.awt.UnoControlScrollBarModel" ), uno::UNO_QUERY_THROW );
+ fDefWidth = 12.75; fDefHeight = 63.8;
+ }
+ else
+ {
+ xNewModel.set( xModelFactory->createInstance( "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( "FontName" , uno::Any( OUString("Tahoma" ) ) );
+ xModelProps->setPropertyValue( "FontHeight" , uno::Any( float( 8.0 ) ) );
+ xModelProps->setPropertyValue( "FontWeight" , uno::Any( awt::FontWeight::NORMAL ) );
+ xModelProps->setPropertyValue( "FontSlant" , uno::Any( awt::FontSlant_NONE ) );
+ xModelProps->setPropertyValue( "FontUnderline" , uno::Any( awt::FontUnderline::NONE ) );
+ xModelProps->setPropertyValue( "FontStrikeout" , uno::Any( awt::FontStrikeout::NONE ) );
+ }
+
+ xDialogContainer->insertByName( aNewName, uno::Any( 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{ uno::Any(aComServiceName) };
+ uno::Sequence< sal_Int16 > aOutIDDummy;
+ uno::Sequence< uno::Any > aOutDummy;
+ xControlInvoke->invoke( "SOAddAXControl" , aArgs, aOutIDDummy, aOutDummy );
+ }
+ catch (const uno::Exception&)
+ {
+ xDialogContainer->removeByName( aNewName );
+ throw;
+ }
+ }
+
+ if ( !xNewControl.is() )
+ throw uno::RuntimeException();
+
+ 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 );
+ }
+ catch (const uno::RuntimeException&)
+ {
+ throw;
+ }
+ catch (const uno::Exception&)
+ {
+ css::uno::Any anyEx = cppu::getCaughtException();
+ throw lang::WrappedTargetRuntimeException( "Can not create AXControl!",
+ uno::Reference< uno::XInterface >(),
+ anyEx );
+ }
+
+ return aResult;
+}
+
+void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex )
+{
+ try
+ {
+ OUString aControlName;
+ sal_Int32 nIndex = -1;
+ 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 )
+ {
+ if ( aControlName.isEmpty() )
+ throw uno::RuntimeException();
+ }
+ else if ( StringKeyOrIndex >>= nIndex )
+ {
+ if (nIndex >= 0 && nIndex < m_xIndexAccess->getCount() )
+ throw uno::RuntimeException();
+ }
+ else
+ throw uno::RuntimeException();
+
+ uno::Reference< awt::XControl > xControl;
+ if ( !aControlName.isEmpty() )
+ {
+ 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.isEmpty() )
+ aControlName = ControlArrayWrapper::getControlName( xControl );
+
+ xDialogContainer->removeByName( aControlName );
+ xControl->dispose();
+ }
+ catch (const 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 (const uno::Exception&)
+ {
+ // throw lang::WrappedTargetException("Can not create AXControl!",
+ // uno::Reference< uno::XInterface >(),
+ // uno::makeAny( e ) );
+ }
+}
+
+
+uno::Type
+ScVbaControls::getElementType()
+{
+ return cppu::UnoType<ooo::vba::msforms::XControl>::get();
+}
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaControls, "ooo.vba.msforms.Controls" )
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacontrols.hxx b/vbahelper/source/msforms/vbacontrols.hxx
new file mode 100644
index 000000000..1e9d95042
--- /dev/null
+++ b/vbahelper/source/msforms/vbacontrols.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROLS_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROLS_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 ) override;
+ 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 ) override;
+ virtual void SAL_CALL Remove( const css::uno::Any& StringKeyOrIndex ) override;
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() override;
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
+
+ // ScVbaCollectionBaseImpl
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) override;
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ css::uno::Reference< css::awt::XControl > mxDialog;
+ css::uno::Reference< css::frame::XModel > mxModel;
+ double mfOffsetX;
+ double mfOffsetY;
+};
+
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROLS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaframe.cxx b/vbahelper/source/msforms/vbaframe.cxx
new file mode 100644
index 000000000..88ca093d3
--- /dev/null
+++ b/vbahelper/source/msforms/vbaframe.cxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#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;
+
+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,
+ std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper,
+ const css::uno::Reference< css::awt::XControl >& xDialog ) :
+ FrameImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) ),
+ mxDialog( xDialog )
+{
+}
+
+// XFrame attributes
+
+OUString SAL_CALL ScVbaFrame::getCaption()
+{
+ OUString Label;
+ m_xProps->getPropertyValue( "Label" ) >>= Label;
+ return Label;
+}
+
+void SAL_CALL ScVbaFrame::setCaption( const OUString& _caption )
+{
+ m_xProps->setPropertyValue( "Label", uno::Any( _caption ) );
+}
+
+sal_Int32 SAL_CALL ScVbaFrame::getSpecialEffect()
+{
+ return msforms::fmSpecialEffect::fmSpecialEffectEtched;
+}
+
+
+void SAL_CALL ScVbaFrame::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ )
+{
+ // #STUB
+}
+
+sal_Int32 SAL_CALL ScVbaFrame::getBorderStyle()
+{
+ return msforms::fmBorderStyle::fmBorderStyleNone;
+}
+
+void SAL_CALL ScVbaFrame::setBorderStyle( sal_Int32 /*nBorderStyle*/ )
+{
+ // #STUB
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaFrame::getFont()
+{
+ return new VbaNewFont( m_xProps );
+}
+
+// XFrame methods
+
+uno::Any SAL_CALL ScVbaFrame::Controls( const uno::Any& rIndex )
+{
+ // 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 xControls->Item( rIndex, uno::Any() );
+ return uno::Any( xControls );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaFrame, "ooo.vba.msforms.Frame" )
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx
new file mode 100644
index 000000000..354858a27
--- /dev/null
+++ b/vbahelper/source/msforms/vbaframe.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAFRAME_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAFRAME_HXX
+
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XFrame.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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,
+ std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper,
+ const css::uno::Reference< css::awt::XControl >& xDialog );
+
+ // XFrame attributes
+ virtual OUString SAL_CALL getCaption() override;
+ virtual void SAL_CALL setCaption( const OUString& _caption ) override;
+
+ virtual sal_Int32 SAL_CALL getSpecialEffect() override;
+ virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) override;
+ virtual sal_Int32 SAL_CALL getBorderStyle() override;
+ virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) override;
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override;
+ // XFrame methods
+ css::uno::Any SAL_CALL Controls( const css::uno::Any& rIndex ) override;
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+
+private:
+ css::uno::Reference< css::awt::XControl > mxDialog;
+};
+
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAFRAME_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaimage.cxx b/vbahelper/source/msforms/vbaimage.cxx
new file mode 100644
index 000000000..827544168
--- /dev/null
+++ b/vbahelper/source/msforms/vbaimage.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "vbaimage.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
+ : ImageImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+}
+
+OUString
+ScVbaImage::getServiceImplName()
+{
+ return "ScVbaImage";
+}
+
+uno::Sequence< OUString >
+ScVbaImage::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.Image"
+ };
+ return aServiceNames;
+}
+
+sal_Int32 SAL_CALL ScVbaImage::getBackColor()
+{
+ return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaImage::setBackColor( sal_Int32 nBackColor )
+{
+ ScVbaControl::setBackColor( nBackColor );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaimage.hxx b/vbahelper/source/msforms/vbaimage.hxx
new file mode 100644
index 000000000..2f7081f52
--- /dev/null
+++ b/vbahelper/source/msforms/vbaimage.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAIMAGE_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAIMAGE_HXX
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XImage.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+ virtual sal_Int32 SAL_CALL getBackColor() override;
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) override;
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAIMAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbalabel.cxx b/vbahelper/source/msforms/vbalabel.cxx
new file mode 100644
index 000000000..5b7164b45
--- /dev/null
+++ b/vbahelper/source/msforms/vbalabel.cxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbalabel.hxx"
+#include "vbanewfont.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
+ : LabelImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+}
+
+// Attributes
+OUString SAL_CALL
+ScVbaLabel::getCaption()
+{
+ OUString Label;
+ m_xProps->getPropertyValue( "Label" ) >>= Label;
+ return Label;
+}
+
+void SAL_CALL
+ScVbaLabel::setCaption( const OUString& _caption )
+{
+ m_xProps->setPropertyValue( "Label", uno::Any( _caption ) );
+}
+uno::Any SAL_CALL
+ScVbaLabel::getValue()
+{
+ return uno::Any( getCaption() );
+}
+
+void SAL_CALL
+ScVbaLabel::setValue( const uno::Any& _value )
+{
+ OUString sCaption;
+ _value >>= sCaption;
+ setCaption( sCaption );
+}
+
+OUString SAL_CALL
+ScVbaLabel::getAccelerator()
+{
+ // #STUB
+ return OUString();
+}
+
+void SAL_CALL
+ScVbaLabel::setAccelerator( const OUString& /*_accelerator*/ )
+{
+ // #STUB
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaLabel::getFont()
+{
+ return new VbaNewFont( m_xProps );
+}
+
+OUString ScVbaLabel::getServiceImplName()
+{
+ return "ScVbaLabel";
+}
+
+sal_Int32 SAL_CALL ScVbaLabel::getBackColor()
+{
+ return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaLabel::setBackColor( sal_Int32 nBackColor )
+{
+ ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Bool SAL_CALL ScVbaLabel::getAutoSize()
+{
+ return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaLabel::setAutoSize( sal_Bool bAutoSize )
+{
+ ScVbaControl::setAutoSize( bAutoSize );
+}
+
+uno::Sequence< OUString >
+ScVbaLabel::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.Label"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbalabel.hxx b/vbahelper/source/msforms/vbalabel.hxx
new file mode 100644
index 000000000..f7fc98416
--- /dev/null
+++ b/vbahelper/source/msforms/vbalabel.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBALABEL_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBALABEL_HXX
+#include <ooo/vba/msforms/XLabel.hpp>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <cppuhelper/implbase.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
+ virtual OUString SAL_CALL getCaption() override;
+ virtual void SAL_CALL setCaption( const OUString& _caption ) override;
+ virtual OUString SAL_CALL getAccelerator() override;
+ virtual void SAL_CALL setAccelerator( const OUString& _accelerator ) override;
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override;
+ virtual sal_Int32 SAL_CALL getBackColor() override;
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) override;
+ virtual sal_Bool SAL_CALL getAutoSize() override;
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) override;
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+ // XDefaultProperty
+ OUString SAL_CALL getDefaultPropertyName( ) override { return "Value"; }
+};
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBALABEL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx
new file mode 100644
index 000000000..40e4445f6
--- /dev/null
+++ b/vbahelper/source/msforms/vbalistbox.cxx
@@ -0,0 +1,275 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbalistbox.hxx"
+#include "vbanewfont.hxx"
+#include <comphelper/sequence.hxx>
+#include <ooo/vba/msforms/fmMultiSelect.hpp>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
+ : ListBoxImpl_BASE(xParent, xContext, xControl, xModel, std::move(pGeomHelper))
+ , m_nIndex(0)
+{
+ mpListHelper.reset( new ListControlHelper( m_xProps ) );
+}
+
+// Attributes
+void SAL_CALL
+ScVbaListBox::setListIndex( const uno::Any& _value )
+{
+ sal_Int32 nIndex = 0;
+ _value >>= nIndex;
+ uno::Reference< XPropValue > xPropVal( Selected( nIndex ), uno::UNO_QUERY_THROW );
+ xPropVal->setValue( uno::Any( true ) );
+}
+
+uno::Any SAL_CALL
+ScVbaListBox::getListIndex()
+{
+ uno::Sequence< sal_Int16 > sSelection;
+ m_xProps->getPropertyValue( "SelectedItems" ) >>= sSelection;
+ if ( !sSelection.hasElements() )
+ return uno::Any( sal_Int32( -1 ) );
+ return uno::Any( sSelection[ 0 ] );
+}
+
+uno::Any SAL_CALL
+ScVbaListBox::getValue()
+{
+ uno::Sequence< sal_Int16 > sSelection;
+ uno::Sequence< OUString > sItems;
+ m_xProps->getPropertyValue( "SelectedItems" ) >>= sSelection;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sItems;
+ if( getMultiSelect() )
+ throw uno::RuntimeException( "Attribute use invalid." );
+ uno::Any aRet;
+ if ( sSelection.hasElements() )
+ aRet <<= sItems[ sSelection[ 0 ] ];
+ return aRet;
+}
+
+void SAL_CALL
+ScVbaListBox::setValue( const uno::Any& _value )
+{
+ if( getMultiSelect() )
+ {
+ throw uno::RuntimeException( "Attribute use invalid." );
+ }
+ OUString sValue = getAnyAsString( _value );
+ uno::Sequence< OUString > sList;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sList;
+ sal_Int16 nValue = static_cast<sal_Int16>(comphelper::findValue(sList, sValue));
+ if( nValue == -1 )
+ throw uno::RuntimeException( "Attribute use invalid." );
+
+ uno::Sequence< sal_Int16 > nSelectedIndices { nValue };
+ uno::Sequence< sal_Int16 > nOldSelectedIndices;
+ m_xProps->getPropertyValue( "SelectedItems" ) >>= nOldSelectedIndices;
+ m_xProps->setPropertyValue( "SelectedItems", uno::Any( nSelectedIndices ) );
+ if ( nSelectedIndices != nOldSelectedIndices )
+ fireClickEvent();
+}
+
+OUString SAL_CALL
+ScVbaListBox::getText()
+{
+ OUString result;
+ getValue() >>= result;
+ return result;
+}
+
+void SAL_CALL
+ScVbaListBox::setText( const OUString& _text )
+{
+ setValue( uno::Any( _text ) ); // seems the same
+}
+
+sal_Int32 SAL_CALL
+ScVbaListBox::getMultiSelect()
+{
+ bool bMultiSelect = false;
+ m_xProps->getPropertyValue( "MultiSelection" ) >>= bMultiSelect;
+
+ return bMultiSelect ? msforms::fmMultiSelect::fmMultiSelectMulti : msforms::fmMultiSelect::fmMultiSelectSingle;
+}
+
+void SAL_CALL
+ScVbaListBox::setMultiSelect( sal_Int32 _multiselect )
+{
+ bool bBoolVal = false;
+ switch ( _multiselect )
+ {
+ case msforms::fmMultiSelect::fmMultiSelectMulti:
+ case msforms::fmMultiSelect::fmMultiSelectExtended:
+ bBoolVal = true;
+ break;
+ case msforms::fmMultiSelect::fmMultiSelectSingle:
+ bBoolVal = false;
+ break;
+ default:
+ throw lang::IllegalArgumentException();
+ break;
+ }
+ m_xProps->setPropertyValue( "MultiSelection" , uno::Any( bBoolVal ) );
+}
+
+
+css::uno::Any SAL_CALL
+ScVbaListBox::Selected( sal_Int32 index )
+{
+ uno::Sequence< OUString > sList;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= 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( "Error Number." );
+ m_nIndex = nIndex;
+ return uno::Any( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) );
+}
+
+// Methods
+void SAL_CALL
+ScVbaListBox::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex )
+{
+ mpListHelper->AddItem( pvargItem, pvargIndex );
+}
+
+void SAL_CALL
+ScVbaListBox::removeItem( const uno::Any& index )
+{
+ mpListHelper->removeItem( index );
+}
+
+void SAL_CALL
+ScVbaListBox::Clear( )
+{
+ 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 )
+{
+ bool bValue = false;
+ if( !(value >>= bValue) )
+ throw uno::RuntimeException( "Invalid type. need boolean." );
+ 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 )
+ {
+ auto pList = nList.getArray();
+ for( ; i < nLength - 1; i++ )
+ {
+ pList[i] = nList[i + 1];
+ }
+ nList.realloc( nLength - 1 );
+ //m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) );
+ fireClickEvent();
+ m_xProps->setPropertyValue( "SelectedItems", uno::Any( nList ) );
+ }
+ return;
+ }
+ }
+ if( !bValue )
+ return;
+
+ if( getMultiSelect() )
+ {
+ nList.realloc( nLength + 1 );
+ nList.getArray()[nLength] = nIndex;
+ }
+ else
+ {
+ nList = { nIndex };
+ }
+ //m_xProps->setPropertyValue( sSourceName, uno::makeAny( nList ) );
+ fireClickEvent();
+ m_xProps->setPropertyValue( "SelectedItems", uno::Any( 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( "SelectedItems" ) >>= nList;
+ sal_Int32 nIndex = m_nIndex;
+ bool bRet = std::find(std::cbegin(nList), std::cend(nList), nIndex) != std::cend(nList);
+
+ return uno::Any( bRet );
+}
+
+void SAL_CALL
+ScVbaListBox::setRowSource( const OUString& _rowsource )
+{
+ ScVbaControl::setRowSource( _rowsource );
+ mpListHelper->setRowSource( _rowsource );
+}
+
+sal_Int32 SAL_CALL
+ScVbaListBox::getListCount()
+{
+ return mpListHelper->getListCount();
+}
+
+uno::Any SAL_CALL
+ScVbaListBox::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn )
+{
+ return mpListHelper->List( pvargIndex, pvarColumn );
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaListBox::getFont()
+{
+ return new VbaNewFont( m_xProps );
+}
+
+OUString
+ScVbaListBox::getServiceImplName()
+{
+ return "ScVbaListBox";
+}
+
+uno::Sequence< OUString >
+ScVbaListBox::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.ScVbaListBox"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbalistbox.hxx b/vbahelper/source/msforms/vbalistbox.hxx
new file mode 100644
index 000000000..b87f9e74f
--- /dev/null
+++ b/vbahelper/source/msforms/vbalistbox.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBALISTBOX_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBALISTBOX_HXX
+#include <memory>
+#include <cppuhelper/implbase.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::ImplInheritanceHelper<ScVbaControl, ov::msforms::XListBox, css::script::XDefaultProperty > ListBoxImpl_BASE;
+class ScVbaListBox : public ListBoxImpl_BASE
+ ,public PropListener
+{
+ std::unique_ptr< ListControlHelper > mpListHelper;
+
+ 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+
+ // Attributes
+ virtual css::uno::Any SAL_CALL getListIndex() override;
+ virtual void SAL_CALL setListIndex( const css::uno::Any& _value ) override;
+ virtual ::sal_Int32 SAL_CALL getListCount() override;
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
+ virtual OUString SAL_CALL getText() override;
+ virtual void SAL_CALL setText( const OUString& _text ) override;
+ virtual sal_Int32 SAL_CALL getMultiSelect() override;
+ virtual void SAL_CALL setMultiSelect( sal_Int32 _multiselect ) override;
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override;
+
+ // Methods
+ virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) override;
+ virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) override;
+ virtual void SAL_CALL removeItem( const css::uno::Any& index ) override;
+ virtual void SAL_CALL Clear( ) override;
+ virtual css::uno::Any SAL_CALL List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn ) override;
+ // XControl
+ virtual void SAL_CALL setRowSource( const OUString& _rowsource ) override;
+
+ // XDefaultProperty
+ OUString SAL_CALL getDefaultPropertyName( ) override { return "Value"; }
+
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+
+ //PropListener
+ virtual void setValueEvent( const css::uno::Any& value ) override;
+ virtual css::uno::Any getValueEvent() override;
+
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.cxx b/vbahelper/source/msforms/vbalistcontrolhelper.cxx
new file mode 100644
index 000000000..71f5e2c42
--- /dev/null
+++ b/vbahelper/source/msforms/vbalistcontrolhelper.cxx
@@ -0,0 +1,190 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbalistcontrolhelper.hxx"
+#include <vector>
+#include <vbahelper/vbapropvalue.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/sequence.hxx>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+namespace {
+
+class ListPropListener : public PropListener
+{
+private:
+ uno::Reference< beans::XPropertySet > m_xProps;
+ uno::Any m_pvargIndex;
+ uno::Any m_pvarColumn;
+
+public:
+ ListPropListener( const uno::Reference< beans::XPropertySet >& xProps, const uno::Any& pvargIndex, const uno::Any& pvarColumn );
+ virtual ~ListPropListener() { };
+ virtual void setValueEvent( const css::uno::Any& value ) override;
+ virtual css::uno::Any getValueEvent() override;
+};
+
+}
+
+ListPropListener::ListPropListener( const uno::Reference< beans::XPropertySet >& xProps, const uno::Any& pvargIndex, const uno::Any& pvarColumn ) : m_xProps( xProps ), m_pvargIndex( pvargIndex ), m_pvarColumn( pvarColumn )
+{
+}
+
+void ListPropListener::setValueEvent( const uno::Any& value )
+{
+ if( m_pvargIndex.hasValue() || m_pvarColumn.hasValue() )
+ throw uno::RuntimeException( "Bad argument" );
+
+ m_xProps->setPropertyValue( "StringItemList", value );
+}
+
+uno::Any ListPropListener::getValueEvent()
+{
+ uno::Sequence< OUString > sList;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sList;
+ sal_Int16 nLength = static_cast< sal_Int16 >( sList.getLength() );
+ uno::Any aRet;
+ if ( m_pvargIndex.hasValue() )
+ {
+ sal_Int16 nIndex = -1;
+ m_pvargIndex >>= nIndex;
+ if( nIndex < 0 || nIndex >= nLength )
+ throw uno::RuntimeException( "Bad row Index" );
+ aRet <<= sList[ nIndex ];
+ }
+ else if ( m_pvarColumn.hasValue() ) // pvarColumn on its own would be bad
+ throw uno::RuntimeException( "Bad column Index" );
+ else // List() ( e.g. no args )
+ {
+ uno::Sequence< uno::Sequence< OUString > > sReturnArray( nLength );
+ auto pReturnArray = sReturnArray.getArray();
+ for ( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ pReturnArray[ i ].realloc( 10 );
+ pReturnArray[ i ].getArray()[ 0 ] = sList[ i ];
+ }
+ aRet <<= sReturnArray;
+ }
+ return aRet;
+}
+
+void
+ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargIndex )
+{
+ if ( !pvargItem.hasValue() )
+ return;
+
+ uno::Sequence< OUString > sList;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sList;
+
+ sal_Int32 nIndex = sList.getLength();
+
+ if ( pvargIndex.hasValue() )
+ pvargIndex >>= nIndex;
+
+ 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.getArray()[ nOldSize ] = sString;
+ }
+ else
+ {
+ // just copy those elements above the one to be inserted
+ std::vector< OUString > sVec;
+ // reserve just the amount we need to copy
+ sVec.reserve( sList.getLength() - nIndex + 1);
+
+ // insert the new element
+ sVec.push_back( sString );
+
+ // point at first element to copy
+ sVec.insert( sVec.end(), std::next(std::cbegin(sList), nIndex), std::cend(sList) );
+
+ sList.realloc( sList.getLength() + 1 );
+
+ // point at first element to be overwritten
+ std::copy(sVec.begin(), sVec.end(), std::next(sList.getArray(), nIndex));
+ }
+
+ m_xProps->setPropertyValue( "StringItemList", uno::Any( sList ) );
+}
+
+void
+ListControlHelper::removeItem( const uno::Any& index )
+{
+ sal_Int32 nIndex = 0;
+ // for int index
+ if ( !(index >>= nIndex) )
+ return;
+
+ uno::Sequence< OUString > sList;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sList;
+ if( nIndex < 0 || nIndex > ( sList.getLength() - 1 ) )
+ throw uno::RuntimeException( "Invalid index" , uno::Reference< uno::XInterface > () );
+ if( sList.hasElements() )
+ {
+ if( sList.getLength() == 1 )
+ {
+ Clear();
+ return;
+ }
+
+ comphelper::removeElementAt(sList, nIndex);
+ }
+
+ m_xProps->setPropertyValue( "StringItemList", uno::Any( sList ) );
+}
+
+void
+ListControlHelper::Clear( )
+{
+ // urk, setValue doesn't seem to work !!
+ //setValue( uno::makeAny( sal_Int16() ) );
+ m_xProps->setPropertyValue( "StringItemList", uno::Any( uno::Sequence< OUString >() ) );
+}
+
+void
+ListControlHelper::setRowSource( std::u16string_view _rowsource )
+{
+ if ( _rowsource.empty() )
+ Clear();
+}
+
+sal_Int32
+ListControlHelper::getListCount()
+{
+ uno::Sequence< OUString > sList;
+ m_xProps->getPropertyValue( "StringItemList" ) >>= sList;
+ return sList.getLength();
+}
+
+uno::Any
+ListControlHelper::List( const ::uno::Any& pvargIndex, const uno::Any& pvarColumn )
+{
+ return uno::Any( uno::Reference< XPropValue > ( new ScVbaPropValue( new ListPropListener( m_xProps, pvargIndex, pvarColumn ) ) ) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.hxx b/vbahelper/source/msforms/vbalistcontrolhelper.hxx
new file mode 100644
index 000000000..e80ba3e85
--- /dev/null
+++ b/vbahelper/source/msforms/vbalistcontrolhelper.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBALISTCONTROLHELPER_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBALISTCONTROLHELPER_HXX
+
+#include <vbahelper/vbahelper.hxx>
+
+class ListControlHelper final
+{
+ css::uno::Reference< css::beans::XPropertySet > m_xProps;
+
+public:
+ explicit ListControlHelper( const css::uno::Reference< css::beans::XPropertySet >& rxControl ) : m_xProps( rxControl ){}
+ /// @throws css::uno::RuntimeException
+ void AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex );
+ /// @throws css::uno::RuntimeException
+ void removeItem( const css::uno::Any& index );
+ /// @throws css::uno::RuntimeException
+ void setRowSource( std::u16string_view _rowsource );
+ /// @throws css::uno::RuntimeException
+ ::sal_Int32 getListCount();
+ /// @throws css::uno::RuntimeException
+ css::uno::Any List( const css::uno::Any& pvargIndex, const css::uno::Any& pvarColumn );
+ /// @throws css::uno::RuntimeException
+ void Clear( );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx
new file mode 100644
index 000000000..183a93b66
--- /dev/null
+++ b/vbahelper/source/msforms/vbamultipage.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "vbamultipage.hxx"
+#include <ooo/vba/XCollection.hpp>
+#include "vbapages.hxx"
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <cppuhelper/implbase.hxx>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+constexpr OUStringLiteral SVALUE( u"MultiPageValue" );
+
+namespace {
+
+class PagesImpl : public cppu::WeakImplHelper< container::XIndexAccess >
+{
+ sal_Int32 mnPages;
+public:
+ explicit PagesImpl( sal_Int32 nPages ) : mnPages( nPages ) {}
+ virtual ::sal_Int32 SAL_CALL getCount() override { return mnPages; }
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
+ {
+ if ( Index < 0 || Index > mnPages )
+ throw lang::IndexOutOfBoundsException();
+ return uno::Any( uno::Reference< uno::XInterface >() );
+ }
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() override
+ {
+ // no Pages object yet #FIXME
+ //return cppu::UnoType<msforms::XPage>::get();
+ return cppu::UnoType<uno::XInterface>::get();
+ }
+ virtual sal_Bool SAL_CALL hasElements( ) override
+ {
+ return ( mnPages > 0 );
+ }
+};
+
+}
+
+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,
+ std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper) :
+ MultiPageImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+}
+
+// Attributes
+sal_Int32 SAL_CALL
+ScVbaMultiPage::getValue()
+{
+ sal_Int32 nValue = 0;
+ m_xProps->getPropertyValue( SVALUE ) >>= nValue;
+ // VBA 0 based tab index
+ return nValue - 1;
+}
+
+void SAL_CALL
+ScVbaMultiPage::setValue( const sal_Int32 _value )
+{
+ // Openoffice 1 based tab index
+ sal_Int32 nVal = _value + 1;
+ sal_Int32 nOldVal = getValue();
+ m_xProps->setPropertyValue( SVALUE, uno::Any( nVal ) );
+ if ( nVal != nOldVal )
+ fireChangeEvent();
+}
+
+OUString
+ScVbaMultiPage::getServiceImplName()
+{
+ return "ScVbaMultiPage";
+}
+
+uno::Any SAL_CALL
+ScVbaMultiPage::Pages( const uno::Any& index )
+{
+ // get the container model
+ uno::Reference< container::XNameContainer > xContainer( m_xProps, uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, new PagesImpl( xContainer->getElementNames().getLength() ) ) );
+ if ( !index.hasValue() )
+ return uno::Any( xColl );
+ return xColl->Item( index, uno::Any() );
+}
+
+uno::Sequence< OUString >
+ScVbaMultiPage::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.MultiPage"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbamultipage.hxx b/vbahelper/source/msforms/vbamultipage.hxx
new file mode 100644
index 000000000..45c861105
--- /dev/null
+++ b/vbahelper/source/msforms/vbamultipage.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAMULTIPAGE_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAMULTIPAGE_HXX
+
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XMultiPage.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< ScVbaControl, ov::msforms::XMultiPage > MultiPageImpl_BASE;
+
+class ScVbaMultiPage : public MultiPageImpl_BASE
+{
+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,
+ std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper);
+
+ // Attributes
+ virtual sal_Int32 SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( sal_Int32 _value ) override;
+ virtual css::uno::Any SAL_CALL Pages( const css::uno::Any& index ) override;
+
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAMULTIPAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbanewfont.cxx b/vbahelper/source/msforms/vbanewfont.cxx
new file mode 100644
index 000000000..b966d8454
--- /dev/null
+++ b/vbahelper/source/msforms/vbanewfont.cxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <rtl/tencinfo.h>
+#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>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+
+VbaNewFont::VbaNewFont(
+ const uno::Reference< beans::XPropertySet >& rxModelProps ) :
+ mxProps( rxModelProps, uno::UNO_SET_THROW )
+{
+}
+
+// XNewFont attributes
+
+OUString SAL_CALL VbaNewFont::getName()
+{
+ uno::Any aAny = mxProps->getPropertyValue( "FontName" );
+ return aAny.get< OUString >();
+}
+
+void SAL_CALL VbaNewFont::setName( const OUString& rName )
+{
+ mxProps->setPropertyValue( "FontName" , uno::Any( rName ) );
+}
+
+double SAL_CALL VbaNewFont::getSize()
+{
+ uno::Any aAny = mxProps->getPropertyValue( "FontHeight" );
+ return aAny.get< float >();
+}
+
+void SAL_CALL VbaNewFont::setSize( double fSize )
+{
+ mxProps->setPropertyValue( "FontHeight" , uno::Any( static_cast< float >( fSize ) ) );
+}
+
+sal_Int16 SAL_CALL VbaNewFont::getCharset()
+{
+ uno::Any aAny = mxProps->getPropertyValue( "FontCharset" );
+ return rtl_getBestWindowsCharsetFromTextEncoding( static_cast< rtl_TextEncoding >( aAny.get< sal_Int16 >() ) );
+}
+
+void SAL_CALL VbaNewFont::setCharset( sal_Int16 nCharset )
+{
+ 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("an unknown or missing encoding");
+ mxProps->setPropertyValue( "FontCharset" , uno::Any( static_cast< sal_Int16 >( eFontEnc ) ) );
+}
+
+sal_Int16 SAL_CALL VbaNewFont::getWeight()
+{
+ return getBold() ? 700 : 400;
+}
+
+void SAL_CALL VbaNewFont::setWeight( sal_Int16 nWeight )
+{
+ setBold( nWeight >= 700 );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getBold()
+{
+ uno::Any aAny = mxProps->getPropertyValue( "FontWeight" );
+ return aAny.get< float >() > awt::FontWeight::NORMAL;
+}
+
+void SAL_CALL VbaNewFont::setBold( sal_Bool bBold )
+{
+ mxProps->setPropertyValue( "FontWeight" , uno::Any( bBold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getItalic()
+{
+ uno::Any aAny = mxProps->getPropertyValue( "FontSlant" );
+ return aAny.get< awt::FontSlant >() != awt::FontSlant_NONE;
+}
+
+void SAL_CALL VbaNewFont::setItalic( sal_Bool bItalic )
+{
+ mxProps->setPropertyValue( "FontSlant" , uno::Any( bItalic ? awt::FontSlant_ITALIC : awt::FontSlant_NONE ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getUnderline()
+{
+ uno::Any aAny = mxProps->getPropertyValue("FontUnderline" );
+ return aAny.get< sal_Int16 >() != awt::FontUnderline::NONE;
+}
+
+void SAL_CALL VbaNewFont::setUnderline( sal_Bool bUnderline )
+{
+ mxProps->setPropertyValue("FontUnderline" , uno::Any( bUnderline ? awt::FontUnderline::SINGLE : awt::FontUnderline::NONE ) );
+}
+
+sal_Bool SAL_CALL VbaNewFont::getStrikethrough()
+{
+ uno::Any aAny = mxProps->getPropertyValue( "FontStrikeout" );
+ return aAny.get< sal_Int16 >() != awt::FontStrikeout::NONE;
+}
+
+void SAL_CALL VbaNewFont::setStrikethrough( sal_Bool bStrikethrough )
+{
+ mxProps->setPropertyValue( "FontStrikeout" ,uno::Any( bStrikethrough ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbanewfont.hxx b/vbahelper/source/msforms/vbanewfont.hxx
new file mode 100644
index 000000000..fb928f9e0
--- /dev/null
+++ b/vbahelper/source/msforms/vbanewfont.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBANEWFONT_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBANEWFONT_HXX
+
+#include <ooo/vba/msforms/XNewFont.hpp>
+#include <vbahelper/vbahelper.hxx>
+#include <cppuhelper/implbase.hxx>
+
+class VbaNewFont : public cppu::WeakImplHelper<ov::msforms::XNewFont>
+{
+public:
+ /// @throws css::uno::RuntimeException
+ explicit VbaNewFont(const css::uno::Reference<css::beans::XPropertySet>& rxModelProps);
+
+ // XNewFont attributes
+ virtual OUString SAL_CALL getName() override;
+ virtual void SAL_CALL setName(const OUString& rName) override;
+ virtual double SAL_CALL getSize() override;
+ virtual void SAL_CALL setSize(double fSize) override;
+ virtual sal_Int16 SAL_CALL getCharset() override;
+ virtual void SAL_CALL setCharset(sal_Int16 nCharset) override;
+ virtual sal_Int16 SAL_CALL getWeight() override;
+ virtual void SAL_CALL setWeight(sal_Int16 nWeight) override;
+ virtual sal_Bool SAL_CALL getBold() override;
+ virtual void SAL_CALL setBold(sal_Bool bBold) override;
+ virtual sal_Bool SAL_CALL getItalic() override;
+ virtual void SAL_CALL setItalic(sal_Bool bItalic) override;
+ virtual sal_Bool SAL_CALL getUnderline() override;
+ virtual void SAL_CALL setUnderline(sal_Bool bUnderline) override;
+ virtual sal_Bool SAL_CALL getStrikethrough() override;
+ virtual void SAL_CALL setStrikethrough(sal_Bool bStrikethrough) override;
+
+private:
+ css::uno::Reference<css::beans::XPropertySet> mxProps;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbapages.cxx b/vbahelper/source/msforms/vbapages.cxx
new file mode 100644
index 000000000..05e0f25c1
--- /dev/null
+++ b/vbahelper/source/msforms/vbapages.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#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 ) : ScVbaPages_BASE( xParent, xContext, xPages )
+{
+}
+
+uno::Type SAL_CALL
+ScVbaPages::getElementType()
+{
+ // return cppu::UnoType<msforms::XPage>::get();
+ return cppu::UnoType<uno::XInterface>::get();
+}
+
+uno::Any
+ScVbaPages::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource;
+}
+
+OUString
+ScVbaPages::getServiceImplName()
+{
+ return "ScVbaPages";
+}
+
+uno::Reference< container::XEnumeration > SAL_CALL
+ScVbaPages::createEnumeration()
+{
+ // #STUB
+ return uno::Reference< container::XEnumeration >();
+}
+
+uno::Sequence< OUString >
+ScVbaPages::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msform.Pages"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbapages.hxx b/vbahelper/source/msforms/vbapages.hxx
new file mode 100644
index 000000000..cc42da280
--- /dev/null
+++ b/vbahelper/source/msforms/vbapages.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAPAGES_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAPAGES_HXX
+
+#include <ooo/vba/msforms/XPages.hpp>
+
+#include <vbahelper/vbacollectionimpl.hxx>
+typedef CollTestImplHelper<
+ov::msforms::XPages > ScVbaPages_BASE;
+
+class ScVbaPages : public ScVbaPages_BASE
+{
+protected:
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+public:
+ /// @throws css::lang::IllegalArgumentException
+ ScVbaPages( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xPages );
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() override;
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
+ // ScVbaPages_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) override;
+
+};
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAPAGES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaprogressbar.cxx b/vbahelper/source/msforms/vbaprogressbar.cxx
new file mode 100644
index 000000000..f988112b5
--- /dev/null
+++ b/vbahelper/source/msforms/vbaprogressbar.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "vbaprogressbar.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+// uno servicename com.sun.star.awt.UnoControlProgressBarMode
+constexpr OUStringLiteral SVALUE( u"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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
+ : ProgressBarImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+}
+
+// Attributes
+uno::Any SAL_CALL
+ScVbaProgressBar::getValue()
+{
+ return m_xProps->getPropertyValue( SVALUE );
+}
+
+void SAL_CALL
+ScVbaProgressBar::setValue( const uno::Any& _value )
+{
+ m_xProps->setPropertyValue( SVALUE, _value );
+}
+
+OUString
+ScVbaProgressBar::getServiceImplName()
+{
+ return "ScVbaProgressBar";
+}
+
+uno::Sequence< OUString >
+ScVbaProgressBar::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.Label"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaprogressbar.hxx b/vbahelper/source/msforms/vbaprogressbar.hxx
new file mode 100644
index 000000000..8385ce457
--- /dev/null
+++ b/vbahelper/source/msforms/vbaprogressbar.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAPROGRESSBAR_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAPROGRESSBAR_HXX
+
+#include <ooo/vba/msforms/XProgressBar.hpp>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <cppuhelper/implbase.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+ // XDefaultProperty
+ OUString SAL_CALL getDefaultPropertyName( ) override { return "Value"; }
+};
+
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAPROGRESSBAR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaradiobutton.cxx b/vbahelper/source/msforms/vbaradiobutton.cxx
new file mode 100644
index 000000000..7a3e624bf
--- /dev/null
+++ b/vbahelper/source/msforms/vbaradiobutton.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbaradiobutton.hxx"
+#include "vbanewfont.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
+ : RadioButtonImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+}
+
+// Attributes
+OUString SAL_CALL
+ScVbaRadioButton::getCaption()
+{
+ OUString Label;
+ m_xProps->getPropertyValue( "Label" ) >>= Label;
+ return Label;
+}
+
+void SAL_CALL
+ScVbaRadioButton::setCaption( const OUString& _caption )
+{
+ m_xProps->setPropertyValue( "Label", uno::Any( _caption ) );
+}
+
+uno::Any SAL_CALL
+ScVbaRadioButton::getValue()
+{
+ 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::Any( nValue == -1 );
+
+}
+
+void SAL_CALL
+ScVbaRadioButton::setValue( const uno::Any& _value )
+{
+ sal_Int16 nValue = 0;
+ sal_Int16 nOldValue = 0;
+ m_xProps->getPropertyValue( "State" ) >>= nOldValue;
+
+ if( !( _value >>= nValue ) )
+ {
+ bool bValue = false;
+ _value >>= bValue;
+ if ( bValue )
+ nValue = -1;
+ }
+
+ if( nValue == -1)
+ nValue = 1;
+ m_xProps->setPropertyValue( "State", uno::Any( nValue ) );
+ if ( nValue != nOldValue )
+ {
+ fireChangeEvent();
+ // In Excel, only when the radio button is checked, the click event is fired.
+ if ( nValue != 0 )
+ {
+ fireClickEvent();
+ }
+ }
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaRadioButton::getFont()
+{
+ return new VbaNewFont( m_xProps );
+}
+
+OUString
+ScVbaRadioButton::getServiceImplName()
+{
+ return "ScVbaRadioButton";
+}
+
+uno::Sequence< OUString >
+ScVbaRadioButton::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.RadioButton"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaradiobutton.hxx b/vbahelper/source/msforms/vbaradiobutton.hxx
new file mode 100644
index 000000000..a6f12ae90
--- /dev/null
+++ b/vbahelper/source/msforms/vbaradiobutton.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBARADIOBUTTON_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBARADIOBUTTON_HXX
+#include <ooo/vba/msforms/XRadioButton.hpp>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <cppuhelper/implbase.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+ // Attributes
+ virtual OUString SAL_CALL getCaption() override;
+ virtual void SAL_CALL setCaption( const OUString& _caption ) override;
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue(const css::uno::Any&) override;
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override;
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+ // XDefaultProperty
+ OUString SAL_CALL getDefaultPropertyName( ) override { return "Value"; }
+
+};
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBARADIOBUTTON_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbascrollbar.cxx b/vbahelper/source/msforms/vbascrollbar.cxx
new file mode 100644
index 000000000..229bfad51
--- /dev/null
+++ b/vbahelper/source/msforms/vbascrollbar.cxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbascrollbar.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+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, std::unique_ptr<AbstractGeometryAttributes> pGeomHelper )
+ : ScrollBarImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+}
+
+// Attributes
+uno::Any SAL_CALL
+ScVbaScrollBar::getValue()
+{
+ return m_xProps->getPropertyValue( "ScrollValue" );
+}
+
+void SAL_CALL
+ScVbaScrollBar::setValue( const uno::Any& _value )
+{
+ m_xProps->setPropertyValue( "ScrollValue", _value );
+}
+
+::sal_Int32 SAL_CALL
+ScVbaScrollBar::getMax()
+{
+ sal_Int32 nMax = 0;
+ m_xProps->getPropertyValue( "ScrollValueMax" ) >>= nMax;
+ return nMax;
+}
+
+void SAL_CALL
+ScVbaScrollBar::setMax( sal_Int32 nVal )
+{
+ m_xProps->setPropertyValue( "ScrollValueMax", uno::Any( nVal ) );
+}
+
+::sal_Int32 SAL_CALL
+ScVbaScrollBar::getMin()
+{
+ sal_Int32 nVal = 0;
+ m_xProps->getPropertyValue( "ScrollValueMin" ) >>= nVal;
+ return nVal;
+}
+
+void SAL_CALL
+ScVbaScrollBar::setMin( sal_Int32 nVal )
+{
+ m_xProps->setPropertyValue( "ScrollValueMin", uno::Any( nVal ) );
+}
+
+void SAL_CALL
+ScVbaScrollBar::setLargeChange( ::sal_Int32 _largechange )
+{
+ m_xProps->setPropertyValue( "BlockIncrement", uno::Any( _largechange ) );
+}
+
+::sal_Int32 SAL_CALL
+ScVbaScrollBar::getLargeChange()
+{
+ sal_Int32 nVal = 0;
+ m_xProps->getPropertyValue( "BlockIncrement" ) >>= nVal;
+ return nVal;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaScrollBar::getSmallChange()
+{
+ sal_Int32 nSmallChange = 0;
+ m_xProps->getPropertyValue( "LineIncrement" ) >>= nSmallChange;
+ return nSmallChange;
+}
+
+void SAL_CALL
+ScVbaScrollBar::setSmallChange( ::sal_Int32 _smallchange )
+{
+ m_xProps->setPropertyValue( "LineIncrement", uno::Any( _smallchange ) );
+}
+
+OUString
+ScVbaScrollBar::getServiceImplName()
+{
+ return "ScVbaScrollBar";
+}
+
+uno::Sequence< OUString >
+ScVbaScrollBar::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.Frame"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbascrollbar.hxx b/vbahelper/source/msforms/vbascrollbar.hxx
new file mode 100644
index 000000000..e695e36b3
--- /dev/null
+++ b/vbahelper/source/msforms/vbascrollbar.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBASCROLLBAR_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBASCROLLBAR_HXX
+
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XScrollBar.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
+ virtual ::sal_Int32 SAL_CALL getMax() override;
+ virtual void SAL_CALL setMax( ::sal_Int32 _max ) override;
+ virtual ::sal_Int32 SAL_CALL getMin() override;
+ virtual void SAL_CALL setMin( ::sal_Int32 _min ) override;
+ virtual ::sal_Int32 SAL_CALL getLargeChange() override;
+ virtual void SAL_CALL setLargeChange( ::sal_Int32 _largechange ) override;
+ virtual ::sal_Int32 SAL_CALL getSmallChange() override;
+ virtual void SAL_CALL setSmallChange( ::sal_Int32 _smallchange ) override;
+
+
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBASCROLLBAR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaspinbutton.cxx b/vbahelper/source/msforms/vbaspinbutton.cxx
new file mode 100644
index 000000000..07514a46a
--- /dev/null
+++ b/vbahelper/source/msforms/vbaspinbutton.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbaspinbutton.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+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, std::unique_ptr<AbstractGeometryAttributes> pGeomHelper )
+ : SpinButtonImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+}
+
+// Attributes
+uno::Any SAL_CALL
+ScVbaSpinButton::getValue()
+{
+ return m_xProps->getPropertyValue( "SpinValue" );
+}
+
+void SAL_CALL
+ScVbaSpinButton::setValue( const uno::Any& _value )
+{
+ m_xProps->setPropertyValue( "SpinValue", _value );
+}
+
+::sal_Int32 SAL_CALL
+ScVbaSpinButton::getMax()
+{
+ sal_Int32 nMax = 0;
+ m_xProps->getPropertyValue( "SpinValueMax" ) >>= nMax;
+ return nMax;
+}
+
+void SAL_CALL
+ScVbaSpinButton::setMax( sal_Int32 nVal )
+{
+ m_xProps->setPropertyValue( "SpinValueMax", uno::Any( nVal ) );
+}
+
+::sal_Int32 SAL_CALL
+ScVbaSpinButton::getMin()
+{
+ sal_Int32 nVal = 0;
+ m_xProps->getPropertyValue( "SpinValueMin" ) >>= nVal;
+ return nVal;
+}
+
+void SAL_CALL
+ScVbaSpinButton::setMin( sal_Int32 nVal )
+{
+ m_xProps->setPropertyValue( "SpinValueMin", uno::Any( nVal ) );
+}
+
+OUString
+ScVbaSpinButton::getServiceImplName()
+{
+ return "ScVbaSpinButton";
+}
+
+uno::Sequence< OUString >
+ScVbaSpinButton::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.Frame"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaspinbutton.hxx b/vbahelper/source/msforms/vbaspinbutton.hxx
new file mode 100644
index 000000000..38f619679
--- /dev/null
+++ b/vbahelper/source/msforms/vbaspinbutton.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBASPINBUTTON_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBASPINBUTTON_HXX
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XSpinButton.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
+ virtual ::sal_Int32 SAL_CALL getMax() override;
+ virtual void SAL_CALL setMax( ::sal_Int32 _max ) override;
+ virtual ::sal_Int32 SAL_CALL getMin() override;
+ virtual void SAL_CALL setMin( ::sal_Int32 _min ) override;
+
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBASPINBUTTON_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbasystemaxcontrol.cxx b/vbahelper/source/msforms/vbasystemaxcontrol.cxx
new file mode 100644
index 000000000..ea135e270
--- /dev/null
+++ b/vbahelper/source/msforms/vbasystemaxcontrol.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#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, std::unique_ptr<AbstractGeometryAttributes> pGeomHelper )
+: SystemAXControlImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+, m_xControlInvocation( xControl, uno::UNO_QUERY_THROW )
+{
+}
+
+
+uno::Reference< beans::XIntrospectionAccess > SAL_CALL VbaSystemAXControl::getIntrospection()
+{
+ return m_xControlInvocation->getIntrospection();
+}
+
+
+uno::Any SAL_CALL VbaSystemAXControl::invoke( const OUString& aFunctionName, const uno::Sequence< uno::Any >& aParams, uno::Sequence< ::sal_Int16 >& aOutParamIndex, uno::Sequence< uno::Any >& aOutParam )
+{
+ return m_xControlInvocation->invoke( aFunctionName, aParams, aOutParamIndex, aOutParam );
+}
+
+
+void SAL_CALL VbaSystemAXControl::setValue( const OUString& aPropertyName, const uno::Any& aValue )
+{
+ m_xControlInvocation->setValue( aPropertyName, aValue );
+}
+
+
+uno::Any SAL_CALL VbaSystemAXControl::getValue( const OUString& aPropertyName )
+{
+ return m_xControlInvocation->getValue( aPropertyName );
+}
+
+
+sal_Bool SAL_CALL VbaSystemAXControl::hasMethod( const OUString& aName )
+{
+ return m_xControlInvocation->hasMethod( aName );
+}
+
+
+sal_Bool SAL_CALL VbaSystemAXControl::hasProperty( const OUString& aName )
+{
+ return m_xControlInvocation->hasProperty( aName );
+}
+
+
+OUString
+VbaSystemAXControl::getServiceImplName()
+{
+ return "VbaSystemAXControl";
+}
+
+
+uno::Sequence< OUString >
+VbaSystemAXControl::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.Frame"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbasystemaxcontrol.hxx b/vbahelper/source/msforms/vbasystemaxcontrol.hxx
new file mode 100644
index 000000000..40f575c8b
--- /dev/null
+++ b/vbahelper/source/msforms/vbasystemaxcontrol.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBASYSTEMAXCONTROL_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBASYSTEMAXCONTROL_HXX
+
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/script/XInvocation.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+
+ // XInvocation
+ virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) override;
+ virtual css::uno::Any SAL_CALL invoke( const OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) override;
+ virtual void SAL_CALL setValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
+ virtual css::uno::Any SAL_CALL getValue( const OUString& aPropertyName ) override;
+ virtual sal_Bool SAL_CALL hasMethod( const OUString& aName ) override;
+ virtual sal_Bool SAL_CALL hasProperty( const OUString& aName ) override;
+
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx
new file mode 100644
index 000000000..f01e9dc1d
--- /dev/null
+++ b/vbahelper/source/msforms/vbatextbox.cxx
@@ -0,0 +1,183 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#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, std::unique_ptr<AbstractGeometryAttributes> pGeomHelper, bool bDialog )
+ : TextBoxImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) ), mbDialog( bDialog )
+{
+}
+
+// Attributes
+uno::Any SAL_CALL
+ScVbaTextBox::getValue()
+{
+ return uno::Any( getText() );
+}
+
+void SAL_CALL
+ScVbaTextBox::setValue( const uno::Any& _value )
+{
+ // booleans are converted to uppercase strings
+ OUString sVal = extractStringFromAny( _value, true );
+ setText( sVal );
+}
+
+//getString() will cause some info lose.
+OUString SAL_CALL
+ScVbaTextBox::getText()
+{
+ uno::Any aValue = m_xProps->getPropertyValue( "Text" );
+ OUString sString;
+ aValue >>= sString;
+ return sString;
+}
+
+void SAL_CALL
+ScVbaTextBox::setText( const OUString& _text )
+{
+ OUString oldText( getText() );
+ if ( !mbDialog )
+ {
+ uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW );
+ xTextRange->setString( _text );
+ }
+ else
+ m_xProps->setPropertyValue( "Text" , uno::Any( _text ) );
+ if ( oldText != _text )
+ fireChangeEvent();
+}
+
+sal_Int32 SAL_CALL
+ScVbaTextBox::getMaxLength()
+{
+ uno::Any aValue = m_xProps->getPropertyValue( "MaxTextLen" );
+ sal_Int16 nMaxLength = 0;
+ aValue >>= nMaxLength;
+ return static_cast<sal_Int32>(nMaxLength);
+}
+
+void SAL_CALL
+ScVbaTextBox::setMaxLength( sal_Int32 _maxlength )
+{
+ sal_Int16 nTmp( _maxlength );
+ uno::Any aValue( nTmp );
+ m_xProps->setPropertyValue( "MaxTextLen" , aValue);
+}
+
+sal_Bool SAL_CALL
+ScVbaTextBox::getMultiline()
+{
+ uno::Any aValue = m_xProps->getPropertyValue( "MultiLine" );
+ bool bRet = false;
+ aValue >>= bRet;
+ return bRet;
+}
+
+void SAL_CALL
+ScVbaTextBox::setMultiline( sal_Bool _multiline )
+{
+ uno::Any aValue( _multiline );
+ m_xProps->setPropertyValue( "MultiLine" , aValue);
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect()
+{
+ return msforms::fmSpecialEffect::fmSpecialEffectSunken;
+}
+
+void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ )
+{
+ // #STUB
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle()
+{
+ return msforms::fmBorderStyle::fmBorderStyleNone;
+}
+
+void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ )
+{
+ // #STUB
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getTextLength()
+{
+ return getText().getLength();
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont()
+{
+ return new VbaNewFont( m_xProps );
+}
+
+sal_Int32 SAL_CALL ScVbaTextBox::getBackColor()
+{
+ return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaTextBox::setBackColor( sal_Int32 nBackColor )
+{
+ ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Bool SAL_CALL ScVbaTextBox::getAutoSize()
+{
+ return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaTextBox::setAutoSize( sal_Bool bAutoSize )
+{
+ ScVbaControl::setAutoSize( bAutoSize );
+}
+
+sal_Bool SAL_CALL ScVbaTextBox::getLocked()
+{
+ return ScVbaControl::getLocked();
+}
+
+void SAL_CALL ScVbaTextBox::setLocked( sal_Bool bLocked )
+{
+ ScVbaControl::setLocked( bLocked );
+}
+
+OUString
+ScVbaTextBox::getServiceImplName()
+{
+ return "ScVbaTextBox";
+}
+
+uno::Sequence< OUString >
+ScVbaTextBox::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.TextBox"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx
new file mode 100644
index 000000000..9a2b96942
--- /dev/null
+++ b/vbahelper/source/msforms/vbatextbox.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBATEXTBOX_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBATEXTBOX_HXX
+
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XTextBox.hpp>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper, bool bDialog = false );
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
+ virtual OUString SAL_CALL getText() override;
+ virtual void SAL_CALL setText( const OUString& _text ) override;
+ virtual sal_Int32 SAL_CALL getMaxLength() override;
+ virtual void SAL_CALL setMaxLength( sal_Int32 _maxlength ) override;
+ virtual sal_Bool SAL_CALL getMultiline() override;
+ virtual void SAL_CALL setMultiline( sal_Bool _multiline ) override;
+ virtual sal_Int32 SAL_CALL getSpecialEffect() override;
+ virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) override;
+ virtual sal_Int32 SAL_CALL getBorderStyle() override;
+ virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) override;
+ virtual sal_Int32 SAL_CALL getTextLength() override;
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override;
+ virtual sal_Int32 SAL_CALL getBackColor() override;
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) override;
+ virtual sal_Bool SAL_CALL getAutoSize() override;
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) override;
+ virtual sal_Bool SAL_CALL getLocked() override;
+ virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) override;
+
+ // XDefaultProperty
+ OUString SAL_CALL getDefaultPropertyName( ) override { return "Value"; }
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBATEXTBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx
new file mode 100644
index 000000000..07008541f
--- /dev/null
+++ b/vbahelper/source/msforms/vbatogglebutton.cxx
@@ -0,0 +1,164 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "vbatogglebutton.hxx"
+#include "vbanewfont.hxx"
+#include <sal/log.hxx>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
+ : ToggleButtonImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
+{
+ SAL_INFO("vbahelper", "ScVbaToggleButton(ctor)");
+ m_xProps->setPropertyValue( "Toggle", uno::Any( true ) );
+}
+
+ScVbaToggleButton::~ScVbaToggleButton()
+{
+ SAL_INFO("vbahelper", "~ScVbaToggleButton(dtor)");
+}
+
+// Attributes
+OUString SAL_CALL
+ScVbaToggleButton::getCaption()
+{
+ OUString Label;
+ m_xProps->getPropertyValue( "Label" ) >>= Label;
+ return Label;
+}
+
+void SAL_CALL
+ScVbaToggleButton::setCaption( const OUString& _caption )
+{
+ m_xProps->setPropertyValue( "Label", uno::Any( _caption ) );
+}
+
+uno::Any SAL_CALL
+ScVbaToggleButton::getValue()
+{
+ sal_Int16 nState = 0;
+ m_xProps->getPropertyValue( "State" ) >>= nState;
+ return uno::Any( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) );
+}
+
+
+void SAL_CALL
+ScVbaToggleButton::setValue( const uno::Any& _value )
+{
+ sal_Int16 nState = 0;
+ if ( ! ( _value >>= nState ) )
+ {
+ bool bState = false;
+ _value >>= bState;
+ if ( bState )
+ nState = -1;
+ }
+ SAL_INFO("vbahelper", "nState - " << nState );
+ nState = ( nState == -1 ) ? 1 : 0;
+ SAL_INFO("vbahelper", "nState - " << nState );
+ m_xProps->setPropertyValue( "State", uno::Any( nState ) );
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize()
+{
+ return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool bAutoSize )
+{
+ ScVbaControl::setAutoSize( bAutoSize );
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getCancel()
+{
+ // #STUB
+ return false;
+}
+
+void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ )
+{
+ // #STUB
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getDefault()
+{
+ // #STUB
+ return false;
+}
+
+void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ )
+{
+ // #STUB
+}
+
+sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor()
+{
+ return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 nBackColor )
+{
+ ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor()
+{
+ // #STUB
+ return 0;
+}
+
+void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ )
+{
+ // #STUB
+}
+
+uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont()
+{
+ return new VbaNewFont( m_xProps );
+}
+
+sal_Bool SAL_CALL ScVbaToggleButton::getLocked()
+{
+ return ScVbaControl::getLocked();
+}
+
+void SAL_CALL ScVbaToggleButton::setLocked( sal_Bool bLocked )
+{
+ ScVbaControl::setLocked( bLocked );
+}
+
+OUString
+ScVbaToggleButton::getServiceImplName()
+{
+ return "ScVbaToggleButton";
+}
+
+uno::Sequence< OUString >
+ScVbaToggleButton::getServiceNames()
+{
+ static uno::Sequence< OUString > const aServiceNames
+ {
+ "ooo.vba.msforms.ToggleButton"
+ };
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbatogglebutton.hxx b/vbahelper/source/msforms/vbatogglebutton.hxx
new file mode 100644
index 000000000..61be1a672
--- /dev/null
+++ b/vbahelper/source/msforms/vbatogglebutton.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBATOGGLEBUTTON_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBATOGGLEBUTTON_HXX
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XToggleButton.hpp>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+
+#include "vbacontrol.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+typedef cppu::ImplInheritanceHelper< ScVbaControl, ov::msforms::XToggleButton, css::script::XDefaultProperty > ToggleButtonImpl_BASE;
+
+class ScVbaToggleButton : public ToggleButtonImpl_BASE
+{
+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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper );
+ virtual ~ScVbaToggleButton() override;
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
+ virtual OUString SAL_CALL getCaption() override;
+ virtual void SAL_CALL setCaption( const OUString& _caption ) override;
+ virtual sal_Bool SAL_CALL getAutoSize() override;
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) override;
+ virtual sal_Bool SAL_CALL getCancel() override;
+ virtual void SAL_CALL setCancel( sal_Bool bCancel ) override;
+ virtual sal_Bool SAL_CALL getDefault() override;
+ virtual void SAL_CALL setDefault( sal_Bool bDefault ) override;
+ virtual sal_Int32 SAL_CALL getBackColor() override;
+ virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) override;
+ virtual sal_Int32 SAL_CALL getForeColor() override;
+ virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) override;
+ virtual sal_Bool SAL_CALL getLocked() override;
+ virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) override;
+ virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override;
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+ // XDefaultProperty
+ OUString SAL_CALL getDefaultPropertyName( ) override { return "Value"; }
+};
+#endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBATOGGLEBUTTON_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx
new file mode 100644
index 000000000..66aa6eff7
--- /dev/null
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -0,0 +1,311 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "vbauserform.hxx"
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+#include "vbacontrols.hxx"
+#include <sal/log.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 )
+ : ScVbaUserForm_BASE( getXSomethingFromArgs< XHelperInterface >( aArgs, 0 ), xContext, getXSomethingFromArgs< uno::XInterface >( aArgs, 1 ), getXSomethingFromArgs< frame::XModel >( aArgs, 2 ), nullptr ),
+ 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( std::make_unique<UserFormGeometryHelper>( xControl, 0.0, 0.0 ) );
+ if ( aArgs.getLength() >= 4 )
+ aArgs[ 3 ] >>= m_sLibName;
+}
+
+ScVbaUserForm::~ScVbaUserForm()
+{
+}
+
+void SAL_CALL
+ScVbaUserForm::Show( )
+{
+ SAL_INFO("vbahelper", "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(static_cast<sal_Int32>((aPosSize.Width - getWidth()) / 2.0), static_cast<sal_Int32>((aPosSize.Height - getHeight()) / 2.0), 0, 0, awt::PosSize::POS );
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ aRet = m_xDialog->execute();
+ }
+ SAL_INFO("vbahelper", "ScVbaUserForm::Show() execute returned " << aRet);
+ if ( !mbDispose )
+ return;
+
+ try
+ {
+ uno::Reference< lang::XComponent > xComp( m_xDialog, uno::UNO_QUERY_THROW );
+ m_xDialog = nullptr;
+ xComp->dispose();
+ mbDispose = false;
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+OUString SAL_CALL
+ScVbaUserForm::getCaption()
+{
+ OUString sCaption;
+ m_xProps->getPropertyValue( "Title" ) >>= sCaption;
+ return sCaption;
+}
+void
+ScVbaUserForm::setCaption( const OUString& _caption )
+{
+ m_xProps->setPropertyValue( "Title", uno::Any( _caption ) );
+}
+
+sal_Bool SAL_CALL
+ScVbaUserForm::getVisible()
+{
+ uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
+ uno::Reference< awt::XWindow2 > xControlWindow( xControl->getPeer(), uno::UNO_QUERY_THROW );
+ return xControlWindow->isVisible();
+}
+
+void SAL_CALL
+ScVbaUserForm::setVisible( sal_Bool bVis )
+{
+ if ( bVis )
+ Show();
+ else
+ Hide();
+}
+
+double SAL_CALL ScVbaUserForm::getInnerWidth()
+{
+ return mpGeometryHelper->getInnerWidth();
+}
+
+void SAL_CALL ScVbaUserForm::setInnerWidth( double fInnerWidth )
+{
+ mpGeometryHelper->setInnerWidth( fInnerWidth );
+}
+
+double SAL_CALL ScVbaUserForm::getInnerHeight()
+{
+ return mpGeometryHelper->getInnerHeight();
+}
+
+void SAL_CALL ScVbaUserForm::setInnerHeight( double fInnerHeight )
+{
+ mpGeometryHelper->setInnerHeight( fInnerHeight );
+}
+
+void SAL_CALL
+ScVbaUserForm::Hide( )
+{
+ mbDispose = false; // hide not dispose
+ if ( m_xDialog.is() )
+ m_xDialog->endExecute();
+}
+
+void SAL_CALL
+ScVbaUserForm::RePaint( )
+{
+ // #STUB
+ // do nothing
+}
+
+void SAL_CALL
+ScVbaUserForm::UnloadObject( )
+{
+ mbDispose = true;
+ if ( m_xDialog.is() )
+ m_xDialog->endExecute();
+}
+
+OUString
+ScVbaUserForm::getServiceImplName()
+{
+ return "ScVbaUserForm";
+}
+
+uno::Sequence< OUString >
+ScVbaUserForm::getServiceNames()
+{
+ return { "ooo.vba.excel.UserForm" };
+}
+
+uno::Reference< beans::XIntrospectionAccess > SAL_CALL
+ScVbaUserForm::getIntrospection( )
+{
+ return uno::Reference< beans::XIntrospectionAccess >();
+}
+
+uno::Any SAL_CALL
+ScVbaUserForm::invoke( const OUString& /*aFunctionName*/, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ )
+{
+ throw uno::RuntimeException(); // unsupported operation
+}
+
+void SAL_CALL
+ScVbaUserForm::setValue( const OUString& aPropertyName, const uno::Any& aValue )
+{
+ 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 );
+ OUString aDfltPropName = xDfltProp->getDefaultPropertyName();
+ uno::Reference< beans::XIntrospectionAccess > xUnoAccess( getIntrospectionAccess( aObject ) );
+ uno::Reference< beans::XPropertySet > xPropSet( xUnoAccess->queryAdapter( cppu::UnoType<beans::XPropertySet>::get()), uno::UNO_QUERY_THROW );
+ xPropSet->setPropertyValue( aDfltPropName, aValue );
+ }
+}
+
+uno::Reference< awt::XControl >
+ScVbaUserForm::nestedSearch( const OUString& aPropertyName, uno::Reference< awt::XControlContainer > const & xContainer )
+{
+ uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName );
+ if ( !xControl.is() )
+ {
+ const uno::Sequence< uno::Reference< awt::XControl > > aControls = xContainer->getControls();
+
+ for ( const auto& rCtrl : aControls )
+ {
+ uno::Reference< awt::XControlContainer > xC( rCtrl, uno::UNO_QUERY );
+ if ( xC.is() )
+ {
+ xControl.set( nestedSearch( aPropertyName, xC ) );
+ if ( xControl.is() )
+ break;
+ }
+ }
+ }
+ return xControl;
+}
+
+uno::Any SAL_CALL
+ScVbaUserForm::getValue( const OUString& aPropertyName )
+{
+ 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 = nestedSearch( aPropertyName, xContainer );
+ xContainer->getControl( aPropertyName );
+ if ( xControl.is() )
+ {
+ uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() );
+ ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() );
+ if (pControl && !m_sLibName.isEmpty())
+ pControl->setLibraryAndCodeName( m_sLibName + "." + getName() );
+ aResult <<= xVBAControl;
+ }
+ }
+
+ return aResult;
+}
+
+sal_Bool SAL_CALL
+ScVbaUserForm::hasMethod( const OUString& /*aName*/ )
+{
+ return false;
+}
+uno::Any SAL_CALL
+ScVbaUserForm::Controls( const uno::Any& index )
+{
+ // 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 xControls->Item( index, uno::Any() );
+ return uno::Any( xControls );
+}
+
+sal_Bool SAL_CALL
+ScVbaUserForm::hasProperty( const OUString& aName )
+{
+ uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY );
+
+ SAL_INFO("vbahelper", "ScVbaUserForm::hasProperty(" << aName << ") " << xControl.is() );
+ if ( xControl.is() )
+ {
+ uno::Reference< beans::XPropertySet > xDlgProps( xControl->getModel(), uno::UNO_QUERY );
+ if ( xDlgProps.is() )
+ {
+ uno::Reference< container::XNameContainer > xAllChildren( xDlgProps->getPropertyValue( "AllDialogChildren" ), uno::UNO_QUERY_THROW );
+ bool bRes = xAllChildren->hasByName( aName );
+ SAL_INFO("vbahelper", "ScVbaUserForm::hasProperty(" << aName << ") " << xAllChildren.is() << " ---> " << bRes );
+ return bRes;
+ }
+ }
+ return false;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+ScVbaUserForm_get_implementation(
+ css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const& args)
+{
+ return cppu::acquire(new ScVbaUserForm(args, context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx
new file mode 100644
index 000000000..ded092bc1
--- /dev/null
+++ b/vbahelper/source/msforms/vbauserform.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAUSERFORM_HXX
+#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBAUSERFORM_HXX
+
+#include <cppuhelper/implbase.hxx>
+#include <ooo/vba/msforms/XUserForm.hpp>
+#include <com/sun/star/awt/XDialog.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+
+#include "vbacontrol.hxx"
+
+//typedef InheritedHelperInterfaceWeakImpl< ov::msforms::XUserForm > ScVbaUserForm_BASE;
+typedef cppu::ImplInheritanceHelper< ScVbaControl, ov::msforms::XUserForm > ScVbaUserForm_BASE;
+
+class ScVbaUserForm : public ScVbaUserForm_BASE
+{
+private:
+ css::uno::Reference< css::awt::XDialog > m_xDialog;
+ bool mbDispose;
+ OUString m_sLibName;
+protected:
+public:
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::uno::RuntimeException
+ ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext );
+ virtual ~ScVbaUserForm() override;
+ static css::uno::Reference< css::awt::XControl > nestedSearch( const OUString& aPropertyName, css::uno::Reference< css::awt::XControlContainer > const & xContainer );
+ // XUserForm
+ virtual void SAL_CALL RePaint( ) override;
+ virtual void SAL_CALL Show( ) override;
+ virtual void SAL_CALL setValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
+ virtual css::uno::Any SAL_CALL getValue( const OUString& aPropertyName ) override;
+ virtual OUString SAL_CALL getCaption() override;
+ virtual void SAL_CALL setCaption( const OUString& _caption ) override;
+ virtual double SAL_CALL getInnerWidth() override;
+ virtual void SAL_CALL setInnerWidth( double fInnerWidth ) override;
+ virtual double SAL_CALL getInnerHeight() override;
+ virtual void SAL_CALL setInnerHeight( double fInnerHeight ) override;
+ virtual void SAL_CALL Hide( ) override;
+ virtual void SAL_CALL UnloadObject( ) override;
+ virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& index ) override;
+ virtual sal_Bool SAL_CALL getVisible() override;
+ virtual void SAL_CALL setVisible( sal_Bool bVis ) override;
+ // XIntrospection
+ virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) override;
+ virtual css::uno::Any SAL_CALL invoke( const OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) override;
+ virtual sal_Bool SAL_CALL hasMethod( const OUString& aName ) override;
+ virtual sal_Bool SAL_CALL hasProperty( const OUString& aName ) override;
+ //XHelperInterface
+ virtual OUString getServiceImplName() override;
+ virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */