summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-04-05 09:45:38 +0100
committerNoel Power <noel.power@suse.com>2013-04-05 17:15:01 +0100
commit3ffd86188b470fa7ebd9e6d10678279a1f63a81c (patch)
tree90e65f9c15873c0bddf54509f5f0f1444000556d /vbahelper
parent6f814b5f4ceca2f50edffd8b9023c613fffb9cdf (diff)
Added and fixed various vba API
Added OLEObject.LinkedCell Added ComboBox.LinkedCell Added Validation.Type Change-Id: I5ffc2212e689870d58ca99d1fbdfd7d101f8b50f
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/Library_msforms.mk1
-rw-r--r--vbahelper/source/msforms/vbacombobox.cxx10
-rw-r--r--vbahelper/source/msforms/vbacombobox.hxx2
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx56
4 files changed, 64 insertions, 5 deletions
diff --git a/vbahelper/Library_msforms.mk b/vbahelper/Library_msforms.mk
index d4bbc0830bf3..5b1a34b67747 100644
--- a/vbahelper/Library_msforms.mk
+++ b/vbahelper/Library_msforms.mk
@@ -55,6 +55,7 @@ $(eval $(call gb_Library_use_libraries,msforms,\
svl \
svt \
svx \
+ svxcore \
tk \
tl \
vbahelper \
diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx
index 63856e56f8b6..de7aa1a7c846 100644
--- a/vbahelper/source/msforms/vbacombobox.cxx
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -277,6 +277,16 @@ void SAL_CALL ScVbaComboBox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeEx
ScVbaControl::setLocked( bLocked );
}
+rtl::OUString SAL_CALL ScVbaComboBox::getLinkedCell() throw (uno::RuntimeException)
+{
+ return ScVbaControl::getControlSource();
+}
+
+void SAL_CALL ScVbaComboBox::setLinkedCell( const ::rtl::OUString& _linkedcell ) throw (uno::RuntimeException)
+{
+ ScVbaControl::setControlSource( _linkedcell );
+}
+
uno::Sequence< OUString >
ScVbaComboBox::getServiceNames()
{
diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx
index f71f9c169953..06adc9df929a 100644
--- a/vbahelper/source/msforms/vbacombobox.hxx
+++ b/vbahelper/source/msforms/vbacombobox.hxx
@@ -69,6 +69,8 @@ public:
virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL getLocked() throw (css::uno::RuntimeException);
virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getLinkedCell() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLinkedCell( const ::rtl::OUString& _linkedcell ) throw (css::uno::RuntimeException);
// Methods
virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index f97ee77cf824..288cefaf20cc 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -56,6 +56,10 @@
#include <vbahelper/helperdecl.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/window.hxx>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <svx/svdobj.hxx>
+
using namespace com::sun::star;
using namespace ooo::vba;
@@ -286,7 +290,7 @@ ScVbaControl::getControlSource() throw (uno::RuntimeException)
table::CellAddress aAddress;
xProps->getPropertyValue( "BoundCell" ) >>= aAddress;
xConvertor->setPropertyValue( "Address" , uno::makeAny( aAddress ) );
- xConvertor->getPropertyValue( "XL_A1_Representation" ) >>= sControlSource;
+ xConvertor->getPropertyValue( "XLA1Representation" ) >>= sControlSource;
}
catch(const uno::Exception&)
{
@@ -299,7 +303,40 @@ void SAL_CALL
ScVbaControl::setControlSource( const OUString& _controlsource ) throw (uno::RuntimeException)
{
OUString sEmpty;
- svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, _controlsource, sEmpty );
+ // 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, sEmpty, sal_uInt16( nRefTab ) );
}
OUString SAL_CALL
@@ -318,7 +355,7 @@ ScVbaControl::getRowSource() throw (uno::RuntimeException)
table::CellRangeAddress aAddress;
xProps->getPropertyValue( "CellRange" ) >>= aAddress;
xConvertor->setPropertyValue( "Address" , uno::makeAny( aAddress ) );
- xConvertor->getPropertyValue( "XL_A1_Representation" ) >>= sRowSource;
+ xConvertor->getPropertyValue( "XLA1Representation" ) >>= sRowSource;
}
catch(const uno::Exception&)
{
@@ -683,12 +720,21 @@ void ScVbaControl::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeExcep
sal_Bool ScVbaControl::getAutoSize() throw (uno::RuntimeException)
{
- return sal_False;
+ bool bIsResizeEnabled = false;
+ uno::Reference< uno::XInterface > xIf( m_xControl, uno::UNO_QUERY_THROW );
+ SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xIf );
+ if ( pObj )
+ bIsResizeEnabled = !pObj->IsResizeProtect();
+ return bIsResizeEnabled;
}
// currently no implementation for this
-void ScVbaControl::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+void ScVbaControl::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
{
+ uno::Reference< uno::XInterface > xIf( m_xControl, uno::UNO_QUERY_THROW );
+ SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xIf );
+ if ( pObj )
+ pObj->SetResizeProtect( !bAutoSize );
}
sal_Bool ScVbaControl::getLocked() throw (uno::RuntimeException)