Kaydet (Commit) 3ffd8618 authored tarafından Noel Power's avatar Noel Power

Added and fixed various vba API

Added OLEObject.LinkedCell
Added ComboBox.LinkedCell
Added Validation.Type

Change-Id: I5ffc2212e689870d58ca99d1fbdfd7d101f8b50f
üst 6f814b5f
...@@ -38,6 +38,7 @@ interface XOLEObject ...@@ -38,6 +38,7 @@ interface XOLEObject
[attribute] double Top; [attribute] double Top;
[attribute] double Height; [attribute] double Height;
[attribute] double Width; [attribute] double Width;
[attribute] string LinkedCell;
}; };
//============================================================================= //=============================================================================
......
...@@ -41,6 +41,7 @@ interface XValidation ...@@ -41,6 +41,7 @@ interface XValidation
[attribute] string ErrorMessage; [attribute] string ErrorMessage;
[attribute, readonly] string Formula1; [attribute, readonly] string Formula1;
[attribute, readonly] string Formula2; [attribute, readonly] string Formula2;
[attribute, readonly] long Type;
void Delete(); void Delete();
void Add( [in] any Type, [in] any AlertStyle, [in] any Operator, [in] any Formula1, [in] any Formula2); void Add( [in] any Type, [in] any AlertStyle, [in] any Operator, [in] any Formula1, [in] any Formula2);
}; };
......
...@@ -44,6 +44,7 @@ interface XComboBox ...@@ -44,6 +44,7 @@ interface XComboBox
[attribute] boolean Locked; [attribute] boolean Locked;
[attribute, readonly] long TextLength; [attribute, readonly] long TextLength;
[attribute, readonly] XNewFont Font; [attribute, readonly] XNewFont Font;
[attribute] string LinkedCell;
void AddItem( [in] any pvargItem, [in] any pvargIndex ); void AddItem( [in] any pvargItem, [in] any pvargIndex );
void removeItem( [in] any index ); void removeItem( [in] any index );
......
...@@ -25,7 +25,10 @@ ...@@ -25,7 +25,10 @@
#include <ooo/vba/XControlProvider.hpp> #include <ooo/vba/XControlProvider.hpp>
#include "vbaoleobject.hxx" #include "vbaoleobject.hxx"
#include <svx/svdobj.hxx>
#include "drwlayer.hxx"
#include "excelvbahelper.hxx"
#include <svtools/bindablecontrolhelper.hxx>
using namespace com::sun::star; using namespace com::sun::star;
using namespace ooo::vba; using namespace ooo::vba;
...@@ -38,7 +41,7 @@ ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParen ...@@ -38,7 +41,7 @@ ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParen
uno::Reference< container::XChild > xChild( xControlModel, uno::UNO_QUERY_THROW ); uno::Reference< container::XChild > xChild( xControlModel, uno::UNO_QUERY_THROW );
xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW ); xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW ); xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
css::uno::Reference< css::frame::XModel > xModel( xChild->getParent(), uno::UNO_QUERY_THROW ); uno::Reference<frame::XModel> xModel( xChild->getParent(), uno::UNO_QUERY_THROW );
uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( "ooo.vba.ControlProvider" ), mxContext ), uno::UNO_QUERY_THROW ); uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( "ooo.vba.ControlProvider" ), mxContext ), uno::UNO_QUERY_THROW );
m_xControl.set( xControlProvider->createControl( xControlShape, xModel ) ); m_xControl.set( xControlProvider->createControl( xControlShape, xModel ) );
...@@ -125,6 +128,16 @@ ScVbaOLEObject::setWidth( double _width ) throw (uno::RuntimeException) ...@@ -125,6 +128,16 @@ ScVbaOLEObject::setWidth( double _width ) throw (uno::RuntimeException)
m_xControl->setWidth( _width ); m_xControl->setWidth( _width );
} }
rtl::OUString SAL_CALL ScVbaOLEObject::getLinkedCell() throw (uno::RuntimeException)
{
return m_xControl->getControlSource();
}
void SAL_CALL ScVbaOLEObject::setLinkedCell( const ::rtl::OUString& _linkedcell ) throw (uno::RuntimeException)
{
m_xControl->setControlSource( _linkedcell );
}
rtl::OUString rtl::OUString
ScVbaOLEObject::getServiceImplName() ScVbaOLEObject::getServiceImplName()
{ {
......
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (css::uno::RuntimeException); virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException); virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException);
virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException); virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException); virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException);
virtual double SAL_CALL getTop() throw (css::uno::RuntimeException); virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
...@@ -53,7 +54,8 @@ public: ...@@ -53,7 +54,8 @@ public:
virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException); virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException);
virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException); virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException); virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getLinkedCell() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setLinkedCell( const ::rtl::OUString& _linkedcell ) throw (::com::sun::star::uno::RuntimeException);
}; };
#endif //SC_VBA_OLEOBJECT_HXX #endif //SC_VBA_OLEOBJECT_HXX
......
...@@ -334,6 +334,46 @@ ScVbaValidation::getFormula2() throw (uno::RuntimeException) ...@@ -334,6 +334,46 @@ ScVbaValidation::getFormula2() throw (uno::RuntimeException)
return xCond->getFormula2(); return xCond->getFormula2();
} }
sal_Int32 SAL_CALL
ScVbaValidation::getType() throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
sheet::ValidationType nValType = sheet::ValidationType_ANY;
xProps->getPropertyValue( STYPE ) >>= nValType;
sal_Int32 nExcelType = excel::XlDVType::xlValidateList; // pick a default
if ( xProps.is() )
{
switch ( nValType )
{
case sheet::ValidationType_LIST:
nExcelType = excel::XlDVType::xlValidateList;
break;
case sheet::ValidationType_ANY: // not ANY not really a great match for anything I fear:-(
nExcelType = excel::XlDVType::xlValidateInputOnly;
break;
case sheet::ValidationType_CUSTOM:
nExcelType = excel::XlDVType::xlValidateCustom;
break;
case sheet::ValidationType_WHOLE:
nExcelType = excel::XlDVType::xlValidateWholeNumber;
break;
case sheet::ValidationType_DECIMAL:
nExcelType = excel::XlDVType::xlValidateDecimal;
break;
case sheet::ValidationType_DATE:
nExcelType = excel::XlDVType::xlValidateDate;
break;
case sheet::ValidationType_TIME:
nExcelType = excel::XlDVType::xlValidateTime;
break;
case sheet::ValidationType_TEXT_LEN:
nExcelType = excel::XlDVType::xlValidateTextLength;
break;
};
}
return nExcelType;
}
rtl::OUString rtl::OUString
ScVbaValidation::getServiceImplName() ScVbaValidation::getServiceImplName()
{ {
......
...@@ -51,6 +51,7 @@ public: ...@@ -51,6 +51,7 @@ public:
virtual void SAL_CALL setErrorMessage( const ::rtl::OUString& _errormessage ) throw (css::uno::RuntimeException); virtual void SAL_CALL setErrorMessage( const ::rtl::OUString& _errormessage ) throw (css::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getFormula1() throw (css::uno::RuntimeException) ; virtual ::rtl::OUString SAL_CALL getFormula1() throw (css::uno::RuntimeException) ;
virtual ::rtl::OUString SAL_CALL getFormula2() throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getFormula2() throw (css::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException);
// Methods // Methods
virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException); virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& AlertStyle, const css::uno::Any& Operator, const css::uno::Any& Formula1, const css::uno::Any& Formula2 ) throw (css::uno::RuntimeException); virtual void SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& AlertStyle, const css::uno::Any& Operator, const css::uno::Any& Formula1, const css::uno::Any& Formula2 ) throw (css::uno::RuntimeException);
......
...@@ -40,7 +40,7 @@ namespace svt ...@@ -40,7 +40,7 @@ namespace svt
BindableControlHelper(); // never implemented BindableControlHelper(); // never implemented
public: public:
SVT_DLLPUBLIC static void ApplyListSourceAndBindableData( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rObj, const rtl::OUString& rsCtrlSource, const rtl::OUString& rsRowSource ); SVT_DLLPUBLIC static void ApplyListSourceAndBindableData( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rObj, const rtl::OUString& rsCtrlSource, const rtl::OUString& rsRowSource, sal_uInt16 nRefTab = 0 );
}; };
//........................................................................ //........................................................................
......
...@@ -67,7 +67,7 @@ bool lcl_isNamedRange( const rtl::OUString& sAddress, const uno::Reference< fram ...@@ -67,7 +67,7 @@ bool lcl_isNamedRange( const rtl::OUString& sAddress, const uno::Reference< fram
void void
BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rObj, const rtl::OUString& rsCtrlSource, const rtl::OUString& rsRowSource ) BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rObj, const rtl::OUString& rsCtrlSource, const rtl::OUString& rsRowSource, sal_uInt16 nRefTab )
{ {
// XBindable etc. // XBindable etc.
uno::Reference< lang::XMultiServiceFactory > xFac; uno::Reference< lang::XMultiServiceFactory > xFac;
...@@ -87,7 +87,8 @@ BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno ...@@ -87,7 +87,8 @@ BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno
{ {
// we need this service to properly convert XL notation also // we need this service to properly convert XL notation also
// Should be easy to extend // Should be easy to extend
xConvertor->setPropertyValue( "XL_A1_Representation", uno::makeAny( rsCtrlSource ) ); xConvertor->setPropertyValue( "ReferenceSheet", uno::makeAny( nRefTab ) );
xConvertor->setPropertyValue( "XLA1Representation", uno::makeAny( rsCtrlSource ) );
xConvertor->getPropertyValue( "Address" ) >>= aAddress; xConvertor->getPropertyValue( "Address" ) >>= aAddress;
} }
...@@ -119,7 +120,8 @@ BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno ...@@ -119,7 +120,8 @@ BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno
{ {
// we need this service to properly convert XL notation also // we need this service to properly convert XL notation also
// Should be easy to extend // Should be easy to extend
xConvertor->setPropertyValue( "XL_A1_Representation", uno::makeAny( rsRowSource ) ); xConvertor->setPropertyValue( "ReferenceSheet", uno::makeAny( nRefTab ) );
xConvertor->setPropertyValue( "XLA1Representation", uno::makeAny( rsRowSource ) );
xConvertor->getPropertyValue( "Address" ) >>= aAddress; xConvertor->getPropertyValue( "Address" ) >>= aAddress;
} }
} }
......
...@@ -55,6 +55,7 @@ $(eval $(call gb_Library_use_libraries,msforms,\ ...@@ -55,6 +55,7 @@ $(eval $(call gb_Library_use_libraries,msforms,\
svl \ svl \
svt \ svt \
svx \ svx \
svxcore \
tk \ tk \
tl \ tl \
vbahelper \ vbahelper \
......
...@@ -277,6 +277,16 @@ void SAL_CALL ScVbaComboBox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeEx ...@@ -277,6 +277,16 @@ void SAL_CALL ScVbaComboBox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeEx
ScVbaControl::setLocked( bLocked ); 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 > uno::Sequence< OUString >
ScVbaComboBox::getServiceNames() ScVbaComboBox::getServiceNames()
{ {
......
...@@ -69,6 +69,8 @@ public: ...@@ -69,6 +69,8 @@ public:
virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException); virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL getLocked() 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 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 // Methods
virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException); virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException);
......
...@@ -56,6 +56,10 @@ ...@@ -56,6 +56,10 @@
#include <vbahelper/helperdecl.hxx> #include <vbahelper/helperdecl.hxx>
#include <toolkit/helper/vclunohelper.hxx> #include <toolkit/helper/vclunohelper.hxx>
#include <vcl/window.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 com::sun::star;
using namespace ooo::vba; using namespace ooo::vba;
...@@ -286,7 +290,7 @@ ScVbaControl::getControlSource() throw (uno::RuntimeException) ...@@ -286,7 +290,7 @@ ScVbaControl::getControlSource() throw (uno::RuntimeException)
table::CellAddress aAddress; table::CellAddress aAddress;
xProps->getPropertyValue( "BoundCell" ) >>= aAddress; xProps->getPropertyValue( "BoundCell" ) >>= aAddress;
xConvertor->setPropertyValue( "Address" , uno::makeAny( aAddress ) ); xConvertor->setPropertyValue( "Address" , uno::makeAny( aAddress ) );
xConvertor->getPropertyValue( "XL_A1_Representation" ) >>= sControlSource; xConvertor->getPropertyValue( "XLA1Representation" ) >>= sControlSource;
} }
catch(const uno::Exception&) catch(const uno::Exception&)
{ {
...@@ -299,7 +303,40 @@ void SAL_CALL ...@@ -299,7 +303,40 @@ void SAL_CALL
ScVbaControl::setControlSource( const OUString& _controlsource ) throw (uno::RuntimeException) ScVbaControl::setControlSource( const OUString& _controlsource ) throw (uno::RuntimeException)
{ {
OUString sEmpty; 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 OUString SAL_CALL
...@@ -318,7 +355,7 @@ ScVbaControl::getRowSource() throw (uno::RuntimeException) ...@@ -318,7 +355,7 @@ ScVbaControl::getRowSource() throw (uno::RuntimeException)
table::CellRangeAddress aAddress; table::CellRangeAddress aAddress;
xProps->getPropertyValue( "CellRange" ) >>= aAddress; xProps->getPropertyValue( "CellRange" ) >>= aAddress;
xConvertor->setPropertyValue( "Address" , uno::makeAny( aAddress ) ); xConvertor->setPropertyValue( "Address" , uno::makeAny( aAddress ) );
xConvertor->getPropertyValue( "XL_A1_Representation" ) >>= sRowSource; xConvertor->getPropertyValue( "XLA1Representation" ) >>= sRowSource;
} }
catch(const uno::Exception&) catch(const uno::Exception&)
{ {
...@@ -683,12 +720,21 @@ void ScVbaControl::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeExcep ...@@ -683,12 +720,21 @@ void ScVbaControl::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeExcep
sal_Bool ScVbaControl::getAutoSize() throw (uno::RuntimeException) 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 // 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) sal_Bool ScVbaControl::getLocked() throw (uno::RuntimeException)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment