From a5d4e7806c6519e139962d88ec969f9baeb4a404 Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Fri, 31 Aug 2012 03:09:18 -0500 Subject: gridfixes: #i117398# cleaned up the row selection API - made explicit that it is about row selection, leaving room for a future selection of columns - some changes for consistency - do not derive XGridControl from XGrid(Row)Selection, those two are orthogonal - published involved UNO types Change-Id: Ie97de42a9ea70a0191657f898ca9d59706e23290 Reviewed-on: https://gerrit.libreoffice.org/542 Reviewed-by: Miklos Vajna Tested-by: Miklos Vajna --- toolkit/source/controls/grid/gridcontrol.cxx | 28 ++++++++++++++-------------- toolkit/source/controls/grid/gridcontrol.hxx | 18 ++++++++++-------- 2 files changed, 24 insertions(+), 22 deletions(-) (limited to 'toolkit') diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 23663a616e6e..57121ce45c02 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -302,8 +302,8 @@ void SAL_CALL UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > { UnoControlBase::createPeer( rxToolkit, rParentPeer ); - const Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW ); - xGrid->addSelectionListener(&m_aSelectionListeners); + const Reference< XGridRowSelection > xGrid( getPeer(), UNO_QUERY_THROW ); + xGrid->addSelectionListener( &m_aSelectionListeners ); } //---------------------------------------------------------------------------------------------------------------------- @@ -385,45 +385,45 @@ sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_ } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UnoGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL UnoGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (RuntimeException, IndexOutOfBoundsException ) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRow( i_rowIndex ); + Reference< XGridRowSelection >( getPeer(), UNO_QUERY_THROW )->selectRow( i_rowIndex ); } //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectAllRows(); + Reference< XGridRowSelection >( getPeer(), UNO_QUERY_THROW )->selectAllRows(); } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UnoGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL UnoGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (RuntimeException, IndexOutOfBoundsException ) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRow( i_rowIndex ); + Reference< XGridRowSelection >( getPeer(), UNO_QUERY_THROW )->deselectRow( i_rowIndex ); } //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectAllRows(); + Reference< XGridRowSelection >( getPeer(), UNO_QUERY_THROW )->deselectAllRows(); } //---------------------------------------------------------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL UnoGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) +::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL UnoGridControl::getSelectedRows() throw (::com::sun::star::uno::RuntimeException) { - return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getSelection(); + return Reference< XGridRowSelection >( getPeer(), UNO_QUERY_THROW )->getSelectedRows(); } //---------------------------------------------------------------------------------------------------------------------- -::sal_Bool SAL_CALL UnoGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) +::sal_Bool SAL_CALL UnoGridControl::hasSelectedRows() throw (::com::sun::star::uno::RuntimeException) { - return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectionEmpty(); + return Reference< XGridRowSelection >( getPeer(), UNO_QUERY_THROW )->hasSelectedRows(); } //---------------------------------------------------------------------------------------------------------------------- -::sal_Bool SAL_CALL UnoGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) +::sal_Bool SAL_CALL UnoGridControl::isRowSelected(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { - return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectedIndex( index ); + return Reference< XGridRowSelection >( getPeer(), UNO_QUERY_THROW )->isRowSelected( index ); } //---------------------------------------------------------------------------------------------------------------------- diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index dfcbede15b00..450e248a3977 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -30,11 +30,12 @@ #define TOOLKIT_GRID_CONTROL_HXX #include +#include #include #include #include -#include +#include #include #include @@ -80,8 +81,9 @@ public: // =================================================================== // = UnoGridControl // =================================================================== -typedef ::cppu::ImplInheritanceHelper1 < UnoControlBase +typedef ::cppu::ImplInheritanceHelper2 < UnoControlBase , ::com::sun::star::awt::grid::XGridControl + , ::com::sun::star::awt::grid::XGridRowSelection > UnoGridControl_Base; class UnoGridControl : public UnoGridControl_Base { @@ -102,14 +104,14 @@ public: virtual ::sal_Int32 SAL_CALL getCurrentColumn( ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getCurrentRow( ) throw (::com::sun::star::uno::RuntimeException); - // ::com::sun::star::awt::grid::XGridSelection - virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); + // ::com::sun::star::awt::grid::XGridRowSelection + virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException ); virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException ); virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelectedRows() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasSelectedRows() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isRowSelected(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); -- cgit