summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-04-07 08:49:15 +0200
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-04-07 08:49:15 +0200
commitea3188de3f10ca22f5b859ec1eeef6ea0d2db59b (patch)
tree041003f87de27d5366f152659510ab7f2d3ac4f3 /svtools
parent586adfc8c014ecc5bb7e96da8c28f6e6e30fb0ab (diff)
gridfixes: ensure removal of a column at the grid control adjusts the cursor, if needed
Diffstat (limited to 'svtools')
-rwxr-xr-xsvtools/source/table/tablecontrol_impl.cxx10
-rw-r--r--svtools/source/uno/svtxgridcontrol.cxx37
-rwxr-xr-xsvtools/source/uno/svtxgridcontrol.hxx14
3 files changed, 52 insertions, 9 deletions
diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx
index feab64901636..2983b6c667ea 100755
--- a/svtools/source/table/tablecontrol_impl.cxx
+++ b/svtools/source/table/tablecontrol_impl.cxx
@@ -654,6 +654,16 @@ namespace svt { namespace table
void TableControl_Impl::columnRemoved( ColPos const i_colIndex )
{
m_nColumnCount = m_pModel->getColumnCount();
+
+ // adjust the current column, if it is larger than the column count now
+ if ( m_nCurColumn >= m_nColumnCount )
+ {
+ if ( m_nColumnCount > 0 )
+ goTo( m_nCurColumn - 1, m_nCurRow );
+ else
+ m_nCurColumn = COL_INVALID;
+ }
+
impl_ni_relayout();
m_rAntiImpl.Invalidate();
diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx
index d8324c160d5a..64b8f9241ae0 100644
--- a/svtools/source/uno/svtxgridcontrol.cxx
+++ b/svtools/source/uno/svtxgridcontrol.cxx
@@ -75,12 +75,13 @@ using ::com::sun::star::awt::grid::XGridColumn;
using ::com::sun::star::container::ContainerEvent;
using ::com::sun::star::awt::grid::GridDataEvent;
using ::com::sun::star::awt::grid::GridInvalidModelException;
+using ::com::sun::star::util::VetoException;
/** === end UNO using === **/
namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId;
namespace AccessibleStateType = ::com::sun::star::accessibility::AccessibleStateType;
-using ::svt::table::TableControl;
+using namespace ::svt::table;
typedef ::com::sun::star::util::Color UnoColor;
@@ -105,6 +106,20 @@ void SVTXGridControl::SetWindow( Window* pWindow )
}
// ---------------------------------------------------------------------------------------------------------------------
+void SVTXGridControl::impl_checkColumnIndex_throw( ::svt::table::TableControl const & i_table, sal_Int32 const i_columnIndex ) const
+{
+ if ( ( i_columnIndex < 0 ) || ( i_columnIndex >= i_table.GetColumnCount() ) )
+ throw IndexOutOfBoundsException( ::rtl::OUString(), *const_cast< SVTXGridControl* >( this ) );
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SVTXGridControl::impl_checkRowIndex_throw( ::svt::table::TableControl const & i_table, sal_Int32 const i_rowIndex ) const
+{
+ if ( ( i_rowIndex < 0 ) || ( i_rowIndex >= i_table.GetRowCount() ) )
+ throw IndexOutOfBoundsException( ::rtl::OUString(), *const_cast< SVTXGridControl* >( this ) );
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
sal_Int32 SAL_CALL SVTXGridControl::getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
@@ -152,6 +167,20 @@ sal_Int32 SAL_CALL SVTXGridControl::getCurrentRow( ) throw (RuntimeException)
return ( nRow >= 0 ) ? nRow : -1;
}
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::goToCell( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) throw (RuntimeException, IndexOutOfBoundsException, VetoException)
+{
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable != NULL, "SVTXGridControl::getCurrentRow: no control (anymore)!" );
+
+ impl_checkColumnIndex_throw( *pTable, i_columnIndex );
+ impl_checkRowIndex_throw( *pTable, i_rowIndex );
+
+ pTable->GoTo( i_columnIndex, i_rowIndex );
+}
+
// ---------------------------------------------------------------------------------------------------------------------
void SAL_CALL SVTXGridControl::addSelectionListener(const Reference< XGridSelectionListener > & listener) throw (RuntimeException)
{
@@ -666,8 +695,7 @@ void SAL_CALL SVTXGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (Runtim
TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::selectRow: no control (anymore)!" );
- if ( ( i_rowIndex < 0 ) || ( i_rowIndex >= pTable->GetRowCount() ) )
- throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
+ impl_checkRowIndex_throw( *pTable, i_rowIndex );
pTable->SelectRow( i_rowIndex, true );
}
@@ -691,8 +719,7 @@ void SAL_CALL SVTXGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (Runt
TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::deselectRow: no control (anymore)!" );
- if ( ( i_rowIndex < 0 ) || ( i_rowIndex >= pTable->GetRowCount() ) )
- throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
+ impl_checkRowIndex_throw( *pTable, i_rowIndex );
pTable->SelectRow( i_rowIndex, false );
}
diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx
index e8cfea21c631..ebde9b76c078 100755
--- a/svtools/source/uno/svtxgridcontrol.hxx
+++ b/svtools/source/uno/svtxgridcontrol.hxx
@@ -46,7 +46,9 @@
#include <toolkit/helper/listenermultiplexer.hxx>
-using namespace ::svt::table;
+namespace svt { namespace table {
+ class TableControl;
+} }
typedef ::cppu::ImplInheritanceHelper4 < VCLXWindow
, ::com::sun::star::awt::grid::XGridControl
@@ -57,9 +59,9 @@ typedef ::cppu::ImplInheritanceHelper4 < VCLXWindow
class SVTXGridControl : public SVTXGridControl_Base
{
private:
- ::boost::shared_ptr< UnoControlTableModel > m_pTableModel;
- bool m_bTableModelInitCompleted;
- SelectionListenerMultiplexer m_aSelectionListeners;
+ ::boost::shared_ptr< ::svt::table::UnoControlTableModel > m_pTableModel;
+ bool m_bTableModelInitCompleted;
+ SelectionListenerMultiplexer m_aSelectionListeners;
protected:
virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
@@ -88,6 +90,7 @@ public:
virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getCurrentColumn( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getCurrentRow( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL goToCell( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::util::VetoException);
// XGridRowSelection
virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
@@ -114,5 +117,8 @@ protected:
private:
void impl_updateColumnsFromModel_nothrow();
void impl_checkTableModelInit();
+
+ void impl_checkColumnIndex_throw( ::svt::table::TableControl const & i_table, sal_Int32 const i_columnIndex ) const;
+ void impl_checkRowIndex_throw( ::svt::table::TableControl const & i_table, sal_Int32 const i_rowIndex ) const;
};
#endif // _SVT_GRIDCONTROL_HXX_