From 405a0f6cf14f30bed6cf676d7c3224c1c2cb1312 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 17 Jan 2011 14:25:56 +0100 Subject: [PATCH] gridsort: fix getRowAtPoint --- svtools/source/table/tablecontrol_impl.cxx | 36 ++++++++++------------ svtools/source/table/tablecontrol_impl.hxx | 4 +++ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 56a5908ebe4f..12370ca305ce 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -1800,31 +1800,13 @@ namespace svt { namespace table RowPos TableControl_Impl::getRowAtPoint( const Point& rPoint ) const { DBG_CHECK_ME(); - - if ( ( rPoint.Y() >= 0 ) && ( rPoint.Y() < m_nColHeaderHeightPixel ) ) - return ROW_COL_HEADERS; - - Rectangle aAllCellsArea; - impl_getAllVisibleCellsArea( aAllCellsArea ); - - TableRowGeometry aHitTest( *this, aAllCellsArea, ROW_COL_HEADERS ); - while ( aHitTest.isValid() ) - { - if ( aHitTest.getRect().IsInside( rPoint ) ) - return aHitTest.getRow(); - aHitTest.moveDown(); - } - return ROW_INVALID; + return impl_getRowForAbscissa( rPoint.Y() ); } //------------------------------------------------------------------------------------------------------------------ ColPos TableControl_Impl::getColAtPoint( const Point& rPoint ) const { DBG_CHECK_ME(); - - if ( ( rPoint.X() >= 0 ) && ( rPoint.X() < m_nRowHeaderWidthPixel ) ) - return COL_ROW_HEADERS; - return impl_getColumnForOrdinate( rPoint.X() ); } @@ -2329,6 +2311,22 @@ namespace svt { namespace table return lowerBound - m_aColumnWidths.begin(); } + //-------------------------------------------------------------------- + RowPos TableControl_Impl::impl_getRowForAbscissa( long const i_abscissa ) const + { + DBG_CHECK_ME(); + + if ( i_abscissa < 0 ) + return ROW_INVALID; + + if ( i_abscissa < m_nColHeaderHeightPixel ) + return ROW_COL_HEADERS; + + long const abscissa = i_abscissa - m_nColHeaderHeightPixel; + long const row = m_nTopRow + abscissa / m_nRowHeightPixel; + return row < m_pModel->getRowCount() ? row : ROW_INVALID; + } + //-------------------------------------------------------------------- bool TableControl_Impl::markRowAsDeselected( RowPos const i_rowIndex ) { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 78b87916083f..a6aebbaa6cc4 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -442,6 +442,10 @@ namespace svt { namespace table */ ColPos impl_getColumnForOrdinate( long const i_ordinate ) const; + /** retrieves the row which covers the given abscissa + */ + RowPos impl_getRowForAbscissa( long const i_abscissa ) const; + /// invalidates the window area occupied by the given column void impl_invalidateColumn( ColPos const i_column );