summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-11-02 16:22:07 +0000
committerNoel Power <noel.power@novell.com>2010-11-02 19:52:04 +0000
commitc2e08dbfff7aca6af33a1ac32be15c97c648a73e (patch)
treebb0497cd2150806759e95f1861e742729a150828 /vbahelper
parent20710c28abe5b2908ca444f4b14865f82d975248 (diff)
initial import of latest cws container_controls
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/prj/build.lst2
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx23
-rw-r--r--vbahelper/source/msforms/vbacontrols.cxx14
-rw-r--r--vbahelper/source/msforms/vbamultipage.cxx24
-rw-r--r--vbahelper/source/msforms/vbauserform.cxx75
-rw-r--r--vbahelper/source/msforms/vbauserform.hxx2
6 files changed, 93 insertions, 47 deletions
diff --git a/vbahelper/prj/build.lst b/vbahelper/prj/build.lst
index 20001db859..ded9ee23b3 100644
--- a/vbahelper/prj/build.lst
+++ b/vbahelper/prj/build.lst
@@ -1,4 +1,4 @@
-vba vbahelper : oovbaapi basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal NULL
+vba vbahelper : oovbaapi oox basic sfx2 svx filter cppuhelper vcl comphelper svtools tools sal NULL
vba vbahelper usr1 - all vba_mkout NULL
#vba vbahelper\inc nmake - all vba_inc NULL
vba vbahelper\source\vbahelper nmake - all vba_vbahelper NULL
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 599ef3336d..fcc9a4a1f3 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -573,23 +573,28 @@ ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< awt::XCo
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) )
pControl = new ScVbaComboBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), true );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) )
- pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ pControl = new ScVbaListBox( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) )
- pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ pControl = new ScVbaLabel( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) )
- pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ pControl = new ScVbaImage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) )
- pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ pControl = new ScVbaProgressBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) )
- pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) )
- pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ pControl = new ScVbaScrollBar( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) )
- pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent );
+ pControl = new ScVbaMultiPage( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ), xParent );
+ // #FIXME implement a page control
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoPageModel") ) ) )
+ pControl = new ScVbaControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoFrameModel") ) ) )
+ pControl = new ScVbaFrame( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) )
- pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ pControl = new ScVbaSpinButton( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
else if ( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.awt.UnoControlSystemAXContainerModel") ) ) )
- pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
+ pControl = new VbaSystemAXControl( xVbaParent, m_xContext, xControl, m_xModel, new UserFormGeometryHelper( m_xContext, xControl ) );
else
throw uno::RuntimeException( rtl::OUString::createFromAscii("Unsupported control " ), uno::Reference< uno::XInterface >() );
return pControl;
diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx
index 9afb60208f..55bc5b8c36 100644
--- a/vbahelper/source/msforms/vbacontrols.cxx
+++ b/vbahelper/source/msforms/vbacontrols.cxx
@@ -71,7 +71,19 @@ private:
mIndices[ msNames[ nIndex ] ] = nIndex;
}
}
-
+ void getNestedControls( ControlVec& vControls, uno::Reference< awt::XControlContainer >& xContainer )
+ {
+ uno::Sequence< uno::Reference< awt::XControl > > aControls = xContainer->getControls();
+ const uno::Reference< awt::XControl >* pCtrl = aControls.getConstArray();
+ const uno::Reference< awt::XControl >* pCtrlsEnd = pCtrl + aControls.getLength();
+ for ( ; pCtrl < pCtrlsEnd; ++pCtrl )
+ {
+ uno::Reference< awt::XControlContainer > xC( *pCtrl, uno::UNO_QUERY );
+ vControls.push_back( *pCtrl );
+ if ( xC.is() )
+ getNestedControls( vControls, xC );
+ }
+ }
public:
ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog )
{
diff --git a/vbahelper/source/msforms/vbamultipage.cxx b/vbahelper/source/msforms/vbamultipage.cxx
index 46593a1568..1ca77dc436 100644
--- a/vbahelper/source/msforms/vbamultipage.cxx
+++ b/vbahelper/source/msforms/vbamultipage.cxx
@@ -29,14 +29,12 @@
#include <ooo/vba/XCollection.hpp>
#include "vbapages.hxx"
#include <vector>
+#include <com/sun/star/container/XNameContainer.hpp>
using namespace com::sun::star;
using namespace ooo::vba;
-// uno servicename com.sun.star.awt.UnoControlProgressBarMode
-const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("ProgressValue") );
-const rtl::OUString SVALUEMAX( RTL_CONSTASCII_USTRINGPARAM("ProgressValueMax") );
-const rtl::OUString SSTEP( RTL_CONSTASCII_USTRINGPARAM("Step") );
+const rtl::OUString SVALUE( RTL_CONSTASCII_USTRINGPARAM("MultiPageValue") );
typedef cppu::WeakImplHelper1< container::XIndexAccess > PagesImpl_Base;
class PagesImpl : public PagesImpl_Base
@@ -72,8 +70,6 @@ ScVbaMultiPage::getPages( sal_Int32 nPages )
ScVbaMultiPage::ScVbaMultiPage( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, const uno::Reference< uno::XInterface >& xDialog ) : MultiPageImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
{
mxDialogProps.set( xDialog, uno::UNO_QUERY_THROW );
- // set dialog step to value of multipage pseudo model
- setValue(getValue());
}
// Attributes
@@ -82,17 +78,17 @@ ScVbaMultiPage::getValue() throw (css::uno::RuntimeException)
{
sal_Int32 nValue = 0;
m_xProps->getPropertyValue( SVALUE ) >>= nValue;
- return nValue;
+ // VBA 0 based tab index
+ return nValue - 1;
}
void SAL_CALL
ScVbaMultiPage::setValue( const sal_Int32 _value ) throw (::com::sun::star::uno::RuntimeException)
{
- // track change in dialog ( dialog value is 1 based, 0 is a special value )
- sal_Int32 nVal = _value; // will be _value + 1 when cws container_controls is integrated
+ // Openoffice 1 based tab index
+ sal_Int32 nVal = _value + 1;
sal_Int32 nOldVal = getValue();
- m_xProps->setPropertyValue( SVALUE, uno::makeAny( _value ) );
- mxDialogProps->setPropertyValue( SSTEP, uno::makeAny( _value + 1) );
+ m_xProps->setPropertyValue( SVALUE, uno::makeAny( nVal ) );
if ( nVal != nOldVal )
fireChangeEvent();
}
@@ -108,9 +104,9 @@ ScVbaMultiPage::getServiceImplName()
uno::Any SAL_CALL
ScVbaMultiPage::Pages( const uno::Any& index ) throw (uno::RuntimeException)
{
- sal_Int32 nValue = 0;
- m_xProps->getPropertyValue( SVALUEMAX ) >>= nValue;
- uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, getPages( nValue ) ) );
+ // get the container model
+ uno::Reference< container::XNameContainer > xContainer( m_xProps, uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xColl( new ScVbaPages( this, mxContext, getPages( xContainer->getElementNames().getLength() ) ) );
if ( !index.hasValue() )
return uno::makeAny( xColl );
return xColl->Item( uno::makeAny( index ), uno::Any() );
diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx
index 1894d3c17b..ec3bcb7bac 100644
--- a/vbahelper/source/msforms/vbauserform.cxx
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -31,6 +31,7 @@
#include <com/sun/star/awt/XControlContainer.hpp>
#include <com/sun/star/awt/XWindow2.hpp>
#include <com/sun/star/beans/PropertyConcept.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
#include <basic/sbx.hxx>
#include <basic/sbstar.hxx>
#include <basic/sbmeth.hxx>
@@ -42,7 +43,7 @@ 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
+// 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
@@ -63,7 +64,7 @@ ScVbaUserForm::~ScVbaUserForm()
{
}
-void SAL_CALL
+void SAL_CALL
ScVbaUserForm::Show( ) throw (uno::RuntimeException)
{
OSL_TRACE("ScVbaUserForm::Show( )");
@@ -79,7 +80,7 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException)
uno::Reference< lang::XComponent > xComp( m_xDialog, uno::UNO_QUERY_THROW );
m_xDialog = NULL;
xComp->dispose();
- mbDispose = false;
+ mbDispose = false;
}
catch( uno::Exception& )
{
@@ -87,7 +88,7 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException)
}
}
-rtl::OUString SAL_CALL
+rtl::OUString SAL_CALL
ScVbaUserForm::getCaption() throw (::com::sun::star::uno::RuntimeException)
{
rtl::OUString sCaption;
@@ -100,7 +101,7 @@ ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::
m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) );
}
-void SAL_CALL
+void SAL_CALL
ScVbaUserForm::Hide( ) throw (uno::RuntimeException)
{
mbDispose = false; // hide not dispose
@@ -126,13 +127,13 @@ void SAL_CALL ScVbaUserForm::setVisible( sal_Bool bVisible ) throw (uno::Runtime
}
}
-void SAL_CALL
+void SAL_CALL
ScVbaUserForm::RePaint( ) throw (uno::RuntimeException)
{
// do nothing
}
-void SAL_CALL
+void SAL_CALL
ScVbaUserForm::UnloadObject( ) throw (uno::RuntimeException)
{
mbDispose = true;
@@ -140,14 +141,14 @@ ScVbaUserForm::UnloadObject( ) throw (uno::RuntimeException)
m_xDialog->endExecute();
}
-rtl::OUString&
+rtl::OUString&
ScVbaUserForm::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaUserForm") );
return sImplName;
}
-uno::Sequence< rtl::OUString >
+uno::Sequence< rtl::OUString >
ScVbaUserForm::getServiceNames()
{
static uno::Sequence< rtl::OUString > aServiceNames;
@@ -159,19 +160,19 @@ ScVbaUserForm::getServiceNames()
return aServiceNames;
}
-uno::Reference< beans::XIntrospectionAccess > SAL_CALL
+uno::Reference< beans::XIntrospectionAccess > SAL_CALL
ScVbaUserForm::getIntrospection( ) throw (uno::RuntimeException)
{
return uno::Reference< beans::XIntrospectionAccess >();
}
-uno::Any SAL_CALL
+uno::Any SAL_CALL
ScVbaUserForm::invoke( const ::rtl::OUString& /*aFunctionName*/, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
{
throw uno::RuntimeException(); // unsupported operation
}
-void SAL_CALL
+void SAL_CALL
ScVbaUserForm::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
{
uno::Any aObject = getValue( aPropertyName );
@@ -191,7 +192,31 @@ ScVbaUserForm::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& a
}
}
-uno::Any SAL_CALL
+uno::Reference< awt::XControl >
+ScVbaUserForm::nestedSearch( const rtl::OUString& aPropertyName, uno::Reference< awt::XControlContainer >& xContainer )
+{
+ uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName );
+ if ( !xControl.is() )
+ {
+ uno::Sequence< uno::Reference< awt::XControl > > aControls = xContainer->getControls();
+ const uno::Reference< awt::XControl >* pCtrl = aControls.getConstArray();
+ const uno::Reference< awt::XControl >* pCtrlsEnd = pCtrl + aControls.getLength();
+
+ for ( ; pCtrl < pCtrlsEnd; ++pCtrl )
+ {
+ uno::Reference< awt::XControlContainer > xC( *pCtrl, uno::UNO_QUERY );
+ if ( xC.is() )
+ {
+ xControl.set( nestedSearch( aPropertyName, xC ) );
+ if ( xControl.is() )
+ break;
+ }
+ }
+ }
+ return xControl;
+}
+
+uno::Any SAL_CALL
ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
{
uno::Any aResult;
@@ -201,7 +226,8 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un
{
uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW );
- uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName );
+ uno::Reference< awt::XControl > xControl = nestedSearch( aPropertyName, xContainer );
+ xContainer->getControl( aPropertyName );
ScVbaControlFactory aFac( mxContext, xControl, m_xModel );
uno::Reference< msforms::XControl > xVBAControl( aFac.createControl( xDialogControl->getModel() ) );
ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() );
@@ -214,12 +240,12 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un
return aResult;
}
-::sal_Bool SAL_CALL
+::sal_Bool SAL_CALL
ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException)
{
return sal_False;
}
-uno::Any SAL_CALL
+uno::Any SAL_CALL
ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException)
{
// if the dialog already closed we should do nothing, but the VBA will call methods of the Controls objects
@@ -231,17 +257,22 @@ ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException)
return uno::makeAny( xControls );
}
-::sal_Bool SAL_CALL
+::sal_Bool SAL_CALL
ScVbaUserForm::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
{
uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY );
+
OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is() );
if ( xControl.is() )
{
- uno::Reference< container::XNameAccess > xNameAccess( xControl->getModel(), uno::UNO_QUERY_THROW );
- sal_Bool bRes = xNameAccess->hasByName( aName );
- OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xControl.is(), bRes );
- return bRes;
+ uno::Reference< beans::XPropertySet > xDlgProps( xControl->getModel(), uno::UNO_QUERY );
+ if ( xDlgProps.is() )
+ {
+ uno::Reference< container::XNameContainer > xAllChildren( xDlgProps->getPropertyValue( rtl::OUString::createFromAscii("AllDialogChildren" ) ), uno::UNO_QUERY_THROW );
+ sal_Bool bRes = xAllChildren->hasByName( aName );
+ OSL_TRACE("ScVbaUserForm::hasProperty(%s) %d ---> %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), xAllChildren.is(), bRes );
+ return bRes;
+ }
}
return sal_False;
}
diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx
index 646ef38b07..625d1fae02 100644
--- a/vbahelper/source/msforms/vbauserform.hxx
+++ b/vbahelper/source/msforms/vbauserform.hxx
@@ -31,6 +31,7 @@
#include <cppuhelper/implbase1.hxx>
#include <ooo/vba/msforms/XUserForm.hpp>
#include <com/sun/star/awt/XDialog.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <vbahelper/vbahelperinterface.hxx>
@@ -49,6 +50,7 @@ protected:
public:
ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException );
virtual ~ScVbaUserForm();
+ static css::uno::Reference< css::awt::XControl > nestedSearch( const rtl::OUString& aPropertyName, css::uno::Reference< css::awt::XControlContainer >& xContainer );
virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException);
// XUserForm