From be8d00fe05ad77bdf4aa86e37faab84b35fb8da8 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 3 Dec 2010 14:46:39 +0100 Subject: dba34c: #i104347# DisableSelectionOnFocus for multi line edit controls --- svtools/source/uno/unoiface.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'svtools') diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index 18ab6f804d0c..51914a3f48d6 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -82,6 +82,7 @@ SAL_DLLPUBLIC_EXPORT Window* CreateWindow( VCLXWindow** ppNewComp, const ::com:: if ( pParent ) { pWindow = new MultiLineEdit( pParent, nWinBits|WB_IGNORETAB); + static_cast< MultiLineEdit* >( pWindow )->DisableSelectionOnFocus(); *ppNewComp = new VCLXMultiLineEdit; } else -- cgit v1.2.3 From 2d8c797828962d0a5fb0725c15d1de6b33a04e8b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 7 Dec 2010 09:51:15 +0100 Subject: gridsort: no reason to burden each and every client with creating a default Data/Column model - do this in the ctor of the grid model. If clients want to override this, they of course still can do --- svtools/source/uno/svtxgridcontrol.cxx | 116 +++++++++++++-------------- toolkit/source/controls/grid/gridcontrol.cxx | 9 +++ 2 files changed, 64 insertions(+), 61 deletions(-) mode change 100755 => 100644 svtools/source/uno/svtxgridcontrol.cxx (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx old mode 100755 new mode 100644 index f5bc837f60b0..b1bcfbe7edd5 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -263,45 +263,44 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An { { m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); - if(m_xDataModel != NULL) + if ( !m_xDataModel.is() ) + throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel); + + Sequence > cellData = m_xDataModel->getData(); + if(cellData.getLength()!= 0) { - Sequence > cellData = m_xDataModel->getData(); - if(cellData.getLength()!= 0) + for (int i = 0; i < cellData.getLength(); i++) { - for (int i = 0; i < cellData.getLength(); i++) + std::vector< Any > newRow; + Sequence< Any > rawRowData = cellData[i]; + //check whether the data row vector length matches with the column count + if(m_xColumnModel->getColumnCount() == 0) { - std::vector< Any > newRow; - Sequence< Any > rawRowData = cellData[i]; - //check whether the data row vector length matches with the column count - if(m_xColumnModel->getColumnCount() == 0) - { - for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) - { - UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); - m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); - } - m_xColumnModel->setDefaultColumns(rawRowData.getLength()); - } - else - if((unsigned int)rawRowData.getLength()!=(unsigned)m_pTableModel->getColumnCount()) - throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel); - - for ( int k = 0; k < rawRowData.getLength(); k++) + for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) { - newRow.push_back(rawRowData[k]); + UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); + m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); } - m_pTableModel->getCellContent().push_back(newRow); + m_xColumnModel->setDefaultColumns(rawRowData.getLength()); } + else + if((unsigned int)rawRowData.getLength()!=(unsigned)m_pTableModel->getColumnCount()) + throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel); - Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); - std::vector< rtl::OUString > newRow( - comphelper::sequenceToContainer< std::vector >(rowHeaders)); - m_pTableModel->setRowCount(m_xDataModel->getRowCount()); - m_pTableModel->setRowHeaderName(newRow); + for ( int k = 0; k < rawRowData.getLength(); k++) + { + newRow.push_back(rawRowData[k]); + } + m_pTableModel->getCellContent().push_back(newRow); } + + Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); + std::vector< rtl::OUString > newRow( + comphelper::sequenceToContainer< std::vector >(rowHeaders)); + m_pTableModel->setRowCount(m_xDataModel->getRowCount()); + m_pTableModel->setRowHeaderName(newRow); } - else - throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel); + sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); if(m_xDataModel->getRowHeight() == 0) { @@ -316,41 +315,36 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_GRID_COLUMNMODEL: { - m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY ); - if(m_xColumnModel != NULL) + m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY_THROW ); + if(m_xColumnModel->getColumnCount() != 0) { - if(m_xColumnModel->getColumnCount() != 0) + Sequence > columns = m_xColumnModel->getColumns(); + std::vector > aNewColumns( + comphelper::sequenceToContainer > >(columns)); + sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); + if(m_xColumnModel->getColumnHeaderHeight() == 0) { - Sequence > columns = m_xColumnModel->getColumns(); - std::vector > aNewColumns( - comphelper::sequenceToContainer > >(columns)); - sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); - if(m_xColumnModel->getColumnHeaderHeight() == 0) - { - m_pTableModel->setColumnHeaderHeight(fontHeight); - m_xColumnModel->setColumnHeaderHeight(fontHeight); - } - else - m_pTableModel->setColumnHeaderHeight(m_xColumnModel->getColumnHeaderHeight()); - for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) - { - UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]); - Reference< XGridColumn > xGridColumn = m_xColumnModel->getColumn(col); - m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); - tableColumn->setHorizontalAlign(xGridColumn->getHorizontalAlign()); - tableColumn->setWidth(xGridColumn->getColumnWidth()); - if(xGridColumn->getPreferredWidth() != 0) - tableColumn->setPreferredWidth(xGridColumn->getPreferredWidth()); - if(xGridColumn->getMaxWidth() != 0) - tableColumn->setMaxWidth(xGridColumn->getMaxWidth()); - if(xGridColumn->getMinWidth() != 0) - tableColumn->setMinWidth(xGridColumn->getMinWidth()); - tableColumn->setResizable(xGridColumn->getResizeable()); - } + m_pTableModel->setColumnHeaderHeight(fontHeight); + m_xColumnModel->setColumnHeaderHeight(fontHeight); + } + else + m_pTableModel->setColumnHeaderHeight(m_xColumnModel->getColumnHeaderHeight()); + for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) + { + UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]); + Reference< XGridColumn > xGridColumn = m_xColumnModel->getColumn(col); + m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); + tableColumn->setHorizontalAlign(xGridColumn->getHorizontalAlign()); + tableColumn->setWidth(xGridColumn->getColumnWidth()); + if(xGridColumn->getPreferredWidth() != 0) + tableColumn->setPreferredWidth(xGridColumn->getPreferredWidth()); + if(xGridColumn->getMaxWidth() != 0) + tableColumn->setMaxWidth(xGridColumn->getMaxWidth()); + if(xGridColumn->getMinWidth() != 0) + tableColumn->setMinWidth(xGridColumn->getMinWidth()); + tableColumn->setResizable(xGridColumn->getResizeable()); } } - else - throw GridInvalidModelException(rtl::OUString::createFromAscii("The column model isn't set!"), m_xColumnModel); break; } diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 491e5b8bb5cc..e15e6683a902 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -85,6 +85,15 @@ UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun:: ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_BACKGROUND ); ImplRegisterProperty( BASEPROPERTY_GRID_LINE_COLOR ); ImplRegisterProperty( BASEPROPERTY_GRID_ROW_BACKGROUND ); + + osl_incrementInterlockedCount( &m_refCount ); + { + setFastPropertyValue( BASEPROPERTY_GRID_COLUMNMODEL, + makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridColumnModel" ) ) ); + setFastPropertyValue( BASEPROPERTY_GRID_DATAMODEL, + makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridDataModel" ) ) ); + } + osl_decrementInterlockedCount( &m_refCount ); } UnoGridModel::UnoGridModel( const UnoGridModel& rModel ) -- cgit v1.2.3 From 7bef1fa0ecb93f800ae3d0b0ab049b00560fcdf1 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 7 Dec 2010 13:50:47 +0100 Subject: gridsort: introduced container listeners at the grid model, reworked and fixed listener relationship between grid model/control/peer --- svtools/source/uno/svtxgridcontrol.cxx | 293 ++++++++------ svtools/source/uno/svtxgridcontrol.hxx | 64 ++-- .../inc/toolkit/helper/mutexandbroadcasthelper.hxx | 6 - .../controls/grid/defaultgridcolumnmodel.cxx | 379 ++++++++++++------- .../controls/grid/defaultgridcolumnmodel.hxx | 63 ++-- toolkit/source/controls/grid/gridcolumn.cxx | 420 ++++++++++----------- toolkit/source/controls/grid/gridcolumn.hxx | 62 ++- toolkit/source/controls/grid/gridcontrol.cxx | 106 ++++-- toolkit/source/controls/grid/gridcontrol.hxx | 27 +- .../source/controls/grid/grideventforwarder.cxx | 141 +++++++ .../source/controls/grid/grideventforwarder.hxx | 84 +++++ toolkit/source/controls/grid/makefile.mk | 3 +- toolkit/util/tk.component | 2 +- 13 files changed, 1028 insertions(+), 622 deletions(-) mode change 100755 => 100644 svtools/source/uno/svtxgridcontrol.hxx create mode 100755 toolkit/source/controls/grid/grideventforwarder.cxx create mode 100755 toolkit/source/controls/grid/grideventforwarder.hxx (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index b1bcfbe7edd5..765a37e90495 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -36,7 +36,7 @@ #include "unocontroltablemodel.hxx" #include #include -#include +#include #include #include #include @@ -50,12 +50,11 @@ #include #include -using ::rtl::OUString; using namespace ::svt::table; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::view; -using namespace ::toolkit; +using namespace ::com::sun::star::container; using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::accessibility::AccessibleEventId; using namespace ::com::sun::star::accessibility::AccessibleTableModelChangeType; @@ -76,38 +75,28 @@ SVTXGridControl::SVTXGridControl() { } -//-------------------------------------------------------------------- +// --------------------------------------------------------------------------------------------------------------------- SVTXGridControl::~SVTXGridControl() { } -::com::sun::star::uno::Any SVTXGridControl::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) -{ - ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, - SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridControl*, this ), - SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridDataListener*, this ), - SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridColumnListener*, this ), - SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); - return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); -} - -// ::com::sun::star::lang::XTypeProvider -IMPL_XTYPEPROVIDER_START( SVTXGridControl ) - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridControl>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener>* ) NULL ), - VCLXWindow::getTypes() -IMPL_XTYPEPROVIDER_END - +// --------------------------------------------------------------------------------------------------------------------- sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getItemIndexAtPoint: no control (anymore)!", -1 ); return pTable->GetCurrentRow( Point(x,y) ); } +// --------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable != NULL, "SVTXGridControl::setToolTip: no control (anymore)!" ); pTable->setTooltip(text, columns); } @@ -125,7 +114,9 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An { ::vos::OGuard aGuard( GetMutex() ); - TableControl* pTable = (TableControl*)GetWindow(); + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable != NULL, "SVTXGridControl::setProperty: no control (anymore)!" ); + switch( GetPropertyId( PropertyName ) ) { case BASEPROPERTY_BACKGROUNDCOLOR: @@ -151,7 +142,6 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An case SelectionType_SINGLE: eSelMode = SINGLE_SELECTION; break; case SelectionType_RANGE: eSelMode = RANGE_SELECTION; break; case SelectionType_MULTI: eSelMode = MULTIPLE_SELECTION; break; - // case SelectionType_NONE: default: eSelMode = NO_SELECTION; break; } if( pTable->getSelEngine()->GetSelectionMode() != eSelMode ) @@ -264,10 +254,10 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An { m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); if ( !m_xDataModel.is() ) - throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel); + throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The data model isn't set!"), *this ); - Sequence > cellData = m_xDataModel->getData(); - if(cellData.getLength()!= 0) + Sequence< Sequence< Any > > cellData = m_xDataModel->getData(); + if ( cellData.getLength() != 0 ) { for (int i = 0; i < cellData.getLength(); i++) { @@ -302,14 +292,11 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); - if(m_xDataModel->getRowHeight() == 0) - { - m_pTableModel->setRowHeight(fontHeight); - m_xDataModel->setRowHeight(fontHeight); - } + if ( m_xDataModel->getRowHeight() == 0 ) + m_pTableModel->setRowHeight( fontHeight ); else - m_pTableModel->setRowHeight(m_xDataModel->getRowHeight()); - m_pTableModel->setRowHeaderWidth(m_xDataModel->getRowHeaderWidth()); + m_pTableModel->setRowHeight( m_xDataModel->getRowHeight() ); + m_pTableModel->setRowHeaderWidth( m_xDataModel->getRowHeaderWidth() ); } break; } @@ -358,77 +345,72 @@ Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru { ::vos::OGuard aGuard( GetMutex() ); + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getProperty: no control (anymore)!", Any() ); + const sal_uInt16 nPropId = GetPropertyId( PropertyName ); - TableControl* pTable = (TableControl*)GetWindow(); - if(pTable) + switch(nPropId) { - switch(nPropId) - { - case BASEPROPERTY_GRID_SELECTIONMODE: - { - SelectionType eSelectionType; + case BASEPROPERTY_GRID_SELECTIONMODE: + { + SelectionType eSelectionType; - SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); - switch( eSelMode ) - { - case SINGLE_SELECTION: eSelectionType = SelectionType_SINGLE; break; - case RANGE_SELECTION: eSelectionType = SelectionType_RANGE; break; - case MULTIPLE_SELECTION:eSelectionType = SelectionType_MULTI; break; -// case NO_SELECTION: - default: eSelectionType = SelectionType_NONE; break; - } - return Any( eSelectionType ); - } - case BASEPROPERTY_GRID_SHOWROWHEADER: - { - return Any ((sal_Bool) m_pTableModel->hasRowHeaders()); - } - case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: - return Any ((sal_Bool) m_pTableModel->hasColumnHeaders()); - case BASEPROPERTY_GRID_DATAMODEL: - return Any ( m_xDataModel ); - case BASEPROPERTY_GRID_COLUMNMODEL: - return Any ( m_xColumnModel); - case BASEPROPERTY_HSCROLL: - return Any ( m_bHScroll); - case BASEPROPERTY_VSCROLL: - return Any ( m_bVScroll); + SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); + switch( eSelMode ) + { + case SINGLE_SELECTION: eSelectionType = SelectionType_SINGLE; break; + case RANGE_SELECTION: eSelectionType = SelectionType_RANGE; break; + case MULTIPLE_SELECTION:eSelectionType = SelectionType_MULTI; break; + default: eSelectionType = SelectionType_NONE; break; } + return Any( eSelectionType ); } + case BASEPROPERTY_GRID_SHOWROWHEADER: + { + return Any ((sal_Bool) m_pTableModel->hasRowHeaders()); + } + case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: + return Any ((sal_Bool) m_pTableModel->hasColumnHeaders()); + case BASEPROPERTY_GRID_DATAMODEL: + return Any ( m_xDataModel ); + case BASEPROPERTY_GRID_COLUMNMODEL: + return Any ( m_xColumnModel); + case BASEPROPERTY_HSCROLL: + return Any ( m_bHScroll); + case BASEPROPERTY_VSCROLL: + return Any ( m_bVScroll); + } + return VCLXWindow::getProperty( PropertyName ); } void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) { PushPropertyIds( rIds, - BASEPROPERTY_GRID_SHOWROWHEADER, - BASEPROPERTY_GRID_SHOWCOLUMNHEADER, - BASEPROPERTY_GRID_DATAMODEL, - BASEPROPERTY_GRID_COLUMNMODEL, - BASEPROPERTY_GRID_SELECTIONMODE, - BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND, - BASEPROPERTY_GRID_HEADER_BACKGROUND, - BASEPROPERTY_GRID_LINE_COLOR, - BASEPROPERTY_GRID_ROW_BACKGROUND, - 0); + BASEPROPERTY_GRID_SHOWROWHEADER, + BASEPROPERTY_GRID_SHOWCOLUMNHEADER, + BASEPROPERTY_GRID_DATAMODEL, + BASEPROPERTY_GRID_COLUMNMODEL, + BASEPROPERTY_GRID_SELECTIONMODE, + BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND, + BASEPROPERTY_GRID_HEADER_BACKGROUND, + BASEPROPERTY_GRID_LINE_COLOR, + BASEPROPERTY_GRID_ROW_BACKGROUND, + 0 + ); VCLXWindow::ImplGetPropertyIds( rIds, true ); } void SAL_CALL SVTXGridControl::setVisible( sal_Bool bVisible ) throw(::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - TableControl* pTable = (TableControl*)GetWindow(); - if ( pTable ) - { - pTable->SetModel(PTableModel(m_pTableModel)); - pTable->Show( bVisible ); - } -} -void SAL_CALL SVTXGridControl::setFocus() throw(::com::sun::star::uno::RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - if ( GetWindow()) - GetWindow()->GrabFocus(); + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable != NULL, "SVTXGridControl::setVisible: no control (anymore)!" ); + + pTable->SetModel( PTableModel( m_pTableModel ) ); + // TODO: what's this SetModel call good for? Looks like a hack to me, to work around some other bug. + pTable->Show( bVisible ); } + void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -449,7 +431,7 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD } else if((unsigned int)rawRowData.getLength()!=(unsigned)colCount) - throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel); + throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), *this ); for ( int k = 0; k < rawRowData.getLength(); k++) newRow.push_back(rawRowData[k]); @@ -457,7 +439,10 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD if(m_pTableModel->hasRowHeaders()) m_pTableModel->getRowHeaderName().push_back(Event.headerName); m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); - TableControl* pTable = (TableControl*)GetWindow(); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowAdded: no control (anymore)!" ); + pTable->InvalidateDataWindow(m_pTableModel->getCellContent().size()-1, 0, false); if(pTable->isAccessibleAlive()) { @@ -481,7 +466,9 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri { ::vos::OGuard aGuard( GetMutex() ); - TableControl* pTable = (TableControl*)GetWindow(); + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowRemoved: no control (anymore)!" ); + if(Event.index == -1) { if(!isSelectionEmpty()) @@ -524,7 +511,9 @@ void SAL_CALL SVTXGridControl::columnChanged(const ::com::sun::star::awt::grid: { ::vos::OGuard aGuard( GetMutex() ); - TableControl* pTable = (TableControl*)GetWindow(); + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::columnChanged: no control (anymore)!" ); + if(Event.valueName == rtl::OUString::createFromAscii("ColumnResize")) { bool resizable = m_pTableModel->getColumnModel()[Event.index]->isResizable(); @@ -573,7 +562,9 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::G { ::vos::OGuard aGuard( GetMutex() ); - TableControl* pTable = (TableControl*)GetWindow(); + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" ); + if(Event.valueName == rtl::OUString::createFromAscii("RowHeight")) { sal_Int32 rowHeight = m_pTableModel->getRowHeight(); @@ -622,6 +613,34 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::G } } +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL SVTXGridControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) +{ + (void)i_event; + + // TODO: add as XGridColumnListener + // TODO: update our TableControl +} + +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL SVTXGridControl::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) +{ + (void)i_event; + + // TODO: remove as XGridColumnListener + // TODO: update our TableControl +} + +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL SVTXGridControl::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) +{ + (void)i_event; + + // TODO: add/remove as XGridColumnListener + // TODO: update our TableControl +} + + void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) { VCLXWindow::disposing( Source ); @@ -629,7 +648,11 @@ void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObj ::sal_Int32 SAL_CALL SVTXGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable, "SVTXGridControl::getMinSelectionIndex: no control (anymore)!", -1 ); + std::vector& selectedRows = pTable->GetSelectedRows(); if(selectedRows.empty()) return -1; @@ -643,7 +666,11 @@ void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObj ::sal_Int32 SAL_CALL SVTXGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable, "SVTXGridControl::getMaxSelectionIndex: no control (anymore)!", -1 ); + std::vector& selectedRows = pTable->GetSelectedRows(); if(selectedRows.empty()) return -1; @@ -657,7 +684,11 @@ void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObj void SAL_CALL SVTXGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::selectRows: no control (anymore)!" ); + SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); if(eSelMode != NO_SELECTION) { @@ -695,7 +726,11 @@ void SAL_CALL SVTXGridControl::selectRows(const ::com::sun::star::uno::Sequence< void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::selectAllRows: no control (anymore)!" ); + SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); if(eSelMode != NO_SELECTION) { @@ -713,7 +748,11 @@ void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::Run void SAL_CALL SVTXGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::deselectRows: no control (anymore)!" ); + std::vector& selectedRows = pTable->GetSelectedRows(); std::vector::iterator itStart = selectedRows.begin(); std::vector::iterator itEnd = selectedRows.end(); @@ -731,7 +770,11 @@ void SAL_CALL SVTXGridControl::deselectRows(const ::com::sun::star::uno::Sequenc void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::deselectAllRows: no control (anymore)!" ); + std::vector& selectedRows = pTable->GetSelectedRows(); if(!selectedRows.empty()) selectedRows.clear(); @@ -743,7 +786,11 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL SVTXGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable, "SVTXGridControl::getSelection: no control (anymore)!", Sequence< sal_Int32 >() ); + std::vector& selectedRows = pTable->GetSelectedRows(); Sequence selectedRowsToSequence(comphelper::containerToSequence(selectedRows)); return selectedRowsToSequence; @@ -756,7 +803,11 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R ::sal_Bool SAL_CALL SVTXGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable, "SVTXGridControl::getSelection: no control (anymore)!", sal_True ); + std::vector& selectedRows = pTable->GetSelectedRows(); if(selectedRows.empty()) return sal_True; @@ -766,16 +817,24 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R ::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { - TableControl* pTable = (TableControl*)GetWindow(); + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable, "SVTXGridControl::isSelectedIndex: no control (anymore)!", sal_False ); + std::vector& selectedRows = pTable->GetSelectedRows(); return std::find(selectedRows.begin(),selectedRows.end(), index) != selectedRows.end(); } void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::isSelectedIndex: no control (anymore)!" ); + if(index<0 || index>=m_pTableModel->getRowCount()) return; - TableControl* pTable = (TableControl*)GetWindow(); SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); if(eSelMode != NO_SELECTION) { @@ -812,8 +871,6 @@ void SAL_CALL SVTXGridControl::selectColumn(::sal_Int32 x) throw (::com::sun::st } void SVTXGridControl::dispose() throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( GetMutex() ); - ::com::sun::star::lang::EventObject aObj; aObj.Source = (::cppu::OWeakObject*)this; m_aSelectionListeners.disposeAndClear( aObj ); @@ -822,21 +879,17 @@ void SVTXGridControl::dispose() throw(::com::sun::star::uno::RuntimeException) void SVTXGridControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); + ::vos::OGuard aGuard( GetMutex() ); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this ); switch ( rVclWindowEvent.GetId() ) { case VCLEVENT_TABLEROW_SELECT: { - TableControl* pTable = (TableControl*)GetWindow(); - - if( pTable ) - { - if ( m_aSelectionListeners.getLength() ) - { - ImplCallItemListeners(); - } - } + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_BREAK( pTable, "SVTXGridControl::ProcessWindowEvent: no control (anymore)!" ); + if ( m_aSelectionListeners.getLength() ) + ImplCallItemListeners(); } break; @@ -848,8 +901,10 @@ void SVTXGridControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent void SVTXGridControl::ImplCallItemListeners() { - TableControl* pTable = (TableControl*) GetWindow(); - if ( pTable && m_aSelectionListeners.getLength() ) + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::ImplCallItemListeners: no control (anymore)!" ); + + if ( m_aSelectionListeners.getLength() ) { ::std::vector selRows = pTable->GetSelectedRows(); ::com::sun::star::awt::grid::GridSelectionEvent aEvent; diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx old mode 100755 new mode 100644 index b15507e4614f..3197b4b8e23b --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -38,55 +38,60 @@ #include #include #include +#include #include #include #include -#include +#include #include using namespace ::svt::table; -class SVTXGridControl : public ::cppu::ImplInheritanceHelper3< VCLXWindow, ::com::sun::star::awt::grid::XGridControl, - ::com::sun::star::awt::grid::XGridDataListener, ::com::sun::star::awt::grid::XGridColumnListener> +typedef ::cppu::ImplInheritanceHelper4 < VCLXWindow + , ::com::sun::star::awt::grid::XGridControl + , ::com::sun::star::awt::grid::XGridDataListener + , ::com::sun::star::awt::grid::XGridColumnListener + , ::com::sun::star::container::XContainerListener + > SVTXGridControl_Base; +class SVTXGridControl : public SVTXGridControl_Base { private: - ::boost::shared_ptr< UnoControlTableModel > m_pTableModel; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >m_xDataModel; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >m_xColumnModel; - bool m_bHasColumnHeaders; - bool m_bHasRowHeaders; - bool m_bVScroll; - bool m_bHScroll; - bool m_bUpdate; - sal_Int32 m_nSelectedRowCount; - SelectionListenerMultiplexer m_aSelectionListeners; + ::boost::shared_ptr< UnoControlTableModel > m_pTableModel; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > m_xDataModel; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > m_xColumnModel; + bool m_bHasColumnHeaders; + bool m_bHasRowHeaders; + bool m_bVScroll; + bool m_bHScroll; + bool m_bUpdate; + sal_Int32 m_nSelectedRowCount; + SelectionListenerMultiplexer m_aSelectionListeners; protected: virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); void ImplCallItemListeners(); public: - SVTXGridControl(); + SVTXGridControl(); ~SVTXGridControl(); - //XGridDataListener overridables - virtual void SAL_CALL rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL dataChanged(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException); + + // XGridDataListener + virtual void SAL_CALL rowAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XContainerListener + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); //XGridColumnListener overridables virtual void SAL_CALL columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent & Event) throw (::com::sun::star::uno::RuntimeException); + // XEventListener virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL acquire() throw() { VCLXWindow::acquire(); } - void SAL_CALL release() throw() { VCLXWindow::release(); } - - // ::com::sun::star::lang::XTypeProvider - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - //::com::sun::star::awt::grid::XGridControl virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); @@ -109,9 +114,10 @@ public: ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); void SAL_CALL setVisible(sal_Bool bVisible) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL setFocus() throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::lang::XComponent void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); - }; - #endif // _SVT_GRIDCONTROL_HXX_ + + // XContainertListener +}; +#endif // _SVT_GRIDCONTROL_HXX_ diff --git a/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx b/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx index c84a6e54d73b..611d90427609 100644 --- a/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx +++ b/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx @@ -39,7 +39,6 @@ class MutexAndBroadcastHelper public: MutexAndBroadcastHelper() : BrdcstHelper( Mutex ) {} - ::osl::Mutex Mutex; ::cppu::OBroadcastHelper BrdcstHelper; @@ -47,11 +46,6 @@ public: }; - - - - - #endif // _TOOLKIT_HELPER_MUTEXANDBROADCASTHELPER_HXX diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 011f3502cdd8..a48f75966bde 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -27,174 +27,273 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" + #include "defaultgridcolumnmodel.hxx" -#include -#include + +/** === begin UNO includes === **/ #include -#include +/** === end UNO includes === **/ -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::style; +#include +#include +#include +//...................................................................................................................... namespace toolkit +//...................................................................................................................... { + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::awt::grid::XGridColumn; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::container::XContainerListener; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::uno::Exception; + /** === end UNO using === **/ + + //================================================================================================================== + //= DefaultGridColumnModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + DefaultGridColumnModel::DefaultGridColumnModel( const Reference< XMultiServiceFactory >& i_factory ) + :DefaultGridColumnModel_Base( m_aMutex ) + ,m_aContext( i_factory ) + ,m_aContainerListeners( m_aMutex ) + ,m_aColumns() + ,m_nColumnHeaderHeight(0) + { + } -/////////////////////////////////////////////////////////////////////// -// class DefaultGridColumnModel -/////////////////////////////////////////////////////////////////////// - -DefaultGridColumnModel::DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory) -: columns(std::vector< Reference< XGridColumn > >()) - ,m_nColumnHeaderHeight(0) - ,m_xFactory(xFactory) -{ -} - -//--------------------------------------------------------------------- - -DefaultGridColumnModel::~DefaultGridColumnModel() -{ -} - -//--------------------------------------------------------------------- - -::sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException) -{ - return columns.size(); -} - -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + DefaultGridColumnModel::~DefaultGridColumnModel() + { + } -::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - Reference xColumn(column); - columns.push_back(xColumn); - sal_Int32 index = columns.size() - 1; - xColumn->setIndex(index); - return index; -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnCount() throw (RuntimeException) + { + return m_aColumns.size(); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn( const Reference< XGridColumn > & i_column ) throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL DefaultGridColumnModel::getColumns() throw (::com::sun::star::uno::RuntimeException) -{ - return comphelper::containerToSequence(columns); -} + m_aColumns.push_back( i_column ); + sal_Int32 index = m_aColumns.size() - 1; + i_column->setIndex( index ); -//--------------------------------------------------------------------- + return index; + } -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) -{ - if ( index >=0 && index < ((sal_Int32)columns.size())) + //------------------------------------------------------------------------------------------------------------------ + Sequence< Reference< XGridColumn > > SAL_CALL DefaultGridColumnModel::getColumns() throw (RuntimeException) { - return columns[index]; + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + return ::comphelper::containerToSequence( m_aColumns ); } - else - return Reference< XGridColumn >(); -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) -{ - m_nColumnHeaderHeight = _value; -} -//--------------------------------------------------------------------- -sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnHeaderHeight() throw (::com::sun::star::uno::RuntimeException) -{ - return m_nColumnHeaderHeight; -} - -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - for(sal_Int32 i=0;i SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (RuntimeException) { - Reference xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY ); - columns.push_back(xColumn); - xColumn->setIndex(i); + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + if ( index >=0 && index < ((sal_Int32)m_aColumns.size())) + { + return m_aColumns[index]; + } + else + // TODO: exception + return Reference< XGridColumn >(); } -} -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException) -{ - Reference xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY ); - xColumn->setColumnWidth(column->getColumnWidth()); - xColumn->setPreferredWidth(column->getPreferredWidth()); - xColumn->setMaxWidth(column->getMaxWidth()); - xColumn->setMinWidth(column->getMinWidth()); - xColumn->setPreferredWidth(column->getPreferredWidth()); - xColumn->setResizeable(column->getResizeable()); - xColumn->setTitle(column->getTitle()); - xColumn->setHorizontalAlign(column->getHorizontalAlign()); - return xColumn; -} -//--------------------------------------------------------------------- -// XComponent -//--------------------------------------------------------------------- - -void SAL_CALL DefaultGridColumnModel::dispose() throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - - ::com::sun::star::lang::EventObject aEvent; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - BrdcstHelper.aLC.disposeAndClear( aEvent ); -} - -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + m_nColumnHeaderHeight = _value; + } -void SAL_CALL DefaultGridColumnModel::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XEventListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnHeaderHeight() throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + return m_nColumnHeaderHeight; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (RuntimeException) + { + ::std::vector< ContainerEvent > aRemovedColumns; + ::std::vector< ContainerEvent > aInsertedColumns; + + { + ::osl::MutexGuard aGuard( m_aMutex ); + + // remove existing columns + while ( !m_aColumns.empty() ) + { + const size_t lastColIndex = m_aColumns.size() - 1; + + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= sal_Int32( lastColIndex ); + aEvent.Element <<= m_aColumns[ lastColIndex ]; + aRemovedColumns.push_back( aEvent ); + + m_aColumns.erase( m_aColumns.begin() + lastColIndex ); + } + + // add new columns + for ( sal_Int32 i=0; i xColumn( m_aContext.createComponent( "com.sun.star.awt.grid.GridColumn" ), UNO_QUERY_THROW ); + + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= i; + aEvent.Element <<= xColumn; + aInsertedColumns.push_back( aEvent ); + + m_aColumns.push_back( xColumn ); + xColumn->setIndex( i ); + } + } + + // fire removal notifications + for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); + event != aRemovedColumns.end(); + ++event + ) + { + m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, *event ); + } + + // fire insertion notifications + for ( ::std::vector< ContainerEvent >::const_iterator event = aInsertedColumns.begin(); + event != aInsertedColumns.end(); + ++event + ) + { + m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, *event ); + } + + // dispose removed columns + for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); + event != aRemovedColumns.end(); + ++event + ) + { + try + { + const Reference< XComponent > xColComp( event->Element, UNO_QUERY_THROW ); + xColComp->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } -void SAL_CALL DefaultGridColumnModel::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn(const Reference< XGridColumn > & column) throw (RuntimeException) + { + Reference< XGridColumn > xColumn( m_aContext.createComponent( "com.sun.star.awt.grid.GridColumn" ), UNO_QUERY_THROW ); + xColumn->setColumnWidth(column->getColumnWidth()); + xColumn->setPreferredWidth(column->getPreferredWidth()); + xColumn->setMaxWidth(column->getMaxWidth()); + xColumn->setMinWidth(column->getMinWidth()); + xColumn->setPreferredWidth(column->getPreferredWidth()); + xColumn->setResizeable(column->getResizeable()); + xColumn->setTitle(column->getTitle()); + xColumn->setHorizontalAlign(column->getHorizontalAlign()); + return xColumn; + } -//--------------------------------------------------------------------- -// XServiceInfo -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL DefaultGridColumnModel::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.DefaultGridColumnModel" ) ); + } -::rtl::OUString SAL_CALL DefaultGridColumnModel::getImplementationName( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridColumnModel" ) ); - return aImplName; -} + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL DefaultGridColumnModel::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException) + { + const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); + for ( sal_Int32 i=0; i SAL_CALL DefaultGridColumnModel::getSupportedServiceNames( ) throw (RuntimeException) + { + const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_DefaultGridColumnModel ) ); + const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; + } -sal_Bool SAL_CALL DefaultGridColumnModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - return ServiceName.equalsAscii( szServiceName_DefaultGridColumnModel ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::addContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + if ( i_listener.is() ) + m_aContainerListeners.addInterface( i_listener ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::removeContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + if ( i_listener.is() ) + m_aContainerListeners.removeInterface( i_listener ); + } -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridColumnModel::getSupportedServiceNames( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridColumnModel ) ); - static const Sequence< OUString > aSeq( &aServiceName, 1 ); - return aSeq; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::disposing() + { + DefaultGridColumnModel_Base::disposing(); + + EventObject aEvent( *this ); + m_aContainerListeners.disposeAndClear( aEvent ); + + ::osl::MutexGuard aGuard( m_aMutex ); + // remove, dispose and clear columns + { + while ( !m_aColumns.empty() ) + { + try + { + const Reference< XComponent > xColComponent( m_aColumns[ 0 ], UNO_QUERY_THROW ); + xColComponent->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + m_aColumns.erase( m_aColumns.begin() ); + } + + Columns aEmpty; + m_aColumns.swap( aEmpty ); + } + } -} +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... -Reference< XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const Reference< XMultiServiceFactory >& _rFactory) +//---------------------------------------------------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rFactory) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel( _rFactory ) ); + return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel( _rFactory ) ); } - diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx index 8b8c8bfc795c..964d604c8ab1 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx @@ -25,76 +25,67 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_toolkit.hxx" +/** === begin UNO includes === **/ #include #include //#include #include #include #include -#include -#include -#include -#include -#include -#include #include -#include +#include +/** === end UNO includes === **/ -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; +#include +#include +#include +#include namespace toolkit { //enum broadcast_type { column_added, column_removed, column_changed}; -class DefaultGridColumnModel : public ::cppu::WeakImplHelper2< XGridColumnModel, XServiceInfo >, - public MutexAndBroadcastHelper +typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::awt::grid::XGridColumnModel + , ::com::sun::star::lang::XServiceInfo + > DefaultGridColumnModel_Base; + +class DefaultGridColumnModel :public ::cppu::BaseMutex + ,public DefaultGridColumnModel_Base { public: - DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory); + DefaultGridColumnModel(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory); virtual ~DefaultGridColumnModel(); // XGridColumnModel - - //virtual ::sal_Bool SAL_CALL getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL setColumnSelectionAllowed(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); - //virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL setColumnHeaderHeight( sal_Int32 _value) throw (com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getColumnHeaderHeight() throw (com::sun::star::uno::RuntimeException); virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException); - // XComponent - virtual void SAL_CALL dispose( ) throw (RuntimeException); - virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException); // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); -private: - /*void broadcast( broadcast_type eType, const GridColumnEvent& aEvent ); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue, sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ); - void broadcast_add( sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ); - void broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );*/ + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + +private: + typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > Columns; - std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > columns; - sal_Bool selectionAllowed; - sal_Int32 m_nColumnHeaderHeight; - Reference< XMultiServiceFactory > m_xFactory; + ::comphelper::ComponentContext m_aContext; + ::cppu::OInterfaceContainerHelper m_aContainerListeners; + Columns m_aColumns; + sal_Int32 m_nColumnHeaderHeight; }; } diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 6720d639f5c1..4094f4433538 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -25,20 +25,11 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" #include "gridcolumn.hxx" + #include #include -#include - -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::style; #define COLWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColWidth" )) #define MAXWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MaxWidth" )) @@ -51,255 +42,240 @@ using namespace ::com::sun::star::style; namespace toolkit { + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::awt; + using namespace ::com::sun::star::awt::grid; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::style; + + //================================================================================================================== + //= DefaultGridColumnModel + //================================================================================================================== + GridColumn::GridColumn() + :GridColumn_Base( m_aMutex ) + ,m_aIdentifier() + ,m_nIndex(0) + ,m_nColumnWidth(4) + ,m_nPreferredWidth(0) + ,m_nMaxWidth(0) + ,m_nMinWidth(0) + ,m_bResizeable(true) + ,m_eHorizontalAlign(HorizontalAlignment(0)) + { + } -/////////////////////////////////////////////////////////////////////// -// class GridColumn -/////////////////////////////////////////////////////////////////////// - -GridColumn::GridColumn() -: identifier(Any()) -,index(0) -,columnWidth(4) -,preferredWidth(0) -,maxWidth(0) -,minWidth(0) -,bResizeable(true) -,horizontalAlign(HorizontalAlignment(0)) -{ -} - -//--------------------------------------------------------------------- - -GridColumn::~GridColumn() -{ -} - -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + GridColumn::~GridColumn() + { + } -void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ) -{ - ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() ); - if( pIter ) + //------------------------------------------------------------------------------------------------------------------ + void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ) { - ::cppu::OInterfaceIteratorHelper aListIter(*pIter); - while(aListIter.hasMoreElements()) + ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() ); + if( pIter ) { - XGridColumnListener* pListener = static_cast(aListIter.next()); - switch( eType ) + ::cppu::OInterfaceIteratorHelper aListIter(*pIter); + while(aListIter.hasMoreElements()) { - case column_attribute_changed: pListener->columnChanged(aEvent); break; + XGridColumnListener* pListener = static_cast(aListIter.next()); + switch( eType ) + { + case column_attribute_changed: pListener->columnChanged(aEvent); break; + } } } } -} - -//--------------------------------------------------------------------- -void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridColumnEvent aEvent( xSource, name, oldValue, newValue, index); - broadcast( column_attribute_changed, aEvent); -} - -void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException) -{ - if(PREFWIDTH == name) - preferredWidth = width; - else if (COLWIDTH == name) - columnWidth = width; -} -//--------------------------------------------------------------------- -// XGridColumn -//--------------------------------------------------------------------- - -::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException) -{ - return identifier; -} - -//--------------------------------------------------------------------- - -void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException) -{ - value >>= identifier; -} - -//-------------------------------------------------------------------- - -::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException) -{ - broadcast_changed(UPDATE, Any(columnWidth), Any()); - return columnWidth; -} - -//-------------------------------------------------------------------- - -void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - columnWidth = value; - broadcast_changed(COLWIDTH, Any(columnWidth),Any(value)); -} -//-------------------------------------------------------------------- - -::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) -{ - broadcast_changed(UPDATE, Any(preferredWidth), Any()); - return preferredWidth; -} - -//-------------------------------------------------------------------- - -void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - preferredWidth = value; - broadcast_changed(PREFWIDTH, Any(preferredWidth),Any(value)); -} -//-------------------------------------------------------------------- - -::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) -{ - return maxWidth; -} - -//-------------------------------------------------------------------- - -void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - maxWidth = value; - broadcast_changed(MAXWIDTH, Any(maxWidth),Any(value)); -} -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue) + { + Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + GridColumnEvent aEvent( xSource, name, oldValue, newValue, m_nIndex); + broadcast( column_attribute_changed, aEvent); + } -::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException) -{ - return minWidth; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException) + { + if(PREFWIDTH == name) + m_nPreferredWidth = width; + else if (COLWIDTH == name) + m_nColumnWidth = width; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException) + { + return m_aIdentifier; + } -void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - minWidth = value; - broadcast_changed(MINWIDTH, Any(minWidth),Any(value)); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException) + { + value >>= m_aIdentifier; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException) + { + broadcast_changed(UPDATE, Any(m_nColumnWidth), Any()); + return m_nColumnWidth; + } -::rtl::OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException) -{ - return title; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + m_nColumnWidth = value; + broadcast_changed(COLWIDTH, Any(m_nColumnWidth),Any(value)); + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) + { + broadcast_changed(UPDATE, Any(m_nPreferredWidth), Any()); + return m_nPreferredWidth; + } -void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) -{ - title = value; - broadcast_changed(TITLE, Any(title),Any(value)); -} -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + m_nPreferredWidth = value; + broadcast_changed(PREFWIDTH, Any(m_nPreferredWidth),Any(value)); + } -sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException) -{ - return bResizeable; -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) + { + return m_nMaxWidth; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + m_nMaxWidth = value; + broadcast_changed(MAXWIDTH, Any(m_nMaxWidth),Any(value)); + } -void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) -{ - bResizeable = value; - broadcast_changed(COLRESIZE, Any(bResizeable),Any(value)); -} -//--------------------------------------------------------------------- -HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) -{ - return horizontalAlign; -} -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException) + { + return m_nMinWidth; + } -void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) -{ - horizontalAlign = align; - broadcast_changed(HALIGN, Any(horizontalAlign),Any(align)); -} -//--------------------------------------------------------------------- -void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + m_nMinWidth = value; + broadcast_changed(MINWIDTH, Any(m_nMinWidth),Any(value)); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException) + { + return m_sTitle; + } -void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) + { + m_sTitle = value; + broadcast_changed(TITLE, Any(m_sTitle),Any(value)); + } -//--------------------------------------------------------------------- -// XComponent -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException) + { + return m_bResizeable; + } -void SAL_CALL GridColumn::dispose() throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) + { + m_bResizeable = value; + broadcast_changed(COLRESIZE, Any(m_bResizeable),Any(value)); + } - ::com::sun::star::lang::EventObject aEvent; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - BrdcstHelper.aLC.disposeAndClear( aEvent ); -} + //------------------------------------------------------------------------------------------------------------------ + HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) + { + return m_eHorizontalAlign; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) + { + m_eHorizontalAlign = align; + broadcast_changed(HALIGN, Any(m_eHorizontalAlign),Any(align)); + } -void SAL_CALL GridColumn::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XEventListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) + { + rBHelper.addListener( XGridColumnListener::static_type(), xListener ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) + { + rBHelper.removeListener( XGridColumnListener::static_type(), xListener ); + } -void SAL_CALL GridColumn::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); -} -void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException) -{ - index = _nIndex; -} -//--------------------------------------------------------------------- -// XServiceInfo -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::dispose() throw (RuntimeException) + { + // simply disambiguate, the base class handles this + GridColumn_Base::dispose(); + } -::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.GridColumn" ) ); - return aImplName; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::addEventListener( const Reference< XEventListener >& i_listener ) throw (RuntimeException) + { + // simply disambiguate, the base class handles this + GridColumn_Base::addEventListener( i_listener ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::removeEventListener( const Reference< XEventListener >& i_listener ) throw (RuntimeException) + { + // simply disambiguate, the base class handles this + GridColumn_Base::removeEventListener( i_listener ); + } -sal_Bool SAL_CALL GridColumn::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - return ServiceName.equalsAscii( szServiceName_GridColumn ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException) + { + m_nIndex = _nIndex; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.GridColumn" ) ); + } -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GridColumn::getSupportedServiceNames( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aServiceName( OUString::createFromAscii( szServiceName_GridColumn ) ); - static const Sequence< OUString > aSeq( &aServiceName, 1 ); - return aSeq; -} + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL GridColumn::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException) + { + const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); + for ( sal_Int32 i=0; i SAL_CALL GridColumn::getSupportedServiceNames( ) throw (RuntimeException) + { + const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_GridColumn ) ); + const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; + } } -Reference< XInterface > SAL_CALL GridColumn_CreateInstance( const Reference< XMultiServiceFactory >& ) +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GridColumn_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::GridColumn ); + return *( new ::toolkit::GridColumn ); } diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index 38d43d55a07b..4a47f44ce674 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -33,32 +33,29 @@ #include #include #include -#include -#include +#include +#include #include #include #include #include -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; - namespace toolkit { enum broadcast_column_type { column_attribute_changed}; -class GridColumn : public ::cppu::WeakImplHelper2< XGridColumn, XServiceInfo >, - public MutexAndBroadcastHelper + +typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::awt::grid::XGridColumn + , ::com::sun::star::lang::XServiceInfo + > GridColumn_Base; +class GridColumn :public ::cppu::BaseMutex + ,public GridColumn_Base { public: GridColumn(); virtual ~GridColumn(); - // XGridColumn + // ::com::sun::star::awt::grid::XGridColumn virtual ::com::sun::star::uno::Any SAL_CALL getIdentifier() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnWidth() throw (::com::sun::star::uno::RuntimeException); @@ -75,33 +72,34 @@ public: virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateColumn( const ::rtl::OUString& name, ::sal_Int32 width ) throw (::com::sun::star::uno::RuntimeException); - // XComponent - virtual void SAL_CALL dispose( ) throw (RuntimeException); - virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException); + + // XComponent (base of XGridColumn) + virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); - virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setIndex(sal_Int32 _nIndex)throw (::com::sun::star::uno::RuntimeException); private: - void broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue); + void broadcast( broadcast_column_type eType, const ::com::sun::star::awt::grid::GridColumnEvent& aEvent ); + void broadcast_changed( ::rtl::OUString name, ::com::sun::star::uno::Any oldValue, ::com::sun::star::uno::Any newValue); - Any identifier; - sal_Int32 index; - sal_Int32 columnWidth; - sal_Int32 preferredWidth; - sal_Int32 maxWidth; - sal_Int32 minWidth; - sal_Bool bResizeable; - ::rtl::OUString title; - ::com::sun::star::style::HorizontalAlignment horizontalAlign; + ::com::sun::star::uno::Any m_aIdentifier; + sal_Int32 m_nIndex; + sal_Int32 m_nColumnWidth; + sal_Int32 m_nPreferredWidth; + sal_Int32 m_nMaxWidth; + sal_Int32 m_nMinWidth; + sal_Bool m_bResizeable; + ::rtl::OUString m_sTitle; + ::com::sun::star::style::HorizontalAlignment m_eHorizontalAlign; }; } diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index e15e6683a902..57b5086e2272 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -28,7 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" -#include +#include "gridcontrol.hxx" +#include "grideventforwarder.hxx" #include #include @@ -39,11 +40,12 @@ #include #include #include -#include +#include using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; @@ -55,6 +57,7 @@ namespace toolkit // ---------------------------------------------------- // class UnoGridModel // ---------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) :UnoControlModel( i_factory ) { @@ -96,21 +99,25 @@ UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun:: osl_decrementInterlockedCount( &m_refCount ); } +//---------------------------------------------------------------------------------------------------------------------- UnoGridModel::UnoGridModel( const UnoGridModel& rModel ) : UnoControlModel( rModel ) { } +//---------------------------------------------------------------------------------------------------------------------- UnoControlModel* UnoGridModel::Clone() const { return new UnoGridModel( *this ); } +//---------------------------------------------------------------------------------------------------------------------- OUString UnoGridModel::getServiceName() throw(RuntimeException) { return OUString::createFromAscii( szServiceName_GridControlModel ); } +//---------------------------------------------------------------------------------------------------------------------- Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const { switch( nPropId ) @@ -141,6 +148,7 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const } +//---------------------------------------------------------------------------------------------------------------------- ::cppu::IPropertyArrayHelper& UnoGridModel::getInfoHelper() { static UnoPropertyArrayHelper* pHelper = NULL; @@ -152,6 +160,7 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return *pHelper; } +//---------------------------------------------------------------------------------------------------------------------- // XMultiPropertySet Reference< XPropertySetInfo > UnoGridModel::getPropertySetInfo( ) throw(RuntimeException) { @@ -160,21 +169,29 @@ Reference< XPropertySetInfo > UnoGridModel::getPropertySetInfo( ) throw(Runtime } -// ---------------------------------------------------- -// class UnoGridControl -// ---------------------------------------------------- +//====================================================================================================================== +//= UnoGridControl +//====================================================================================================================== UnoGridControl::UnoGridControl( const Reference< XMultiServiceFactory >& i_factory ) :UnoGridControl_Base( i_factory ) ,mSelectionMode(SelectionType(1)) ,m_aSelectionListeners( *this ) + ,m_pEventForwarder( new GridEventForwarder( *this ) ) +{ +} + +//---------------------------------------------------------------------------------------------------------------------- +UnoGridControl::~UnoGridControl() { } +//---------------------------------------------------------------------------------------------------------------------- OUString UnoGridControl::GetComponentServiceName() { return OUString::createFromAscii( "Grid" ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::dispose( ) throw(RuntimeException) { lang::EventObject aEvt; @@ -183,105 +200,146 @@ void SAL_CALL UnoGridControl::dispose( ) throw(RuntimeException) UnoControl::dispose(); } -void UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) { UnoControlBase::createPeer( rxToolkit, rParentPeer ); - Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW ); + const Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW ); xGrid->addSelectionListener(&m_aSelectionListeners); +} - Reference xListener ( getPeer(), UNO_QUERY_THROW ); - Reference xColListener ( getPeer(), UNO_QUERY_THROW ); - Reference xPropSet ( getModel(), UNO_QUERY_THROW ); - - Reference xGridDataModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "GridDataModel" )), UNO_QUERY_THROW ); - if(xGridDataModel != NULL) - xGridDataModel->addDataListener(xListener); - Reference xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW ); - if(xGridColumnModel != NULL) +//---------------------------------------------------------------------------------------------------------------------- +namespace +{ + void lcl_setEventForwarding( const Reference< XControlModel >& i_gridControlModel, const ::boost::scoped_ptr< GridEventForwarder >& i_listener, + bool const i_add ) { - for(int i = 0;igetColumnCount();i++) + const Reference< XPropertySet > xModelProps( i_gridControlModel, UNO_QUERY ); + if ( !xModelProps.is() ) + return; + + try { - xGridColumnModel->getColumn(i)->addColumnListener(xColListener); + const Reference< XContainer > xColModel( + xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnModel" ) ) ), + UNO_QUERY_THROW ); + if ( i_add ) + xColModel->addContainerListener( i_listener.get() ); + else + xColModel->removeContainerListener( i_listener.get() ); + + const Reference< XGridDataModel > xDataModel( + xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridDataModel" ) ) ), + UNO_QUERY_THROW + ); + if ( i_add ) + xDataModel->addDataListener( i_listener.get() ); + else + xDataModel->removeDataListener( i_listener.get() ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } } +//---------------------------------------------------------------------------------------------------------------------- +sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_model ) throw(RuntimeException) +{ + lcl_setEventForwarding( getModel(), m_pEventForwarder, false ); + if ( !UnoGridControl_Base::setModel( i_model ) ) + return sal_False; + lcl_setEventForwarding( getModel(), m_pEventForwarder, true ); + return sal_True; +} -// ------------------------------------------------------------------- -// XGridControl - +//---------------------------------------------------------------------------------------------------------------------- ::sal_Int32 UnoGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl > xGrid ( getPeer(), UNO_QUERY_THROW ); return xGrid->getItemIndexAtPoint( x, y ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->setToolTip( text, columns ); } -// ------------------------------------------------------------------- -// XGridSelection -// ------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- ::sal_Int32 SAL_CALL UnoGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMinSelectionIndex(); } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Int32 SAL_CALL UnoGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMaxSelectionIndex(); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRows( rangeOfRows); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectAllRows(); } + +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRows( rangeOfRows); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectAllRows(); } + +//---------------------------------------------------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL UnoGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getSelection(); } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Bool SAL_CALL UnoGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectionEmpty(); } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Bool SAL_CALL UnoGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectedIndex( index ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRow( y ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { m_aSelectionListeners.addInterface( listener ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { m_aSelectionListeners.removeInterface( listener ); } + }//namespace toolkit Reference< XInterface > SAL_CALL GridControl_CreateInstance( const Reference< XMultiServiceFactory >& i_factory ) diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index c41981cacfd1..d5c76f4a07f6 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -30,21 +30,20 @@ #include #include + #include #include #include #include #include - #include -namespace toolkit { +#include -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; +namespace toolkit +{ + +class GridEventForwarder; // =================================================================== // = UnoGridModel @@ -52,7 +51,7 @@ using namespace ::com::sun::star::container; class UnoGridModel : public UnoControlModel { protected: - Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: @@ -89,14 +88,13 @@ public: // ::com::sun::star::awt::XControl void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel ) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridControl - virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridSelection - virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); @@ -114,9 +112,14 @@ public: DECLIMPL_SERVICEINFO_DERIVED( UnoGridControl, UnoControlBase, szServiceName_GridControl ) using UnoControl::getPeer; + +protected: + ~UnoGridControl(); + private: - ::com::sun::star::view::SelectionType mSelectionMode; - SelectionListenerMultiplexer m_aSelectionListeners; + ::com::sun::star::view::SelectionType mSelectionMode; + SelectionListenerMultiplexer m_aSelectionListeners; + ::boost::scoped_ptr< GridEventForwarder > m_pEventForwarder; }; } // toolkit diff --git a/toolkit/source/controls/grid/grideventforwarder.cxx b/toolkit/source/controls/grid/grideventforwarder.cxx new file mode 100755 index 000000000000..2c3d740af04e --- /dev/null +++ b/toolkit/source/controls/grid/grideventforwarder.cxx @@ -0,0 +1,141 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_toolkit.hxx" + +#include "grideventforwarder.hxx" +#include "gridcontrol.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::awt::grid::GridDataEvent; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::lang::EventObject; + /** === end UNO using === **/ + + //================================================================================================================== + //= GridEventForwarder + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + GridEventForwarder::GridEventForwarder( UnoGridControl& i_parent ) + :m_parent( i_parent ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + GridEventForwarder::~GridEventForwarder() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::acquire() + { + m_parent.acquire(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::release() + { + m_parent.release(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::rowAdded( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->rowAdded( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::rowRemoved( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->rowRemoved( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::dataChanged( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->dataChanged( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) + { + Reference< XContainerListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->elementInserted( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) + { + Reference< XContainerListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->elementRemoved( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) + { + Reference< XContainerListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->elementReplaced( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::disposing( const EventObject& i_event ) throw (RuntimeException) + { + Reference< XEventListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->disposing( i_event ); + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... diff --git a/toolkit/source/controls/grid/grideventforwarder.hxx b/toolkit/source/controls/grid/grideventforwarder.hxx new file mode 100755 index 000000000000..3066ead79c94 --- /dev/null +++ b/toolkit/source/controls/grid/grideventforwarder.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef TOOLKIT_GRIDEVENTFORWARDER_HXX +#define TOOLKIT_GRIDEVENTFORWARDER_HXX + +/** === begin UNO includes === **/ +#include +#include +#include +/** === end UNO includes === **/ + +#include + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + class UnoGridControl; + + //================================================================================================================== + //= GridEventForwarder + //================================================================================================================== + typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::grid::XGridDataListener + , ::com::sun::star::container::XContainerListener + > GridEventForwarder_Base; + + class GridEventForwarder : public GridEventForwarder_Base + { + public: + GridEventForwarder( UnoGridControl& i_parent ); + virtual ~GridEventForwarder(); + + public: + // XInterface + virtual void SAL_CALL acquire(); + virtual void SAL_CALL release(); + + // XGridDataListener + virtual void SAL_CALL rowAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XContainerListener + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + + private: + UnoGridControl& m_parent; + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_GRIDEVENTFORWARDER_HXX diff --git a/toolkit/source/controls/grid/makefile.mk b/toolkit/source/controls/grid/makefile.mk index 70bfc34b9d02..c7bc6f038b10 100644 --- a/toolkit/source/controls/grid/makefile.mk +++ b/toolkit/source/controls/grid/makefile.mk @@ -43,7 +43,8 @@ SLOFILES= \ $(SLO)$/gridcontrol.obj\ $(SLO)$/defaultgriddatamodel.obj\ $(SLO)$/defaultgridcolumnmodel.obj\ - $(SLO)$/gridcolumn.obj + $(SLO)$/gridcolumn.obj\ + $(SLO)$/grideventforwarder.obj # --- Targets ------------------------------------------------------ diff --git a/toolkit/util/tk.component b/toolkit/util/tk.component index e782283c39eb..e919e8451dbb 100644 --- a/toolkit/util/tk.component +++ b/toolkit/util/tk.component @@ -41,7 +41,7 @@ - + -- cgit v1.2.3 From 89b5dccad85eb95058d127108734ae02ab27bc9a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 17 Dec 2010 10:00:05 +0100 Subject: gridsort: removed setter methods from ITableModel - they're an aspect of concret implementations, if at all --- svtools/inc/svtools/table/tablemodel.hxx | 47 +++++------------------------- svtools/source/table/tablecontrol_impl.cxx | 40 ------------------------- 2 files changed, 8 insertions(+), 79 deletions(-) mode change 100644 => 100755 svtools/source/table/tablecontrol_impl.cxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 3da396d9d86c..f67bfe72b05b 100644 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -322,9 +322,6 @@ namespace svt { namespace table */ virtual TableSize getRowCount() const = 0; - SVT_DLLPRIVATE virtual void setColumnCount(TableSize _nColCount) = 0; - SVT_DLLPRIVATE virtual void setRowCount(TableSize _nRowCount) = 0; - /** determines whether the table has column headers If this method returns , the renderer returned by @@ -333,15 +330,6 @@ namespace svt { namespace table @see IColumnRenderer */ virtual bool hasColumnHeaders() const = 0; - /** sets whether the table should have row headers - @see IColumnRenderer - */ - SVT_DLLPRIVATE virtual void setRowHeaders( bool rowHeaders) = 0; - - /** sets whether the table should have column headers - @see IColumnRenderer - */ - SVT_DLLPRIVATE virtual void setColumnHeaders( bool columnHeaders) = 0; /** determines whether the table has row headers @@ -359,14 +347,6 @@ namespace svt { namespace table */ virtual bool isCellEditable( ColPos col, RowPos row ) const = 0; - /** adds the given listener to the list of ->ITableModelListener's - */ - SVT_DLLPRIVATE virtual void addTableModelListener( const PTableModelListener& listener ) = 0; - - /** revokes the given listener from the list of ->ITableModelListener's - */ - SVT_DLLPRIVATE virtual void removeTableModelListener( const PTableModelListener& listener ) = 0; - /** returns a model for a certain column @param column @@ -395,7 +375,7 @@ namespace svt { namespace table @return the renderer to use. Must not be */ - SVT_DLLPRIVATE virtual PTableRenderer getRenderer() const = 0; + virtual PTableRenderer getRenderer() const = 0; /** returns the component handling input in a view associated with the model */ @@ -407,9 +387,7 @@ namespace svt { namespace table the logical height of rows in the table, in 1/100 millimeters. The height must be greater 0. */ - SVT_DLLPRIVATE virtual TableMetrics getRowHeight() const = 0; - - SVT_DLLPRIVATE virtual void setRowHeight(TableMetrics _nRowHeight) = 0; + virtual TableMetrics getRowHeight() const = 0; /** determines the height of the column header row @@ -420,7 +398,7 @@ namespace svt { namespace table the logical height of the column header row, in 1/100 millimeters. Must be greater than 0. */ - SVT_DLLPRIVATE virtual TableMetrics getColumnHeaderHeight() const = 0; + virtual TableMetrics getColumnHeaderHeight() const = 0; /** determines the width of the row header column @@ -431,7 +409,7 @@ namespace svt { namespace table the logical width of the row header column, in 1/100 millimeters. Must be greater than 0. */ - SVT_DLLPRIVATE virtual TableMetrics getRowHeaderWidth() const = 0; + virtual TableMetrics getRowHeaderWidth() const = 0; /** determines the visibility of the vertical scrollbar of the table control @param overAllHeight the height of the table with all rows @@ -444,32 +422,23 @@ namespace svt { namespace table @param actWidth the given width of the table */ virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const = 0; - virtual bool hasVerticalScrollbar() =0; + + virtual bool hasVerticalScrollbar() = 0; virtual bool hasHorizontalScrollbar() = 0; - /** fills cells with content - */ - virtual void setCellContent(const std::vector< std::vector< ::com::sun::star::uno::Any > >& cellContent)=0; + /** gets the content of the cells */ virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0; - /**sets title of header rows - */ - SVT_DLLPRIVATE virtual void setRowHeaderName(const std::vector& cellColumnContent)=0; + /** gets title of header rows */ virtual std::vector& getRowHeaderName() = 0; SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getLineColor() = 0; - SVT_DLLPRIVATE virtual void setLineColor(::com::sun::star::util::Color _rColor) = 0; SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0; - SVT_DLLPRIVATE virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor) = 0; SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getTextColor() = 0; - SVT_DLLPRIVATE virtual void setTextColor(::com::sun::star::util::Color _rColor) = 0; SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0; - SVT_DLLPRIVATE virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0; - SVT_DLLPRIVATE virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; SVT_DLLPRIVATE virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0; - SVT_DLLPRIVATE virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _xAlign) = 0; /// destroys the table model instance virtual ~ITableModel() { } diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx old mode 100644 new mode 100755 index 6c58cb530330..acb8f9e691a9 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -102,22 +102,6 @@ namespace svt { namespace table { return false; } - virtual void setRowHeaders(bool _bRowHeaders) - { - (void)_bRowHeaders; - } - virtual void setColumnHeaders(bool _bColumnHeaders) - { - (void)_bColumnHeaders; - } - void setColumnCount(TableSize _nColCount) - { - (void) _nColCount; - } - void setRowCount(TableSize _nRowCount) - { - (void)_nRowCount; - } virtual bool isCellEditable( ColPos col, RowPos row ) const { (void)col; @@ -186,58 +170,34 @@ namespace svt { namespace table { return false; } - virtual void setCellContent(const std::vector >& ) - { - } virtual ::com::sun::star::util::Color getLineColor() { return 0; } - virtual void setLineColor(::com::sun::star::util::Color ) - { - } virtual ::com::sun::star::util::Color getHeaderBackgroundColor() { return -1; } - virtual void setHeaderBackgroundColor(::com::sun::star::util::Color ) - { - } virtual ::com::sun::star::util::Color getTextColor() { return 0; } - virtual void setTextColor(::com::sun::star::util::Color ) - { - } virtual ::com::sun::star::util::Color getOddRowBackgroundColor() { return -1; } - virtual void setOddRowBackgroundColor(::com::sun::star::util::Color ) - { - } virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() { return com::sun::star::style::VerticalAlignment(0); } - virtual void setVerticalAlign(com::sun::star::style::VerticalAlignment ) - { - } virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() { return -1; } - virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color ) - { - } virtual std::vector >& getCellContent() { return m_aCellContent; } - virtual void setRowHeaderName(const std::vector& ) - { - } virtual std::vector& getRowHeaderName() { aRowHeaderNames.clear(); -- cgit v1.2.3 From 6531aff8404bb4a26f4dfeaf9c253c0147e3fa34 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 17 Dec 2010 13:38:24 +0100 Subject: gridsort: more refactoring of the relationship (especially with respect to listeners) between the various table/grid classes. Now we're not as strict as before with respect to the construction order. Also, updating various aspects of a column model (e.g. inserting a new column) will work now even if there already is a control for the model. Still a long way to go to fix some more obvious problems, which make using the grid control API a PITA (you're lost if you do now know *exactly* which things to do in which order). --- svtools/inc/svtools/table/tablecontrol.hxx | 139 +++---- svtools/inc/svtools/table/tablemodel.hxx | 71 ++-- svtools/source/table/tablecontrol.cxx | 7 +- svtools/source/table/tablecontrol_impl.cxx | 402 ++++++++++++--------- svtools/source/table/tablecontrol_impl.hxx | 123 ++++--- svtools/source/uno/svtxgridcontrol.cxx | 182 ++++++---- svtools/source/uno/svtxgridcontrol.hxx | 11 +- svtools/source/uno/unocontroltablemodel.cxx | 214 ++++++----- svtools/source/uno/unocontroltablemodel.hxx | 109 +++--- .../controls/grid/defaultgridcolumnmodel.cxx | 6 + toolkit/source/controls/grid/gridcontrol.cxx | 4 +- 11 files changed, 724 insertions(+), 544 deletions(-) mode change 100644 => 100755 svtools/inc/svtools/table/tablemodel.hxx mode change 100644 => 100755 svtools/source/table/tablecontrol_impl.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index f3b7ed88b565..07384540261b 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -33,8 +33,10 @@ #include #include #include -#include #include + +#include + //........................................................................ namespace svt { namespace table @@ -69,17 +71,18 @@ namespace svt { namespace table class SVT_DLLPUBLIC TableControl : public Control, public IAccessibleTable { private: - DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* ); - DECL_DLLPRIVATE_LINK( ImplMouseButtonUpHdl, MouseEvent* ); + DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* ); + DECL_DLLPRIVATE_LINK( ImplMouseButtonUpHdl, MouseEvent* ); - DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); - TableControl_Impl* m_pImpl; + ::boost::shared_ptr< TableControl_Impl > m_pImpl; ::com::sun::star::uno::Sequence< sal_Int32 > m_nCols; ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aText; Link m_aSelectHdl; bool m_bSelectionChanged; bool m_bTooltip; + public: ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable; @@ -157,22 +160,25 @@ namespace svt { namespace table { return GoTo( GetCurrentColumn(), _nRow ); } - SVT_DLLPRIVATE virtual void Resize(); - virtual void Select(); - SVT_DLLPRIVATE void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } - const Link& GetSelectHdl() const { return m_aSelectHdl; } - /**invalidates the table if table has been changed e.g. new row added - */ - void InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved); - /**gets the vector, which contains the selected rows - */ - std::vector& GetSelectedRows(); - /**after removing a row, updates the vector which contains the selected rows - if the row, which should be removed, is selected, it will be erased from the vector - */ - SelectionEngine* getSelEngine(); - TableDataWindow* getDataWindow(); + SVT_DLLPRIVATE virtual void Resize(); + virtual void Select(); + SVT_DLLPRIVATE void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } + const Link& GetSelectHdl() const { return m_aSelectHdl; } + + /**invalidates the table if table has been changed e.g. new row added + */ + void InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved); + + /**gets the vector, which contains the selected rows + */ + std::vector& GetSelectedRows(); + + /**after removing a row, updates the vector which contains the selected rows + if the row, which should be removed, is selected, it will be erased from the vector + */ + SelectionEngine* getSelEngine(); + TableDataWindow* getDataWindow(); // Window overridables virtual void GetFocus(); @@ -180,55 +186,54 @@ namespace svt { namespace table virtual void KeyInput( const KeyEvent& rKEvt ); virtual void StateChanged( StateChangedType i_nStateChange ); - /** Creates and returns the accessible object of the whole GridControl. */ - SVT_DLLPRIVATE virtual XACC CreateAccessible(); - SVT_DLLPRIVATE virtual XACC CreateAccessibleControl( sal_Int32 _nIndex ); - SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const; - SVT_DLLPRIVATE virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow ); - SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const; - virtual void FillAccessibleStateSet( - ::utl::AccessibleStateSetHelper& rStateSet, - AccessibleTableControlObjType eObjType ) const; - //// Window - virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; - virtual void GrabFocus(); - virtual XACC GetAccessible( BOOL bCreate = TRUE ); - virtual Window* GetAccessibleParentWindow() const; - virtual Window* GetWindowInstance(); - virtual sal_Int32 GetAccessibleControlCount() const; - virtual sal_Bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ); - virtual long GetRowCount() const; - virtual long GetColumnCount() const; - virtual sal_Bool HasRowHeader() const; - virtual sal_Int32 GetSelectedRowCount() const; - virtual bool IsRowSelected( long _nRow ) const; - virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ); - virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, BOOL _bOnScreen = TRUE ); - virtual Rectangle calcTableRect( BOOL _bOnScreen = TRUE ); - virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex); - virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint); - virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const; - virtual ::rtl::OUString GetRowDescription( sal_Int32 _nRow ) const; - virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const; - virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const; - virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const; - virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const; - virtual sal_Bool HasRowHeader(); - virtual sal_Bool HasColHeader(); - virtual sal_Bool isAccessibleAlive( ) const; - virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); - virtual void RemoveSelectedRow(RowPos _nRowPos); - virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; - ::com::sun::star::uno::Sequence< sal_Int32 >& getColumnsForTooltip(); - ::com::sun::star::uno::Sequence< ::rtl::OUString >& getTextForTooltip(); - void setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols); - void clearSelection(); - void selectionChanged(bool _bChanged); - bool isTooltip(); + /** Creates and returns the accessible object of the whole GridControl. */ + SVT_DLLPRIVATE virtual XACC CreateAccessible(); + SVT_DLLPRIVATE virtual XACC CreateAccessibleControl( sal_Int32 _nIndex ); + SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const; + SVT_DLLPRIVATE virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow ); + SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const; + virtual void FillAccessibleStateSet( + ::utl::AccessibleStateSetHelper& rStateSet, + AccessibleTableControlObjType eObjType ) const; + //// Window + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; + virtual void GrabFocus(); + virtual XACC GetAccessible( BOOL bCreate = TRUE ); + virtual Window* GetAccessibleParentWindow() const; + virtual Window* GetWindowInstance(); + virtual sal_Int32 GetAccessibleControlCount() const; + virtual sal_Bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ); + virtual long GetRowCount() const; + virtual long GetColumnCount() const; + virtual sal_Bool HasRowHeader() const; + virtual sal_Int32 GetSelectedRowCount() const; + virtual bool IsRowSelected( long _nRow ) const; + virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ); + virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, BOOL _bOnScreen = TRUE ); + virtual Rectangle calcTableRect( BOOL _bOnScreen = TRUE ); + virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex); + virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint); + virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const; + virtual ::rtl::OUString GetRowDescription( sal_Int32 _nRow ) const; + virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const; + virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const; + virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const; + virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const; + virtual sal_Bool HasRowHeader(); + virtual sal_Bool HasColHeader(); + virtual sal_Bool isAccessibleAlive( ) const; + virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); + virtual void RemoveSelectedRow(RowPos _nRowPos); + virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; + ::com::sun::star::uno::Sequence< sal_Int32 >& getColumnsForTooltip(); + ::com::sun::star::uno::Sequence< ::rtl::OUString >& getTextForTooltip(); + void setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols); + void clearSelection(); + void selectionChanged(bool _bChanged); + bool isTooltip(); protected: - /// retrieves the XAccessible implementation associated with the GridControl instance - ::svt::IAccessibleFactory& getAccessibleFactory(); + ::svt::IAccessibleFactory& getAccessibleFactory(); private: TableControl(); // never implemented diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx old mode 100644 new mode 100755 index f67bfe72b05b..a9d6c7325e65 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -28,16 +28,20 @@ #define SVTOOLS_INC_TABLE_TABLEMODEL_HXX #include "svtools/svtdllapi.h" -#include -#include -#include -#include -#include +#include "svtools/table/tabletypes.hxx" +#include "svtools/table/tablerenderer.hxx" +#include "svtools/table/tableinputhandler.hxx" + #include -#include #include #include +#include +#include + +#include +#include + //........................................................................ namespace svt { namespace table { @@ -81,10 +85,9 @@ namespace svt { namespace table /** declares an interface to be implemented by components interested in changes in an ->ITableModel */ - class SAL_NO_VTABLE ITableModelListener + class SAL_NO_VTABLE ITableModelListener : public ::boost::enable_shared_from_this< ITableModelListener > { public: - //virtual void onTableModelChanged(PTableModel pTableModel) = 0; /** notifies the listener that one or more rows have been inserted into the table @@ -122,9 +125,9 @@ namespace svt { namespace table the table @param first - the old index of the first removed row + the old index of the first removed column @param last - the old index of the last removed row. Must not be smaller + the old index of the last removed column. Must not be smaller than ->first */ virtual void columnsRemoved( ColPos first, ColPos last ) = 0; @@ -355,21 +358,9 @@ namespace svt { namespace table @return the model of the column in question. Must not be - - @see getColumnModelByID */ virtual PColumnModel getColumnModel( ColPos column ) = 0; - /** finds a column model by ID - - @param id - the id of the column which is to be looked up - @return - the column model with the given ID, or if there is - no such column - */ - virtual PColumnModel getColumnModelByID( ColumnID id ) = 0; - /** returns a renderer which is able to paint the table represented by this table model @@ -423,22 +414,30 @@ namespace svt { namespace table */ virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const = 0; - virtual bool hasVerticalScrollbar() = 0; - virtual bool hasHorizontalScrollbar() = 0; + /** adds a listener to be notified of changes in the table model + */ + virtual void addTableModelListener( const PTableModelListener& i_listener ) = 0; - /** gets the content of the cells - */ - virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0; + /** remove a listener to be notified of changes in the table model + */ + virtual void removeTableModelListener( const PTableModelListener& i_listener ) = 0; - /** gets title of header rows - */ - virtual std::vector& getRowHeaderName() = 0; - SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getLineColor() = 0; - SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0; - SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getTextColor() = 0; - SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0; - SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0; - SVT_DLLPRIVATE virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0; + virtual bool hasVerticalScrollbar() = 0; + virtual bool hasHorizontalScrollbar() = 0; + + /** gets the content of the cells + */ + virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0; + + /** gets title of header rows + */ + virtual std::vector& getRowHeaderName() = 0; + virtual ::com::sun::star::util::Color getLineColor() = 0; + virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0; + virtual ::com::sun::star::util::Color getTextColor() = 0; + virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0; + virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0; + virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0; /// destroys the table model instance virtual ~ITableModel() { } diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 33c80e642118..cde198a92a6e 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -88,11 +88,12 @@ namespace svt { namespace table TableControl::~TableControl() { ImplCallEventListeners( VCLEVENT_OBJECT_DYING ); - DELETEZ( m_pImpl ); + + m_pImpl->setModel( PTableModel() ); + m_pImpl.reset(); + if ( m_pAccessTable->m_pAccessible ) - { m_pAccessTable->m_pAccessible->dispose(); - } } //-------------------------------------------------------------------- diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index acb8f9e691a9..46ebda453b10 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -30,19 +30,20 @@ #include "svtools/table/tablecontrol.hxx" #include "svtools/table/defaultinputhandler.hxx" #include "svtools/table/tablemodel.hxx" +#include "svtools/table/tabledatawindow.hxx" + #include "tablecontrol_impl.hxx" #include "tablegeometry.hxx" -#include "svtools/table/tabledatawindow.hxx" -#include + +#include + #include #include #include -#include #include -#include +#include #include -#include //........................................................................ namespace svt { namespace table @@ -108,28 +109,12 @@ namespace svt { namespace table (void)row; return false; } - virtual void addTableModelListener( const PTableModelListener& listener ) - { - (void)listener; - // ignore - } - virtual void removeTableModelListener( const PTableModelListener& listener ) - { - (void)listener; - // ignore - } virtual PColumnModel getColumnModel( ColPos column ) { DBG_ERROR( "EmptyTableModel::getColumnModel: invalid call!" ); (void)column; return PColumnModel(); } - virtual PColumnModel getColumnModelByID( ColumnID id ) - { - DBG_ERROR( "EmptyTableModel::getColumnModel: invalid call!" ); - (void)id; - return PColumnModel(); - } virtual PTableRenderer getRenderer() const { return PTableRenderer(); @@ -154,56 +139,64 @@ namespace svt { namespace table { return 0; } - virtual ScrollbarVisibility getVerticalScrollbarVisibility(int , int ) const + virtual ScrollbarVisibility getVerticalScrollbarVisibility(int , int ) const { - return ScrollbarShowNever; + return ScrollbarShowNever; } virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int , int ) const { - return ScrollbarShowNever; + return ScrollbarShowNever; + } + virtual void addTableModelListener( const PTableModelListener& i_listener ) + { + (void)i_listener; + } + virtual void removeTableModelListener( const PTableModelListener& i_listener ) + { + (void)i_listener; + } + virtual bool hasVerticalScrollbar() + { + return false; + } + virtual bool hasHorizontalScrollbar() + { + return false; + } + virtual ::com::sun::star::util::Color getLineColor() + { + return 0; + } + virtual ::com::sun::star::util::Color getHeaderBackgroundColor() + { + return -1; + } + virtual ::com::sun::star::util::Color getTextColor() + { + return 0; + } + virtual ::com::sun::star::util::Color getOddRowBackgroundColor() + { + return -1; + } + virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() + { + return com::sun::star::style::VerticalAlignment(0); + } + virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() + { + return -1; + } + virtual std::vector >& getCellContent() + { + return m_aCellContent; + } + virtual std::vector& getRowHeaderName() + { + aRowHeaderNames.clear(); + aRowHeaderNames.push_back(rtl::OUString::createFromAscii("")); + return aRowHeaderNames; } - virtual bool hasVerticalScrollbar() - { - return false; - } - virtual bool hasHorizontalScrollbar() - { - return false; - } - virtual ::com::sun::star::util::Color getLineColor() - { - return 0; - } - virtual ::com::sun::star::util::Color getHeaderBackgroundColor() - { - return -1; - } - virtual ::com::sun::star::util::Color getTextColor() - { - return 0; - } - virtual ::com::sun::star::util::Color getOddRowBackgroundColor() - { - return -1; - } - virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() - { - return com::sun::star::style::VerticalAlignment(0); - } - virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() - { - return -1; - } - virtual std::vector >& getCellContent() - { - return m_aCellContent; - } - virtual std::vector& getRowHeaderName() - { - aRowHeaderNames.clear(); - aRowHeaderNames.push_back(rtl::OUString::createFromAscii("")); - return aRowHeaderNames; - } private: std::vector aRowHeaderNames; std::vector > m_aCellContent; @@ -376,33 +369,33 @@ namespace svt { namespace table ,m_pModel ( new EmptyTableModel ) ,m_pInputHandler ( ) ,m_nRowHeightPixel ( 15 ) - ,m_nColHeaderHeightPixel( 0 ) + ,m_nColHeaderHeightPixel( 0 ) ,m_nRowHeaderWidthPixel ( 0 ) ,m_nColumnCount ( 0 ) ,m_nRowCount ( 0 ) ,m_nCurColumn ( COL_INVALID ) ,m_nCurRow ( ROW_INVALID ) ,m_nLeftColumn ( 0 ) - ,m_nTopRow ( 0 ) + ,m_nTopRow ( 0 ) ,m_nCursorHidden ( 1 ) ,m_pDataWindow ( new TableDataWindow( *this ) ) - ,m_pVScroll ( NULL ) + ,m_pVScroll ( NULL ) ,m_pHScroll ( NULL ) ,m_pScrollCorner ( NULL ) - ,m_pSelEngine ( ) - ,m_nRowSelected ( ) - ,m_pTableFunctionSet ( new TableFunctionSet(this ) ) - ,m_nAnchor (-1 ) - ,m_bResizing ( false ) - ,m_nResizingColumn ( 0 ) - ,m_bResizingGrid ( false ) + ,m_pSelEngine ( ) + ,m_nRowSelected ( ) + ,m_pTableFunctionSet ( new TableFunctionSet( this ) ) + ,m_nAnchor (-1 ) + ,m_bResizing ( false ) + ,m_nResizingColumn ( 0 ) + ,m_bResizingGrid ( false ) #if DBG_UTIL ,m_nRequiredInvariants ( INV_SCROLL_POSITION ) #endif { DBG_CTOR( TableControl_Impl, TableControl_Impl_checkInvariants ); - m_pSelEngine = new SelectionEngine(m_pDataWindow, m_pTableFunctionSet); - m_pSelEngine->SetSelectionMode(SINGLE_SELECTION); + m_pSelEngine = new SelectionEngine(m_pDataWindow, m_pTableFunctionSet); + m_pSelEngine->SetSelectionMode(SINGLE_SELECTION); m_pDataWindow->SetPosPixel( Point( 0, 0 ) ); m_pDataWindow->Show(); } @@ -437,15 +430,21 @@ namespace svt { namespace table TempHideCursor aHideCursor( *this ); + if ( !!m_pModel ) + m_pModel->removeTableModelListener( shared_from_this() ); + m_pModel = _pModel; if ( !m_pModel) m_pModel.reset( new EmptyTableModel ); + m_pModel->addTableModelListener( shared_from_this() ); + m_nCurRow = ROW_INVALID; m_nCurColumn = COL_INVALID; // recalc some model-dependent cached info impl_ni_updateCachedModelValues(); + impl_ni_updateScrollbars(); // completely invalidate m_rAntiImpl.Invalidate(); @@ -455,6 +454,60 @@ namespace svt { namespace table if ( m_nColumnCount ) m_nCurColumn = 0; } + //-------------------------------------------------------------------- + void TableControl_Impl::rowsInserted( RowPos first, RowPos last ) + { + OSL_ENSURE( false, "TableControl_Impl::rowsInserted: not implemented!" ); + // there's no known implementation (yet) which calls this method + OSL_UNUSED( first ); + OSL_UNUSED( last ); + } + + //-------------------------------------------------------------------- + void TableControl_Impl::rowsRemoved( RowPos first, RowPos last ) + { + OSL_ENSURE( false, "TableControl_Impl::rowsRemoved: not implemented!" ); + // there's no known implementation (yet) which calls this method + OSL_UNUSED( first ); + OSL_UNUSED( last ); + } + + //-------------------------------------------------------------------- + void TableControl_Impl::columnsInserted( ColPos first, ColPos last ) + { + impl_ni_updateColumnWidths(); + (void)first; + (void)last; + } + + //-------------------------------------------------------------------- + void TableControl_Impl::columnsRemoved( ColPos first, ColPos last ) + { + impl_ni_updateColumnWidths(); + (void)first; + (void)last; + } + + //-------------------------------------------------------------------- + void TableControl_Impl::columnMoved( ColPos oldIndex, ColPos newIndex ) + { + OSL_ENSURE( false, "TableControl_Impl::columnMoved: not implemented!" ); + // there's no known implementation (yet) which calls this method + OSL_UNUSED( oldIndex ); + OSL_UNUSED( newIndex ); + } + + //-------------------------------------------------------------------- + void TableControl_Impl::cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ) + { + OSL_ENSURE( false, "TableControl_Impl::cellsUpdated: not implemented!" ); + // there's no known implementation (yet) which calls this method + OSL_UNUSED( firstCol ); + OSL_UNUSED( lastCol ); + OSL_UNUSED( firstRow ); + OSL_UNUSED( lastRow ); + } + //-------------------------------------------------------------------- void TableControl_Impl::impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const { @@ -510,8 +563,8 @@ namespace svt { namespace table m_pInputHandler.reset(); m_nColumnCount = m_nRowCount = 0; - m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_APPFONT ).Height(); - if ( m_pModel->hasColumnHeaders() ) + m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_APPFONT ).Height(); + if ( m_pModel->hasColumnHeaders() ) m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_APPFONT ).Height(); if ( m_pModel->hasRowHeaders() ) m_nRowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT).Width(); @@ -535,114 +588,114 @@ namespace svt { namespace table return; TableSize colCount = m_pModel->getColumnCount(); + if ( colCount == 0 ) + return; m_aColumnWidthsPixel.reserve( colCount ); m_aAccColumnWidthsPixel.reserve( colCount ); - if(colCount>0) + + std::vector aPrePixelWidths(0); + long accumulatedPixelWidth = 0; + int lastResizableCol = -1; + double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width(); + if(m_pModel->hasRowHeaders()) { - std::vector aPrePixelWidths(0); - long accumulatedPixelWidth = 0; - int lastResizableCol = -1; - double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width(); - if(m_pModel->hasRowHeaders()) - { - TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); - gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); - } - if(m_pModel->hasVerticalScrollbar()) + TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); + gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); + } + if(m_pModel->hasVerticalScrollbar()) + { + sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); + gridWidth-=scrollbarWidth; + } + double colWidthsSum = 0.0; + double colWithoutFixedWidthsSum = 0.0; + double minColWithoutFixedSum = 0.0; + for ( ColPos col = 0; col < colCount; ++col ) + { + PColumnModel pColumn = m_pModel->getColumnModel( col ); + DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + if ( !pColumn ) + continue; + TableMetrics colWidth = 0; + TableMetrics colPrefWidth = pColumn->getPreferredWidth(); + bool bResizable = pColumn->isResizable(); + if(pColumn->getMinWidth() == 0 && bResizable) { - sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); - gridWidth-=scrollbarWidth; + pColumn->setMinWidth(1); + minColWithoutFixedSum+=m_rAntiImpl.PixelToLogic( Size( 1, 0 ), MAP_APPFONT ).Width(); } - double colWidthsSum = 0.0; - double colWithoutFixedWidthsSum = 0.0; - double minColWithoutFixedSum = 0.0; - for ( ColPos col = 0; col < colCount; ++col ) + if(pColumn->getMaxWidth() == 0 && bResizable) + pColumn->setMaxWidth(m_rAntiImpl.PixelToLogic( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width()); + if( colPrefWidth != 0) { - PColumnModel pColumn = m_pModel->getColumnModel( col ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; - TableMetrics colWidth = 0; - TableMetrics colPrefWidth = pColumn->getPreferredWidth(); - bool bResizable = pColumn->isResizable(); - if(pColumn->getMinWidth() == 0 && bResizable) - { - pColumn->setMinWidth(1); - minColWithoutFixedSum+=m_rAntiImpl.PixelToLogic( Size( 1, 0 ), MAP_APPFONT ).Width(); - } - if(pColumn->getMaxWidth() == 0 && bResizable) - pColumn->setMaxWidth(m_rAntiImpl.PixelToLogic( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width()); - if( colPrefWidth != 0) + if(m_bResizingGrid) { - if(m_bResizingGrid) - { - colWidth = pColumn->getWidth(); - pColumn->setPreferredWidth(0); - } - else - { - colWidth = colPrefWidth; - pColumn->setWidth(colPrefWidth); - } + colWidth = pColumn->getWidth(); + pColumn->setPreferredWidth(0); } else - colWidth = pColumn->getWidth(); - long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - if(bResizable && colPrefWidth == 0) { - colWithoutFixedWidthsSum+=pixelWidth; - lastResizableCol = col; + colWidth = colPrefWidth; + pColumn->setWidth(colPrefWidth); } - colWidthsSum+=pixelWidth; - aPrePixelWidths.push_back(pixelWidth); } - double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; - double scalingFactor = 1.0; - if(m_bResizingGrid) + else + colWidth = pColumn->getWidth(); + long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + if(bResizable && colPrefWidth == 0) { - if(gridWidthWithoutFixed > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) - scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; + colWithoutFixedWidthsSum+=pixelWidth; + lastResizableCol = col; } - else + colWidthsSum+=pixelWidth; + aPrePixelWidths.push_back(pixelWidth); + } + double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; + double scalingFactor = 1.0; + if(m_bResizingGrid) + { + if(gridWidthWithoutFixed > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) + scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; + } + else + { + if(colWidthsSum < gridWidthWithoutFixed) { - if(colWidthsSum < gridWidthWithoutFixed) - { - if(colWithoutFixedWidthsSum>0) - scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; - } + if(colWithoutFixedWidthsSum>0) + scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; } - for ( ColPos i = 0; i < colCount; ++i ) + } + for ( ColPos i = 0; i < colCount; ++i ) + { + PColumnModel pColumn = m_pModel->getColumnModel( i ); + DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + if ( !pColumn ) + continue; + if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) { - PColumnModel pColumn = m_pModel->getColumnModel( i ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; - if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) - { - aPrePixelWidths[i]*=scalingFactor; - TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width(); - pColumn->setWidth(logicColWidth); - } - m_aColumnWidthsPixel.push_back( aPrePixelWidths[i] ); - m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += aPrePixelWidths[i] ); + aPrePixelWidths[i]*=scalingFactor; + TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width(); + pColumn->setWidth(logicColWidth); } - if(gridWidth > m_aAccColumnWidthsPixel[colCount-1]) + m_aColumnWidthsPixel.push_back( aPrePixelWidths[i] ); + m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += aPrePixelWidths[i] ); + } + if(gridWidth > m_aAccColumnWidthsPixel[colCount-1]) + { + if(lastResizableCol >= 0) { - if(lastResizableCol >= 0) + PColumnModel pColumn = m_pModel->getColumnModel(lastResizableCol); + m_aColumnWidthsPixel[lastResizableCol]+=gridWidth-m_aAccColumnWidthsPixel[colCount-1]; + TableMetrics logicColWidth1 = m_rAntiImpl.PixelToLogic( Size( m_aColumnWidthsPixel[lastResizableCol], 0 ), MAP_APPFONT ).Width(); + pColumn->setWidth(logicColWidth1); + while(lastResizableCol < colCount) { - PColumnModel pColumn = m_pModel->getColumnModel(lastResizableCol); - m_aColumnWidthsPixel[lastResizableCol]+=gridWidth-m_aAccColumnWidthsPixel[colCount-1]; - TableMetrics logicColWidth1 = m_rAntiImpl.PixelToLogic( Size( m_aColumnWidthsPixel[lastResizableCol], 0 ), MAP_APPFONT ).Width(); - pColumn->setWidth(logicColWidth1); - while(lastResizableCol < colCount) - { - if(lastResizableCol == 0) - m_aAccColumnWidthsPixel[0] = m_aColumnWidthsPixel[lastResizableCol]; - else - m_aAccColumnWidthsPixel[lastResizableCol]=m_aAccColumnWidthsPixel[lastResizableCol-1]+m_aColumnWidthsPixel[lastResizableCol]; - ++lastResizableCol; - } + if(lastResizableCol == 0) + m_aAccColumnWidthsPixel[0] = m_aColumnWidthsPixel[lastResizableCol]; + else + m_aAccColumnWidthsPixel[lastResizableCol]=m_aAccColumnWidthsPixel[lastResizableCol-1]+m_aColumnWidthsPixel[lastResizableCol]; + ++lastResizableCol; } } } @@ -769,10 +822,10 @@ namespace svt { namespace table m_nRowCount = m_pModel->getRowCount(); m_nColumnCount = m_pModel->getColumnCount(); - if(m_aAccColumnWidthsPixel.empty()) - { + if ( m_aAccColumnWidthsPixel.empty() ) impl_ni_updateColumnWidths(); - } + OSL_ENSURE( m_aAccColumnWidthsPixel.size() == m_nColumnCount, "TableControl_Impl::impl_ni_updateScrollbars: inconsistency!" ); + const long nAllColumnsWidth = m_aAccColumnWidthsPixel.empty() ? 0 : m_aAccColumnWidthsPixel[ m_nColumnCount - 1 ]; // do we need a vertical scrollbar? bool bFirstRoundVScrollNeed = false; @@ -786,7 +839,7 @@ namespace svt { namespace table } // do we need a horizontal scrollbar? if ( lcl_determineScrollbarNeed( - m_pModel->getHorizontalScrollbarVisibility(aDataCellPlayground.GetWidth(), m_aAccColumnWidthsPixel[m_nColumnCount-1]), + m_pModel->getHorizontalScrollbarVisibility(aDataCellPlayground.GetWidth(), nAllColumnsWidth), lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false ), m_nColumnCount ) ) { @@ -832,7 +885,7 @@ namespace svt { namespace table lcl_updateScrollbar( m_rAntiImpl, m_pHScroll, - m_pModel->getHorizontalScrollbarVisibility(aDataCellPlayground.GetWidth(), m_aAccColumnWidthsPixel[m_nColumnCount-1]), + m_pModel->getHorizontalScrollbarVisibility(aDataCellPlayground.GetWidth(), nAllColumnsWidth), lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false ), // visible units m_nLeftColumn, // current position @@ -918,8 +971,7 @@ namespace svt { namespace table m_bResizingGrid = true; } } - if(m_nColumnCount != 0) - impl_ni_updateScrollbars(); + impl_ni_updateScrollbars(); } } @@ -931,7 +983,7 @@ namespace svt { namespace table if ( !getModel() ) return; PTableRenderer pRenderer = getModel()->getRenderer(); - DBG_ASSERT( !!pRenderer, "TableDataWindow::Paint: invalid renderer!" ); + DBG_ASSERT( !!pRenderer, "TableDataWindow::doPaintContent: invalid renderer!" ); if ( !pRenderer ) return; diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx old mode 100644 new mode 100755 index 053766d92841..b456cf248bed --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -27,18 +27,13 @@ #ifndef SVTOOLS_TABLECONTROL_IMPL_HXX #define SVTOOLS_TABLECONTROL_IMPL_HXX -#ifndef SVTOOLS_INC_TABLE_TABLEMODEL_HXX #include -#endif - -#ifndef SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX #include -#endif - #include -#include + #include +#include class ScrollBar; class ScrollBarBox; @@ -57,7 +52,8 @@ namespace svt { namespace table //==================================================================== //= TableControl_Impl //==================================================================== - class TableControl_Impl : public IAbstractTableControl + class TableControl_Impl :public IAbstractTableControl + ,public ITableModelListener { friend class TableGeometry; friend class TableRowGeometry; @@ -78,7 +74,7 @@ namespace svt { namespace table */ ArrayOfLong m_aAccColumnWidthsPixel; - ArrayOfLong m_aVisibleColumnWidthsPixel; + ArrayOfLong m_aVisibleColumnWidthsPixel; /// the height of a single row in the table, measured in pixels long m_nRowHeightPixel; /// the height of the column header row in the table, measured in pixels @@ -109,18 +105,18 @@ namespace svt { namespace table /// the horizontal scrollbar, if any ScrollBar* m_pHScroll; ScrollBarBox* m_pScrollCorner; - //selection engine - for determining selection range, e.g. single, multiple - SelectionEngine* m_pSelEngine; - //vector which contains the selected rows - std::vector m_nRowSelected; - //part of selection engine - TableFunctionSet* m_pTableFunctionSet; - //part of selection engine - RowPos m_nAnchor; - bool m_bResizing; - ColPos m_nResizingColumn; - bool m_bResizingGrid; - rtl::OUString m_aTooltipText; + //selection engine - for determining selection range, e.g. single, multiple + SelectionEngine* m_pSelEngine; + //vector which contains the selected rows + std::vector m_nRowSelected; + //part of selection engine + TableFunctionSet* m_pTableFunctionSet; + //part of selection engine + RowPos m_nAnchor; + bool m_bResizing; + ColPos m_nResizingColumn; + bool m_bResizingGrid; + rtl::OUString m_aTooltipText; #if DBG_UTIL #define INV_SCROLL_POSITION 1 @@ -185,44 +181,53 @@ namespace svt { namespace table if it's okay that the given cooordinate is only partially visible */ void ensureVisible( ColPos _nColumn, RowPos _nRow, bool _bAcceptPartialVisibility ); - /** returns the row, which contains the input point*/ - virtual RowPos getCurrentRow (const Point& rPoint); - - void setCursorAtCurrentCell(const Point& rPoint); - /** checks whether the vector with the selected rows contains the current row*/ - BOOL isRowSelected(const ::std::vector& selectedRows, RowPos current); - - bool isRowSelected(RowPos current); - /** returns the position of the current row in the selection vector */ - int getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current); - /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/ - void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect ); - /** to be called when a new row is added to the control*/ - void invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect ); - /** returns the vector, which contains the selected rows*/ - std::vector& getSelectedRows(); - /** updates the vector, which contains the selected rows after removing the row nRowPos*/ - void removeSelectedRow(RowPos _nRowPos); - void invalidateRows(); - void clearSelection(); - // IAbstractTableControl - virtual void hideCursor(); - virtual void showCursor(); - virtual bool dispatchAction( TableControlAction _eAction ); - virtual SelectionEngine* getSelEngine(); - virtual bool isTooltipActive(); - virtual rtl::OUString& setTooltip(const Point& rPoint ); - virtual void resizeColumn(const Point& rPoint); - virtual bool startResizeColumn(const Point& rPoint); - virtual bool endResizeColumn(const Point& rPoint); - - TableDataWindow* getDataWindow(); - ScrollBar* getHorzScrollbar(); - ScrollBar* getVertScrollbar(); - - ::rtl::OUString convertToString(const ::com::sun::star::uno::Any& _value); - Rectangle calcHeaderRect(bool bColHeader); - Rectangle calcTableRect(); + /** returns the row, which contains the input point*/ + virtual RowPos getCurrentRow (const Point& rPoint); + + void setCursorAtCurrentCell(const Point& rPoint); + /** checks whether the vector with the selected rows contains the current row*/ + BOOL isRowSelected(const ::std::vector& selectedRows, RowPos current); + + bool isRowSelected(RowPos current); + /** returns the position of the current row in the selection vector */ + int getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current); + /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/ + void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect ); + /** to be called when a new row is added to the control*/ + void invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect ); + /** returns the vector, which contains the selected rows*/ + std::vector& getSelectedRows(); + /** updates the vector, which contains the selected rows after removing the row nRowPos*/ + void removeSelectedRow(RowPos _nRowPos); + void invalidateRows(); + void clearSelection(); + // IAbstractTableControl + virtual void hideCursor(); + virtual void showCursor(); + virtual bool dispatchAction( TableControlAction _eAction ); + virtual SelectionEngine* getSelEngine(); + virtual bool isTooltipActive(); + virtual rtl::OUString& setTooltip(const Point& rPoint ); + virtual void resizeColumn(const Point& rPoint); + virtual bool startResizeColumn(const Point& rPoint); + virtual bool endResizeColumn(const Point& rPoint); + + TableDataWindow* getDataWindow(); + ScrollBar* getHorzScrollbar(); + ScrollBar* getVertScrollbar(); + + ::rtl::OUString convertToString(const ::com::sun::star::uno::Any& _value); + Rectangle calcHeaderRect(bool bColHeader); + Rectangle calcTableRect(); + + // ITableModelListener + virtual void rowsInserted( RowPos first, RowPos last ); + virtual void rowsRemoved( RowPos first, RowPos last ); + virtual void columnsInserted( ColPos first, ColPos last ); + virtual void columnsRemoved( ColPos first, ColPos last ); + virtual void columnMoved( ColPos oldIndex, ColPos newIndex ); + virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ); + private: /** toggles the cursor visibility diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 765a37e90495..050e938d2487 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -80,6 +80,18 @@ SVTXGridControl::~SVTXGridControl() { } +// --------------------------------------------------------------------------------------------------------------------- +void SVTXGridControl::SetWindow( Window* pWindow ) +{ + TableControl* pTable = dynamic_cast< TableControl* >( pWindow ); + ENSURE_OR_THROW( ( pTable != NULL ) || ( pWindow == NULL ), "SVTXGridControl::SetWindow: illegal window!" ); + + SVTXGridControl_Base::SetWindow( pWindow ); + + if ( pTable ) + pTable->SetModel( PTableModel( m_pTableModel ) ); +} + // --------------------------------------------------------------------------------------------------------------------- sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { @@ -269,7 +281,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) { UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); - m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); + m_pTableModel->appendColumn( PColumnModel( tableColumn ) ); } m_xColumnModel->setDefaultColumns(rawRowData.getLength()); } @@ -302,36 +314,14 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_GRID_COLUMNMODEL: { + // remove all old columns + m_pTableModel->removeAllColumns(); + + // obtain new col model m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY_THROW ); - if(m_xColumnModel->getColumnCount() != 0) - { - Sequence > columns = m_xColumnModel->getColumns(); - std::vector > aNewColumns( - comphelper::sequenceToContainer > >(columns)); - sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); - if(m_xColumnModel->getColumnHeaderHeight() == 0) - { - m_pTableModel->setColumnHeaderHeight(fontHeight); - m_xColumnModel->setColumnHeaderHeight(fontHeight); - } - else - m_pTableModel->setColumnHeaderHeight(m_xColumnModel->getColumnHeaderHeight()); - for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) - { - UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]); - Reference< XGridColumn > xGridColumn = m_xColumnModel->getColumn(col); - m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); - tableColumn->setHorizontalAlign(xGridColumn->getHorizontalAlign()); - tableColumn->setWidth(xGridColumn->getColumnWidth()); - if(xGridColumn->getPreferredWidth() != 0) - tableColumn->setPreferredWidth(xGridColumn->getPreferredWidth()); - if(xGridColumn->getMaxWidth() != 0) - tableColumn->setMaxWidth(xGridColumn->getMaxWidth()); - if(xGridColumn->getMinWidth() != 0) - tableColumn->setMinWidth(xGridColumn->getMinWidth()); - tableColumn->setResizable(xGridColumn->getResizeable()); - } - } + + // remove new columns + impl_updateColumnsFromModel_nothrow(); break; } @@ -400,16 +390,6 @@ void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) ); VCLXWindow::ImplGetPropertyIds( rIds, true ); } -void SAL_CALL SVTXGridControl::setVisible( sal_Bool bVisible ) throw(::com::sun::star::uno::RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable != NULL, "SVTXGridControl::setVisible: no control (anymore)!" ); - - pTable->SetModel( PTableModel( m_pTableModel ) ); - // TODO: what's this SetModel call good for? Looks like a hack to me, to work around some other bug. - pTable->Show( bVisible ); -} void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { @@ -425,7 +405,7 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) { UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); - m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); + m_pTableModel->appendColumn( PColumnModel( tableColumn ) ); m_xColumnModel->getColumn(col)->addColumnListener(listener); } @@ -516,45 +496,59 @@ void SAL_CALL SVTXGridControl::columnChanged(const ::com::sun::star::awt::grid: if(Event.valueName == rtl::OUString::createFromAscii("ColumnResize")) { - bool resizable = m_pTableModel->getColumnModel()[Event.index]->isResizable(); + bool resizable = m_pTableModel->getColumnModel( Event.index )->isResizable(); Event.newValue>>=resizable; - m_pTableModel->getColumnModel()[Event.index]->setResizable(resizable); + m_pTableModel->getColumnModel( Event.index )->setResizable(resizable); } else if(Event.valueName == rtl::OUString::createFromAscii("ColWidth")) { - sal_Int32 colWidth = m_pTableModel->getColumnModel()[Event.index]->getWidth(); + sal_Int32 colWidth = m_pTableModel->getColumnModel( Event.index )->getWidth(); Event.newValue>>=colWidth; - m_pTableModel->getColumnModel()[Event.index]->setWidth(colWidth); + m_pTableModel->getColumnModel( Event.index )->setWidth(colWidth); } else if(Event.valueName == rtl::OUString::createFromAscii("MaxWidth")) { - sal_Int32 maxWidth = m_pTableModel->getColumnModel()[Event.index]->getMaxWidth(); + sal_Int32 maxWidth = m_pTableModel->getColumnModel( Event.index )->getMaxWidth(); Event.newValue>>=maxWidth; - m_pTableModel->getColumnModel()[Event.index]->setMaxWidth(maxWidth); + m_pTableModel->getColumnModel( Event.index )->setMaxWidth(maxWidth); } else if(Event.valueName == rtl::OUString::createFromAscii("MinWidth")) { - sal_Int32 minWidth = m_pTableModel->getColumnModel()[Event.index]->getMinWidth(); + sal_Int32 minWidth = m_pTableModel->getColumnModel( Event.index )->getMinWidth(); Event.newValue>>=minWidth; - m_pTableModel->getColumnModel()[Event.index]->setMinWidth(minWidth); + m_pTableModel->getColumnModel( Event.index )->setMinWidth(minWidth); } else if(Event.valueName == rtl::OUString::createFromAscii("PrefWidth")) { - sal_Int32 prefWidth = m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth(); + sal_Int32 prefWidth = m_pTableModel->getColumnModel( Event.index )->getPreferredWidth(); Event.newValue>>=prefWidth; - m_pTableModel->getColumnModel()[Event.index]->setPreferredWidth(prefWidth); + m_pTableModel->getColumnModel( Event.index )->setPreferredWidth(prefWidth); } else if(Event.valueName == rtl::OUString::createFromAscii("HAlign")) { - ::com::sun::star::style::HorizontalAlignment hAlign = m_pTableModel->getColumnModel()[Event.index]->getHorizontalAlign(); + ::com::sun::star::style::HorizontalAlignment hAlign = m_pTableModel->getColumnModel( Event.index )->getHorizontalAlign(); Event.newValue>>=hAlign; - m_pTableModel->getColumnModel()[Event.index]->setHorizontalAlign(hAlign); + m_pTableModel->getColumnModel( Event.index )->setHorizontalAlign(hAlign); } else if(Event.valueName == rtl::OUString::createFromAscii("UpdateWidth")) { - if(m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth() != 0) - m_xColumnModel->getColumn(Event.index)->updateColumn(rtl::OUString::createFromAscii("PrefWidth"), m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth()); - m_xColumnModel->getColumn(Event.index)->updateColumn(rtl::OUString::createFromAscii("ColWidth"), m_pTableModel->getColumnModel()[Event.index]->getWidth()); + const PColumnModel pTableColumn( m_pTableModel->getColumnModel( Event.index ) ); + ENSURE_OR_RETURN_VOID( !!pTableColumn, "invalid table column!" ); + + Reference< XGridColumn > xColumn; + try + { + xColumn.set( m_xColumnModel->getColumn( Event.index ), UNO_SET_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + return; + } + + if ( pTableColumn->getPreferredWidth() != 0 ) + xColumn->updateColumn(rtl::OUString::createFromAscii("PrefWidth"), pTableColumn->getPreferredWidth()); + xColumn->updateColumn(rtl::OUString::createFromAscii("ColWidth"), pTableColumn->getWidth() ); } pTable->Invalidate(); } @@ -616,28 +610,29 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::G //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) { - (void)i_event; + const Reference< XGridColumn > xGridColumn( i_event.Element, UNO_QUERY ); + const PColumnModel tableColumn( new UnoControlTableColumn( xGridColumn ) ); + // will throw if this is not a valid grid column + m_pTableModel->appendColumn( tableColumn ); - // TODO: add as XGridColumnListener - // TODO: update our TableControl + impl_setColumnListening( Reference< XGridColumn >( i_event.Element, UNO_QUERY ), true ); } //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) { - (void)i_event; + impl_setColumnListening( Reference< XGridColumn >( i_event.Element, UNO_QUERY ), false ); - // TODO: remove as XGridColumnListener - // TODO: update our TableControl + // TODO: remove the respective column from our table model } //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) { - (void)i_event; + impl_setColumnListening( Reference< XGridColumn >( i_event.ReplacedElement, UNO_QUERY ), false ); + impl_setColumnListening( Reference< XGridColumn >( i_event.Element, UNO_QUERY ), true ); - // TODO: add/remove as XGridColumnListener - // TODO: update our TableControl + // TODO: replace the respective column in our table model } @@ -946,3 +941,60 @@ void SVTXGridControl::ImplCallItemListeners() m_aSelectionListeners.selectionChanged( aEvent ); } } + +void SVTXGridControl::impl_updateColumnsFromModel_nothrow() +{ + ENSURE_OR_RETURN_VOID( m_xColumnModel.is(), "no model!" ); + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable != NULL, "no table!" ); + + try + { + if ( m_xColumnModel->getColumnCount() != 0 ) + { + if ( m_xColumnModel->getColumnHeaderHeight() == 0 ) + { + sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() + 3 ), MAP_APPFONT ).Height(); + m_pTableModel->setColumnHeaderHeight( fontHeight ); + } + else + m_pTableModel->setColumnHeaderHeight( m_xColumnModel->getColumnHeaderHeight() ); + + const Sequence< Reference< XGridColumn > > columns = m_xColumnModel->getColumns(); + for ( const Reference< XGridColumn >* colRef = columns.getConstArray(); + colRef != columns.getConstArray() + columns.getLength(); + ++colRef + ) + { + ENSURE_OR_CONTINUE( colRef->is(), "illegal column!" ); + + impl_setColumnListening( *colRef, true ); + + UnoControlTableColumn* tableColumn = new UnoControlTableColumn( *colRef ); + m_pTableModel->appendColumn( PColumnModel( tableColumn ) ); + + tableColumn->setHorizontalAlign( (*colRef)->getHorizontalAlign() ); + tableColumn->setWidth( (*colRef)->getColumnWidth() ); + tableColumn->setResizable( (*colRef)->getResizeable() ); + tableColumn->setPreferredWidth( (*colRef)->getPreferredWidth() ); + tableColumn->setMaxWidth( (*colRef)->getMaxWidth() ); + tableColumn->setMinWidth( (*colRef)->getMinWidth() ); + } + } + + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +void SVTXGridControl::impl_setColumnListening( const Reference< XGridColumn >& i_column, bool const i_start ) +{ + ENSURE_OR_RETURN_VOID( i_column.is(), "SVTXGridControl::impl_setColumnListening: illegal column!" ); + + if ( i_start ) + i_column->addColumnListener( this ); + else + i_column->removeColumnListener( this ); +} diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index 3197b4b8e23b..ef4dc7225bf5 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -113,11 +113,18 @@ public: void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); - void SAL_CALL setVisible(sal_Bool bVisible) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::lang::XComponent void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); - // XContainertListener +protected: + // VCLXWindow + virtual void SetWindow( Window* pWindow ); + +private: + void impl_removeAllColumns_nothrow(); + void impl_updateColumnsFromModel_nothrow(); + + void impl_setColumnListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn >& i_column, bool const i_start ); }; #endif // _SVT_GRIDCONTROL_HXX_ diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index d239ee3c740d..e8ebd029884c 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -38,6 +38,7 @@ #include #include #include +#include using ::rtl::OUString; using namespace ::svt::table; @@ -45,18 +46,31 @@ using namespace ::com::sun::star::uno; //-------------------------------------------------------------------- - UnoControlTableColumn::UnoControlTableColumn(Reference m_xGridColumn) + UnoControlTableColumn::UnoControlTableColumn( const Reference< XGridColumn >& i_gridColumn ) :m_nID( 0 ) ,m_sName() ,m_bIsResizable( true ) ,m_nWidth( 4 ) ,m_nMinWidth( 0 ) ,m_nMaxWidth( 0 ) - ,m_nPrefWidth ( 0 ) - ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0)) + ,m_nPrefWidth ( 0 ) + ,m_eHorizontalAlign( com::sun::star::style::HorizontalAlignment_LEFT ) { - m_sName = m_xGridColumn->getTitle(); + ENSURE_OR_THROW( i_gridColumn.is(), "illegal column" ); + m_sName = i_gridColumn->getTitle(); + + // don't do this here. The attribute getters at the XGridColumn implementation do some notifications, + // which is absolutely weird. Sadly, this also means that we can't call the getters while we're + // being constructed, and not yet inserted into the column model. +// m_eHorizontalAlign = i_gridColumn->getHorizontalAlign(); +// m_nWidth = i_gridColumn->getColumnWidth(); +// m_bIsResizable = i_gridColumn->getResizeable(); +// +// m_nPrefWidth = i_gridColumn->getPreferredWidth(); +// m_nMaxWidth = i_gridColumn->getMaxWidth(); +// m_nMinWidth = i_gridColumn->getMinWidth(); } + //-------------------------------------------------------------------- UnoControlTableColumn::UnoControlTableColumn() :m_nID( 0 ) @@ -65,8 +79,8 @@ using namespace ::com::sun::star::uno; ,m_nWidth( 4 ) ,m_nMinWidth( 0 ) ,m_nMaxWidth( 0 ) - ,m_nPrefWidth ( 0 ) - ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0)) + ,m_nPrefWidth ( 0 ) + ,m_eHorizontalAlign(com::sun::star::style::HorizontalAlignment(0)) { } @@ -155,60 +169,62 @@ using namespace ::com::sun::star::uno; //-------------------------------------------------------------------- ::com::sun::star::style::HorizontalAlignment UnoControlTableColumn::getHorizontalAlign() { - return m_xHorizontalAlign; + return m_eHorizontalAlign; } //-------------------------------------------------------------------- void UnoControlTableColumn::setHorizontalAlign( com::sun::star::style::HorizontalAlignment _align ) { - m_xHorizontalAlign = _align; + m_eHorizontalAlign = _align; } //==================================================================== //= DefaultTableModel_Impl //==================================================================== + typedef ::std::vector< PTableModelListener > ModellListeners; struct UnoControlTableModel_Impl { - ::std::vector< PColumnModel > aColumns; - TableSize nRowCount; - bool bHasColumnHeaders; - bool bHasRowHeaders; - bool bVScroll; - bool bHScroll; - PTableRenderer pRenderer; - PTableInputHandler pInputHandler; - TableMetrics nRowHeight; - TableMetrics nColumnHeaderHeight; - TableMetrics nRowHeaderWidth; - std::vector aRowHeadersTitle; - std::vector > aCellContent; - ::com::sun::star::util::Color m_xLineColor; - ::com::sun::star::util::Color m_xHeaderColor; - ::com::sun::star::util::Color m_xTextColor; - ::com::sun::star::util::Color m_xRowColor1; - ::com::sun::star::util::Color m_xRowColor2; - ::com::sun::star::style::VerticalAlignment m_xVerticalAlign; + ::std::vector< PColumnModel > aColumns; + TableSize nRowCount; + bool bHasColumnHeaders; + bool bHasRowHeaders; + bool bVScroll; + bool bHScroll; + PTableRenderer pRenderer; + PTableInputHandler pInputHandler; + TableMetrics nRowHeight; + TableMetrics nColumnHeaderHeight; + TableMetrics nRowHeaderWidth; + ::std::vector aRowHeadersTitle; + ::std::vector > aCellContent; + ::com::sun::star::util::Color m_nLineColor; + ::com::sun::star::util::Color m_nHeaderColor; + ::com::sun::star::util::Color m_nTextColor; + ::com::sun::star::util::Color m_nRowColor1; + ::com::sun::star::util::Color m_nRowColor2; + ::com::sun::star::style::VerticalAlignment m_eVerticalAlign; + ModellListeners m_aListeners; UnoControlTableModel_Impl() - :aColumns ( ) - ,nRowCount ( 0 ) - ,bHasColumnHeaders ( false ) - ,bHasRowHeaders ( false ) - ,bVScroll ( false ) - ,bHScroll ( false ) + :aColumns ( ) + ,nRowCount ( 0 ) + ,bHasColumnHeaders ( true ) + ,bHasRowHeaders ( true ) + ,bVScroll ( false ) + ,bHScroll ( false ) ,pRenderer ( ) ,pInputHandler ( ) - ,nRowHeight ( 0 ) - ,nColumnHeaderHeight( 0 ) + ,nRowHeight ( 10 ) + ,nColumnHeaderHeight( 10 ) ,nRowHeaderWidth ( 10 ) - ,aRowHeadersTitle ( ) - ,aCellContent ( ) - ,m_xLineColor ( 0xFFFFFF ) - ,m_xHeaderColor ( 0xFFFFFF ) - ,m_xTextColor ( 0 )//black as default - ,m_xRowColor1 ( 0xFFFFFF ) - ,m_xRowColor2 ( 0xFFFFFF ) - ,m_xVerticalAlign (com::sun::star::style::VerticalAlignment(0)) + ,aRowHeadersTitle ( ) + ,aCellContent ( ) + ,m_nLineColor ( 0xFFFFFF ) + ,m_nHeaderColor ( 0xFFFFFF ) + ,m_nTextColor ( 0 )//black as default + ,m_nRowColor1 ( 0xFFFFFF ) + ,m_nRowColor2 ( 0xFFFFFF ) + ,m_eVerticalAlign ( com::sun::star::style::VerticalAlignment_TOP ) { } }; @@ -220,8 +236,8 @@ using namespace ::com::sun::star::uno; UnoControlTableModel::UnoControlTableModel() :m_pImpl( new UnoControlTableModel_Impl ) { - m_pImpl->bHasColumnHeaders = false; - m_pImpl->bHasRowHeaders = false; + m_pImpl->bHasColumnHeaders = true; + m_pImpl->bHasRowHeaders = true; m_pImpl->pRenderer.reset( new GridTableRenderer( *this ) ); m_pImpl->pInputHandler.reset( new DefaultInputHandler ); } @@ -284,42 +300,51 @@ using namespace ::com::sun::star::uno; return false; } - //-------------------------------------------------------------------- - void UnoControlTableModel::addTableModelListener( const PTableModelListener& listener ) - { - (void) listener; - // TODO - DBG_ERROR( "DefaultTableModel::addTableModelListener: not yet implemented!" ); - } - - //-------------------------------------------------------------------- - void UnoControlTableModel::removeTableModelListener( const PTableModelListener& listener ) - { - (void)listener; - // TODO - DBG_ERROR( "DefaultTableModel::removeTableModelListener: not yet implemented!" ); - } - //-------------------------------------------------------------------- PColumnModel UnoControlTableModel::getColumnModel( ColPos column ) { - DBG_ASSERT( ( column >= 0 ) && ( column < getColumnCount() ), - "DefaultTableModel::getColumnModel: invalid index!" ); + ENSURE_OR_RETURN( ( column >= 0 ) && ( column < getColumnCount() ), + "DefaultTableModel::getColumnModel: invalid index!", PColumnModel() ); return m_pImpl->aColumns[ column ]; } //-------------------------------------------------------------------- - std::vector& UnoControlTableModel::getColumnModel() + void UnoControlTableModel::appendColumn( const PColumnModel& i_column ) { - return m_pImpl->aColumns; + ENSURE_OR_RETURN_VOID( !!i_column, "illegal column" ); + + const ColPos nInsertPosition = m_pImpl->aColumns.size(); + m_pImpl->aColumns.push_back( i_column ); + + // notify listeners + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->columnsInserted( nInsertPosition, nInsertPosition ); + } } + //-------------------------------------------------------------------- - PColumnModel UnoControlTableModel::getColumnModelByID( ColumnID id ) + void UnoControlTableModel::removeAllColumns() { - (void)id; - // TODO - DBG_ERROR( "DefaultTableModel::getColumnModelByID: not yet implemented!" ); - return PColumnModel(); + if ( m_pImpl->aColumns.empty() ) + return; + + const ColPos nLastIndex = m_pImpl->aColumns.size() - 1; + m_pImpl->aColumns.clear(); + + // notify listeners + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->columnsRemoved( 0, nLastIndex ); + } } //-------------------------------------------------------------------- @@ -403,6 +428,31 @@ using namespace ::com::sun::star::uno; else return ScrollbarShowAlways; } + + //-------------------------------------------------------------------- + void UnoControlTableModel::addTableModelListener( const PTableModelListener& i_listener ) + { + ENSURE_OR_RETURN_VOID( !!i_listener, "illegal NULL listener" ); + m_pImpl->m_aListeners.push_back( i_listener ); + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::removeTableModelListener( const PTableModelListener& i_listener ) + { + for ( ModellListeners::iterator lookup = m_pImpl->m_aListeners.begin(); + lookup != m_pImpl->m_aListeners.end(); + ++lookup + ) + { + if ( *lookup == i_listener ) + { + m_pImpl->m_aListeners.erase( lookup ); + return; + } + } + OSL_ENSURE( false, "UnoControlTableModel::removeTableModelListener: listener is not registered - sure you're doing the right thing here?" ); + } + //-------------------------------------------------------------------- void UnoControlTableModel::setVerticalScrollbarVisibility(bool _bVScroll) const { @@ -447,67 +497,67 @@ using namespace ::com::sun::star::uno; //-------------------------------------------------------------------- ::com::sun::star::util::Color UnoControlTableModel::getLineColor() { - return m_pImpl->m_xLineColor; + return m_pImpl->m_nLineColor; } //-------------------------------------------------------------------- void UnoControlTableModel::setLineColor( ::com::sun::star::util::Color _rColor ) { - m_pImpl->m_xLineColor = _rColor; + m_pImpl->m_nLineColor = _rColor; } //-------------------------------------------------------------------- ::com::sun::star::util::Color UnoControlTableModel::getHeaderBackgroundColor() { - return m_pImpl->m_xHeaderColor; + return m_pImpl->m_nHeaderColor; } //-------------------------------------------------------------------- void UnoControlTableModel::setHeaderBackgroundColor( ::com::sun::star::util::Color _rColor ) { - m_pImpl->m_xHeaderColor = _rColor; + m_pImpl->m_nHeaderColor = _rColor; } //-------------------------------------------------------------------- ::com::sun::star::util::Color UnoControlTableModel::getTextColor() { - return m_pImpl->m_xTextColor; + return m_pImpl->m_nTextColor; } //-------------------------------------------------------------------- void UnoControlTableModel::setTextColor( ::com::sun::star::util::Color _rColor ) { - m_pImpl->m_xTextColor = _rColor; + m_pImpl->m_nTextColor = _rColor; } //-------------------------------------------------------------------- ::com::sun::star::util::Color UnoControlTableModel::getOddRowBackgroundColor() { - return m_pImpl->m_xRowColor1; + return m_pImpl->m_nRowColor1; } //-------------------------------------------------------------------- void UnoControlTableModel::setOddRowBackgroundColor( ::com::sun::star::util::Color _rColor ) { - m_pImpl->m_xRowColor1 = _rColor; + m_pImpl->m_nRowColor1 = _rColor; } //-------------------------------------------------------------------- ::com::sun::star::util::Color UnoControlTableModel::getEvenRowBackgroundColor() { - return m_pImpl->m_xRowColor2; + return m_pImpl->m_nRowColor2; } //-------------------------------------------------------------------- void UnoControlTableModel::setEvenRowBackgroundColor( ::com::sun::star::util::Color _rColor ) { - m_pImpl->m_xRowColor2 = _rColor; + m_pImpl->m_nRowColor2 = _rColor; } //-------------------------------------------------------------------- ::com::sun::star::style::VerticalAlignment UnoControlTableModel::getVerticalAlign() { - return m_pImpl->m_xVerticalAlign; + return m_pImpl->m_eVerticalAlign; } //-------------------------------------------------------------------- void UnoControlTableModel::setVerticalAlign( com::sun::star::style::VerticalAlignment _xAlign ) { - m_pImpl->m_xVerticalAlign = _xAlign; + m_pImpl->m_eVerticalAlign = _xAlign; } diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index c00642448f79..18f20043d1be 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -53,18 +53,18 @@ using namespace ::com::sun::star::awt::grid; class UnoControlTableColumn : public IColumnModel { private: - ColumnID m_nID; - String m_sName; - bool m_bIsResizable; - TableMetrics m_nWidth; - TableMetrics m_nMinWidth; - TableMetrics m_nMaxWidth; - TableMetrics m_nPrefWidth; - ::com::sun::star::style::HorizontalAlignment m_xHorizontalAlign; + ColumnID m_nID; + String m_sName; + bool m_bIsResizable; + TableMetrics m_nWidth; + TableMetrics m_nMinWidth; + TableMetrics m_nMaxWidth; + TableMetrics m_nPrefWidth; + ::com::sun::star::style::HorizontalAlignment m_eHorizontalAlign; public: - UnoControlTableColumn(Reference); - UnoControlTableColumn(); + UnoControlTableColumn( const Reference< XGridColumn >& i_gridColumn ); + UnoControlTableColumn(); // IColumnModel overridables virtual ColumnID getID() const; @@ -79,10 +79,10 @@ class UnoControlTableColumn : public IColumnModel virtual void setMinWidth( TableMetrics _nMinWidth ); virtual TableMetrics getMaxWidth() const; virtual void setMaxWidth( TableMetrics _nMaxWidth ); - virtual TableMetrics getPreferredWidth() const; + virtual TableMetrics getPreferredWidth() const; virtual void setPreferredWidth( TableMetrics _nPrefWidth ); - virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign(); - virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign); + virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign(); + virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign); }; struct UnoControlTableModel_Impl; @@ -122,52 +122,55 @@ class UnoControlTableModel : public ITableModel public: // ITableModel overridables - virtual TableSize getColumnCount() const; - virtual TableSize getRowCount() const; - virtual void setColumnCount(TableSize _nColCount); - virtual void setRowCount(TableSize _nRowCount); - virtual bool hasColumnHeaders() const; - virtual bool hasRowHeaders() const; - virtual void setRowHeaders(bool _bRowHeaders); - virtual void setColumnHeaders(bool _bColumnHeaders); - virtual bool isCellEditable( ColPos col, RowPos row ) const; - virtual void addTableModelListener( const PTableModelListener& listener ); - virtual void removeTableModelListener( const PTableModelListener& listener ); - virtual PColumnModel getColumnModel( ColPos column ); - virtual std::vector& getColumnModel(); - virtual PColumnModel getColumnModelByID( ColumnID id ); - virtual PTableRenderer getRenderer() const; + virtual TableSize getColumnCount() const; + virtual TableSize getRowCount() const; + virtual bool hasColumnHeaders() const; + virtual bool hasRowHeaders() const; + virtual bool isCellEditable( ColPos col, RowPos row ) const; + virtual PColumnModel getColumnModel( ColPos column ); + virtual PTableRenderer getRenderer() const; virtual PTableInputHandler getInputHandler() const; - virtual TableMetrics getRowHeight() const; - virtual TableMetrics getColumnHeaderHeight() const; - virtual TableMetrics getRowHeaderWidth() const; - virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const; + virtual TableMetrics getRowHeight() const; + virtual TableMetrics getColumnHeaderHeight() const; + virtual TableMetrics getRowHeaderWidth() const; + virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight,int actHeight) const; virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const; - virtual void setVerticalScrollbarVisibility(bool _bVScroll) const; - virtual void setHorizontalScrollbarVisibility(bool _bHScroll) const; - virtual void setCellContent(const std::vector >& cellContent); - virtual std::vector >& getCellContent(); - virtual void setRowHeaderName(const std::vector& cellColumnContent); - virtual std::vector& getRowHeaderName(); - virtual ::com::sun::star::util::Color getLineColor(); - virtual void setLineColor(::com::sun::star::util::Color _rColor); - virtual ::com::sun::star::util::Color getHeaderBackgroundColor(); - virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor); - virtual ::com::sun::star::util::Color getTextColor(); - virtual void setTextColor(::com::sun::star::util::Color _rColor); - virtual ::com::sun::star::util::Color getOddRowBackgroundColor(); - virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor); - virtual ::com::sun::star::util::Color getEvenRowBackgroundColor(); - virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor); - virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign(); - virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); - virtual bool hasVerticalScrollbar(); - virtual bool hasHorizontalScrollbar(); + virtual void addTableModelListener( const PTableModelListener& i_listener ); + virtual void removeTableModelListener( const PTableModelListener& i_listener ); + virtual bool hasVerticalScrollbar(); + virtual bool hasHorizontalScrollbar(); + virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent(); + virtual std::vector& getRowHeaderName(); + virtual ::com::sun::star::util::Color getLineColor(); + virtual ::com::sun::star::util::Color getHeaderBackgroundColor(); + virtual ::com::sun::star::util::Color getTextColor(); + virtual ::com::sun::star::util::Color getOddRowBackgroundColor(); + virtual ::com::sun::star::util::Color getEvenRowBackgroundColor(); + virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign(); + + + // other operations + void setRowCount(TableSize _nRowCount); + void setRowHeaderName(const std::vector& cellColumnContent); + void setVerticalScrollbarVisibility(bool _bVScroll) const; + void setHorizontalScrollbarVisibility(bool _bHScroll) const; + void setCellContent(const std::vector >& cellContent); + void setColumnCount(TableSize _nColCount); + void setRowHeaders(bool _bRowHeaders); + void setColumnHeaders(bool _bColumnHeaders); + void setLineColor(::com::sun::star::util::Color _rColor); + void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor); + void setTextColor(::com::sun::star::util::Color _rColor); + void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor); + void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor); + void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); + void appendColumn( const PColumnModel& i_column ); + void removeAllColumns(); }; inline void UnoControlTableModel::SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM ) { - getColumnModel( _nColumn )->setWidth( _nWidth100thMM ); + getColumnModel( _nColumn )->setWidth( _nWidth100thMM ); } inline TableMetrics UnoControlTableModel::GetColumnWidth( ColPos _nColumn ) diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index a48f75966bde..2a5b5683efad 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -36,6 +36,7 @@ #include #include +#include #include //...................................................................................................................... @@ -156,6 +157,11 @@ namespace toolkit for ( sal_Int32 i=0; i xColumn( m_aContext.createComponent( "com.sun.star.awt.grid.GridColumn" ), UNO_QUERY_THROW ); + ::rtl::OUStringBuffer colTitle; + colTitle.appendAscii( "Column " ); + colTitle.append( i ); + xColumn->setTitle( colTitle.makeStringAndClear() ); + xColumn->setPreferredWidth( 80 /* APPFONT */ ); ContainerEvent aEvent; aEvent.Source = *this; diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 57b5086e2272..cc16d1f2c355 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -127,9 +127,9 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const case BASEPROPERTY_GRID_SELECTIONMODE: return uno::makeAny( SelectionType(1) ); case BASEPROPERTY_GRID_SHOWROWHEADER: - return uno::makeAny( (sal_Bool)sal_False ); + return uno::makeAny( (sal_Bool)sal_True ); case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: - return uno::makeAny( (sal_Bool)sal_False ); + return uno::makeAny( (sal_Bool)sal_True ); case BASEPROPERTY_GRID_DATAMODEL: return uno::makeAny( Reference ()); case BASEPROPERTY_GRID_COLUMNMODEL: -- cgit v1.2.3 From caa7780d3aae5624cf930c0794c63114564d8781 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 17 Dec 2010 14:07:29 +0100 Subject: gridsort: removed XGridColumn::updateColumn The implementation of this column was only a wrapper around what setColumnWidth/setPreferredWidth would have done. Also, the mechanism how this method was used was really weird, effectively propagating the (preferred) width from the ITableColumn implementation of the grid peer to the XGridColumn implementation of the grid column model. This was done each time the (preferred) width was access for reading - not really a clever solution. Now, the ITableColumn knows its respective XGridColumn, and simply forwards the (preferred) width as needed. --- svtools/source/uno/svtxgridcontrol.cxx | 27 --------- svtools/source/uno/unocontroltablemodel.cxx | 41 +++++++++----- svtools/source/uno/unocontroltablemodel.hxx | 9 +-- toolkit/source/controls/grid/gridcolumn.cxx | 87 ++++++++++++++++------------- toolkit/source/controls/grid/gridcolumn.hxx | 11 ++-- 5 files changed, 88 insertions(+), 87 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 050e938d2487..512eb347f577 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -530,26 +530,6 @@ void SAL_CALL SVTXGridControl::columnChanged(const ::com::sun::star::awt::grid: Event.newValue>>=hAlign; m_pTableModel->getColumnModel( Event.index )->setHorizontalAlign(hAlign); } - else if(Event.valueName == rtl::OUString::createFromAscii("UpdateWidth")) - { - const PColumnModel pTableColumn( m_pTableModel->getColumnModel( Event.index ) ); - ENSURE_OR_RETURN_VOID( !!pTableColumn, "invalid table column!" ); - - Reference< XGridColumn > xColumn; - try - { - xColumn.set( m_xColumnModel->getColumn( Event.index ), UNO_SET_THROW ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - return; - } - - if ( pTableColumn->getPreferredWidth() != 0 ) - xColumn->updateColumn(rtl::OUString::createFromAscii("PrefWidth"), pTableColumn->getPreferredWidth()); - xColumn->updateColumn(rtl::OUString::createFromAscii("ColWidth"), pTableColumn->getWidth() ); - } pTable->Invalidate(); } void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) @@ -972,13 +952,6 @@ void SVTXGridControl::impl_updateColumnsFromModel_nothrow() UnoControlTableColumn* tableColumn = new UnoControlTableColumn( *colRef ); m_pTableModel->appendColumn( PColumnModel( tableColumn ) ); - - tableColumn->setHorizontalAlign( (*colRef)->getHorizontalAlign() ); - tableColumn->setWidth( (*colRef)->getColumnWidth() ); - tableColumn->setResizable( (*colRef)->getResizeable() ); - tableColumn->setPreferredWidth( (*colRef)->getPreferredWidth() ); - tableColumn->setMaxWidth( (*colRef)->getMaxWidth() ); - tableColumn->setMinWidth( (*colRef)->getMinWidth() ); } } diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index e8ebd029884c..ff246be0c3ae 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -43,7 +43,7 @@ using ::rtl::OUString; using namespace ::svt::table; using namespace ::com::sun::star::uno; - +using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- UnoControlTableColumn::UnoControlTableColumn( const Reference< XGridColumn >& i_gridColumn ) @@ -55,20 +55,17 @@ using namespace ::com::sun::star::uno; ,m_nMaxWidth( 0 ) ,m_nPrefWidth ( 0 ) ,m_eHorizontalAlign( com::sun::star::style::HorizontalAlignment_LEFT ) + ,m_xGridColumn( i_gridColumn ) { - ENSURE_OR_THROW( i_gridColumn.is(), "illegal column" ); - m_sName = i_gridColumn->getTitle(); + m_sName = m_xGridColumn->getTitle(); + + m_eHorizontalAlign = m_xGridColumn->getHorizontalAlign(); + m_nWidth = m_xGridColumn->getColumnWidth(); + m_bIsResizable = m_xGridColumn->getResizeable(); - // don't do this here. The attribute getters at the XGridColumn implementation do some notifications, - // which is absolutely weird. Sadly, this also means that we can't call the getters while we're - // being constructed, and not yet inserted into the column model. -// m_eHorizontalAlign = i_gridColumn->getHorizontalAlign(); -// m_nWidth = i_gridColumn->getColumnWidth(); -// m_bIsResizable = i_gridColumn->getResizeable(); -// -// m_nPrefWidth = i_gridColumn->getPreferredWidth(); -// m_nMaxWidth = i_gridColumn->getMaxWidth(); -// m_nMinWidth = i_gridColumn->getMinWidth(); + m_nPrefWidth = m_xGridColumn->getPreferredWidth(); + m_nMaxWidth = m_xGridColumn->getMaxWidth(); + m_nMinWidth = m_xGridColumn->getMinWidth(); } //-------------------------------------------------------------------- @@ -130,6 +127,15 @@ using namespace ::com::sun::star::uno; void UnoControlTableColumn::setWidth( TableMetrics _nWidth ) { m_nWidth = _nWidth; + try + { + if ( m_xGridColumn.is() ) + m_xGridColumn->setColumnWidth( getWidth() ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //-------------------------------------------------------------------- @@ -165,6 +171,15 @@ using namespace ::com::sun::star::uno; void UnoControlTableColumn::setPreferredWidth( TableMetrics _nPrefWidth ) { m_nPrefWidth = _nPrefWidth; + try + { + if ( m_xGridColumn.is() ) + m_xGridColumn->setPreferredWidth( getPreferredWidth() ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //-------------------------------------------------------------------- ::com::sun::star::style::HorizontalAlignment UnoControlTableColumn::getHorizontalAlign() diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 18f20043d1be..fc6e90f16f6a 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -47,8 +47,6 @@ using namespace ::svt::table; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt::grid; class UnoControlTableColumn : public IColumnModel { @@ -62,8 +60,11 @@ class UnoControlTableColumn : public IColumnModel TableMetrics m_nPrefWidth; ::com::sun::star::style::HorizontalAlignment m_eHorizontalAlign; + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > + m_xGridColumn; + public: - UnoControlTableColumn( const Reference< XGridColumn >& i_gridColumn ); + UnoControlTableColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn >& i_gridColumn ); UnoControlTableColumn(); // IColumnModel overridables @@ -154,7 +155,7 @@ class UnoControlTableModel : public ITableModel void setRowHeaderName(const std::vector& cellColumnContent); void setVerticalScrollbarVisibility(bool _bVScroll) const; void setHorizontalScrollbarVisibility(bool _bHScroll) const; - void setCellContent(const std::vector >& cellContent); + void setCellContent(const std::vector >& cellContent); void setColumnCount(TableSize _nColCount); void setRowHeaders(bool _bRowHeaders); void setColumnHeaders(bool _bColumnHeaders); diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 4094f4433538..0503c69b0493 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -38,7 +38,6 @@ #define HALIGN ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "HAlign" )) #define TITLE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" )) #define COLRESIZE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResize" )) -#define UPDATE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UpdateWidth" )) namespace toolkit { @@ -71,43 +70,22 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ) - { - ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() ); - if( pIter ) - { - ::cppu::OInterfaceIteratorHelper aListIter(*pIter); - while(aListIter.hasMoreElements()) - { - XGridColumnListener* pListener = static_cast(aListIter.next()); - switch( eType ) - { - case column_attribute_changed: pListener->columnChanged(aEvent); break; - } - } - } - } - - //------------------------------------------------------------------------------------------------------------------ - void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue) + void GridColumn::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue, ::osl::ClearableMutexGuard& i_Guard ) { Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); GridColumnEvent aEvent( xSource, name, oldValue, newValue, m_nIndex); - broadcast( column_attribute_changed, aEvent); - } - //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException) - { - if(PREFWIDTH == name) - m_nPreferredWidth = width; - else if (COLWIDTH == name) - m_nColumnWidth = width; + ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() ); + + i_Guard.clear(); + if( pIter ) + pIter->notifyEach( &XGridColumnListener::columnChanged, aEvent ); } //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); return m_aIdentifier; } @@ -120,94 +98,127 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException) { - broadcast_changed(UPDATE, Any(m_nColumnWidth), Any()); + ::osl::MutexGuard aGuard( m_aMutex ); return m_nColumnWidth; } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( m_nColumnWidth == value ) + return; + m_nColumnWidth = value; - broadcast_changed(COLWIDTH, Any(m_nColumnWidth),Any(value)); + broadcast_changed( COLWIDTH, Any( m_nColumnWidth ), Any( value ), aGuard ); } //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) { - broadcast_changed(UPDATE, Any(m_nPreferredWidth), Any()); + ::osl::MutexGuard aGuard( m_aMutex ); return m_nPreferredWidth; } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( m_nPreferredWidth == value ) + return; + m_nPreferredWidth = value; - broadcast_changed(PREFWIDTH, Any(m_nPreferredWidth),Any(value)); + broadcast_changed( PREFWIDTH, Any( m_nPreferredWidth ), Any( value ), aGuard ); } //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); return m_nMaxWidth; } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( m_nMaxWidth == value ) + return; + m_nMaxWidth = value; - broadcast_changed(MAXWIDTH, Any(m_nMaxWidth),Any(value)); + broadcast_changed( MAXWIDTH, Any( m_nMaxWidth ), Any( value ), aGuard ); } //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); return m_nMinWidth; } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( m_nMinWidth == value ) + return; + m_nMinWidth = value; - broadcast_changed(MINWIDTH, Any(m_nMinWidth),Any(value)); + broadcast_changed( MINWIDTH, Any( m_nMinWidth ), Any( value ), aGuard ); } //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); return m_sTitle; } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( m_sTitle == value ) + return; + m_sTitle = value; - broadcast_changed(TITLE, Any(m_sTitle),Any(value)); + broadcast_changed( TITLE, Any( m_sTitle ), Any( value ), aGuard ); } //------------------------------------------------------------------------------------------------------------------ sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); return m_bResizeable; } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( m_bResizeable == value ) + return; + m_bResizeable = value; - broadcast_changed(COLRESIZE, Any(m_bResizeable),Any(value)); + broadcast_changed( COLRESIZE, Any( m_bResizeable ), Any( value ), aGuard ); } //------------------------------------------------------------------------------------------------------------------ HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); return m_eHorizontalAlign; } //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( m_eHorizontalAlign == align ) + return; + m_eHorizontalAlign = align; - broadcast_changed(HALIGN, Any(m_eHorizontalAlign),Any(align)); + broadcast_changed( HALIGN, Any( m_eHorizontalAlign ), Any( align ), aGuard ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index 4a47f44ce674..51f9ccf8e4b2 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -43,8 +43,6 @@ namespace toolkit { -enum broadcast_column_type { column_attribute_changed}; - typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::awt::grid::XGridColumn , ::com::sun::star::lang::XServiceInfo > GridColumn_Base; @@ -74,7 +72,6 @@ public: virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateColumn( const ::rtl::OUString& name, ::sal_Int32 width ) throw (::com::sun::star::uno::RuntimeException); // XComponent (base of XGridColumn) virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); @@ -88,8 +85,12 @@ public: virtual void SAL_CALL setIndex(sal_Int32 _nIndex)throw (::com::sun::star::uno::RuntimeException); private: - void broadcast( broadcast_column_type eType, const ::com::sun::star::awt::grid::GridColumnEvent& aEvent ); - void broadcast_changed( ::rtl::OUString name, ::com::sun::star::uno::Any oldValue, ::com::sun::star::uno::Any newValue); + void broadcast_changed( + ::rtl::OUString name, + ::com::sun::star::uno::Any oldValue, + ::com::sun::star::uno::Any newValue, + ::osl::ClearableMutexGuard& i_Guard + ); ::com::sun::star::uno::Any m_aIdentifier; sal_Int32 m_nIndex; -- cgit v1.2.3 From 40b70c5f947f72a5776f114372cb5cc3a6ca7973 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 17 Dec 2010 14:25:50 +0100 Subject: gridsort: renamed XGridColumn::add/removeColumnListener to add/removeGridColumnListener - this consistency with the actual listener type name will make introspection work --- svtools/source/uno/svtxgridcontrol.cxx | 5 ++--- toolkit/source/controls/grid/gridcolumn.cxx | 4 ++-- toolkit/source/controls/grid/gridcolumn.hxx | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 512eb347f577..594289b6a8b8 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -406,7 +406,6 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD { UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); m_pTableModel->appendColumn( PColumnModel( tableColumn ) ); - m_xColumnModel->getColumn(col)->addColumnListener(listener); } } @@ -967,7 +966,7 @@ void SVTXGridControl::impl_setColumnListening( const Reference< XGridColumn >& i ENSURE_OR_RETURN_VOID( i_column.is(), "SVTXGridControl::impl_setColumnListening: illegal column!" ); if ( i_start ) - i_column->addColumnListener( this ); + i_column->addGridColumnListener( this ); else - i_column->removeColumnListener( this ); + i_column->removeGridColumnListener( this ); } diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 0503c69b0493..d966e6656661 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -222,13 +222,13 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) + void SAL_CALL GridColumn::addGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) { rBHelper.addListener( XGridColumnListener::static_type(), xListener ); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) + void SAL_CALL GridColumn::removeGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) { rBHelper.removeListener( XGridColumnListener::static_type(), xListener ); } diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index 51f9ccf8e4b2..f621f68c9d88 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -70,8 +70,8 @@ public: virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addGridColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeGridColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); // XComponent (base of XGridColumn) virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From d1b2c8cc1df5eadb8d8cc150bf515817fdabff30 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 17 Dec 2010 14:41:50 +0100 Subject: gridsort: properly react on elementInserted notifications --- svtools/source/uno/svtxgridcontrol.cxx | 8 +++++--- svtools/source/uno/unocontroltablemodel.cxx | 12 +++++++++--- svtools/source/uno/unocontroltablemodel.hxx | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 594289b6a8b8..2dee47478120 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -589,10 +589,12 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::G //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) { - const Reference< XGridColumn > xGridColumn( i_event.Element, UNO_QUERY ); + const Reference< XGridColumn > xGridColumn( i_event.Element, UNO_QUERY_THROW ); + sal_Int32 nIndex( m_pTableModel->getColumnCount() ); + OSL_VERIFY( i_event.Accessor >>= nIndex ); + const PColumnModel tableColumn( new UnoControlTableColumn( xGridColumn ) ); - // will throw if this is not a valid grid column - m_pTableModel->appendColumn( tableColumn ); + m_pTableModel->insertColumn( nIndex, tableColumn ); impl_setColumnListening( Reference< XGridColumn >( i_event.Element, UNO_QUERY ), true ); } diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index ff246be0c3ae..8ee40f925591 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -326,10 +326,16 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- void UnoControlTableModel::appendColumn( const PColumnModel& i_column ) { + insertColumn( m_pImpl->aColumns.size(), i_column ); + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::insertColumn( ColPos const i_position, const PColumnModel& i_column ) + { + ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( i_position <= m_pImpl->aColumns.size() ), "illegal position!" ); ENSURE_OR_RETURN_VOID( !!i_column, "illegal column" ); - const ColPos nInsertPosition = m_pImpl->aColumns.size(); - m_pImpl->aColumns.push_back( i_column ); + m_pImpl->aColumns.insert( m_pImpl->aColumns.begin(), i_column ); // notify listeners ModellListeners aListeners( m_pImpl->m_aListeners ); @@ -338,7 +344,7 @@ using namespace ::com::sun::star::awt::grid; ++loop ) { - (*loop)->columnsInserted( nInsertPosition, nInsertPosition ); + (*loop)->columnsInserted( i_position, i_position ); } } diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index fc6e90f16f6a..f81c0bf88433 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -166,6 +166,7 @@ class UnoControlTableModel : public ITableModel void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor); void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); void appendColumn( const PColumnModel& i_column ); + void insertColumn( ColPos const i_position, const PColumnModel& i_column ); void removeAllColumns(); }; -- cgit v1.2.3 From 7eaf01c7332179229dab928fec6aff5369c6b9d7 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 17 Dec 2010 15:29:15 +0100 Subject: gridsort: no need for the param-less UnoControlTableColumn anymore - the recently introduced notifications will always create an instance with the correct XGridColumn delegator --- svtools/source/uno/svtxgridcontrol.cxx | 13 +-- svtools/source/uno/unocontroltablemodel.cxx | 121 +++++++++++++++------------- svtools/source/uno/unocontroltablemodel.hxx | 11 +-- 3 files changed, 68 insertions(+), 77 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 2dee47478120..1a6ce6ff88e5 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -278,12 +278,8 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An //check whether the data row vector length matches with the column count if(m_xColumnModel->getColumnCount() == 0) { - for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) - { - UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); - m_pTableModel->appendColumn( PColumnModel( tableColumn ) ); - } m_xColumnModel->setDefaultColumns(rawRowData.getLength()); + // this will trigger notifications, which in turn will let us update our m_pTableModel } else if((unsigned int)rawRowData.getLength()!=(unsigned)m_pTableModel->getColumnCount()) @@ -400,13 +396,8 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD int colCount = m_xColumnModel->getColumnCount(); if(colCount == 0) { - Reference listener(*this,UNO_QUERY_THROW); m_xColumnModel->setDefaultColumns(rawRowData.getLength()); - for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col ) - { - UnoControlTableColumn* tableColumn = new UnoControlTableColumn(); - m_pTableModel->appendColumn( PColumnModel( tableColumn ) ); - } + // this will trigger notifications, which in turn will let us update our m_pTableModel } else if((unsigned int)rawRowData.getLength()!=(unsigned)colCount) diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 8ee40f925591..4ed310aa8b28 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -46,38 +46,42 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- - UnoControlTableColumn::UnoControlTableColumn( const Reference< XGridColumn >& i_gridColumn ) - :m_nID( 0 ) - ,m_sName() - ,m_bIsResizable( true ) - ,m_nWidth( 4 ) - ,m_nMinWidth( 0 ) - ,m_nMaxWidth( 0 ) - ,m_nPrefWidth ( 0 ) - ,m_eHorizontalAlign( com::sun::star::style::HorizontalAlignment_LEFT ) - ,m_xGridColumn( i_gridColumn ) + namespace { - m_sName = m_xGridColumn->getTitle(); - - m_eHorizontalAlign = m_xGridColumn->getHorizontalAlign(); - m_nWidth = m_xGridColumn->getColumnWidth(); - m_bIsResizable = m_xGridColumn->getResizeable(); + template< class ATTRIBUTE_TYPE > + void lcl_set( Reference< XGridColumn > const & i_column, void ( SAL_CALL XGridColumn::*i_setter )( ATTRIBUTE_TYPE ), + ATTRIBUTE_TYPE i_value ) + { + try + { + (i_column.get()->*i_setter) ( i_value ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } - m_nPrefWidth = m_xGridColumn->getPreferredWidth(); - m_nMaxWidth = m_xGridColumn->getMaxWidth(); - m_nMinWidth = m_xGridColumn->getMinWidth(); + template< class ATTRIBUTE_TYPE > + ATTRIBUTE_TYPE lcl_get( Reference< XGridColumn > const & i_column, ATTRIBUTE_TYPE ( SAL_CALL XGridColumn::*i_getter )() ) + { + ATTRIBUTE_TYPE value = ATTRIBUTE_TYPE(); + try + { + value = (i_column.get()->*i_getter)(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return value; + } } //-------------------------------------------------------------------- - UnoControlTableColumn::UnoControlTableColumn() + UnoControlTableColumn::UnoControlTableColumn( const Reference< XGridColumn >& i_gridColumn ) :m_nID( 0 ) - ,m_sName() - ,m_bIsResizable( true ) - ,m_nWidth( 4 ) - ,m_nMinWidth( 0 ) - ,m_nMaxWidth( 0 ) - ,m_nPrefWidth ( 0 ) - ,m_eHorizontalAlign(com::sun::star::style::HorizontalAlignment(0)) + ,m_xGridColumn( i_gridColumn, UNO_SET_THROW ) { } @@ -97,100 +101,101 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- String UnoControlTableColumn::getName() const { - return m_sName; + ::rtl::OUString sName; + try + { + sName = m_xGridColumn->getTitle(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sName; } //-------------------------------------------------------------------- void UnoControlTableColumn::setName( const String& _rName ) { - m_sName = _rName; + try + { + m_xGridColumn->setTitle( _rName ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } + //-------------------------------------------------------------------- bool UnoControlTableColumn::isResizable() const { - return m_bIsResizable; + return lcl_get( m_xGridColumn, &XGridColumn::getResizeable ); } //-------------------------------------------------------------------- void UnoControlTableColumn::setResizable( bool _bResizable ) { - m_bIsResizable = _bResizable; + return lcl_set( m_xGridColumn, &XGridColumn::setResizeable, sal_Bool( _bResizable ) ); } //-------------------------------------------------------------------- TableMetrics UnoControlTableColumn::getWidth() const { - return m_nWidth; + return lcl_get( m_xGridColumn, &XGridColumn::getColumnWidth ); } //-------------------------------------------------------------------- void UnoControlTableColumn::setWidth( TableMetrics _nWidth ) { - m_nWidth = _nWidth; - try - { - if ( m_xGridColumn.is() ) - m_xGridColumn->setColumnWidth( getWidth() ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } + lcl_set( m_xGridColumn, &XGridColumn::setColumnWidth, _nWidth ); } //-------------------------------------------------------------------- TableMetrics UnoControlTableColumn::getMinWidth() const { - return m_nMinWidth; + return lcl_get( m_xGridColumn, &XGridColumn::getMinWidth ); } //-------------------------------------------------------------------- void UnoControlTableColumn::setMinWidth( TableMetrics _nMinWidth ) { - m_nMinWidth = _nMinWidth; + lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMinWidth ); } //-------------------------------------------------------------------- TableMetrics UnoControlTableColumn::getMaxWidth() const { - return m_nMaxWidth; + return lcl_get( m_xGridColumn, &XGridColumn::getMaxWidth ); } //-------------------------------------------------------------------- void UnoControlTableColumn::setMaxWidth( TableMetrics _nMaxWidth ) { - m_nMaxWidth = _nMaxWidth; + lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMaxWidth ); } + //-------------------------------------------------------------------- TableMetrics UnoControlTableColumn::getPreferredWidth() const { - return m_nPrefWidth; + return lcl_get( m_xGridColumn, &XGridColumn::getPreferredWidth ); } //-------------------------------------------------------------------- void UnoControlTableColumn::setPreferredWidth( TableMetrics _nPrefWidth ) { - m_nPrefWidth = _nPrefWidth; - try - { - if ( m_xGridColumn.is() ) - m_xGridColumn->setPreferredWidth( getPreferredWidth() ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } + lcl_set( m_xGridColumn, &XGridColumn::setPreferredWidth, _nPrefWidth ); } + //-------------------------------------------------------------------- ::com::sun::star::style::HorizontalAlignment UnoControlTableColumn::getHorizontalAlign() { - return m_eHorizontalAlign; + return lcl_get( m_xGridColumn, &XGridColumn::getHorizontalAlign ); } //-------------------------------------------------------------------- void UnoControlTableColumn::setHorizontalAlign( com::sun::star::style::HorizontalAlignment _align ) { - m_eHorizontalAlign = _align; + lcl_set( m_xGridColumn, &XGridColumn::setHorizontalAlign, _align ); } //==================================================================== diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index f81c0bf88433..2a627358554f 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -52,20 +52,12 @@ class UnoControlTableColumn : public IColumnModel { private: ColumnID m_nID; - String m_sName; - bool m_bIsResizable; - TableMetrics m_nWidth; - TableMetrics m_nMinWidth; - TableMetrics m_nMaxWidth; - TableMetrics m_nPrefWidth; - ::com::sun::star::style::HorizontalAlignment m_eHorizontalAlign; const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > m_xGridColumn; public: UnoControlTableColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn >& i_gridColumn ); - UnoControlTableColumn(); // IColumnModel overridables virtual ColumnID getID() const; @@ -84,6 +76,9 @@ class UnoControlTableColumn : public IColumnModel virtual void setPreferredWidth( TableMetrics _nPrefWidth ); virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign(); virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign); + + private: + UnoControlTableColumn(); // not implemented }; struct UnoControlTableModel_Impl; -- cgit v1.2.3 From 6f7105ef88fcb3e8979617cbbac3a8503e4766ea Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 23 Dec 2010 15:48:53 +0100 Subject: gridsort: re-factoring the column-resizing thingie, step 1 In the current implementation, this is rather complex, and hardly maintainable. Also, it all happens in TableControl_Impl and TableDataWindow, while in the original design, the InputHandler was intended to care for this kind of tasks (one class - one responsibility). --- svtools/inc/svtools/table/abstracttablecontrol.hxx | 23 +- svtools/inc/svtools/table/tablecontrol.hxx | 3 +- svtools/inc/svtools/table/tablemodel.hxx | 2 +- svtools/source/table/defaultinputhandler.cxx | 70 +- svtools/source/table/tablecontrol.cxx | 28 +- svtools/source/table/tablecontrol_impl.cxx | 795 ++++++++++++--------- svtools/source/table/tablecontrol_impl.hxx | 120 +++- svtools/source/table/tabledatawindow.cxx | 15 +- svtools/source/table/tablegeometry.cxx | 85 ++- svtools/source/table/tablegeometry.hxx | 6 + svtools/source/uno/svtxgridcontrol.cxx | 3 +- svtools/source/uno/unocontroltablemodel.cxx | 6 +- toolkit/source/controls/grid/gridcontrol.cxx | 2 +- 13 files changed, 691 insertions(+), 467 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx index 9206f20ecbcb..ac91006e42f5 100644 --- a/svtools/inc/svtools/table/abstracttablecontrol.hxx +++ b/svtools/inc/svtools/table/abstracttablecontrol.hxx @@ -73,7 +73,6 @@ namespace svt { namespace table /// selects the row, from the actual cursor till bottom cursorSelectRowAreaBottom, - /// invalid and final enumeration value, not to be actually used invalidTableControlAction }; @@ -113,16 +112,18 @@ namespace svt { namespace table @see TableControlAction */ virtual bool dispatchAction( TableControlAction _eAction ) = 0; - /** returns selection engine*/ - virtual SelectionEngine* getSelEngine() = 0; - virtual void setCursorAtCurrentCell(const Point& rPoint) = 0; - virtual bool isTooltipActive() = 0; - virtual rtl::OUString& setTooltip(const Point& rPoint ) = 0; - virtual RowPos getCurrentRow(const Point& rPoint ) = 0; - virtual void resizeColumn(const Point& rPoint ) = 0; - virtual bool startResizeColumn(const Point& rPoint) = 0; - virtual bool endResizeColumn(const Point& rPoint) = 0; - virtual bool isRowSelected(RowPos _nRow) = 0; + + /** returns selection engine*/ + virtual SelectionEngine* getSelEngine() = 0; + virtual void activateCellAt( const Point& rPoint ) = 0; + virtual bool isTooltipActive() = 0; + virtual rtl::OUString& setTooltip(const Point& rPoint ) = 0; + virtual RowPos getRowAtPoint( const Point& rPoint ) = 0; + virtual ColPos getColAtPoint( const Point& rPoint ) = 0; + virtual void resizeColumn(const Point& rPoint ) = 0; + virtual bool checkResizeColumn(const Point& rPoint) = 0; + virtual bool endResizeColumn(const Point& rPoint) = 0; + virtual bool isRowSelected(RowPos _nRow) = 0; virtual ~IAbstractTableControl() {}; }; diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 07384540261b..b75ebe0dcc88 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -111,8 +111,7 @@ namespace svt { namespace table sal_Int32 GetCurrentRow() const; /** returns the row, which contains the input point*/ - - ColPos GetCurrentRow (const Point& rPoint); + ColPos GetRowAtPoint( const Point& rPoint ); /** retrieves the current column diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index a9d6c7325e65..99cd0e2792d6 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -232,7 +232,7 @@ namespace svt { namespace table If there is more than one column with width COLWIDTH_FIT_TO_VIEW in a model, they're all layouted equal-width. - If the columns with a read width (i.e. other than COLWIDTH_FIT_TO_VIEW) are, + If the columns with a real width (i.e. other than COLWIDTH_FIT_TO_VIEW) are, in sum, wider than the view, then the view is free to choose a real width for any columns which return COLWIDTH_FIT_TO_VIEW here. diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index f6a58ad17efe..9f170c929eba 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -64,9 +64,9 @@ namespace svt { namespace table bool DefaultInputHandler::MouseMove( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt ) { Point aPoint = _rMEvt.GetPosPixel(); - if(m_bResize) + if ( m_bResize ) { - _rControl.resizeColumn(aPoint); + _rControl.resizeColumn( aPoint ); return true; } return false; @@ -77,25 +77,35 @@ namespace svt { namespace table { bool bHandled = false; Point aPoint = _rMEvt.GetPosPixel(); - RowPos nRow = _rControl.getCurrentRow(aPoint); - if(nRow == -1) + RowPos nRow = _rControl.getRowAtPoint( aPoint ); + if ( nRow == ROW_COL_HEADERS ) { - m_bResize = _rControl.startResizeColumn(aPoint); + m_bResize = _rControl.checkResizeColumn(aPoint); bHandled = true; } else if(nRow >= 0) { - if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION) + bool bSetCursor = false; + if ( _rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) { - _rControl.setCursorAtCurrentCell(aPoint); - bHandled = true; + bSetCursor = true; } else { - if(!_rControl.isRowSelected(nRow)) - bHandled = _rControl.getSelEngine()->SelMouseButtonDown(_rMEvt); + if ( !_rControl.isRowSelected( nRow ) ) + { + bHandled = _rControl.getSelEngine()->SelMouseButtonDown( _rMEvt ); + } else - bHandled = true; + { + bSetCursor = true; + } + } + + if ( bSetCursor ) + { + _rControl.activateCellAt( aPoint ); + bHandled = true; } } return bHandled; @@ -104,29 +114,22 @@ namespace svt { namespace table bool DefaultInputHandler::MouseButtonUp( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt ) { bool bHandled = false; - Point aPoint = _rMEvt.GetPosPixel(); - if(_rControl.getCurrentRow(aPoint) >= 0) + const Point aPoint = _rMEvt.GetPosPixel(); + + if ( m_bResize ) { - if(m_bResize) - { - m_bResize = _rControl.endResizeColumn(aPoint); - bHandled = true; - } - else if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION) + m_bResize = _rControl.endResizeColumn( aPoint ); + bHandled = true; + } + else if ( _rControl.getRowAtPoint( aPoint ) >= 0 ) + { + if ( _rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) { bHandled = true; } else { - bHandled = _rControl.getSelEngine()->SelMouseButtonUp(_rMEvt); - } - } - else - { - if(m_bResize) - { - m_bResize = _rControl.endResizeColumn(aPoint); - bHandled = true; + bHandled = _rControl.getSelEngine()->SelMouseButtonUp( _rMEvt ); } } return bHandled; @@ -158,11 +161,11 @@ namespace svt { namespace table { KEY_PAGEDOWN, KEY_MOD1, cursorToLastLine }, { KEY_HOME, KEY_MOD1, cursorTopLeft }, { KEY_END, KEY_MOD1, cursorBottomRight }, - { KEY_SPACE, KEY_MOD1, cursorSelectRow }, - { KEY_UP, KEY_SHIFT, cursorSelectRowUp }, - { KEY_DOWN, KEY_SHIFT, cursorSelectRowDown }, - { KEY_END, KEY_SHIFT, cursorSelectRowAreaBottom }, - { KEY_HOME, KEY_SHIFT, cursorSelectRowAreaTop }, + { KEY_SPACE, KEY_MOD1, cursorSelectRow }, + { KEY_UP, KEY_SHIFT, cursorSelectRowUp }, + { KEY_DOWN, KEY_SHIFT, cursorSelectRowDown }, + { KEY_END, KEY_SHIFT, cursorSelectRowAreaBottom }, + { KEY_HOME, KEY_SHIFT, cursorSelectRowAreaTop }, { 0, 0, invalidTableControlAction } }; @@ -173,7 +176,6 @@ namespace svt { namespace table if ( ( pActions->nKeyCode == nKeyCode ) && ( pActions->nKeyModifier == rKeyCode.GetAllModifier() ) ) { bHandled = _rControl.dispatchAction( pActions->eAction ); - bHandled = true; // always handled issue #i114340 break; } } diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index cde198a92a6e..24486d024091 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -100,10 +100,7 @@ namespace svt { namespace table void TableControl::GetFocus() { if ( !m_pImpl->getInputHandler()->GetFocus( *m_pImpl ) ) - { Control::GetFocus(); - Control::GrabFocus(); - } } //-------------------------------------------------------------------- @@ -246,23 +243,26 @@ namespace svt { namespace table { m_pImpl->removeSelectedRow(_nRowPos); } - //-------------------------------------------------------------------- - RowPos TableControl::GetCurrentRow(const Point& rPoint) + //-------------------------------------------------------------------- + RowPos TableControl::GetRowAtPoint( const Point& rPoint ) { - return m_pImpl->getCurrentRow( rPoint ); + return m_pImpl->getRowAtPoint( rPoint ); } + //-------------------------------------------------------------------- SelectionEngine* TableControl::getSelEngine() { return m_pImpl->getSelEngine(); } + //-------------------------------------------------------------------- TableDataWindow* TableControl::getDataWindow() { return m_pImpl->getDataWindow(); } + //-------------------------------------------------------------------- Reference< XAccessible > TableControl::CreateAccessible() { Window* pParent = GetAccessibleParentWindow(); @@ -494,10 +494,10 @@ sal_Int32 TableControl::GetAccessibleControlCount() const } sal_Bool TableControl::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) { - sal_Int32 nRow = m_pImpl->getCurrentRow(_rPoint); - sal_Int32 nCol = GetCurrentColumn(); + sal_Int32 nRow = m_pImpl->getRowAtPoint( _rPoint ); + sal_Int32 nCol = m_pImpl->getColAtPoint( _rPoint ); _rnIndex = nRow * GetColumnCount() + nCol; - return nRow>=0 ? sal_True : sal_False; + return nRow >= 0 ? sal_True : sal_False; } long TableControl::GetRowCount() const @@ -523,9 +523,9 @@ bool TableControl::IsRowSelected( long _nRow ) const } sal_Bool TableControl::ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ) { - _rnRow = m_pImpl->getCurrentRow(_rPoint); - _rnColPos = GetCurrentColumn(); - return _rnRow>=0 ? sal_True : sal_False; + _rnRow = m_pImpl->getRowAtPoint( _rPoint ); + _rnColPos = m_pImpl->getColAtPoint( _rPoint ); + return _rnRow >= 0 ? sal_True : sal_False; } void TableControl::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const { @@ -612,12 +612,12 @@ IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG ) IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData ) { CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData ); - return 1; + return 1; } IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData ) { CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData ); - return 1; + return 1; } // ----------------------------------------------------------------------- void TableControl::Select() diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 46ebda453b10..09ac0412c615 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -280,12 +280,9 @@ namespace svt { namespace table if ( m_pModel->getRowCount() != m_nRowCount ) return "row counts are inconsistent!"; - if ( ( m_nCurColumn != COL_INVALID ) && !m_aColumnWidthsPixel.empty() && ( m_nCurColumn < 0 ) || ( m_nCurColumn >= (ColPos)m_aColumnWidthsPixel.size() ) ) + if ( ( m_nCurColumn != COL_INVALID ) && !m_aColumnWidths.empty() && ( m_nCurColumn < 0 ) || ( m_nCurColumn >= (ColPos)m_aColumnWidths.size() ) ) return "current column is invalid!"; - if ( m_aColumnWidthsPixel.size() != m_aAccColumnWidthsPixel.size() ) - return "columnd width caches are inconsistent!"; - if ( !lcl_checkLimitsExclusive_OrDefault_OrFallback( m_nTopRow, (RowPos)-1, m_nRowCount, getModel(), (RowPos)0 ) ) return "invalid top row value!"; @@ -326,7 +323,11 @@ namespace svt { namespace table return "row header widths are inconsistent!"; } - // TODO: check m_aColumnWidthsPixel and m_aAccColumnWidthsPixel + // TODO: check m_aColumnWidths + // - for each element, getStart <= getEnd() + // - for each i: col[ i ].getEnd() == col[ i+1 ].getStart() + // - col[ m_nLeftColumn ].getStart == m_nRowHeaderWidthPixel + if ( m_nCursorHidden < 0 ) return "invalid hidden count for the cursor!"; @@ -335,6 +336,8 @@ namespace svt { namespace table DBG_SUSPEND_INV( INV_SCROLL_POSITION ); // prevent infinite recursion + if ( m_nLeftColumn < 0 ) + return "invalid left-most column index"; if ( m_pVScroll->GetThumbPos() != m_nTopRow ) return "vertical scroll bar |position| is incorrect!"; if ( m_pVScroll->GetRange().Max() != m_nRowCount ) @@ -386,7 +389,7 @@ namespace svt { namespace table ,m_nRowSelected ( ) ,m_pTableFunctionSet ( new TableFunctionSet( this ) ) ,m_nAnchor (-1 ) - ,m_bResizing ( false ) + ,m_bResizingColumn ( false ) ,m_nResizingColumn ( 0 ) ,m_bResizingGrid ( false ) #if DBG_UTIL @@ -519,19 +522,20 @@ namespace svt { namespace table // determine the right-most border of the last column which is // at least partially visible _rCellArea.Right() = m_nRowHeaderWidthPixel; - if ( !m_aAccColumnWidthsPixel.empty() ) + if ( !m_aColumnWidths.empty() ) { - // the number of pixels which are scroll out of the left hand + // the number of pixels which are scrolled out of the left hand // side of the window - long nScrolledOutLeft = m_nLeftColumn == 0 ? 0 : m_aAccColumnWidthsPixel[ m_nLeftColumn - 1 ]; + const long nScrolledOutLeft = m_nLeftColumn == 0 ? 0 : m_aColumnWidths[ m_nLeftColumn - 1 ].getEnd(); - ArrayOfLong::const_reverse_iterator loop = m_aAccColumnWidthsPixel.rbegin(); + ColumnPositions::const_reverse_iterator loop = m_aColumnWidths.rbegin(); do { - _rCellArea.Right() = *loop++ - nScrolledOutLeft + m_nRowHeaderWidthPixel; + _rCellArea.Right() = loop->getEnd() - nScrolledOutLeft + m_nRowHeaderWidthPixel; + ++loop; } - while ( ( loop != m_aAccColumnWidthsPixel.rend() ) - && ( *loop - nScrolledOutLeft >= _rCellArea.Right() ) + while ( ( loop != m_aColumnWidths.rend() ) + && ( loop->getEnd() - nScrolledOutLeft >= _rCellArea.Right() ) ); } // so far, _rCellArea.Right() denotes the first pixel *after* the cell area @@ -582,54 +586,54 @@ namespace svt { namespace table //-------------------------------------------------------------------- void TableControl_Impl::impl_ni_updateColumnWidths() { - m_aColumnWidthsPixel.resize( 0 ); - m_aAccColumnWidthsPixel.resize( 0 ); + m_aColumnWidths.resize( 0 ); if ( !m_pModel ) return; - TableSize colCount = m_pModel->getColumnCount(); + const TableSize colCount = m_pModel->getColumnCount(); if ( colCount == 0 ) return; - m_aColumnWidthsPixel.reserve( colCount ); - m_aAccColumnWidthsPixel.reserve( colCount ); + m_aColumnWidths.reserve( colCount ); std::vector aPrePixelWidths(0); long accumulatedPixelWidth = 0; - int lastResizableCol = -1; + int lastResizableCol = COL_INVALID; double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width(); - if(m_pModel->hasRowHeaders()) + if ( m_pModel->hasRowHeaders() && ( gridWidth != 0 ) ) { - TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); - gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); +#if OSL_DEBUG_LEVEL > 0 + const TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); + const long rowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); + OSL_ENSURE( rowHeaderWidthPixel == m_nRowHeaderWidthPixel, + "TableControl_Impl::impl_ni_updateColumnWidths: cached row header width is not correct anymore!" ); +#endif + accumulatedPixelWidth += m_nRowHeaderWidthPixel; + gridWidth -= m_nRowHeaderWidthPixel; } - if(m_pModel->hasVerticalScrollbar()) + + if ( m_pModel->hasVerticalScrollbar() && ( gridWidth != 0 ) ) { sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); gridWidth-=scrollbarWidth; } + double colWidthsSum = 0.0; double colWithoutFixedWidthsSum = 0.0; double minColWithoutFixedSum = 0.0; + for ( ColPos col = 0; col < colCount; ++col ) { - PColumnModel pColumn = m_pModel->getColumnModel( col ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; + const PColumnModel pColumn = m_pModel->getColumnModel( col ); + ENSURE_OR_CONTINUE( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + TableMetrics colWidth = 0; - TableMetrics colPrefWidth = pColumn->getPreferredWidth(); - bool bResizable = pColumn->isResizable(); - if(pColumn->getMinWidth() == 0 && bResizable) - { - pColumn->setMinWidth(1); - minColWithoutFixedSum+=m_rAntiImpl.PixelToLogic( Size( 1, 0 ), MAP_APPFONT ).Width(); - } - if(pColumn->getMaxWidth() == 0 && bResizable) - pColumn->setMaxWidth(m_rAntiImpl.PixelToLogic( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width()); - if( colPrefWidth != 0) + const TableMetrics colPrefWidth = pColumn->getPreferredWidth(); + const bool bResizable = pColumn->isResizable(); + + if ( colPrefWidth != 0) { - if(m_bResizingGrid) + if ( m_bResizingGrid ) { colWidth = pColumn->getWidth(); pColumn->setPreferredWidth(0); @@ -637,66 +641,88 @@ namespace svt { namespace table else { colWidth = colPrefWidth; - pColumn->setWidth(colPrefWidth); + pColumn->setWidth( colPrefWidth ); } } else colWidth = pColumn->getWidth(); - long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - if(bResizable && colPrefWidth == 0) + + const long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); + if ( bResizable && colPrefWidth == 0 ) { - colWithoutFixedWidthsSum+=pixelWidth; + colWithoutFixedWidthsSum += pixelWidth; lastResizableCol = col; } - colWidthsSum+=pixelWidth; - aPrePixelWidths.push_back(pixelWidth); + colWidthsSum += pixelWidth; + aPrePixelWidths.push_back( pixelWidth ); } + double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; double scalingFactor = 1.0; - if(m_bResizingGrid) + if ( m_bResizingGrid ) { - if(gridWidthWithoutFixed > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum)) - scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; + if ( gridWidthWithoutFixed > ( minColWithoutFixedSum + colWidthsSum - colWithoutFixedWidthsSum ) ) + scalingFactor = gridWidthWithoutFixed / colWithoutFixedWidthsSum; } else { - if(colWidthsSum < gridWidthWithoutFixed) + if ( colWidthsSum < gridWidthWithoutFixed ) { - if(colWithoutFixedWidthsSum>0) - scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum; + if ( colWithoutFixedWidthsSum > 0 ) + scalingFactor = gridWidthWithoutFixed / colWithoutFixedWidthsSum; } } for ( ColPos i = 0; i < colCount; ++i ) { - PColumnModel pColumn = m_pModel->getColumnModel( i ); - DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); - if ( !pColumn ) - continue; - if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0) + const PColumnModel pColumn = m_pModel->getColumnModel( i ); + ENSURE_OR_CONTINUE( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + + if ( pColumn->isResizable() && ( pColumn->getPreferredWidth() == 0 ) ) { - aPrePixelWidths[i]*=scalingFactor; - TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width(); - pColumn->setWidth(logicColWidth); + aPrePixelWidths[i] *= scalingFactor; + const TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width(); + pColumn->setWidth( logicColWidth ); } - m_aColumnWidthsPixel.push_back( aPrePixelWidths[i] ); - m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += aPrePixelWidths[i] ); + + const long columnStart = accumulatedPixelWidth; + const long columnEnd = columnStart + aPrePixelWidths[i]; + m_aColumnWidths.push_back( ColumnWidthInfo( columnStart, columnEnd ) ); + accumulatedPixelWidth = columnEnd; } - if(gridWidth > m_aAccColumnWidthsPixel[colCount-1]) + + // care for the horizontal scroll position (as indicated by m_nLeftColumn) + if ( m_nLeftColumn > 0 ) { - if(lastResizableCol >= 0) + const long offsetPixel = m_aColumnWidths[ 0 ].getStart() - m_aColumnWidths[ m_nLeftColumn ].getStart(); + for ( ColumnPositions::iterator colPos = m_aColumnWidths.begin(); + colPos != m_aColumnWidths.end(); + ++colPos + ) { - PColumnModel pColumn = m_pModel->getColumnModel(lastResizableCol); - m_aColumnWidthsPixel[lastResizableCol]+=gridWidth-m_aAccColumnWidthsPixel[colCount-1]; - TableMetrics logicColWidth1 = m_rAntiImpl.PixelToLogic( Size( m_aColumnWidthsPixel[lastResizableCol], 0 ), MAP_APPFONT ).Width(); - pColumn->setWidth(logicColWidth1); - while(lastResizableCol < colCount) - { - if(lastResizableCol == 0) - m_aAccColumnWidthsPixel[0] = m_aColumnWidthsPixel[lastResizableCol]; - else - m_aAccColumnWidthsPixel[lastResizableCol]=m_aAccColumnWidthsPixel[lastResizableCol-1]+m_aColumnWidthsPixel[lastResizableCol]; - ++lastResizableCol; - } + colPos->move( offsetPixel ); + } + } + + const long freeSpaceRight = gridWidth - m_aColumnWidths[ colCount-1 ].getEnd(); + if ( ( freeSpaceRight > 0 ) + && ( lastResizableCol != COL_INVALID ) + && ( lastResizableCol >= m_nLeftColumn ) + ) + { + // make the last resizable column wider + ColumnWidthInfo& rResizeColInfo( m_aColumnWidths[ lastResizableCol ] ); + rResizeColInfo.setEnd( rResizeColInfo.getEnd() + freeSpaceRight ); + + // update the column model + const TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( rResizeColInfo.getWidth(), 0 ), MAP_APPFONT ).Width(); + const PColumnModel pColumn = m_pModel->getColumnModel( lastResizableCol ); + pColumn->setWidth( logicColWidth ); + + // update all other columns after the resized one + ColPos adjustColumn = lastResizableCol; + while ( ++adjustColumn < colCount ) + { + m_aColumnWidths[ adjustColumn ].move( freeSpaceRight ); } } } @@ -707,8 +733,10 @@ namespace svt { namespace table //................................................................ /// determines whether a scrollbar is needed for the given values bool lcl_determineScrollbarNeed( ScrollbarVisibility _eVisibility, - long _nVisibleUnits, long _nRange ) + long _nVisibleUnits, long _nRange, long const i_nPosition ) { + if ( i_nPosition > 0 ) + return true; if ( _eVisibility == ScrollbarShowNever ) return false; if ( _eVisibility == ScrollbarShowAlways ) @@ -735,7 +763,7 @@ namespace svt { namespace table bool _bHorizontal, const Link& _rScrollHandler ) { // do we need the scrollbar? - bool bNeedBar = lcl_determineScrollbarNeed( _eVisibility, _nVisibleUnits, _nRange ); + bool bNeedBar = lcl_determineScrollbarNeed( _eVisibility, _nVisibleUnits, _nRange, _nPosition ); // do we currently have the scrollbar? bool bHaveBar = _rpBar != NULL; @@ -743,6 +771,8 @@ namespace svt { namespace table // do we need to correct the scrollbar visibility? if ( bHaveBar && !bNeedBar ) { + if ( _rpBar->IsTracking() ) + _rpBar->EndTracking(); DELETEZ( _rpBar ); } else if ( !bHaveBar && bNeedBar ) @@ -822,26 +852,30 @@ namespace svt { namespace table m_nRowCount = m_pModel->getRowCount(); m_nColumnCount = m_pModel->getColumnCount(); - if ( m_aAccColumnWidthsPixel.empty() ) + if ( m_aColumnWidths.empty() ) impl_ni_updateColumnWidths(); - OSL_ENSURE( m_aAccColumnWidthsPixel.size() == m_nColumnCount, "TableControl_Impl::impl_ni_updateScrollbars: inconsistency!" ); - const long nAllColumnsWidth = m_aAccColumnWidthsPixel.empty() ? 0 : m_aAccColumnWidthsPixel[ m_nColumnCount - 1 ]; + OSL_ENSURE( m_aColumnWidths.size() == m_nColumnCount, "TableControl_Impl::impl_ni_updateScrollbars: inconsistency!" ); + const long nAllColumnsWidth = m_aColumnWidths.empty() + ? 0 + : m_aColumnWidths[ m_nColumnCount - 1 ].getEnd() - m_aColumnWidths[ 0 ].getStart(); // do we need a vertical scrollbar? bool bFirstRoundVScrollNeed = false; if ( lcl_determineScrollbarNeed( m_pModel->getVerticalScrollbarVisibility(aDataCellPlayground.GetHeight(), m_nRowHeightPixel*m_nRowCount), lcl_getRowsFittingInto( aDataCellPlayground.GetHeight(), m_nRowHeightPixel ), - m_nRowCount ) ) + m_nRowCount, + m_nTopRow ) ) { aDataCellPlayground.Right() -= nScrollbarMetrics; bFirstRoundVScrollNeed = true; } // do we need a horizontal scrollbar? if ( lcl_determineScrollbarNeed( - m_pModel->getHorizontalScrollbarVisibility(aDataCellPlayground.GetWidth(), nAllColumnsWidth), + m_pModel->getHorizontalScrollbarVisibility( aDataCellPlayground.GetWidth(), nAllColumnsWidth ), lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false ), - m_nColumnCount ) ) + m_nColumnCount, + m_nLeftColumn ) ) { aDataCellPlayground.Bottom() -= nScrollbarMetrics; @@ -852,7 +886,8 @@ namespace svt { namespace table if ( !bFirstRoundVScrollNeed && lcl_determineScrollbarNeed( m_pModel->getVerticalScrollbarVisibility(aDataCellPlayground.GetHeight(),m_nRowHeightPixel*m_nRowCount), lcl_getRowsFittingInto( aDataCellPlayground.GetHeight(), m_nRowHeightPixel ), - m_nRowCount ) ) + m_nRowCount, + m_nTopRow ) ) { aDataCellPlayground.Right() -= nScrollbarMetrics; } @@ -901,7 +936,7 @@ namespace svt { namespace table int nRange = m_nColumnCount; if( m_nLeftColumn + nVisibleUnits == nRange-1) { - if(m_aAccColumnWidthsPixel[nRange-2] - m_aAccColumnWidthsPixel[m_nLeftColumn] + m_aColumnWidthsPixel[nRange-1]>aDataCellPlayground.GetWidth()) + if ( m_aColumnWidths[ nRange-2 ].getEnd() - m_aColumnWidths[ m_nLeftColumn ].getEnd() + m_aColumnWidths[ nRange-1 ].getWidth() > aDataCellPlayground.GetWidth() ) { m_pHScroll->SetVisibleSize( nVisibleUnits -1 ); m_pHScroll->SetPageSize(nVisibleUnits -1); @@ -946,11 +981,11 @@ namespace svt { namespace table void TableControl_Impl::onResize() { DBG_CHECK_ME(); - if(m_nRowCount != 0) + if ( m_nRowCount != 0 ) { - if(m_nColumnCount != 0) + if ( m_nColumnCount != 0 ) { - if(m_bResizingGrid) + if ( m_bResizingGrid ) impl_ni_updateColumnWidths(); invalidateRows(); m_bResizingGrid = true; @@ -960,13 +995,13 @@ namespace svt { namespace table { //In the case that column headers are defined but data hasn't yet been set, //only column headers will be shown - if(m_pModel->hasColumnHeaders()) + if ( m_pModel->hasColumnHeaders() ) { - if(m_nColHeaderHeightPixel>1) + if ( m_nColHeaderHeightPixel > 1 ) { - m_pDataWindow->SetSizePixel( m_rAntiImpl.GetOutputSizePixel()); - if(m_bResizingGrid) - //update column widths to fit in grid + m_pDataWindow->SetSizePixel( m_rAntiImpl.GetOutputSizePixel() ); + if ( m_bResizingGrid ) + //update column widths to fit in grid impl_ni_updateColumnWidths(); m_bResizingGrid = true; } @@ -1006,8 +1041,8 @@ namespace svt { namespace table TableRowGeometry aHeaderRow( *this, Rectangle( Point( 0, 0 ), aAllCellsWithHeaders.BottomRight() ), ROW_COL_HEADERS ); Rectangle aColRect(aHeaderRow.getRect()); - //to avoid double lines when scrolling horizontally - if(m_nLeftColumn != 0) + // to avoid double lines when scrolling horizontally + if ( m_nLeftColumn != 0 ) --aColRect.Left(); pRenderer->PaintHeaderArea( *m_pDataWindow, aColRect, true, false, rStyle @@ -1094,19 +1129,21 @@ namespace svt { namespace table } } Rectangle aRect = aRowIterator.getRect().GetIntersection( aAllDataCellsArea ); - //to avoid double lines - if( aRowIterator.getRow() != 0 ) + // to avoid double lines + if ( aRowIterator.getRow() != 0 ) --aRect.Top(); - if(m_nLeftColumn != 0) + if ( m_nLeftColumn != 0 ) --aRect.Left(); else { - if(m_pModel->hasRowHeaders()) + if ( m_pModel->hasRowHeaders( )) --aRect.Left(); } // give the redenderer a chance to prepare the row - pRenderer->PrepareRow( aRowIterator.getRow(), isActiveRow, isSelectedRow, - *m_pDataWindow, aRect, rStyle ); + pRenderer->PrepareRow( + aRowIterator.getRow(), isActiveRow, isSelectedRow, + *m_pDataWindow, aRect, rStyle + ); // paint the row header if ( m_pModel->hasRowHeaders() ) @@ -1580,55 +1617,64 @@ namespace svt { namespace table _rCellRect.Top()--;_rCellRect.Left()--; } //------------------------------------------------------------------------------- - RowPos TableControl_Impl::getCurrentRow(const Point& rPoint) + RowPos TableControl_Impl::getRowAtPoint( const Point& rPoint ) { DBG_CHECK_ME(); - Rectangle rCellRect; - RowPos newRowPos = -2;//-1 is HeaderRow - ColPos newColPos = 0; - for(int i=-1;i= 0 ) && ( rPoint.Y() < m_nColHeaderHeightPixel ) ) + return ROW_COL_HEADERS; + + Rectangle aAllCellsArea; + impl_getAllVisibleCellsArea( aAllCellsArea ); + + TableRowGeometry aHitTest( *this, aAllCellsArea, ROW_COL_HEADERS ); + while ( aHitTest.isValid() ) { - for(int j=-1;j= rCellRect.Left() && rPoint.X() <= rCellRect.Right()) && rPoint.Y() >= rCellRect.Top() && rPoint.Y() <= rCellRect.Bottom()) - { - newRowPos = i; - newColPos = j; - if(newColPos != -1) - m_nCurColumn = newColPos; - return newRowPos; - } - } + if ( aHitTest.getRect().IsInside( rPoint ) ) + return aHitTest.getRow(); + aHitTest.moveDown(); } - return newRowPos; + return ROW_INVALID; } + //------------------------------------------------------------------------------- - void TableControl_Impl::setCursorAtCurrentCell(const Point& rPoint) + ColPos TableControl_Impl::getColAtPoint( const Point& rPoint ) { DBG_CHECK_ME(); - hideCursor(); - Rectangle rCellRect; - RowPos newRowPos = -2;//-1 is HeaderRow - ColPos newColPos = 0; - for(int i=0;i= 0 ) && ( rPoint.X() < m_nRowHeaderWidthPixel ) ) + return COL_ROW_HEADERS; + + Rectangle aAllCellsArea; + impl_getAllVisibleCellsArea( aAllCellsArea ); + + TableColumnGeometry aHitTest( *this, aAllCellsArea, COL_ROW_HEADERS ); + while ( aHitTest.isValid() ) { - for(int j=-1;j= rCellRect.Left() && rPoint.X() <= rCellRect.Right()) && rPoint.Y() >= rCellRect.Top() && rPoint.Y() <= rCellRect.Bottom()) - { - newRowPos = i; - m_nCurRow = newRowPos; - newColPos = j; - if(newColPos == -1) - m_nCurColumn = 0; - else - m_nCurColumn = newColPos; - } - } + if ( aHitTest.getRect().IsInside( rPoint ) ) + return aHitTest.getCol(); + aHitTest.moveRight(); + } + + return COL_INVALID; + } + + //------------------------------------------------------------------------------- + void TableControl_Impl::activateCellAt(const Point& rPoint) + { + DBG_CHECK_ME(); + + TempHideCursor aHideCursor( *this ); + + const RowPos newRowPos = getRowAtPoint( rPoint ); + const ColPos newColPos = getColAtPoint( rPoint ); + + if ( ( newRowPos != ROW_INVALID ) && ( newColPos != COL_INVALID ) ) + { + m_nCurColumn = newColPos; + m_nCurRow = newRowPos; + ensureVisible( m_nCurColumn, m_nCurRow, true ); } - showCursor(); } //------------------------------------------------------------------------------- void TableControl_Impl::invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect) @@ -1639,29 +1685,31 @@ namespace svt { namespace table impl_getAllVisibleCellsArea( aAllCells ); _rCellRect.Left() = aAllCells.Left(); _rCellRect.Right() = aAllCells.Right(); - Rectangle rCells; //if only one row is selected if(_nPrevRow == _nCurRow) { - impl_getCellRect(m_nCurColumn,_nCurRow,rCells); - _rCellRect.Top()=--rCells.Top(); - _rCellRect.Bottom()=rCells.Bottom(); + Rectangle aCellRect; + impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect ); + _rCellRect.Top() = --aCellRect.Top(); + _rCellRect.Bottom() = aCellRect.Bottom(); } //if the region is above the current row else if(_nPrevRow < _nCurRow ) { - impl_getCellRect(m_nCurColumn,_nPrevRow,rCells); - _rCellRect.Top()= --rCells.Top(); - impl_getCellRect(m_nCurColumn,_nCurRow,rCells); - _rCellRect.Bottom()=rCells.Bottom(); + Rectangle aCellRect; + impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect ); + _rCellRect.Top() = --aCellRect.Top(); + impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect ); + _rCellRect.Bottom() = aCellRect.Bottom(); } //if the region is beneath the current row else { - impl_getCellRect(m_nCurColumn,_nCurRow,rCells); - _rCellRect.Top()= --rCells.Top(); - impl_getCellRect(m_nCurColumn,_nPrevRow,rCells); - _rCellRect.Bottom()=rCells.Bottom(); + Rectangle aCellRect; + impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect ); + _rCellRect.Top() = --aCellRect.Top(); + impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect ); + _rCellRect.Bottom() = aCellRect.Bottom(); } m_pDataWindow->Invalidate(_rCellRect); } @@ -1722,14 +1770,28 @@ namespace svt { namespace table impl_ni_updateScrollbars(); TableSize nVisibleRows = impl_getVisibleRows(true); TableSize nVisibleCols = impl_getVisibleColumns(true); - if(m_nTopRow+nVisibleRows>m_nRowCount && m_nRowCount>=nVisibleRows) - m_nTopRow--; + if ( ( m_nTopRow + nVisibleRows > m_nRowCount ) + && ( m_nRowCount >= nVisibleRows ) + ) + { + --m_nTopRow; + } else + { m_nTopRow = 0; - if(m_nLeftColumn+nVisibleCols>m_nColumnCount && m_nColumnCount>=nVisibleCols) - m_nLeftColumn--; + } + + if ( ( m_nLeftColumn + nVisibleCols > m_nColumnCount ) + && ( m_nColumnCount >= nVisibleCols ) + ) + { + --m_nLeftColumn; + } else + { m_nLeftColumn = 0; + } + m_pDataWindow->Invalidate(); } @@ -1794,25 +1856,25 @@ namespace svt { namespace table TempHideCursor aHideCursor( *this ); if ( _nColumn < m_nLeftColumn ) - impl_ni_ScrollColumns( _nColumn - m_nLeftColumn ); + impl_scrollColumns( _nColumn - m_nLeftColumn ); else { TableSize nVisibleColumns = impl_getVisibleColumns( _bAcceptPartialVisibility ); if ( _nColumn > m_nLeftColumn + nVisibleColumns - 1 ) { - impl_ni_ScrollColumns( _nColumn - ( m_nLeftColumn + nVisibleColumns - 1 ) ); + impl_scrollColumns( _nColumn - ( m_nLeftColumn + nVisibleColumns - 1 ) ); // TODO: since not all columns have the same width, this might in theory result // in the column still not being visible. } } if ( _nRow < m_nTopRow ) - impl_ni_ScrollRows( _nRow - m_nTopRow ); + impl_scrollRows( _nRow - m_nTopRow ); else { TableSize nVisibleRows = impl_getVisibleRows( _bAcceptPartialVisibility ); if ( _nRow > m_nTopRow + nVisibleRows - 1 ) - impl_ni_ScrollRows( _nRow - ( m_nTopRow + nVisibleRows - 1 ) ); + impl_scrollRows( _nRow - ( m_nTopRow + nVisibleRows - 1 ) ); } } @@ -1830,7 +1892,7 @@ namespace svt { namespace table m_nTopRow = nNewTopRow; // if updates are enabled currently, scroll the viewport - if ( m_rAntiImpl.IsUpdateMode() && ( m_nTopRow != nOldTopRow ) ) + if ( m_nTopRow != nOldTopRow ) { DBG_SUSPEND_INV( INV_SCROLL_POSITION ); TempHideCursor aHideCursor( *this ); @@ -1856,24 +1918,37 @@ namespace svt { namespace table m_pVScroll->SetThumbPos( m_nTopRow ); } + // The scroll bar availaility might change when we scrolled. This is because we do not hide + // the scrollbar when it is, in theory, unnecessary, but currently at a position > 0. In this case, it will + // be auto-hidden when it's scrolled back to pos 0. + if ( m_nTopRow == 0 ) + m_rAntiImpl.PostUserEvent( LINK( this, TableControl_Impl, OnUpdateScrollbars ) ); + return (TableSize)( m_nTopRow - nOldTopRow ); } + //-------------------------------------------------------------------- + TableSize TableControl_Impl::impl_scrollRows( TableSize const i_rowDelta ) + { + DBG_CHECK_ME(); + return impl_ni_ScrollRows( i_rowDelta ); + } + //-------------------------------------------------------------------- TableSize TableControl_Impl::impl_ni_ScrollColumns( TableSize _nColumnDelta ) { // compute new left column - ColPos nNewLeftColumn = + const ColPos nNewLeftColumn = ::std::max( ::std::min( (ColPos)( m_nLeftColumn + _nColumnDelta ), (ColPos)( m_nColumnCount - 1 ) ), (ColPos)0 ); - ColPos nOldLeftColumn = m_nLeftColumn; + const ColPos nOldLeftColumn = m_nLeftColumn; m_nLeftColumn = nNewLeftColumn; // if updates are enabled currently, scroll the viewport - if ( m_rAntiImpl.IsUpdateMode() && ( m_nLeftColumn != nOldLeftColumn ) ) + if ( m_nLeftColumn != nOldLeftColumn ) { DBG_SUSPEND_INV( INV_SCROLL_POSITION ); TempHideCursor aHideCursor( *this ); @@ -1882,17 +1957,29 @@ namespace svt { namespace table // Same for onEndScroll // scroll the view port, if possible - Rectangle aDataArea( Point( m_nRowHeaderWidthPixel, 0 ), m_pDataWindow->GetOutputSizePixel() ); + const Rectangle aDataArea( Point( m_nRowHeaderWidthPixel, 0 ), m_pDataWindow->GetOutputSizePixel() ); long nPixelDelta = - ( m_nLeftColumn > 0 ? m_aAccColumnWidthsPixel[ m_nLeftColumn - 1 ] : 0 ) - - ( nOldLeftColumn > 0 ? m_aAccColumnWidthsPixel[ nOldLeftColumn - 1 ] : 0 ); + m_aColumnWidths[ nOldLeftColumn ].getStart() + - m_aColumnWidths[ m_nLeftColumn ].getStart(); + + // update our column positions + // Do this *before* scrolling, as SCROLL_UPDATE will trigger a paint, which already needs the correct + // information in m_aColumnWidths + for ( ColumnPositions::iterator colPos = m_aColumnWidths.begin(); + colPos != m_aColumnWidths.end(); + ++colPos + ) + { + colPos->move( nPixelDelta ); + } + // scroll the window content (if supported and possible), or invalidate the complete window if ( m_pDataWindow->GetBackground().IsScrollable() && abs( nPixelDelta ) < aDataArea.GetWidth() ) { - m_pDataWindow->Scroll( (long)-nPixelDelta, 0, aDataArea, SCROLL_CLIP | SCROLL_UPDATE ); + m_pDataWindow->Scroll( nPixelDelta, 0, aDataArea, SCROLL_CLIP | SCROLL_UPDATE ); } else m_pDataWindow->Invalidate( INVALIDATE_UPDATE ); @@ -1901,8 +1988,22 @@ namespace svt { namespace table m_pHScroll->SetThumbPos( m_nLeftColumn ); } + // The scroll bar availaility might change when we scrolled. This is because we do not hide + // the scrollbar when it is, in theory, unnecessary, but currently at a position > 0. In this case, it will + // be auto-hidden when it's scrolled back to pos 0. + if ( m_nLeftColumn == 0 ) + m_rAntiImpl.PostUserEvent( LINK( this, TableControl_Impl, OnUpdateScrollbars ) ); + return (TableSize)( m_nLeftColumn - nOldLeftColumn ); } + + //------------------------------------------------------------------------------- + TableSize TableControl_Impl::impl_scrollColumns( TableSize const i_columnDelta ) + { + DBG_CHECK_ME(); + return impl_ni_ScrollColumns( i_columnDelta ); + } + //------------------------------------------------------------------------------- SelectionEngine* TableControl_Impl::getSelEngine() { @@ -1952,12 +2053,13 @@ namespace svt { namespace table ::rtl::OUString& TableControl_Impl::setTooltip(const Point& rPoint ) { ::rtl::OUString aTooltipText; - RowPos current = getCurrentRow(rPoint); + const RowPos hitRow = getRowAtPoint( rPoint ); + const ColPos hitCol = getColAtPoint( rPoint ); com::sun::star::uno::Sequence< sal_Int32 > cols = m_rAntiImpl.getColumnsForTooltip(); com::sun::star::uno::Sequence< ::rtl::OUString > text = m_rAntiImpl.getTextForTooltip(); if(text.getLength()==0 && cols.getLength()==0) { - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][m_nCurColumn]; + ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][hitCol]; aTooltipText = convertToString(content); } else if(text.getLength() == 0) @@ -1966,13 +2068,13 @@ namespace svt { namespace table { if(i==0) { - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; + ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][cols[i]]; aTooltipText = convertToString(content); } else { aTooltipText+= ::rtl::OUString::createFromAscii("\n"); - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; + ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][cols[i]]; aTooltipText += convertToString(content); } } @@ -2002,7 +2104,7 @@ namespace svt { namespace table { if(i==0) { - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; + ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][cols[i]]; aTooltipText = text[i] + convertToString(content); } else @@ -2011,7 +2113,7 @@ namespace svt { namespace table aTooltipText+= text[i]; if(nCols > i) { - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]]; + ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][cols[i]]; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; aTooltipText += convertToString(content); } @@ -2020,168 +2122,196 @@ namespace svt { namespace table } return m_aTooltipText = aTooltipText; } + + //-------------------------------------------------------------------- + ColPos TableControl_Impl::impl_getColumnForOrdinate( long const i_ordinate ) const + { + DBG_CHECK_ME(); + + if ( m_aColumnWidths.empty() ) + return COL_INVALID; + + ColumnPositions::const_iterator lowerBound = ::std::lower_bound( + m_aColumnWidths.begin(), + m_aColumnWidths.end(), + i_ordinate + 1, + ColumnInfoPositionLess() + ); + if ( lowerBound == m_aColumnWidths.end() ) + { + // point is *behind* the start of the last column ... + if ( i_ordinate < m_aColumnWidths.rbegin()->getEnd() ) + // ... but still before its end + return m_nColumnCount - 1; + return COL_INVALID; + } + return lowerBound - m_aColumnWidths.begin(); + } + //-------------------------------------------------------------------- - void TableControl_Impl::resizeColumn(const Point& rPoint) - { - Pointer aNewPointer(POINTER_ARROW); - int headerRowWidth = 0; - if(m_pModel->hasRowHeaders()) - headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); - int resizingColumn=m_nCurColumn-m_nLeftColumn; - PColumnModel pColumn = m_pModel->getColumnModel(m_nCurColumn); - impl_ni_getAccVisibleColWidths(); - int newColWidth = m_aColumnWidthsPixel[m_nCurColumn]; - //make resize area for the separator wider - int nLeft = m_aVisibleColumnWidthsPixel[resizingColumn]-4; - //subtract 1 from m_aAccColumnWidthPixel because right border should be part of the current cell - int nRight = m_aVisibleColumnWidthsPixel[resizingColumn]-1; - if( rPoint.X()> nLeft && rPoint.X()isResizable()) - aNewPointer = Pointer( POINTER_HSPLIT ); - //MouseButton was pressed but not yet released, mouse is moving - if(m_bResizing) - { - if(rPoint.X() > m_pDataWindow->GetOutputSizePixel().Width() || rPoint.X() < m_aVisibleColumnWidthsPixel[resizingColumn]-newColWidth) - aNewPointer = Pointer( POINTER_NOTALLOWED); + void TableControl_Impl::resizeColumn( const Point& rPoint ) + { + Pointer aNewPointer( POINTER_ARROW ); + const ColPos hitColumn = impl_getColumnForOrdinate( rPoint.X() ); + if ( m_bResizingColumn ) + { + const ColumnWidthInfo& rColInfo( m_aColumnWidths[ m_nResizingColumn ] ); + if ( ( rPoint.X() > m_pDataWindow->GetOutputSizePixel().Width() ) + || ( rPoint.X() < rColInfo.getStart() ) + ) + { + aNewPointer = Pointer( POINTER_NOTALLOWED ); + } else + { aNewPointer = Pointer( POINTER_HSPLIT ); + } m_pDataWindow->HideTracking(); - int lineHeight = 0; - if(m_pModel->hasColumnHeaders()) - lineHeight+= m_nColHeaderHeightPixel; - lineHeight+=m_nRowHeightPixel*m_nRowCount; - int gridHeight = m_pDataWindow->GetOutputSizePixel().Height(); - if(lineHeight >= gridHeight) + + int lineHeight = m_nColHeaderHeightPixel; + lineHeight += m_nRowHeightPixel * m_nRowCount; + const int gridHeight = m_pDataWindow->GetOutputSizePixel().Height(); + if ( lineHeight >= gridHeight ) lineHeight = gridHeight; - m_pDataWindow->ShowTracking(Rectangle(Point(rPoint.X(),0), Size(1, lineHeight )), - SHOWTRACK_SPLIT | SHOWTRACK_WINDOW); + + m_pDataWindow->ShowTracking( + Rectangle( + Point( rPoint.X(), 0 ), + Size( 1, lineHeight ) + ), + SHOWTRACK_SPLIT | SHOWTRACK_WINDOW + ); } - m_pDataWindow->SetPointer(aNewPointer); + else if ( hitColumn != COL_INVALID ) + { + // hit test for the column separator + const PColumnModel pColumn = m_pModel->getColumnModel( hitColumn ); + const ColumnWidthInfo& rColInfo( m_aColumnWidths[ hitColumn ] ); + if ( ( rColInfo.getEnd() - 2 <= rPoint.X() ) + && ( rColInfo.getEnd() + 2 > rPoint.X() ) + && pColumn->isResizable() + ) + aNewPointer = Pointer( POINTER_HSPLIT ); + } + + m_pDataWindow->SetPointer( aNewPointer ); } + //-------------------------------------------------------------------- - bool TableControl_Impl::startResizeColumn(const Point& rPoint) + bool TableControl_Impl::checkResizeColumn( const Point& rPoint ) { m_bResizingGrid = false; - m_nResizingColumn = m_nCurColumn; - PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn); - //make resize area for the separator wider - int nLeft = m_aVisibleColumnWidthsPixel[m_nResizingColumn-m_nLeftColumn]-4; - int nRight = m_aVisibleColumnWidthsPixel[m_nResizingColumn-m_nLeftColumn]-1; - if(rPoint.X()> nLeft && rPoint.X()isResizable()) + + if ( m_bResizingColumn ) + return true; + + const ColPos hitColumn = impl_getColumnForOrdinate( rPoint.X() ); + if ( hitColumn == COL_INVALID ) + return false; + + const PColumnModel pColumn = m_pModel->getColumnModel( hitColumn ); + const ColumnWidthInfo& rColInfo( m_aColumnWidths[ hitColumn ] ); + + // hit test for the column separator + if ( ( rColInfo.getEnd() - 2 <= rPoint.X() ) + && ( rColInfo.getEnd() + 2 > rPoint.X() ) + && pColumn->isResizable() + ) { + m_nResizingColumn = hitColumn; m_pDataWindow->CaptureMouse(); - m_bResizing = true; + m_bResizingColumn = true; } - return m_bResizing; + return m_bResizingColumn; } //-------------------------------------------------------------------- - bool TableControl_Impl::endResizeColumn(const Point& rPoint) + bool TableControl_Impl::endResizeColumn( const Point& rPoint ) { - if(m_bResizing) + DBG_CHECK_ME(); + ENSURE_OR_RETURN_FALSE( m_bResizingColumn, "TableControl_Impl::endResizeColumn: not resizing currently!" ); + + m_pDataWindow->HideTracking(); + const PColumnModel pColumn = m_pModel->getColumnModel( m_nResizingColumn ); + const long maxWidthLogical = pColumn->getMaxWidth(); + const long minWidthLogical = pColumn->getMinWidth(); + + // new position of mouse + const long requestedEnd = rPoint.X(); + + // old position of right border + const long oldEnd = m_aColumnWidths[ m_nResizingColumn ].getEnd(); + + // position of left border if cursor in the to-be-resized column + const long columnStart = m_aColumnWidths[ m_nResizingColumn ].getStart(); + const long requestedWidth = requestedEnd - columnStart; + // TODO: this is not correct, strictly: It assumes that the mouse was pressed exactly on the "end" pos, + // but for a while now, we have relaxed this, and allow clicking a few pixels aside, too + + if ( requestedEnd >= columnStart ) { - m_pDataWindow->HideTracking(); - PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn); - int maxWidth = m_rAntiImpl.LogicToPixel( Size( pColumn->getMaxWidth(), 0 ), MAP_APPFONT ).Width(); - int minWidth = m_rAntiImpl.LogicToPixel( Size( pColumn->getMinWidth(), 0 ), MAP_APPFONT ).Width(); - int resizeCol = m_nResizingColumn-m_nLeftColumn; - //new position of mouse - int actX = rPoint.X(); - //old position of right border - int oldX = m_aVisibleColumnWidthsPixel[resizeCol]; - //position of left border if cursor in the first cell - int leftX = 0; - if(m_nResizingColumn > m_nLeftColumn) - leftX = m_aVisibleColumnWidthsPixel[resizeCol-1]; - else if(m_nResizingColumn == m_nLeftColumn && m_pModel->hasRowHeaders()) - leftX = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); - int actWidth = actX - leftX; - int newActWidth = 0; - //minimize the column width - if(oldX > actX && actX >= leftX) + long requestedWidthLogical = m_rAntiImpl.PixelToLogic( Size( requestedWidth, 0 ), MAP_APPFONT ).Width(); + // respect column width limits + if ( oldEnd > requestedEnd ) { - if(minWidth < actWidth) - { - newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width(); - pColumn->setPreferredWidth(newActWidth); - } - else - pColumn->setPreferredWidth(pColumn->getMinWidth()); - if(m_nLeftColumn != 0) - impl_updateLeftColumn(); - } - else if(oldX < actX) - { - if(actWidth < maxWidth) + // column has become smaller, check against minimum width + if ( ( minWidthLogical != 0 ) && ( requestedWidthLogical < minWidthLogical ) ) + requestedWidthLogical = minWidthLogical; + + // impl_updateLeftColumn(); + // does this make sense here? We didn't call impl_ni_updateColumnWidths, yet, so m_aColumnWidths + // still contains the old values + } + else if ( oldEnd < requestedEnd ) { - newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width(); - pColumn->setPreferredWidth(newActWidth); + // column has become larger, check against max width + if ( ( maxWidthLogical != 0 ) && ( requestedWidthLogical >= maxWidthLogical ) ) + requestedWidthLogical = maxWidthLogical; } - else - pColumn->setPreferredWidth(pColumn->getMaxWidth()); + pColumn->setPreferredWidth( requestedWidthLogical ); } - m_nCurColumn = m_nResizingColumn; + impl_ni_updateColumnWidths(); impl_ni_updateScrollbars(); - m_pDataWindow->Invalidate(INVALIDATE_UPDATE); - m_pDataWindow->SetPointer(Pointer()); - m_bResizing = false; + m_pDataWindow->Invalidate( INVALIDATE_UPDATE ); + m_pDataWindow->SetPointer( Pointer() ); + m_bResizingColumn = false; m_bResizingGrid = true; + + m_pDataWindow->ReleaseMouse(); + return m_bResizingColumn; } - m_pDataWindow->ReleaseMouse(); - return m_bResizing; - } + //------------------------------------------------------------------------------- - void TableControl_Impl::impl_ni_getAccVisibleColWidths() + void TableControl_Impl::impl_updateLeftColumn() { - TableSize nVisCols = impl_getVisibleColumns(true); - int widthsPixel = 0; - m_aVisibleColumnWidthsPixel.resize(0); - m_aVisibleColumnWidthsPixel.reserve(nVisCols); - int headerRowWidth = 0; - if(m_pModel->hasRowHeaders()) - { - headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); - widthsPixel+=headerRowWidth; - } - int col = m_nLeftColumn; - while(nVisCols) + DBG_CHECK_ME(); + if ( m_nLeftColumn == 0 ) + return; + + // the right end of the last column + const long lastColumnEnd = m_aColumnWidths[ m_nColumnCount - 1 ].getEnd(); + + // free space at the right of the last column + const long freeSpace = m_pDataWindow->GetOutputSizePixel().Width() - lastColumnEnd; + + // if the columnd left of the currently-left-most column would fit into the free + // space, then implicitly scroll + const long leftNeighbourWidth = m_aColumnWidths[ m_nLeftColumn - 1 ].getWidth(); + if ( leftNeighbourWidth < freeSpace ) { - m_aVisibleColumnWidthsPixel.push_back(widthsPixel+=m_aColumnWidthsPixel[col]); - col++; - nVisCols--; + for ( ColumnPositions::iterator colPos = m_aColumnWidths.begin(); + colPos != m_aColumnWidths.end(); + ++colPos + ) + { + colPos->move( leftNeighbourWidth ); + } + + --m_nLeftColumn; + // TODO: wouldn't this require updating the scrollbar? } - } - //------------------------------------------------------------------------------- - void TableControl_Impl::impl_updateLeftColumn() - { - int nVisCols = m_aVisibleColumnWidthsPixel.size(); - int headerRowWidth = 0; - //sum of currently visible columns - int widthsPixel = 0; - //header pixel should be added, because header doesn't vanish when scrolling - if(m_pModel->hasRowHeaders()) - { - headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width(); - widthsPixel+=headerRowWidth; - } - int col = m_nLeftColumn; - //add column width of the neighbour of the left column - widthsPixel+=m_aColumnWidthsPixel[col-1]; - //compute the sum of the new column widths - while(nVisCols) - { - PColumnModel pColumn = m_pModel->getColumnModel(col); - int colWidth = pColumn->getWidth(); - int colPrefWidth = pColumn->getPreferredWidth(); - if(colPrefWidth!=0) - colWidth = colPrefWidth; - widthsPixel += m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - col++; - nVisCols--; - } - //when the sum of all visible columns and the next to the left column is smaller than - //window width, then update m_nLeftColumn - if(widthsPixelGetOutputSizePixel().Width()) - m_nLeftColumn--; + + // TODO: isnt' it that this might be done repeatedly? } //-------------------------------------------------------------------- rtl::OUString TableControl_Impl::convertToString(const ::com::sun::star::uno::Any& value) @@ -2220,6 +2350,14 @@ namespace svt { namespace table return aRect; } + //-------------------------------------------------------------------- + IMPL_LINK( TableControl_Impl, OnUpdateScrollbars, void*, /**/ ) + { + DBG_CHECK_ME(); + impl_ni_updateScrollbars(); + return 1L; + } + //-------------------------------------------------------------------- IMPL_LINK( TableControl_Impl, OnScroll, ScrollBar*, _pScrollbar ) { @@ -2261,26 +2399,27 @@ namespace svt { namespace table BOOL TableFunctionSet::SetCursorAtPoint(const Point& rPoint, BOOL bDontSelectAtCursor) { BOOL bHandled = FALSE; - Rectangle rCells; - //curRow is the row where the mouse click happened, m_nCurRow is the last selected row, before the mouse click - RowPos curRow = m_pTableControl->getCurrentRow(rPoint); - if(curRow == -2) + // newRow is the row which includes the point, m_nCurRow is the last selected row, before the mouse click + const RowPos newRow = m_pTableControl->getRowAtPoint( rPoint ); + const ColPos newCol = m_pTableControl->getColAtPoint( rPoint ); + if ( ( newRow == ROW_INVALID ) || ( newCol == COL_INVALID ) ) return FALSE; - if( bDontSelectAtCursor ) + + if ( bDontSelectAtCursor ) { - if(m_pTableControl->m_nRowSelected.size()>1) + if ( m_pTableControl->m_nRowSelected.size()>1 ) m_pTableControl->m_pSelEngine->AddAlways(TRUE); bHandled = TRUE; } - else if(m_pTableControl->m_nAnchor == m_pTableControl->m_nCurRow) + else if ( m_pTableControl->m_nAnchor == m_pTableControl->m_nCurRow ) { //selecting region, - int diff = m_pTableControl->m_nCurRow - curRow; + int diff = m_pTableControl->m_nCurRow - newRow; //selected region lies above the last selection if( diff >= 0) { //put selected rows in vector - while(m_pTableControl->m_nAnchor>=curRow) + while ( m_pTableControl->m_nAnchor >= newRow ) { bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, m_pTableControl->m_nAnchor); //if row isn't selected, put it in vector, otherwise don't put it there, because it will be twice there @@ -2294,7 +2433,7 @@ namespace svt { namespace table //selected region lies beneath the last selected row else { - while(m_pTableControl->m_nAnchor<=curRow) + while ( m_pTableControl->m_nAnchor <= newRow ) { bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, m_pTableControl->m_nAnchor); if(!isAlreadySelected) @@ -2304,35 +2443,39 @@ namespace svt { namespace table } m_pTableControl->m_nAnchor--; } - m_pTableControl->invalidateSelectedRegion(m_pTableControl->m_nCurRow, curRow, rCells); + Rectangle aCellRect; + m_pTableControl->invalidateSelectedRegion( m_pTableControl->m_nCurRow, newRow, aCellRect ); bHandled = TRUE; } //no region selected else { if(m_pTableControl->m_nRowSelected.empty()) - m_pTableControl->m_nRowSelected.push_back(curRow); + m_pTableControl->m_nRowSelected.push_back( newRow ); else { if(m_pTableControl->m_pSelEngine->GetSelectionMode()==SINGLE_SELECTION) { DeselectAll(); - m_pTableControl->m_nRowSelected.push_back(curRow); + m_pTableControl->m_nRowSelected.push_back( newRow ); } else { - bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, curRow); - if(!isAlreadySelected) - m_pTableControl->m_nRowSelected.push_back(curRow); + bool isAlreadySelected = m_pTableControl->isRowSelected( m_pTableControl->m_nRowSelected, newRow ); + if ( !isAlreadySelected ) + m_pTableControl->m_nRowSelected.push_back( newRow ); } } if(m_pTableControl->m_nRowSelected.size()>1 && m_pTableControl->m_pSelEngine->GetSelectionMode()!=SINGLE_SELECTION) m_pTableControl->m_pSelEngine->AddAlways(TRUE); - m_pTableControl->invalidateSelectedRegion(curRow, curRow, rCells); + + Rectangle aCellRect; + m_pTableControl->invalidateSelectedRegion( newRow, newRow, aCellRect ); bHandled = TRUE; } - m_pTableControl->m_nCurRow = curRow; - m_pTableControl->ensureVisible(m_pTableControl->m_nCurColumn,m_pTableControl->m_nCurRow,false); + m_pTableControl->m_nCurRow = newRow; + m_pTableControl->m_nCurColumn = newCol; + m_pTableControl->ensureVisible( newCol, newRow, true ); return bHandled; } //------------------------------------------------------------------------------- @@ -2343,7 +2486,7 @@ namespace svt { namespace table return FALSE; else { - RowPos curRow = m_pTableControl->getCurrentRow(rPoint); + RowPos curRow = m_pTableControl->getRowAtPoint( rPoint ); m_pTableControl->m_nAnchor = -1; bool selected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, curRow); m_nCurrentRow = curRow; diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index b456cf248bed..91a57752fca2 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -43,7 +43,53 @@ namespace svt { namespace table { //........................................................................ - typedef ::std::vector< long > ArrayOfLong; + struct ColumnWidthInfo + { + ColumnWidthInfo() + :nStartPixel( 0 ) + ,nEndPixel( 0 ) + { + } + + ColumnWidthInfo( long const i_startPixel, long const i_endPixel ) + :nStartPixel( i_startPixel ) + ,nEndPixel( i_endPixel ) + { + } + + long getStart() const { return nStartPixel; } + long getEnd() const { return nEndPixel; } + + void setEnd( long const i_end ) { nEndPixel = i_end; } + void move( long const i_offset ) { nStartPixel += i_offset; nEndPixel += i_offset; } + + long getWidth() const { return nEndPixel - nStartPixel; } + + private: + /** the start of the column, in pixels. Might be negative, in case the column is scrolled out of the visible + area. + */ + long nStartPixel; + + /** the end of the column, in pixels, plus 1. Effectively, this is the accumulated width of a all columns + up to the current one. + */ + long nEndPixel; + }; + + struct ColumnInfoPositionLess + { + bool operator()( ColumnWidthInfo const& i_colInfo, long const i_position ) + { + return i_colInfo.getEnd() < i_position; + } + bool operator()( long const i_position, ColumnWidthInfo const& i_colInfo ) + { + return i_position < i_colInfo.getStart(); + } + }; + + typedef ::std::vector< ColumnWidthInfo > ColumnPositions; class TableControl; class TableDataWindow; @@ -59,7 +105,8 @@ namespace svt { namespace table friend class TableRowGeometry; friend class TableColumnGeometry; friend class SuspendInvariants; - friend class TableFunctionSet; + friend class TableFunctionSet; + private: /// the control whose impl-instance we implemnt TableControl& m_rAntiImpl; @@ -67,14 +114,9 @@ namespace svt { namespace table PTableModel m_pModel; /// the input handler to use, usually the input handler as provided by ->m_pModel PTableInputHandler m_pInputHandler; - /// the widths of the single columns, measured in pixel - ArrayOfLong m_aColumnWidthsPixel; - /** the accumulated widths of the single columns, i.e. their exclusive right borders, - counting the space for a possible row header column - */ - ArrayOfLong m_aAccColumnWidthsPixel; + /// info about the widths of our columns + ColumnPositions m_aColumnWidths; - ArrayOfLong m_aVisibleColumnWidthsPixel; /// the height of a single row in the table, measured in pixels long m_nRowHeightPixel; /// the height of the column header row in the table, measured in pixels @@ -103,7 +145,7 @@ namespace svt { namespace table /// the vertical scrollbar, if any ScrollBar* m_pVScroll; /// the horizontal scrollbar, if any - ScrollBar* m_pHScroll; + ScrollBar* m_pHScroll; ScrollBarBox* m_pScrollCorner; //selection engine - for determining selection range, e.g. single, multiple SelectionEngine* m_pSelEngine; @@ -112,11 +154,11 @@ namespace svt { namespace table //part of selection engine TableFunctionSet* m_pTableFunctionSet; //part of selection engine - RowPos m_nAnchor; - bool m_bResizing; - ColPos m_nResizingColumn; - bool m_bResizingGrid; - rtl::OUString m_aTooltipText; + RowPos m_nAnchor; + bool m_bResizingColumn; + ColPos m_nResizingColumn; + bool m_bResizingGrid; + rtl::OUString m_aTooltipText; #if DBG_UTIL #define INV_SCROLL_POSITION 1 @@ -143,8 +185,6 @@ namespace svt { namespace table inline long getRowCount() const { return m_nRowCount; } inline long getColumnCount() const { return m_nColumnCount; } - inline long getColHeaderHightPixel() const { return m_nColHeaderHeightPixel; } - inline const TableControl& getAntiImpl() const { return m_rAntiImpl; } inline TableControl& getAntiImpl() { return m_rAntiImpl; } @@ -181,10 +221,7 @@ namespace svt { namespace table if it's okay that the given cooordinate is only partially visible */ void ensureVisible( ColPos _nColumn, RowPos _nRow, bool _bAcceptPartialVisibility ); - /** returns the row, which contains the input point*/ - virtual RowPos getCurrentRow (const Point& rPoint); - void setCursorAtCurrentCell(const Point& rPoint); /** checks whether the vector with the selected rows contains the current row*/ BOOL isRowSelected(const ::std::vector& selectedRows, RowPos current); @@ -201,16 +238,19 @@ namespace svt { namespace table void removeSelectedRow(RowPos _nRowPos); void invalidateRows(); void clearSelection(); - // IAbstractTableControl - virtual void hideCursor(); - virtual void showCursor(); - virtual bool dispatchAction( TableControlAction _eAction ); - virtual SelectionEngine* getSelEngine(); - virtual bool isTooltipActive(); - virtual rtl::OUString& setTooltip(const Point& rPoint ); - virtual void resizeColumn(const Point& rPoint); - virtual bool startResizeColumn(const Point& rPoint); - virtual bool endResizeColumn(const Point& rPoint); + // IAbstractTableControl + virtual void hideCursor(); + virtual void showCursor(); + virtual bool dispatchAction( TableControlAction _eAction ); + virtual SelectionEngine* getSelEngine(); + virtual void activateCellAt( const Point& rPoint ); + virtual bool isTooltipActive(); + virtual rtl::OUString& setTooltip(const Point& rPoint ); + virtual RowPos getRowAtPoint( const Point& rPoint ); + virtual ColPos getColAtPoint( const Point& rPoint ); + virtual void resizeColumn(const Point& rPoint); + virtual bool checkResizeColumn(const Point& rPoint); + virtual bool endResizeColumn(const Point& rPoint); TableDataWindow* getDataWindow(); ScrollBar* getHorzScrollbar(); @@ -301,6 +341,10 @@ namespace svt { namespace table */ TableSize impl_ni_ScrollRows( TableSize _nRowDelta ); + /** equivalent to impl_ni_ScrollRows, but checks the instances invariants beforehand (in a non-product build only) + */ + TableSize impl_scrollRows( TableSize const i_rowDelta ); + /** scrolls the view by the given number of columns The method is not bound to the classes public invariants, as it's used in @@ -311,8 +355,13 @@ namespace svt { namespace table from the given numbers to scroll in case the begin or the end of the column range were reached. */ - TableSize impl_ni_ScrollColumns( TableSize _nRowDelta ); - /** retrieves the area occupied by the totality of (at least partially) visible cells + TableSize impl_ni_ScrollColumns( TableSize _nColumnDelta ); + + /** equivalent to impl_ni_ScrollColumns, but checks the instances invariants beforehand (in a non-product build only) + */ + TableSize impl_scrollColumns( TableSize const i_columnDelta ); + + /** retrieves the area occupied by the totality of (at least partially) visible cells The returned area includes row and column headers. Also, it takes into account the the fact that there might be less columns than would normally @@ -330,11 +379,16 @@ namespace svt { namespace table */ void impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const; - void impl_ni_getAccVisibleColWidths(); + /** retrieves the column which covers the given ordinate + */ + ColPos impl_getColumnForOrdinate( long const i_ordinate ) const; + void impl_updateLeftColumn(); DECL_LINK( OnScroll, ScrollBar* ); + DECL_LINK( OnUpdateScrollbars, void* ); }; + //see seleng.hxx, seleng.cxx, FunctionSet overridables, part of selection engine class TableFunctionSet : public FunctionSet { diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index bbd7f6829369..41bd851e6b82 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -83,14 +83,14 @@ namespace svt { namespace table Point aPoint = rMEvt.GetPosPixel(); if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) ) { - if(m_rTableControl.getCurrentRow(aPoint)>=0 && m_rTableControl.isTooltipActive() ) + if ( m_rTableControl.isTooltipActive() && m_rTableControl.getRowAtPoint( aPoint ) >= 0 ) { SetPointer(POINTER_ARROW); - rtl::OUString& rHelpText = m_rTableControl.setTooltip(aPoint); + const ::rtl::OUString& rHelpText = m_rTableControl.setTooltip(aPoint); Help::EnableBalloonHelp(); - Window::SetHelpText( rHelpText.getStr()); + Window::SetHelpText( rHelpText ); } - else if(m_rTableControl.getCurrentRow(aPoint) == -1) + else if ( m_rTableControl.getRowAtPoint( aPoint ) == ROW_COL_HEADERS ) { if(Help::IsBalloonHelpEnabled()) Help::DisableBalloonHelp(); @@ -107,8 +107,8 @@ namespace svt { namespace table //-------------------------------------------------------------------- void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt ) { - Point aPoint = rMEvt.GetPosPixel(); - RowPos nCurRow = m_rTableControl.getCurrentRow(aPoint); + const Point aPoint = rMEvt.GetPosPixel(); + const RowPos nCurRow = m_rTableControl.getRowAtPoint( aPoint ); std::vector selectedRows(m_rTableControl.getSelectedRows()); if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) ) Window::MouseButtonDown( rMEvt ); @@ -125,7 +125,6 @@ namespace svt { namespace table } } m_aMouseButtonDownHdl.Call((MouseEvent*) &rMEvt); - m_rTableControl.getAntiImpl().LoseFocus(); } //-------------------------------------------------------------------- void TableDataWindow::MouseButtonUp( const MouseEvent& rMEvt ) @@ -133,7 +132,7 @@ namespace svt { namespace table if ( !m_rTableControl.getInputHandler()->MouseButtonUp( m_rTableControl, rMEvt ) ) Window::MouseButtonUp( rMEvt ); m_aMouseButtonUpHdl.Call((MouseEvent*) &rMEvt); - m_rTableControl.getAntiImpl().GetFocus(); + m_rTableControl.getAntiImpl().GrabFocus(); } //-------------------------------------------------------------------- void TableDataWindow::SetPointer( const Pointer& rPointer ) diff --git a/svtools/source/table/tablegeometry.cxx b/svtools/source/table/tablegeometry.cxx index d60de9e6438f..01425f3bb292 100644 --- a/svtools/source/table/tablegeometry.cxx +++ b/svtools/source/table/tablegeometry.cxx @@ -49,30 +49,42 @@ namespace svt { namespace table { if ( m_nRowPos == ROW_COL_HEADERS ) { - //DBG_ASSERT( m_rControl.m_pModel->hasColumnHeaders(), - // "TableRowGeometry::TableRowGeometry: why asking for the geoemtry of the non-existent column header row?" ); m_aRect.Top() = 0; m_aRect.Bottom() = m_rControl.m_nColHeaderHeightPixel - 1; } else { - if ( ( m_nRowPos >= m_rControl.m_nTopRow ) && ( m_nRowPos < m_rControl.m_pModel->getRowCount() ) ) - { - m_aRect.Top() = m_rControl.m_nColHeaderHeightPixel + ( m_nRowPos - m_rControl.m_nTopRow ) * m_rControl.m_nRowHeightPixel; - m_aRect.Bottom() = m_aRect.Top() + m_rControl.m_nRowHeightPixel - 1; - } - else - m_aRect.SetEmpty(); + impl_initRect(); } } //-------------------------------------------------------------------- - bool TableRowGeometry::moveDown() + void TableRowGeometry::impl_initRect() { - if ( ++m_nRowPos < m_rControl.m_pModel->getRowCount() ) - m_aRect.Move( 0, m_rControl.m_nRowHeightPixel ); + if ( ( m_nRowPos >= m_rControl.m_nTopRow ) && ( m_nRowPos < m_rControl.m_pModel->getRowCount() ) ) + { + m_aRect.Top() = m_rControl.m_nColHeaderHeightPixel + ( m_nRowPos - m_rControl.m_nTopRow ) * m_rControl.m_nRowHeightPixel; + m_aRect.Bottom() = m_aRect.Top() + m_rControl.m_nRowHeightPixel - 1; + } else m_aRect.SetEmpty(); + } + + //-------------------------------------------------------------------- + bool TableRowGeometry::moveDown() + { + if ( m_nRowPos == ROW_COL_HEADERS ) + { + m_nRowPos = m_rControl.m_nTopRow; + impl_initRect(); + } + else + { + if ( ++m_nRowPos < m_rControl.m_pModel->getRowCount() ) + m_aRect.Move( 0, m_rControl.m_nRowHeightPixel ); + else + m_aRect.SetEmpty(); + } return isValid(); } @@ -87,41 +99,50 @@ namespace svt { namespace table { if ( m_nColPos == COL_ROW_HEADERS ) { -/* DBG_ASSERT( m_rControl.m_pModel->hasRowHeaders(), - "TableColumnGeometry::TableColumnGeometry: why asking for the geoemtry of the non-existent row header column?" )*/; m_aRect.Left() = 0; m_aRect.Right() = m_rControl.m_nRowHeaderWidthPixel - 1; } else { - ColPos nLeftColumn = m_rControl.m_nLeftColumn; - if ( ( m_nColPos >= nLeftColumn ) && ( m_nColPos < (ColPos)m_rControl.m_aColumnWidthsPixel.size() ) ) - { - m_aRect.Left() = m_rControl.m_nRowHeaderWidthPixel; - // TODO: take into account any possibly frozen columns + impl_initRect(); + } + } - for ( ColPos col = nLeftColumn; col < m_nColPos; ++col ) - m_aRect.Left() += m_rControl.m_aColumnWidthsPixel[ col ]; - m_aRect.Right() = m_aRect.Left() + m_rControl.m_aColumnWidthsPixel[ m_nColPos ] - 1; - } - else - m_aRect.SetEmpty(); + //-------------------------------------------------------------------- + void TableColumnGeometry::impl_initRect() + { + ColPos nLeftColumn = m_rControl.m_nLeftColumn; + if ( ( m_nColPos >= nLeftColumn ) && ( m_nColPos < (ColPos)m_rControl.m_aColumnWidths.size() ) ) + { + m_aRect.Left() = m_rControl.m_nRowHeaderWidthPixel; + // TODO: take into account any possibly frozen columns + + for ( ColPos col = nLeftColumn; col < m_nColPos; ++col ) + m_aRect.Left() += m_rControl.m_aColumnWidths[ col ].getWidth(); + m_aRect.Right() = m_aRect.Left() + m_rControl.m_aColumnWidths[ m_nColPos ].getWidth() - 1; } + else + m_aRect.SetEmpty(); } //-------------------------------------------------------------------- bool TableColumnGeometry::moveRight() { - DBG_ASSERT( m_nColPos != COL_ROW_HEADERS, "TableColumnGeometry::moveRight: cannot move the row header column!" ); - // what would be COL_ROW_HEADERS + 1? - - if ( ++m_nColPos < (ColPos)m_rControl.m_aColumnWidthsPixel.size() ) + if ( m_nColPos == COL_ROW_HEADERS ) { - m_aRect.Left() = m_aRect.Right() + 1; - m_aRect.Right() += m_rControl.m_aColumnWidthsPixel[ m_nColPos ]; + m_nColPos = m_rControl.m_nLeftColumn; + impl_initRect(); } else - m_aRect.SetEmpty(); + { + if ( ++m_nColPos < (ColPos)m_rControl.m_aColumnWidths.size() ) + { + m_aRect.Left() = m_aRect.Right() + 1; + m_aRect.Right() += m_rControl.m_aColumnWidths[ m_nColPos ].getWidth(); + } + else + m_aRect.SetEmpty(); + } return isValid(); } diff --git a/svtools/source/table/tablegeometry.hxx b/svtools/source/table/tablegeometry.hxx index 3ddde0c98c64..7bfc2527d5fc 100644 --- a/svtools/source/table/tablegeometry.hxx +++ b/svtools/source/table/tablegeometry.hxx @@ -91,6 +91,9 @@ namespace svt { namespace table RowPos getRow() const { return m_nRowPos; } // operations bool moveDown(); + + private: + void impl_initRect(); }; //==================================================================== @@ -112,6 +115,9 @@ namespace svt { namespace table ColPos getCol() const { return m_nColPos; } // operations bool moveRight(); + + private: + void impl_initRect(); }; //==================================================================== diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 1a6ce6ff88e5..8d4a20be3c43 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -99,7 +99,7 @@ sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getItemIndexAtPoint: no control (anymore)!", -1 ); - return pTable->GetCurrentRow( Point(x,y) ); + return pTable->GetRowAtPoint( Point( x, y ) ); } // --------------------------------------------------------------------------------------------------------------------- @@ -398,7 +398,6 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD { m_xColumnModel->setDefaultColumns(rawRowData.getLength()); // this will trigger notifications, which in turn will let us update our m_pTableModel - } else if((unsigned int)rawRowData.getLength()!=(unsigned)colCount) throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), *this ); diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 4ed310aa8b28..a4c4b4f0a29c 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -229,7 +229,7 @@ using namespace ::com::sun::star::awt::grid; :aColumns ( ) ,nRowCount ( 0 ) ,bHasColumnHeaders ( true ) - ,bHasRowHeaders ( true ) + ,bHasRowHeaders ( false ) ,bVScroll ( false ) ,bHScroll ( false ) ,pRenderer ( ) @@ -257,7 +257,7 @@ using namespace ::com::sun::star::awt::grid; :m_pImpl( new UnoControlTableModel_Impl ) { m_pImpl->bHasColumnHeaders = true; - m_pImpl->bHasRowHeaders = true; + m_pImpl->bHasRowHeaders = false; m_pImpl->pRenderer.reset( new GridTableRenderer( *this ) ); m_pImpl->pInputHandler.reset( new DefaultInputHandler ); } @@ -340,7 +340,7 @@ using namespace ::com::sun::star::awt::grid; ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( i_position <= m_pImpl->aColumns.size() ), "illegal position!" ); ENSURE_OR_RETURN_VOID( !!i_column, "illegal column" ); - m_pImpl->aColumns.insert( m_pImpl->aColumns.begin(), i_column ); + m_pImpl->aColumns.insert( m_pImpl->aColumns.begin() + i_position, i_column ); // notify listeners ModellListeners aListeners( m_pImpl->m_aListeners ); diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 8a109b667176..df301f9a57bd 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -127,7 +127,7 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const case BASEPROPERTY_GRID_SELECTIONMODE: return uno::makeAny( SelectionType(1) ); case BASEPROPERTY_GRID_SHOWROWHEADER: - return uno::makeAny( (sal_Bool)sal_True ); + return uno::makeAny( (sal_Bool)sal_False ); case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: return uno::makeAny( (sal_Bool)sal_True ); case BASEPROPERTY_GRID_DATAMODEL: -- cgit v1.2.3 From 1d52df1454476ab4ca2d0e297746719c7a9212f1 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 23 Dec 2010 15:49:18 +0100 Subject: gridsort: simplified the scrollbar handling --- svtools/inc/svtools/table/tablemodel.hxx | 28 ++--------- svtools/source/table/tablecontrol_impl.cxx | 78 ++++++++++++----------------- svtools/source/uno/svtxgridcontrol.cxx | 4 +- svtools/source/uno/unocontroltablemodel.cxx | 40 +++++---------- svtools/source/uno/unocontroltablemodel.hxx | 10 ++-- 5 files changed, 53 insertions(+), 107 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 99cd0e2792d6..72438bd0e357 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -48,19 +48,6 @@ namespace svt { namespace table //........................................................................ - //==================================================================== - //= cell data - //==================================================================== - struct TableContentType - { - ::rtl::OUString sContent; - Image* pImage; - TableContentType() : - sContent(), - pImage( ) - { - } - }; //==================================================================== //= ScrollbarVisibility //==================================================================== @@ -402,17 +389,13 @@ namespace svt { namespace table */ virtual TableMetrics getRowHeaderWidth() const = 0; - /** determines the visibility of the vertical scrollbar of the table control - @param overAllHeight the height of the table with all rows - @param actHeight the given height of the table + /** returns the visibilit mode of the vertical scrollbar */ - virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight,int actHeight) const = 0; + virtual ScrollbarVisibility getVerticalScrollbarVisibility() const = 0; - /** determines the visibility of the horizontal scrollbar of the table control - @param overAllWidth the width of the table with all columns - @param actWidth the given width of the table + /** returns the visibilit mode of the horizontal scrollbar */ - virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const = 0; + virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const = 0; /** adds a listener to be notified of changes in the table model */ @@ -422,9 +405,6 @@ namespace svt { namespace table */ virtual void removeTableModelListener( const PTableModelListener& i_listener ) = 0; - virtual bool hasVerticalScrollbar() = 0; - virtual bool hasHorizontalScrollbar() = 0; - /** gets the content of the cells */ virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0; diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 09ac0412c615..fbc5e29d1a02 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -139,11 +139,11 @@ namespace svt { namespace table { return 0; } - virtual ScrollbarVisibility getVerticalScrollbarVisibility(int , int ) const + virtual ScrollbarVisibility getVerticalScrollbarVisibility() const { return ScrollbarShowNever; } - virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int , int ) const + virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const { return ScrollbarShowNever; } @@ -155,14 +155,6 @@ namespace svt { namespace table { (void)i_listener; } - virtual bool hasVerticalScrollbar() - { - return false; - } - virtual bool hasHorizontalScrollbar() - { - return false; - } virtual ::com::sun::star::util::Color getLineColor() { return 0; @@ -612,12 +604,6 @@ namespace svt { namespace table gridWidth -= m_nRowHeaderWidthPixel; } - if ( m_pModel->hasVerticalScrollbar() && ( gridWidth != 0 ) ) - { - sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); - gridWidth-=scrollbarWidth; - } - double colWidthsSum = 0.0; double colWithoutFixedWidthsSum = 0.0; double minColWithoutFixedSum = 0.0; @@ -732,16 +718,18 @@ namespace svt { namespace table { //................................................................ /// determines whether a scrollbar is needed for the given values - bool lcl_determineScrollbarNeed( ScrollbarVisibility _eVisibility, - long _nVisibleUnits, long _nRange, long const i_nPosition ) + bool lcl_determineScrollbarNeed( long const i_position, ScrollbarVisibility const i_visibility, + long const i_availableSpace, long const i_neededSpace ) { - if ( i_nPosition > 0 ) - return true; - if ( _eVisibility == ScrollbarShowNever ) + if ( i_visibility == ScrollbarShowNever ) return false; - if ( _eVisibility == ScrollbarShowAlways ) + if ( i_visibility == ScrollbarShowAlways ) + return true; + if ( i_position > 0 ) return true; - return _nVisibleUnits > _nRange; + if ( i_availableSpace >= i_neededSpace ) + return false; + return true; } //................................................................ @@ -758,24 +746,21 @@ namespace svt { namespace table //................................................................ void lcl_updateScrollbar( Window& _rParent, ScrollBar*& _rpBar, - ScrollbarVisibility _eVisibility, long _nVisibleUnits, + bool const i_needBar, long _nVisibleUnits, long _nPosition, long _nLineSize, long _nRange, bool _bHorizontal, const Link& _rScrollHandler ) { - // do we need the scrollbar? - bool bNeedBar = lcl_determineScrollbarNeed( _eVisibility, _nVisibleUnits, _nRange, _nPosition ); - // do we currently have the scrollbar? bool bHaveBar = _rpBar != NULL; // do we need to correct the scrollbar visibility? - if ( bHaveBar && !bNeedBar ) + if ( bHaveBar && !i_needBar ) { if ( _rpBar->IsTracking() ) _rpBar->EndTracking(); DELETEZ( _rpBar ); } - else if ( !bHaveBar && bNeedBar ) + else if ( !bHaveBar && i_needBar ) { _rpBar = new ScrollBar( &_rParent, @@ -859,23 +844,21 @@ namespace svt { namespace table ? 0 : m_aColumnWidths[ m_nColumnCount - 1 ].getEnd() - m_aColumnWidths[ 0 ].getStart(); + const ScrollbarVisibility eVertScrollbar = m_pModel->getVerticalScrollbarVisibility(); + const ScrollbarVisibility eHorzScrollbar = m_pModel->getHorizontalScrollbarVisibility(); + // do we need a vertical scrollbar? + bool bNeedVerticalScrollbar = lcl_determineScrollbarNeed( + m_nTopRow, eVertScrollbar, aDataCellPlayground.GetHeight(), m_nRowHeightPixel * m_nRowCount ); bool bFirstRoundVScrollNeed = false; - if ( lcl_determineScrollbarNeed( - m_pModel->getVerticalScrollbarVisibility(aDataCellPlayground.GetHeight(), m_nRowHeightPixel*m_nRowCount), - lcl_getRowsFittingInto( aDataCellPlayground.GetHeight(), m_nRowHeightPixel ), - m_nRowCount, - m_nTopRow ) ) + if ( bNeedVerticalScrollbar ) { aDataCellPlayground.Right() -= nScrollbarMetrics; bFirstRoundVScrollNeed = true; } // do we need a horizontal scrollbar? - if ( lcl_determineScrollbarNeed( - m_pModel->getHorizontalScrollbarVisibility( aDataCellPlayground.GetWidth(), nAllColumnsWidth ), - lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false ), - m_nColumnCount, - m_nLeftColumn ) ) + const bool bNeedHorizontalScrollbar = lcl_determineScrollbarNeed( m_nLeftColumn, eHorzScrollbar, aDataCellPlayground.GetWidth(), nAllColumnsWidth ); + if ( bNeedHorizontalScrollbar ) { aDataCellPlayground.Bottom() -= nScrollbarMetrics; @@ -883,20 +866,21 @@ namespace svt { namespace table // the need for a vertical one may have changed, since the horizontal // SB might just occupy enough space so that not all rows do fit // anymore - if ( !bFirstRoundVScrollNeed && lcl_determineScrollbarNeed( - m_pModel->getVerticalScrollbarVisibility(aDataCellPlayground.GetHeight(),m_nRowHeightPixel*m_nRowCount), - lcl_getRowsFittingInto( aDataCellPlayground.GetHeight(), m_nRowHeightPixel ), - m_nRowCount, - m_nTopRow ) ) + if ( !bFirstRoundVScrollNeed ) { - aDataCellPlayground.Right() -= nScrollbarMetrics; + bNeedVerticalScrollbar = lcl_determineScrollbarNeed( + m_nTopRow, eVertScrollbar, aDataCellPlayground.GetHeight(), m_nRowHeightPixel * m_nRowCount ); + if ( bNeedVerticalScrollbar ) + { + aDataCellPlayground.Right() -= nScrollbarMetrics; + } } } // create or destroy the vertical scrollbar, as needed lcl_updateScrollbar( m_rAntiImpl, m_pVScroll, - m_pModel->getVerticalScrollbarVisibility(aDataCellPlayground.GetHeight(),m_nRowHeightPixel*m_nRowCount), + bNeedVerticalScrollbar, lcl_getRowsFittingInto( aDataCellPlayground.GetHeight(), m_nRowHeightPixel ), // visible units m_nTopRow, // current position @@ -920,7 +904,7 @@ namespace svt { namespace table lcl_updateScrollbar( m_rAntiImpl, m_pHScroll, - m_pModel->getHorizontalScrollbarVisibility(aDataCellPlayground.GetWidth(), nAllColumnsWidth), + bNeedHorizontalScrollbar, lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false ), // visible units m_nLeftColumn, // current position diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 8d4a20be3c43..12b10f755318 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -167,7 +167,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An if( aValue >>= bHScroll ) { m_bHScroll = bHScroll; - m_pTableModel->setHorizontalScrollbarVisibility(bHScroll); + m_pTableModel->setHorizontalScrollbarVisibility( bHScroll ? ScrollbarShowAlways : ScrollbarShowSmart ); } break; } @@ -177,7 +177,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An if( aValue >>= bVScroll ) { m_bVScroll = bVScroll; - m_pTableModel->setVerticalScrollbarVisibility(bVScroll); + m_pTableModel->setVerticalScrollbarVisibility( bVScroll ? ScrollbarShowAlways : ScrollbarShowSmart ); } break; } diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index a4c4b4f0a29c..aa00f799dfd0 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -208,8 +208,8 @@ using namespace ::com::sun::star::awt::grid; TableSize nRowCount; bool bHasColumnHeaders; bool bHasRowHeaders; - bool bVScroll; - bool bHScroll; + ScrollbarVisibility eVScrollMode; + ScrollbarVisibility eHScrollMode; PTableRenderer pRenderer; PTableInputHandler pInputHandler; TableMetrics nRowHeight; @@ -230,8 +230,8 @@ using namespace ::com::sun::star::awt::grid; ,nRowCount ( 0 ) ,bHasColumnHeaders ( true ) ,bHasRowHeaders ( false ) - ,bVScroll ( false ) - ,bHScroll ( false ) + ,eVScrollMode ( ScrollbarShowNever ) + ,eHScrollMode ( ScrollbarShowNever ) ,pRenderer ( ) ,pInputHandler ( ) ,nRowHeight ( 10 ) @@ -438,21 +438,15 @@ using namespace ::com::sun::star::awt::grid; } //-------------------------------------------------------------------- - ScrollbarVisibility UnoControlTableModel::getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const + ScrollbarVisibility UnoControlTableModel::getVerticalScrollbarVisibility() const { - if(overAllHeight>=actHeight && !m_pImpl->bVScroll) - return ScrollbarShowNever; - else - return ScrollbarShowAlways; + return m_pImpl->eVScrollMode; } //-------------------------------------------------------------------- - ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const + ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility() const { - if(overAllWidth>=actWidth && !m_pImpl->bHScroll) - return ScrollbarShowNever; - else - return ScrollbarShowAlways; + return m_pImpl->eHScrollMode; } //-------------------------------------------------------------------- @@ -480,25 +474,15 @@ using namespace ::com::sun::star::awt::grid; } //-------------------------------------------------------------------- - void UnoControlTableModel::setVerticalScrollbarVisibility(bool _bVScroll) const + void UnoControlTableModel::setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const { - m_pImpl->bVScroll = _bVScroll; + m_pImpl->eVScrollMode = i_visibility; } //-------------------------------------------------------------------- - void UnoControlTableModel::setHorizontalScrollbarVisibility(bool _bHScroll) const + void UnoControlTableModel::setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const { - m_pImpl->bHScroll = _bHScroll; - } - //-------------------------------------------------------------------- - bool UnoControlTableModel::hasVerticalScrollbar() - { - return m_pImpl->bVScroll; - } - //-------------------------------------------------------------------- - bool UnoControlTableModel::hasHorizontalScrollbar() - { - return m_pImpl->bHScroll; + m_pImpl->eHScrollMode = i_visibility; } //-------------------------------------------------------------------- void UnoControlTableModel::setCellContent(const std::vector >& cellContent) diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 2a627358554f..ac943200b77a 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -129,12 +129,10 @@ class UnoControlTableModel : public ITableModel virtual TableMetrics getRowHeight() const; virtual TableMetrics getColumnHeaderHeight() const; virtual TableMetrics getRowHeaderWidth() const; - virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight,int actHeight) const; - virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const; + virtual ScrollbarVisibility getVerticalScrollbarVisibility() const; + virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const; virtual void addTableModelListener( const PTableModelListener& i_listener ); virtual void removeTableModelListener( const PTableModelListener& i_listener ); - virtual bool hasVerticalScrollbar(); - virtual bool hasHorizontalScrollbar(); virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent(); virtual std::vector& getRowHeaderName(); virtual ::com::sun::star::util::Color getLineColor(); @@ -148,8 +146,8 @@ class UnoControlTableModel : public ITableModel // other operations void setRowCount(TableSize _nRowCount); void setRowHeaderName(const std::vector& cellColumnContent); - void setVerticalScrollbarVisibility(bool _bVScroll) const; - void setHorizontalScrollbarVisibility(bool _bHScroll) const; + void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; + void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setCellContent(const std::vector >& cellContent); void setColumnCount(TableSize _nColCount); void setRowHeaders(bool _bRowHeaders); -- cgit v1.2.3 From cb2f6f86c9de551b806f20e68c50e4037ec51590 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 3 Jan 2011 16:01:14 +0100 Subject: gridsort: removed methods from ITableModel which exposed implementation details of the UnoControlTableModel. Also, instead of exposing those implementation details in UnoControlTableModel, added atomar operations for stuff like adding / clearing of rows, and the like. --- svtools/inc/svtools/table/gridtablerenderer.hxx | 7 +- svtools/inc/svtools/table/tablemodel.hxx | 9 +- svtools/inc/svtools/table/tablerenderer.hxx | 6 +- svtools/source/table/gridtablerenderer.cxx | 6 +- svtools/source/table/tablecontrol.cxx | 16 +- svtools/source/table/tablecontrol_impl.cxx | 67 +++++---- svtools/source/table/tablecontrol_impl.hxx | 10 ++ svtools/source/uno/svtxgridcontrol.cxx | 160 ++++++++++---------- svtools/source/uno/unocontroltablemodel.cxx | 161 ++++++++++++++++----- svtools/source/uno/unocontroltablemodel.hxx | 23 ++- .../source/controls/grid/defaultgriddatamodel.cxx | 19 +-- 11 files changed, 303 insertions(+), 181 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/gridtablerenderer.hxx b/svtools/inc/svtools/table/gridtablerenderer.hxx index e474306c0423..01a2e308f3c0 100644 --- a/svtools/inc/svtools/table/gridtablerenderer.hxx +++ b/svtools/inc/svtools/table/gridtablerenderer.hxx @@ -87,17 +87,18 @@ namespace svt { namespace table OutputDevice& _rDevice, const Rectangle& _rRowArea, const StyleSettings& _rStyle ); virtual void PaintRowHeader( + RowPos const i_rowPos, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, - const StyleSettings& _rStyle, rtl::OUString& _rText ); + const StyleSettings& _rStyle ); virtual void PaintCellImage( ColPos _nColumn, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, Image* _pCellData ); - virtual void PaintCellString( ColPos _nColumn, + virtual void PaintCellString( ColPos _nColumn, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, - const StyleSettings& _rStyle, rtl::OUString& _rText ); + const StyleSettings& _rStyle, rtl::OUString& _rText ); virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect); virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect); }; diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 72438bd0e357..273ed003d7aa 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -405,13 +405,14 @@ namespace svt { namespace table */ virtual void removeTableModelListener( const PTableModelListener& i_listener ) = 0; - /** gets the content of the cells + /** retrieves the content of the given cell */ - virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0; + virtual void getCellContent( RowPos const i_row, ColPos const i_col, ::com::sun::star::uno::Any& o_cellContent ) = 0; - /** gets title of header rows + /** retrieves title of a given row */ - virtual std::vector& getRowHeaderName() = 0; + virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const = 0; + virtual ::com::sun::star::util::Color getLineColor() = 0; virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0; virtual ::com::sun::star::util::Color getTextColor() = 0; diff --git a/svtools/inc/svtools/table/tablerenderer.hxx b/svtools/inc/svtools/table/tablerenderer.hxx index f81771dd22e6..a0c54f7a9538 100644 --- a/svtools/inc/svtools/table/tablerenderer.hxx +++ b/svtools/inc/svtools/table/tablerenderer.hxx @@ -175,12 +175,10 @@ namespace svt { namespace table the are into which the row header should be painted @param _rStyle the style to be used for drawing - @param _rText - the title of the header row */ - virtual void PaintRowHeader( bool _bActive, bool _bSelected, + virtual void PaintRowHeader( RowPos const i_rowPos, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, - const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0; + const StyleSettings& _rStyle ) = 0; /** paints a certain cell diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 8e5bd181a583..869c6c0a6fca 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -197,8 +197,8 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - void GridTableRenderer::PaintRowHeader( bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, - const StyleSettings& _rStyle, rtl::OUString& _rText ) + void GridTableRenderer::PaintRowHeader( RowPos const i_rowPos, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle ) { _rDevice.Push( PUSH_LINECOLOR); _rDevice.SetLineColor(_rStyle.GetSeparatorColor()); @@ -220,7 +220,7 @@ namespace svt { namespace table Rectangle aRect(_rArea); aRect.Left()+=4; aRect.Right()-=4; aRect.Bottom()-=2; - _rDevice.DrawText( aRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + _rDevice.DrawText( aRect, m_pImpl->rModel.getRowHeader( i_rowPos ), nHorFlag | nVerFlag | TEXT_DRAW_CLIP); // TODO: active? selected? (void)_bActive; (void)_bSelected; diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 24486d024091..94932fdcdd01 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -363,7 +363,7 @@ namespace svt { namespace table ::rtl::OUString TableControl::GetRowName( sal_Int32 _nIndex) const { - return GetModel()->getRowHeaderName()[_nIndex]; + return GetModel()->getRowHeader( _nIndex ); } // ----------------------------------------------------------------------------- @@ -381,20 +381,18 @@ namespace svt { namespace table // ----------------------------------------------------------------------------- -::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const +::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos ) const { - ::com::sun::star::uno::Any cellContent(::com::sun::star::uno::Any(::rtl::OUString::createFromAscii(""))); - std::vector >& aTableContent = GetModel()->getCellContent(); - if(&aTableContent) - cellContent = aTableContent[_nRowPos][_nColPos]; - return cellContent; + Any aCellContent; + GetModel()->getCellContent( _nRowPos, _nColPos, aCellContent ); + return aCellContent; } + // ----------------------------------------------------------------------------- ::rtl::OUString TableControl::GetAccessibleCellText( sal_Int32 _nRowPos, sal_Int32 _nColPos) const { - const ::com::sun::star::uno::Any cellContent = GetCellContent(_nRowPos, _nColPos); - return m_pImpl->convertToString(cellContent); + return m_pImpl->getCellContentAsString( _nRowPos, _nColPos ); } // ----------------------------------------------------------------------------- diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index fbc5e29d1a02..81d188745f69 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -50,6 +50,12 @@ namespace svt { namespace table { //........................................................................ + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::graphic::XGraphic; + using ::com::sun::star::uno::Any; + /** === end UNO using === **/ + //==================================================================== //= TempHideCursor //==================================================================== @@ -179,19 +185,17 @@ namespace svt { namespace table { return -1; } - virtual std::vector >& getCellContent() + virtual void getCellContent( RowPos const i_row, ColPos const i_col, ::com::sun::star::uno::Any& o_cellContent ) { - return m_aCellContent; + (void)i_row; + (void)i_col; + o_cellContent.clear(); } - virtual std::vector& getRowHeaderName() + virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const { - aRowHeaderNames.clear(); - aRowHeaderNames.push_back(rtl::OUString::createFromAscii("")); - return aRowHeaderNames; + (void)i_rowPos; + return ::rtl::OUString(); } - private: - std::vector aRowHeaderNames; - std::vector > m_aCellContent; }; @@ -1094,7 +1098,6 @@ namespace svt { namespace table // paint all rows Rectangle aAllDataCellsArea; impl_getAllVisibleDataCellArea( aAllDataCellsArea ); - ::std::vector< std::vector< ::com::sun::star::uno::Any > >& aCellContent = m_pModel->getCellContent(); for ( TableRowGeometry aRowIterator( *this, aAllCellsWithHeaders, getTopRow() ); aRowIterator.isValid(); aRowIterator.moveDown() ) @@ -1132,10 +1135,9 @@ namespace svt { namespace table // paint the row header if ( m_pModel->hasRowHeaders() ) { - Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); - rtl::OUString rowHeaderName = m_pModel->getRowHeaderName()[aRowIterator.getRow()]; - pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, - rStyle, rowHeaderName ); + const Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); + pRenderer->PaintRowHeader( aRowIterator.getRow(), isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, + rStyle ); } if ( !colCount ) continue; @@ -1146,9 +1148,12 @@ namespace svt { namespace table ) { bool isSelectedColumn = false; - ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; - ::com::sun::star::uno::Any rCellData = aCellContent[aRowIterator.getRow()][aCell.getColumn()]; - if(rCellData>>=xGraphic) + + Any aCellContent; + m_pModel->getCellContent( aRowIterator.getRow(), aCell.getColumn(), aCellContent ); + + Reference< XGraphic > xGraphic; + if ( aCellContent >>= xGraphic ) { Image* pImage = new Image(xGraphic); if(pImage!=NULL) @@ -1157,7 +1162,7 @@ namespace svt { namespace table } else { - ::rtl::OUString sContent = convertToString(rCellData); + ::rtl::OUString sContent = convertToString( aCellContent ); pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, *m_pDataWindow, aCell.getRect(), rStyle, sContent ); } @@ -1862,6 +1867,14 @@ namespace svt { namespace table } } + //-------------------------------------------------------------------- + ::rtl::OUString TableControl_Impl::getCellContentAsString( RowPos const i_row, ColPos const i_col ) + { + ::com::sun::star::uno::Any content; + m_pModel->getCellContent( i_row, i_col, content ); + return convertToString( content ); + } + //-------------------------------------------------------------------- TableSize TableControl_Impl::impl_ni_ScrollRows( TableSize _nRowDelta ) { @@ -2043,8 +2056,7 @@ namespace svt { namespace table com::sun::star::uno::Sequence< ::rtl::OUString > text = m_rAntiImpl.getTextForTooltip(); if(text.getLength()==0 && cols.getLength()==0) { - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][hitCol]; - aTooltipText = convertToString(content); + aTooltipText = getCellContentAsString( hitRow, hitCol ); } else if(text.getLength() == 0) { @@ -2052,14 +2064,12 @@ namespace svt { namespace table { if(i==0) { - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][cols[i]]; - aTooltipText = convertToString(content); + aTooltipText = getCellContentAsString( hitRow, cols[i] ); } else { - aTooltipText+= ::rtl::OUString::createFromAscii("\n"); - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][cols[i]]; - aTooltipText += convertToString(content); + aTooltipText += ::rtl::OUString::createFromAscii("\n"); + aTooltipText += getCellContentAsString( hitRow, cols[i] ); } } } @@ -2088,8 +2098,7 @@ namespace svt { namespace table { if(i==0) { - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][cols[i]]; - aTooltipText = text[i] + convertToString(content); + aTooltipText = text[i] + getCellContentAsString( hitRow, cols[i] ); } else { @@ -2097,9 +2106,7 @@ namespace svt { namespace table aTooltipText+= text[i]; if(nCols > i) { - ::com::sun::star::uno::Any content = m_pModel->getCellContent()[hitRow][cols[i]]; - ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic; - aTooltipText += convertToString(content); + aTooltipText += getCellContentAsString( hitRow, cols[i] ); } } } diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 91a57752fca2..9276f8ab95c7 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -222,22 +222,32 @@ namespace svt { namespace table */ void ensureVisible( ColPos _nColumn, RowPos _nRow, bool _bAcceptPartialVisibility ); + /** retrieves the content of the given cell, converted to a string + */ + ::rtl::OUString getCellContentAsString( RowPos const i_row, ColPos const i_col ); + /** checks whether the vector with the selected rows contains the current row*/ BOOL isRowSelected(const ::std::vector& selectedRows, RowPos current); bool isRowSelected(RowPos current); + /** returns the position of the current row in the selection vector */ int getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current); + /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/ void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect ); + /** to be called when a new row is added to the control*/ void invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect ); + /** returns the vector, which contains the selected rows*/ std::vector& getSelectedRows(); + /** updates the vector, which contains the selected rows after removing the row nRowPos*/ void removeSelectedRow(RowPos _nRowPos); void invalidateRows(); void clearSelection(); + // IAbstractTableControl virtual void hideCursor(); virtual void showCursor(); diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 12b10f755318..5f3dce2668a7 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -271,32 +271,44 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An Sequence< Sequence< Any > > cellData = m_xDataModel->getData(); if ( cellData.getLength() != 0 ) { - for (int i = 0; i < cellData.getLength(); i++) + const sal_Int32 nDataRowCount = cellData.getLength(); + + const Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); + const sal_Int32 nRowHeaderCount = rowHeaders.getLength(); + + if ( ( nRowHeaderCount != 0 ) && ( nRowHeaderCount != nDataRowCount ) ) + throw GridInvalidDataException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "row header / content data inconsistency" ) ), *this ); + + // check data consistency + sal_Int32 nDataColumnCount = 0; + for ( sal_Int32 i=0; i newRow; - Sequence< Any > rawRowData = cellData[i]; - //check whether the data row vector length matches with the column count - if(m_xColumnModel->getColumnCount() == 0) - { - m_xColumnModel->setDefaultColumns(rawRowData.getLength()); - // this will trigger notifications, which in turn will let us update our m_pTableModel - } - else - if((unsigned int)rawRowData.getLength()!=(unsigned)m_pTableModel->getColumnCount()) - throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel); - - for ( int k = 0; k < rawRowData.getLength(); k++) - { - newRow.push_back(rawRowData[k]); - } - m_pTableModel->getCellContent().push_back(newRow); + const Sequence< Any >& rRawRowData = cellData[i]; + if ( ( i > 0 ) && ( rRawRowData.getLength() != nDataColumnCount ) ) + throw GridInvalidDataException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "inconsistent column counts in the row data" ) ), *this ); + nDataColumnCount = rRawRowData.getLength(); } - Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); - std::vector< rtl::OUString > newRow( - comphelper::sequenceToContainer< std::vector >(rowHeaders)); - m_pTableModel->setRowCount(m_xDataModel->getRowCount()); - m_pTableModel->setRowHeaderName(newRow); + // ensure default columns exist, if they have not previously been added + if ( ( nDataColumnCount > 0 ) && ( m_xColumnModel->getColumnCount() == 0 ) ) + m_xColumnModel->setDefaultColumns( nDataColumnCount ); + // this will trigger notifications, which in turn will let us update our m_pTableModel + + // ensure the row data has as much columns as indicate by our model + if ( nDataColumnCount != m_pTableModel->getColumnCount() ) + throw GridInvalidDataException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Grid model's column count doesn't match the row data's column count." ) ), + *this ); + + // finally add the rows + // TODO: suspend the model's notifications for the single rows, do one notification after all + // rows have been inserted + for ( TableSize i = 0; i < nDataRowCount; ++i ) + { + m_pTableModel->appendRow( cellData[i], rowHeaders[i] ); + } } sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); @@ -391,29 +403,23 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD { ::vos::OGuard aGuard( GetMutex() ); - std::vector< Any > newRow; - Sequence< Any > rawRowData = Event.rowData; - int colCount = m_xColumnModel->getColumnCount(); - if(colCount == 0) + const TableSize rowDataLength = (TableSize)Event.rowData.getLength(); + const TableSize colCount = m_xColumnModel->getColumnCount(); + if ( colCount == 0 ) { - m_xColumnModel->setDefaultColumns(rawRowData.getLength()); + m_xColumnModel->setDefaultColumns( rowDataLength ); // this will trigger notifications, which in turn will let us update our m_pTableModel } - else if((unsigned int)rawRowData.getLength()!=(unsigned)colCount) + if ( rowDataLength != colCount ) throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), *this ); - for ( int k = 0; k < rawRowData.getLength(); k++) - newRow.push_back(rawRowData[k]); - m_pTableModel->getCellContent().push_back(newRow); - if(m_pTableModel->hasRowHeaders()) - m_pTableModel->getRowHeaderName().push_back(Event.headerName); - m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); + m_pTableModel->appendRow( Event.rowData, Event.headerName ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowAdded: no control (anymore)!" ); - pTable->InvalidateDataWindow(m_pTableModel->getCellContent().size()-1, 0, false); - if(pTable->isAccessibleAlive()) + pTable->InvalidateDataWindow( m_pTableModel->getRowCount() - 1, 0, false ); + if ( pTable->isAccessibleAlive() ) { pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, makeAny( AccessibleTableModelChange(INSERT, m_pTableModel->getRowCount()-1, m_pTableModel->getRowCount(), 0, m_pTableModel->getColumnCount())), @@ -440,33 +446,30 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri if(Event.index == -1) { - if(!isSelectionEmpty()) + if ( !isSelectionEmpty() ) deselectAllRows(); - if(m_pTableModel->hasRowHeaders()) - m_pTableModel->getRowHeaderName().clear(); + + m_pTableModel->clearAllRows(); + pTable->clearSelection(); - m_pTableModel->getCellContent().clear(); - if(pTable->isAccessibleAlive()) + + if ( pTable->isAccessibleAlive() ) { pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, makeAny( AccessibleTableModelChange(DELETE, 0, m_pTableModel->getColumnCount(), 0, m_pTableModel->getColumnCount())), Any()); } } - else if(Event.index >= 0 && Event.index < m_pTableModel->getRowCount()) + else if ( Event.index >= 0 && Event.index < m_pTableModel->getRowCount() ) { - if(isSelectedIndex(Event.index)) + if ( isSelectedIndex( Event.index ) ) { - Sequence selected(1); + Sequence< sal_Int32 > selected(1); selected[0]=Event.index; - deselectRows(selected); + deselectRows( selected ); } - if(m_pTableModel->hasRowHeaders()) - m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index); - std::vector >::iterator rowPos =m_pTableModel->getCellContent().begin() + Event.index; - m_pTableModel->getCellContent().erase( rowPos ); + m_pTableModel->removeRow( Event.index ); } - m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); pTable->InvalidateDataWindow(Event.index, Event.index, true); if(pTable->isAccessibleAlive()) { @@ -521,58 +524,63 @@ void SAL_CALL SVTXGridControl::columnChanged(const ::com::sun::star::awt::grid: } pTable->Invalidate(); } -void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) + +void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" ); - if(Event.valueName == rtl::OUString::createFromAscii("RowHeight")) + if ( Event.valueName.equalsAscii( "RowHeight" ) ) { sal_Int32 rowHeight = m_pTableModel->getRowHeight(); Event.newValue>>=rowHeight; m_pTableModel->setRowHeight(rowHeight); pTable->Invalidate(); } - else if(Event.valueName == rtl::OUString::createFromAscii("RowHeaderWidth")) + else if ( Event.valueName.equalsAscii( "RowHeaderWidth" ) ) { sal_Int32 rowHeaderWidth = m_pTableModel->getRowHeaderWidth(); Event.newValue>>=rowHeaderWidth; m_pTableModel->setRowHeaderWidth(rowHeaderWidth); pTable->Invalidate(); } - else if(Event.valueName == rtl::OUString::createFromAscii("RowHeaders")) + else if ( Event.valueName.equalsAscii( "RowHeaders" ) ) { - Sequence< rtl::OUString > headers(0); - Event.newValue>>=headers; - std::vector< rtl::OUString > headerNames( comphelper::sequenceToContainer >(headers) ); - m_pTableModel->setRowHeaderName(headerNames); + Sequence< rtl::OUString > rowHeaders; + OSL_VERIFY( Event.newValue >>= rowHeaders ); + m_pTableModel->setRowHeaderNames( rowHeaders ); pTable->Invalidate(); } - else if(Event.valueName == rtl::OUString::createFromAscii("CellUpdated")) + else if ( Event.valueName.equalsAscii( "CellUpdated" ) ) { - std::vector< std::vector< Any > >& rowContent = m_pTableModel->getCellContent(); sal_Int32 col = -1; - Event.oldValue>>=col; - rowContent[Event.index][col] = Event.newValue; - pTable->InvalidateDataWindow(Event.index, Event.index, false); + OSL_VERIFY( Event.oldValue >>= col ); + + m_pTableModel->updateCellContent( Event.index, col, Event.newValue ); + pTable->InvalidateDataWindow( Event.index, Event.index, false ); } - else if(Event.valueName == rtl::OUString::createFromAscii("RowUpdated")) + else if ( Event.valueName.equalsAscii( "RowUpdated" ) ) { - std::vector >& rowContent = m_pTableModel->getCellContent(); - Sequence< sal_Int32 > cols(0); - Sequence< Any > values(0); - Event.oldValue>>=cols; - Event.newValue>>=values; - for(int i = 0; i< cols.getLength(); i++) + Sequence< sal_Int32 > cols; + OSL_VERIFY( Event.oldValue >>= cols ); + + Sequence< Any > values; + OSL_VERIFY( Event.newValue >>= values ); + + ENSURE_OR_RETURN_VOID( cols.getLength() == values.getLength(), "SVTXGridControl::dataChanged: inconsistent array lengths!" ); + + const TableSize columnCount = m_pTableModel->getColumnCount(); + // TODO: suspend listener notification, so that the table model doesn't notify |cols.size()| different events. + // Instead, only one event should be broadcasted. + for ( ColPos i = 0; i< cols.getLength(); ++i ) { - if(cols[i]>=0 && cols[i]getColumnCount()) - rowContent[Event.index][cols[i]]=values[i]; - else - break; + ENSURE_OR_CONTINUE( ( cols[i] >= 0 ) && ( cols[i] < columnCount ), "illegal column index" ); + m_pTableModel->updateCellContent( Event.index, cols[i], values[i] ); } - pTable->InvalidateDataWindow(Event.index, Event.index, false); + + pTable->InvalidateDataWindow( Event.index, Event.index, false ); } } diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index aa00f799dfd0..ed297b42dcf8 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -27,17 +27,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svtools.hxx" -#include "unocontroltablemodel.hxx" -#include -#include "svtools/table/gridtablerenderer.hxx" #include "svtools/table/defaultinputhandler.hxx" +#include "svtools/table/gridtablerenderer.hxx" #include "svtools/table/tablecontrol.hxx" +#include "unocontroltablemodel.hxx" + +#include +#include +#include + #include +#include #include -#include #include -#include -#include +#include #include using ::rtl::OUString; @@ -204,26 +207,26 @@ using namespace ::com::sun::star::awt::grid; typedef ::std::vector< PTableModelListener > ModellListeners; struct UnoControlTableModel_Impl { - ::std::vector< PColumnModel > aColumns; - TableSize nRowCount; - bool bHasColumnHeaders; - bool bHasRowHeaders; - ScrollbarVisibility eVScrollMode; - ScrollbarVisibility eHScrollMode; - PTableRenderer pRenderer; - PTableInputHandler pInputHandler; - TableMetrics nRowHeight; - TableMetrics nColumnHeaderHeight; - TableMetrics nRowHeaderWidth; - ::std::vector aRowHeadersTitle; - ::std::vector > aCellContent; - ::com::sun::star::util::Color m_nLineColor; - ::com::sun::star::util::Color m_nHeaderColor; - ::com::sun::star::util::Color m_nTextColor; - ::com::sun::star::util::Color m_nRowColor1; - ::com::sun::star::util::Color m_nRowColor2; + ::std::vector< PColumnModel > aColumns; + TableSize nRowCount; + bool bHasColumnHeaders; + bool bHasRowHeaders; + ScrollbarVisibility eVScrollMode; + ScrollbarVisibility eHScrollMode; + PTableRenderer pRenderer; + PTableInputHandler pInputHandler; + TableMetrics nRowHeight; + TableMetrics nColumnHeaderHeight; + TableMetrics nRowHeaderWidth; + ::std::vector< ::rtl::OUString > aRowHeadersTitle; + ::std::vector< ::std::vector< Any > > aCellContent; + ::com::sun::star::util::Color m_nLineColor; + ::com::sun::star::util::Color m_nHeaderColor; + ::com::sun::star::util::Color m_nTextColor; + ::com::sun::star::util::Color m_nRowColor1; + ::com::sun::star::util::Color m_nRowColor2; ::com::sun::star::style::VerticalAlignment m_eVerticalAlign; - ModellListeners m_aListeners; + ModellListeners m_aListeners; UnoControlTableModel_Impl() :aColumns ( ) @@ -308,11 +311,6 @@ using namespace ::com::sun::star::awt::grid; m_pImpl->aColumns.resize( _nColCount); } //-------------------------------------------------------------------- - void UnoControlTableModel::setRowCount(TableSize _nRowCount) - { - m_pImpl->nRowCount = _nRowCount; - } - //-------------------------------------------------------------------- bool UnoControlTableModel::isCellEditable( ColPos col, RowPos row ) const { (void)col; @@ -490,20 +488,111 @@ using namespace ::com::sun::star::awt::grid; m_pImpl->aCellContent = cellContent; } - std::vector >& UnoControlTableModel::getCellContent() + //-------------------------------------------------------------------- + void UnoControlTableModel::getCellContent( RowPos const i_row, ColPos const i_col, Any& o_cellContent ) + { + ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( i_row < m_pImpl->aCellContent.size() ), + "UnoControlTableModel::getCellContent: illegal row index!" ); + ::std::vector< Any >& rRowContent( m_pImpl->aCellContent[ i_row ] ); + ENSURE_OR_RETURN_VOID( ( i_col >= 0 ) && ( i_col < rRowContent.size() ), + "UnoControlTableModel::getCellContent: illegal column index" ); + o_cellContent = rRowContent[ i_col ]; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::updateCellContent( RowPos const i_row, ColPos const i_col, Any const & i_cellContent ) + { + ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( i_row < m_pImpl->aCellContent.size() ), + "UnoControlTableModel::getCellContent: illegal row index!" ); + ::std::vector< Any >& rRowContent( m_pImpl->aCellContent[ i_row ] ); + ENSURE_OR_RETURN_VOID( ( i_col >= 0 ) && ( i_col < rRowContent.size() ), + "UnoControlTableModel::getCellContent: illegal column index" ); + rRowContent[ i_col ] = i_cellContent; + + // TODO: listener notification + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::setRowHeaderNames( const Sequence< ::rtl::OUString >& i_rowHeaders ) + { + ENSURE_OR_RETURN_VOID( size_t( i_rowHeaders.getLength() ) == m_pImpl->aRowHeadersTitle.size(), + "UnoControlTableModel::setRowHeaderNames: illegal number of row headers!" ); + // this method is not intended to set a new row count, but only to modify the existing row headers + + ::std::copy( + ::comphelper::stl_begin( i_rowHeaders ), + ::comphelper::stl_end( i_rowHeaders ), + m_pImpl->aRowHeadersTitle.begin() + ); + + // TODO: listener notification + } + + //-------------------------------------------------------------------- + ::rtl::OUString UnoControlTableModel::getRowHeader( RowPos const i_rowPos ) const { - return m_pImpl->aCellContent; + ENSURE_OR_RETURN( ( i_rowPos >= 0 ) && ( i_rowPos < m_pImpl->aRowHeadersTitle.size() ), + "UnoControlTableModel::getRowHeader: illegal row position!", ::rtl::OUString() ); + return m_pImpl->aRowHeadersTitle[ i_rowPos ]; } + //-------------------------------------------------------------------- - void UnoControlTableModel::setRowHeaderName(const std::vector& cellColumnContent) + void UnoControlTableModel::appendRow( Sequence< Any > const & i_rowData, ::rtl::OUString const & i_rowHeader ) { - m_pImpl->aRowHeadersTitle = cellColumnContent; + ENSURE_OR_RETURN_VOID( i_rowData.getLength() == getColumnCount(), "UnoControlTableModel::appendRow: invalid row data!" ); + + // add row data + ::std::vector< Any > newRow( i_rowData.getLength() ); + if ( !newRow.empty() ) + ::std::copy( + ::comphelper::stl_begin( i_rowData ), + ::comphelper::stl_end( i_rowData ), + newRow.begin() + ); + + m_pImpl->aCellContent.push_back( newRow ); + + if ( hasRowHeaders() ) + m_pImpl->aRowHeadersTitle.push_back( i_rowHeader ); + + ++m_pImpl->nRowCount; + + // TODO: listener notification } - std::vector& UnoControlTableModel::getRowHeaderName() + //-------------------------------------------------------------------- + void UnoControlTableModel::removeRow( RowPos const i_rowPos ) { - return m_pImpl->aRowHeadersTitle; + ENSURE_OR_RETURN_VOID( ( i_rowPos >= 0 ) && ( i_rowPos < getRowCount() ), "UnoControlTableModel::removeRow: illegal row position!" ); + + if ( hasRowHeaders() ) + m_pImpl->aRowHeadersTitle.erase( m_pImpl->aRowHeadersTitle.begin() + i_rowPos ); + + const ::std::vector< ::std::vector< Any > >::iterator contentPos = m_pImpl->aCellContent.begin() + i_rowPos; + m_pImpl->aCellContent.erase( contentPos ); + + --m_pImpl->nRowCount; + + // TODO: listener notification } + + //-------------------------------------------------------------------- + void UnoControlTableModel::clearAllRows() + { + if ( hasRowHeaders() ) + { + ::std::vector< ::rtl::OUString > aEmpty; + m_pImpl->aRowHeadersTitle.swap( aEmpty ); + } + + ::std::vector< ::std::vector< Any > > aEmptyContent; + m_pImpl->aCellContent.swap( aEmptyContent ); + + m_pImpl->nRowCount = 0; + + // TODO: listener notification + } + //-------------------------------------------------------------------- ::com::sun::star::util::Color UnoControlTableModel::getLineColor() { diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index ac943200b77a..d7192cbd7a9b 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -133,8 +133,8 @@ class UnoControlTableModel : public ITableModel virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const; virtual void addTableModelListener( const PTableModelListener& i_listener ); virtual void removeTableModelListener( const PTableModelListener& i_listener ); - virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent(); - virtual std::vector& getRowHeaderName(); + virtual void getCellContent( RowPos const i_row, ColPos const i_col, ::com::sun::star::uno::Any& o_cellContent ); + virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const; virtual ::com::sun::star::util::Color getLineColor(); virtual ::com::sun::star::util::Color getHeaderBackgroundColor(); virtual ::com::sun::star::util::Color getTextColor(); @@ -143,9 +143,21 @@ class UnoControlTableModel : public ITableModel virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign(); + // column write access + void appendColumn( const PColumnModel& i_column ); + void insertColumn( ColPos const i_position, const PColumnModel& i_column ); + void removeAllColumns(); + + // row write access + void setRowHeaderNames( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_rowHeaders ); + void appendRow( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > const & i_rowData, ::rtl::OUString const & i_rowHeader ); + void removeRow( RowPos const i_rowPos ); + void clearAllRows(); + + // cell data write access + void updateCellContent( RowPos const i_rowPos, ColPos const i_colPos, ::com::sun::star::uno::Any const & i_cellContent ); + // other operations - void setRowCount(TableSize _nRowCount); - void setRowHeaderName(const std::vector& cellColumnContent); void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setCellContent(const std::vector >& cellContent); @@ -158,9 +170,6 @@ class UnoControlTableModel : public ITableModel void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor); void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor); void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); - void appendColumn( const PColumnModel& i_column ); - void insertColumn( ColPos const i_position, const PColumnModel& i_column ); - void removeAllColumns(); }; inline void UnoControlTableModel::SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM ) diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index bf6eb5ed501c..6adf7b994035 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -149,24 +149,25 @@ void SAL_CALL DefaultGridDataModel::setRowHeight(::sal_Int32 value) throw (::com //--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & value) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & i_rowHeaders ) throw (::com::sun::star::uno::RuntimeException) { - ::com::sun::star::uno::Sequence< ::rtl::OUString > oldValue( comphelper::containerToSequence(rowHeaders) ); + ::com::sun::star::uno::Sequence< ::rtl::OUString > oldValue( comphelper::containerToSequence( rowHeaders ) ); - std::vector< rtl::OUString>::iterator iterator; - int i = 0; - int sequenceSize = value.getLength(); + const sal_Int32 sequenceSize = i_rowHeaders.getLength(); - for(iterator = rowHeaders.begin(); iterator != rowHeaders.end(); iterator++) + sal_Int32 i = 0; + for ( std::vector< rtl::OUString >::iterator iterator = rowHeaders.begin(); + iterator != rowHeaders.end(); + ++iterator, ++i + ) { if ( sequenceSize > i ) - *iterator = value[i]; + *iterator = i_rowHeaders[i]; else *iterator = ::rtl::OUString(); - i++; } - broadcast_changed( ROWHEADERS, 0, Any(oldValue), Any(comphelper::containerToSequence(rowHeaders)) ); + broadcast_changed( ROWHEADERS, 0, Any( oldValue ), Any( comphelper::containerToSequence( rowHeaders ) ) ); } //--------------------------------------------------------------------- -- cgit v1.2.3 From b83e7371c47c0cf5373ec6e99efe05f9a4da09f5 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 3 Jan 2011 23:14:55 +0100 Subject: gridsort: allow cloning grid columns, and the (default) grid data/column model --- svtools/source/uno/unocontroltablemodel.cxx | 2 +- .../controls/grid/defaultgridcolumnmodel.cxx | 49 ++- .../controls/grid/defaultgridcolumnmodel.hxx | 7 +- .../source/controls/grid/defaultgriddatamodel.cxx | 472 +++++++++++---------- .../source/controls/grid/defaultgriddatamodel.hxx | 15 +- toolkit/source/controls/grid/gridcolumn.cxx | 24 +- toolkit/source/controls/grid/gridcolumn.hxx | 4 + toolkit/source/controls/grid/gridcontrol.cxx | 32 +- 8 files changed, 355 insertions(+), 250 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index ed297b42dcf8..88776e6dc0f9 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -84,7 +84,7 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- UnoControlTableColumn::UnoControlTableColumn( const Reference< XGridColumn >& i_gridColumn ) :m_nID( 0 ) - ,m_xGridColumn( i_gridColumn, UNO_SET_THROW ) + ,m_xGridColumn( i_gridColumn, UNO_QUERY_THROW ) { } diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 16e0c8a0a0bc..c1cafd568326 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -59,6 +59,7 @@ namespace toolkit using ::com::sun::star::container::ContainerEvent; using ::com::sun::star::uno::Exception; using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::util::XCloneable; /** === end UNO using === **/ //================================================================================================================== @@ -74,6 +75,35 @@ namespace toolkit { } + //------------------------------------------------------------------------------------------------------------------ + DefaultGridColumnModel::DefaultGridColumnModel( DefaultGridColumnModel const & i_copySource ) + :DefaultGridColumnModel_Base( m_aMutex ) + ,m_aContext( i_copySource.m_aContext ) + ,m_aContainerListeners( m_aMutex ) + ,m_aColumns() + ,m_nColumnHeaderHeight( i_copySource.m_nColumnHeaderHeight ) + { + Columns aColumns; + aColumns.reserve( i_copySource.m_aColumns.size() ); + try + { + for ( Columns::const_iterator col = i_copySource.m_aColumns.begin(); + col != i_copySource.m_aColumns.end(); + ++col + ) + { + const Reference< XCloneable > xCloneable( *col, UNO_QUERY_THROW ); + aColumns.push_back( Reference< XGridColumn >( xCloneable->createClone(), UNO_QUERY_THROW ) ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + if ( aColumns.size() == i_copySource.m_aColumns.size() ) + m_aColumns.swap( aColumns ); + } + //------------------------------------------------------------------------------------------------------------------ DefaultGridColumnModel::~DefaultGridColumnModel() { @@ -210,18 +240,9 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn(const Reference< XGridColumn > & column) throw (RuntimeException) + Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn( const Reference< XGridColumn > & i_column ) throw (RuntimeException) { - Reference< XGridColumn > xColumn( m_aContext.createComponent( "com.sun.star.awt.grid.GridColumn" ), UNO_QUERY_THROW ); - xColumn->setColumnWidth(column->getColumnWidth()); - xColumn->setPreferredWidth(column->getPreferredWidth()); - xColumn->setMaxWidth(column->getMaxWidth()); - xColumn->setMinWidth(column->getMinWidth()); - xColumn->setPreferredWidth(column->getPreferredWidth()); - xColumn->setResizeable(column->getResizeable()); - xColumn->setTitle(column->getTitle()); - xColumn->setHorizontalAlign(column->getHorizontalAlign()); - return xColumn; + return Reference< XGridColumn >( i_column->createClone(), UNO_QUERY_THROW ); } //------------------------------------------------------------------------------------------------------------------ @@ -293,6 +314,12 @@ namespace toolkit } } + //------------------------------------------------------------------------------------------------------------------ + Reference< XCloneable > SAL_CALL DefaultGridColumnModel::createClone( ) throw (RuntimeException) + { + return new DefaultGridColumnModel( *this ); + } + //...................................................................................................................... } // namespace toolkit //...................................................................................................................... diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx index 4b4382048566..dbd89df57b7d 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx @@ -28,7 +28,6 @@ /** === begin UNO includes === **/ #include #include -//#include #include #include #include @@ -54,7 +53,8 @@ class DefaultGridColumnModel :public ::cppu::BaseMutex ,public DefaultGridColumnModel_Base { public: - DefaultGridColumnModel(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory); + DefaultGridColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory ); + DefaultGridColumnModel( DefaultGridColumnModel const & i_copySource ); virtual ~DefaultGridColumnModel(); // XGridColumnModel @@ -76,6 +76,9 @@ public: virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + // OComponentHelper virtual void SAL_CALL disposing(); diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 6adf7b994035..eb6f777c3b41 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -45,301 +45,315 @@ using namespace ::com::sun::star::lang; #define ROWUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowUpdated" )) #define ROWHEADERWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaderWidth" )) +//...................................................................................................................... namespace toolkit +//...................................................................................................................... { + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::util::XCloneable; + /** === end UNO using === **/ + + //================================================================================================================== + //= DefaultGridDataModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::DefaultGridDataModel() + :m_nRowHeight(0) + ,m_aRowHeaders() + ,m_nRowHeaderWidth(10) + { + } -/////////////////////////////////////////////////////////////////////// -// class DefaultGridDataModel -/////////////////////////////////////////////////////////////////////// - -DefaultGridDataModel::DefaultGridDataModel() -: rowHeight(0), - rowHeaders(std::vector< ::rtl::OUString >()), - m_nRowHeaderWidth(10) -{ -} - -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::DefaultGridDataModel( DefaultGridDataModel const & i_copySource ) + :m_nRowHeight( i_copySource.m_nRowHeight ) + ,m_aData( i_copySource.m_aData ) + ,m_aRowHeaders( i_copySource.m_aRowHeaders ) + ,m_nRowHeaderWidth( i_copySource.m_nRowHeaderWidth ) + { + } -DefaultGridDataModel::~DefaultGridDataModel() -{ -} + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::~DefaultGridDataModel() + { + } -void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException) -{ - ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridDataListener::static_type() ); - if( pIter ) + //------------------------------------------------------------------------------------------------------------------ + void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException) { - ::cppu::OInterfaceIteratorHelper aListIter(*pIter); - while(aListIter.hasMoreElements()) + ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridDataListener::static_type() ); + if( pIter ) { - XGridDataListener* pListener = static_cast(aListIter.next()); - switch( eType ) + ::cppu::OInterfaceIteratorHelper aListIter(*pIter); + while(aListIter.hasMoreElements()) { - case row_added: pListener->rowAdded(aEvent); break; - case row_removed: pListener->rowRemoved(aEvent); break; - case data_changed: pListener->dataChanged(aEvent); break; + XGridDataListener* pListener = static_cast(aListIter.next()); + switch( eType ) + { + case row_added: pListener->rowAdded(aEvent); break; + case row_removed: pListener->rowRemoved(aEvent); break; + case data_changed: pListener->dataChanged(aEvent); break; + } } } } -} -//--------------------------------------------------------------------- - -void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, name, oldValue, newValue, index, ::rtl::OUString(), Sequence< Any >()); - broadcast( data_changed, aEvent); -} + //------------------------------------------------------------------------------------------------------------------ + void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue) throw (::com::sun::star::uno::RuntimeException) + { + Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + GridDataEvent aEvent( xSource, name, oldValue, newValue, index, ::rtl::OUString(), Sequence< Any >()); + broadcast( data_changed, aEvent); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void DefaultGridDataModel::broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, + ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) + { + Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, (const ::com::sun::star::uno::Sequence< Any >&)rowData ); + broadcast( row_added, aEvent); + } -void DefaultGridDataModel::broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, - ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, (const ::com::sun::star::uno::Sequence< Any >&)rowData ); - broadcast( row_added, aEvent); -} + //------------------------------------------------------------------------------------------------------------------ + void DefaultGridDataModel::broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, + ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) + { + Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, rowData ); + broadcast( row_removed, aEvent); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeight() throw (::com::sun::star::uno::RuntimeException) + { + return m_nRowHeight; + } -void DefaultGridDataModel::broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, - ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, rowData ); - broadcast( row_removed, aEvent); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::setRowHeight(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + sal_Int32 oldValue = m_nRowHeight; + m_nRowHeight = value; -//--------------------------------------------------------------------- + broadcast_changed( ROWHEIGHT, 0, Any(oldValue), Any(value)); + } -//--------------------------------------------------------------------- -// XDefaultGridDataModel -//--------------------------------------------------------------------- -::sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeight() throw (::com::sun::star::uno::RuntimeException) -{ - return rowHeight; -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridDataModel::getRowCount() throw (::com::sun::star::uno::RuntimeException) + { + return m_aData.size(); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getRowHeaders() throw (::com::sun::star::uno::RuntimeException) + { + return comphelper::containerToSequence(m_aRowHeaders); + } -void SAL_CALL DefaultGridDataModel::setRowHeight(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - sal_Int32 oldValue = rowHeight; - rowHeight = value; + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & i_rowHeaders ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Sequence< ::rtl::OUString > oldValue( comphelper::containerToSequence( m_aRowHeaders ) ); - broadcast_changed( ROWHEIGHT, 0, Any(oldValue), Any(value)); -} + const sal_Int32 sequenceSize = i_rowHeaders.getLength(); -//--------------------------------------------------------------------- + sal_Int32 i = 0; + for ( std::vector< rtl::OUString >::iterator iterator = m_aRowHeaders.begin(); + iterator != m_aRowHeaders.end(); + ++iterator, ++i + ) + { + if ( sequenceSize > i ) + *iterator = i_rowHeaders[i]; + else + *iterator = ::rtl::OUString(); + } -::sal_Int32 SAL_CALL DefaultGridDataModel::getRowCount() throw (::com::sun::star::uno::RuntimeException) -{ - return data.size(); -} + broadcast_changed( ROWHEADERS, 0, Any( oldValue ), Any( comphelper::containerToSequence( m_aRowHeaders ) ) ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & rRowdata) throw (::com::sun::star::uno::RuntimeException) + { + // store header name + m_aRowHeaders.push_back(headername); -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getRowHeaders() throw (::com::sun::star::uno::RuntimeException) -{ - return comphelper::containerToSequence(rowHeaders); -} + // store row m_aData + std::vector< Any > newRow; + for ( int i = 0; i < rRowdata.getLength();i++) + { + newRow.push_back(rRowdata[i]); + } -//--------------------------------------------------------------------- + m_aData.push_back( newRow ); -void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & i_rowHeaders ) throw (::com::sun::star::uno::RuntimeException) -{ - ::com::sun::star::uno::Sequence< ::rtl::OUString > oldValue( comphelper::containerToSequence( rowHeaders ) ); + broadcast_add( m_aData.size()-1, headername, comphelper::containerToSequence(newRow)); - const sal_Int32 sequenceSize = i_rowHeaders.getLength(); + } - sal_Int32 i = 0; - for ( std::vector< rtl::OUString >::iterator iterator = rowHeaders.begin(); - iterator != rowHeaders.end(); - ++iterator, ++i - ) + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { - if ( sequenceSize > i ) - *iterator = i_rowHeaders[i]; + if ( index >= 0 && index <= getRowCount()-1) + { + ::rtl::OUString headerName( (::rtl::OUString) m_aRowHeaders[index] ); + m_aRowHeaders.erase(m_aRowHeaders.begin() + index); + + Sequence< Any >& rowData ( (Sequence< Any >&)m_aData[index] ); + m_aData.erase(m_aData.begin() + index); + broadcast_remove( index, headerName, rowData); + } else - *iterator = ::rtl::OUString(); + return; } - broadcast_changed( ROWHEADERS, 0, Any( oldValue ), Any( comphelper::containerToSequence( rowHeaders ) ) ); -} - -//--------------------------------------------------------------------- - -void SAL_CALL DefaultGridDataModel::addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & rRowdata) throw (::com::sun::star::uno::RuntimeException) -{ - // store header name - rowHeaders.push_back(headername); - - // store row data - std::vector< Any > newRow; - for ( int i = 0; i < rRowdata.getLength();i++) + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL DefaultGridDataModel::getData() throw (::com::sun::star::uno::RuntimeException) { - newRow.push_back(rRowdata[i]); - } - data.push_back( newRow ); + std::vector< std::vector< Any > >::iterator iterator; + std::vector< Sequence< Any > > dummyContainer(0); - broadcast_add( data.size()-1, headername, comphelper::containerToSequence(newRow)); -} + for(iterator = m_aData.begin(); iterator != m_aData.end(); iterator++) + { + Sequence< Any > cols(comphelper::containerToSequence(*iterator)); + dummyContainer.push_back( cols ); + } + Sequence< Sequence< Any > > dataSequence(comphelper::containerToSequence(dummyContainer)); -//--------------------------------------------------------------------- + return dataSequence; + } -void SAL_CALL DefaultGridDataModel::removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) -{ - if ( index >= 0 && index <= getRowCount()-1) + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::addGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException) { - ::rtl::OUString headerName( (::rtl::OUString) rowHeaders[index] ); - rowHeaders.erase(rowHeaders.begin() + index); - - Sequence< Any >& rowData ( (Sequence< Any >&)data[index] ); - data.erase(data.begin() + index); - broadcast_remove( index, headerName, rowData); + BrdcstHelper.addListener( XGridDataListener::static_type(), xListener ); } - else - return; -} -//--------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL DefaultGridDataModel::getData() throw (::com::sun::star::uno::RuntimeException) -{ - - std::vector< std::vector< Any > >::iterator iterator; - std::vector< Sequence< Any > > dummyContainer(0); - - for(iterator = data.begin(); iterator != data.end(); iterator++) + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::removeGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException) { - Sequence< Any > cols(comphelper::containerToSequence(*iterator)); - dummyContainer.push_back( cols ); + BrdcstHelper.removeListener( XGridDataListener::static_type(), xListener ); } - Sequence< Sequence< Any > > dataSequence(comphelper::containerToSequence(dummyContainer)); - - return dataSequence; -} -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::removeAll() throw (RuntimeException) + { + m_aRowHeaders.clear(); + m_aData.clear(); + broadcast_remove( -1, ::rtl::OUString(), 0); + } -void SAL_CALL DefaultGridDataModel::addGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XGridDataListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) + { + sal_Int32 oldValue = m_nRowHeaderWidth; + m_nRowHeaderWidth = _value; + broadcast_changed( ROWHEADERWIDTH, 0, Any(oldValue), Any(_value) ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException) + { + return m_nRowHeaderWidth; + } -void SAL_CALL DefaultGridDataModel::removeGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XGridDataListener::static_type(), xListener ); -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::removeAll() throw (RuntimeException) -{ - rowHeaders.clear(); - data.clear(); - broadcast_remove( -1, ::rtl::OUString(), 0); -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) -{ - sal_Int32 oldValue = m_nRowHeaderWidth; - m_nRowHeaderWidth = _value; - broadcast_changed( ROWHEADERWIDTH, 0, Any(oldValue), Any(_value) ); -} -//--------------------------------------------------------------------- -sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException) -{ - return m_nRowHeaderWidth; -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::updateCell(::sal_Int32 row, ::sal_Int32 column, const Any& value) throw (::com::sun::star::uno::RuntimeException) -{ - if(row >= 0 && row < (signed)data.size()) + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::updateCell(::sal_Int32 row, ::sal_Int32 column, const Any& value) throw (::com::sun::star::uno::RuntimeException) { - if(column >= 0 && column < (signed)data[0].size()) + if(row >= 0 && row < (signed)m_aData.size()) { - data[row][column] = value; - Sequence< Any >dataSeq(comphelper::containerToSequence(data[row])); - broadcast_changed( CELLUPDATED, row, Any(column), value ); + if(column >= 0 && column < (signed)m_aData[0].size()) + { + m_aData[row][column] = value; + Sequence< Any >dataSeq(comphelper::containerToSequence(m_aData[row])); + broadcast_changed( CELLUPDATED, row, Any(column), value ); + } } } -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::updateRow(::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 > & columns, const ::com::sun::star::uno::Sequence< Any > & values) throw (::com::sun::star::uno::RuntimeException) -{ - if(row >= 0 && row < (signed)data.size()) + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::updateRow(::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 > & columns, const ::com::sun::star::uno::Sequence< Any > & values) throw (::com::sun::star::uno::RuntimeException) { - if(columns.getLength() == values.getLength()) + if(row >= 0 && row < (signed)m_aData.size()) { - for(int i = 0; i < columns.getLength(); i++) - data[row][i] = values[i]; - Sequence< Any >dataSeq(comphelper::containerToSequence(data[row])); - broadcast_changed( ROWUPDATED, row, Any(columns), Any(values) ); + if(columns.getLength() == values.getLength()) + { + for(int i = 0; i < columns.getLength(); i++) + m_aData[row][i] = values[i]; + Sequence< Any >dataSeq(comphelper::containerToSequence(m_aData[row])); + broadcast_changed( ROWUPDATED, row, Any(columns), Any(values) ); + } } } -} -//--------------------------------------------------------------------- -// XComponent -//--------------------------------------------------------------------- - -void SAL_CALL DefaultGridDataModel::dispose() throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - ::com::sun::star::lang::EventObject aEvent; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - BrdcstHelper.aLC.disposeAndClear( aEvent ); - -} - -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::dispose() throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); -void SAL_CALL DefaultGridDataModel::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XEventListener::static_type(), xListener ); -} + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); + BrdcstHelper.aLC.disposeAndClear( aEvent ); -//--------------------------------------------------------------------- + } -void SAL_CALL DefaultGridDataModel::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); -} -//--------------------------------------------------------------------- -// XServiceInfo -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) + { + BrdcstHelper.addListener( XEventListener::static_type(), xListener ); + } -::rtl::OUString SAL_CALL DefaultGridDataModel::getImplementationName( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridDataModel" ) ); - return aImplName; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) + { + BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL DefaultGridDataModel::getImplementationName( ) throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridDataModel" ) ); + return aImplName; + } -sal_Bool SAL_CALL DefaultGridDataModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - return ServiceName.equalsAscii( szServiceName_DefaultGridDataModel ); -} + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL DefaultGridDataModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + return ServiceName.equalsAscii( szServiceName_DefaultGridDataModel ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getSupportedServiceNames( ) throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + static const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridDataModel ) ); + static const Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; + } -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getSupportedServiceNames( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridDataModel ) ); - static const Sequence< OUString > aSeq( &aServiceName, 1 ); - return aSeq; -} + //------------------------------------------------------------------------------------------------------------------ + Reference< XCloneable > SAL_CALL DefaultGridDataModel::createClone( ) throw (RuntimeException) + { + return new DefaultGridDataModel( *this ); + } -} +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... Reference< XInterface > SAL_CALL DefaultGridDataModel_CreateInstance( const Reference< XMultiServiceFactory >& ) { diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index b30bd758147c..242c8ba514ab 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -57,6 +57,7 @@ class DefaultGridDataModel : public ::cppu::WeakImplHelper2< XGridDataModel, XSe { public: DefaultGridDataModel(); + DefaultGridDataModel( DefaultGridDataModel const & i_copySource ); virtual ~DefaultGridDataModel(); // XGridDataModel @@ -66,7 +67,7 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowHeaders() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & value) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & data) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & m_aData) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL removeGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); @@ -75,11 +76,15 @@ public: virtual sal_Int32 SAL_CALL getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateCell( ::sal_Int32 row, ::sal_Int32 column, const ::com::sun::star::uno::Any& value ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateRow( ::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& values ) throw (::com::sun::star::uno::RuntimeException); + // XComponent virtual void SAL_CALL dispose( ) throw (RuntimeException); virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException); + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); @@ -92,10 +97,10 @@ private: void broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); void broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); - sal_Int32 rowHeight; - std::vector< std::vector < Any > > data; - std::vector< ::rtl::OUString > rowHeaders; - sal_Int32 m_nRowHeaderWidth; + sal_Int32 m_nRowHeight; + std::vector< std::vector < Any > > m_aData; + std::vector< ::rtl::OUString > m_aRowHeaders; + sal_Int32 m_nRowHeaderWidth; }; } diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index d966e6656661..576871fc677a 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -46,11 +46,13 @@ namespace toolkit using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::util; using namespace ::com::sun::star::style; //================================================================================================================== //= DefaultGridColumnModel //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ GridColumn::GridColumn() :GridColumn_Base( m_aMutex ) ,m_aIdentifier() @@ -60,7 +62,21 @@ namespace toolkit ,m_nMaxWidth(0) ,m_nMinWidth(0) ,m_bResizeable(true) - ,m_eHorizontalAlign(HorizontalAlignment(0)) + ,m_eHorizontalAlign( HorizontalAlignment_LEFT ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + GridColumn::GridColumn( GridColumn const & i_copySource ) + :GridColumn_Base( m_aMutex ) + ,m_aIdentifier( i_copySource.m_aIdentifier ) + ,m_nIndex( i_copySource.m_nIndex ) + ,m_nColumnWidth( i_copySource.m_nColumnWidth ) + ,m_nPreferredWidth( i_copySource.m_nPreferredWidth ) + ,m_nMaxWidth( i_copySource.m_nMaxWidth ) + ,m_nMinWidth( i_copySource.m_nMinWidth ) + ,m_bResizeable( i_copySource.m_bResizeable ) + ,m_eHorizontalAlign( i_copySource.m_eHorizontalAlign ) { } @@ -283,6 +299,12 @@ namespace toolkit const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); return aSeq; } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XCloneable > SAL_CALL GridColumn::createClone( ) throw (RuntimeException) + { + return new GridColumn( *this ); + } } ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GridColumn_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index f621f68c9d88..b8d70551032a 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -51,6 +51,7 @@ class GridColumn :public ::cppu::BaseMutex { public: GridColumn(); + GridColumn( GridColumn const & i_copySource ); virtual ~GridColumn(); // ::com::sun::star::awt::grid::XGridColumn @@ -78,6 +79,9 @@ public: virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + // XCloneable (base of XGridColumn) + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 79b8ae8a6c61..8b323648a887 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -92,8 +92,38 @@ UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun:: //---------------------------------------------------------------------------------------------------------------------- UnoGridModel::UnoGridModel( const UnoGridModel& rModel ) -: UnoControlModel( rModel ) + :UnoControlModel( rModel ) { + // clone the data model + const Reference< XFastPropertySet > xCloneSource( &const_cast< UnoGridModel& >( rModel ) ); + bool success = false; + try + { + const Reference< XCloneable > xCloneable( xCloneSource->getFastPropertyValue( BASEPROPERTY_GRID_DATAMODEL ), UNO_QUERY_THROW ); + setFastPropertyValue( BASEPROPERTY_GRID_DATAMODEL, makeAny( xCloneable->createClone() ) ); + success = true; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + if ( !success ) + setFastPropertyValue( BASEPROPERTY_GRID_DATAMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridDataModel" ) ) ); + + // clone the column model + success = false; + try + { + const Reference< XCloneable > xCloneable( xCloneSource->getFastPropertyValue( BASEPROPERTY_GRID_COLUMNMODEL ), UNO_QUERY_THROW ); + setFastPropertyValue( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( xCloneable->createClone() ) ); + success = true; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + if ( !success ) + setFastPropertyValue( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridColumnModel" ) ) ); } //---------------------------------------------------------------------------------------------------------------------- -- cgit v1.2.3 From d48dfdc09b7880b1d22e8fe44f70c81209bd1f19 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 3 Jan 2011 23:18:47 +0100 Subject: gridsort: IColumnModel: make the ID attribute an css.uno.Any, so it can be exchanged with XGridColumn's identifier --- svtools/inc/svtools/table/tablemodel.hxx | 5 +++-- svtools/inc/svtools/table/tabletypes.hxx | 3 --- svtools/source/uno/unocontroltablemodel.cxx | 28 +++++++++++++++++++++------- svtools/source/uno/unocontroltablemodel.hxx | 9 ++++----- 4 files changed, 28 insertions(+), 17 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 273ed003d7aa..a9137eab28a2 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -162,7 +162,8 @@ namespace svt { namespace table @see setID */ - virtual ColumnID getID() const = 0; + virtual ::com::sun::star::uno::Any + getID() const = 0; /** sets a new column ID @@ -173,7 +174,7 @@ namespace svt { namespace table @see getID */ - virtual bool setID( const ColumnID _nID ) = 0; + virtual void setID( const ::com::sun::star::uno::Any& _nID ) = 0; /** returns the name of the column diff --git a/svtools/inc/svtools/table/tabletypes.hxx b/svtools/inc/svtools/table/tabletypes.hxx index 645120e30d4b..0d285d420323 100644 --- a/svtools/inc/svtools/table/tabletypes.hxx +++ b/svtools/inc/svtools/table/tabletypes.hxx @@ -49,9 +49,6 @@ namespace svt { namespace table */ typedef sal_Int32 AnyPos; - /// the ID of a column in a table - typedef sal_Int32 ColumnID; - typedef sal_Int32 TableMetrics; /** special column width value which indicates that the column should be automatically resized to fit the view diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 88776e6dc0f9..dfbde6cb4058 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -83,22 +83,36 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- UnoControlTableColumn::UnoControlTableColumn( const Reference< XGridColumn >& i_gridColumn ) - :m_nID( 0 ) - ,m_xGridColumn( i_gridColumn, UNO_QUERY_THROW ) + :m_xGridColumn( i_gridColumn, UNO_QUERY_THROW ) { } //-------------------------------------------------------------------- - ColumnID UnoControlTableColumn::getID() const + Any UnoControlTableColumn::getID() const { - return m_nID; + Any aID; + try + { + aID = m_xGridColumn->getIdentifier(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return aID; } //-------------------------------------------------------------------- - bool UnoControlTableColumn::setID( const ColumnID _nID ) + void UnoControlTableColumn::setID( const Any& i_ID ) { - m_nID = _nID; - return true; + try + { + m_xGridColumn->setIdentifier( i_ID ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //-------------------------------------------------------------------- diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index d7192cbd7a9b..9eaa202f8cd0 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -51,17 +51,16 @@ using namespace ::svt::table; class UnoControlTableColumn : public IColumnModel { private: - ColumnID m_nID; - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > - m_xGridColumn; + m_xGridColumn; public: UnoControlTableColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn >& i_gridColumn ); // IColumnModel overridables - virtual ColumnID getID() const; - virtual bool setID( const ColumnID _nID ); + virtual ::com::sun::star::uno::Any + getID() const; + virtual void setID( const ::com::sun::star::uno::Any& i_ID ); virtual String getName() const; virtual void setName( const String& _rName ); virtual bool isResizable() const; -- cgit v1.2.3 From 891179797b83156811f4a0607c64ad14cf5c90ff Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 4 Jan 2011 10:26:14 +0100 Subject: gridsort: don't decide in the TableControl whether a cell content is a image or a string-convertible - this is the renderer's task in the original design. --- svtools/inc/svtools/table/gridtablerenderer.hxx | 28 ++- svtools/inc/svtools/table/tablerenderer.hxx | 39 +-- svtools/source/table/cellvalueconversion.cxx | 73 ++++++ svtools/source/table/cellvalueconversion.hxx | 52 ++++ svtools/source/table/gridtablerenderer.cxx | 309 ++++++++++++++---------- svtools/source/table/makefile.mk | 3 +- svtools/source/table/tablecontrol_impl.cxx | 52 +--- svtools/source/table/tablecontrol_impl.hxx | 1 - toolkit/source/controls/grid/gridcontrol.cxx | 9 +- 9 files changed, 343 insertions(+), 223 deletions(-) create mode 100755 svtools/source/table/cellvalueconversion.cxx create mode 100755 svtools/source/table/cellvalueconversion.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/gridtablerenderer.hxx b/svtools/inc/svtools/table/gridtablerenderer.hxx index 01a2e308f3c0..01492ae26fc4 100644 --- a/svtools/inc/svtools/table/gridtablerenderer.hxx +++ b/svtools/inc/svtools/table/gridtablerenderer.hxx @@ -43,9 +43,6 @@ namespace svt { namespace table This class is able to paint a table grid, table headers, and cell backgrounds according to the selected/active state of cells. - - TODO update the documentation when it's decided whether this renderer - also does value handling */ class GridTableRenderer : public ITableRenderer { @@ -74,7 +71,7 @@ namespace svt { namespace table */ RowPos getCurrentRow(); - protected: + public: // ITableRenderer overridables virtual void PaintHeaderArea( OutputDevice& _rDevice, const Rectangle& _rArea, @@ -91,16 +88,27 @@ namespace svt { namespace table bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ); - virtual void PaintCellImage( ColPos _nColumn, - bool _bActive, bool _bSelected, - OutputDevice& _rDevice, const Rectangle& _rArea, - const StyleSettings& _rStyle, Image* _pCellData ); - virtual void PaintCellString( ColPos _nColumn, + virtual void PaintCell( ColPos const i_col, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, - const StyleSettings& _rStyle, rtl::OUString& _rText ); + const StyleSettings& _rStyle ); virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect); virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect); + + private: + struct CellRenderContext; + + void impl_paintCellContent( + CellRenderContext const & i_context + ); + void impl_paintCellImage( + CellRenderContext const & i_context, + Image const & i_image + ); + void impl_paintCellText( + CellRenderContext const & i_context, + ::rtl::OUString const & i_text + ); }; //........................................................................ } } // namespace svt::table diff --git a/svtools/inc/svtools/table/tablerenderer.hxx b/svtools/inc/svtools/table/tablerenderer.hxx index a0c54f7a9538..4477f7065001 100644 --- a/svtools/inc/svtools/table/tablerenderer.hxx +++ b/svtools/inc/svtools/table/tablerenderer.hxx @@ -205,46 +205,11 @@ namespace svt { namespace table the are into which the cell should be painted @param _rStyle the style to be used for drawing - @param _pCellData - the content of the cell */ - virtual void PaintCellImage( ColPos _nColumn, + virtual void PaintCell( ColPos const i_col, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, - const StyleSettings& _rStyle, Image* _pCellData ) = 0; - - /** paints a certain cell - - The row to be painted is denoted by the most recent call to - ->PrepareRow. - - @param _bSelected - if and only if the cell to be painted is - selected currently. This is the case if either - the row or the column of the cell is currently selected. -
- Note that this flag is equal to the respective flag in the - previous ->PrepareRow call, it's passed here for convinience - only. - @param _bActive - if the cell is currently active. -
- Note that this flag is equal to the respective flag in the - previous ->PrepareRow call, it's passed here for convinience - only. - @param _rDevice - denotes the device to paint onto - @param _rArea - the are into which the cell should be painted - @param _rStyle - the style to be used for drawing - @param _rText - the content of the cell - */ - virtual void PaintCellString( ColPos _nColumn, - bool _bActive, bool _bSelected, - OutputDevice& _rDevice, const Rectangle& _rArea, - const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0; + const StyleSettings& _rStyle ) = 0; /** draws a cell cursor in the given rectangle diff --git a/svtools/source/table/cellvalueconversion.cxx b/svtools/source/table/cellvalueconversion.cxx new file mode 100755 index 000000000000..9b36ad095203 --- /dev/null +++ b/svtools/source/table/cellvalueconversion.cxx @@ -0,0 +1,73 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "cellvalueconversion.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace svt +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Any; + /** === end UNO using === **/ + + //================================================================================================================== + //= CellValueConversion + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString CellValueConversion::convertToString( const Any& i_value ) + { + // TODO: use css.script.XTypeConverter? + + sal_Int32 nInt = 0; + sal_Bool bBool = false; + double fDouble = 0; + ::rtl::OUString sConvertString; + + ::rtl::OUString sStringValue; + if ( i_value >>= sConvertString ) + sStringValue = sConvertString; + else if ( i_value >>= nInt ) + sStringValue = sConvertString.valueOf( nInt ); + else if ( i_value >>= bBool ) + sStringValue = sConvertString.valueOf( bBool ); + else if ( i_value >>= fDouble ) + sStringValue = sConvertString.valueOf( fDouble ); + else + OSL_ENSURE( !i_value.hasValue(), "CellValueConversion::convertToString: cannot handle the given cell content type!" ); + + return sStringValue; + } + +//...................................................................................................................... +} // namespace svt +//...................................................................................................................... diff --git a/svtools/source/table/cellvalueconversion.hxx b/svtools/source/table/cellvalueconversion.hxx new file mode 100755 index 000000000000..4d6b8c8d6aac --- /dev/null +++ b/svtools/source/table/cellvalueconversion.hxx @@ -0,0 +1,52 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SVTOOLS_CELLVALUECONVERSION_HXX +#define SVTOOLS_CELLVALUECONVERSION_HXX + +/** === begin UNO includes === **/ +#include +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace svt +{ +//...................................................................................................................... + + //================================================================================================================== + //= CellValueConversion + //================================================================================================================== + class CellValueConversion + { + public: + static ::rtl::OUString convertToString( const ::com::sun::star::uno::Any& i_cellValue ); + }; + +//...................................................................................................................... +} // namespace svt +//...................................................................................................................... + +#endif // SVTOOLS_CELLVALUECONVERSION_HXX diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 869c6c0a6fca..8eec7b8d437e 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -27,8 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svtools.hxx" +#include "cellvalueconversion.hxx" #include "svtools/table/gridtablerenderer.hxx" +#include + #include #include #include @@ -38,6 +41,19 @@ namespace svt { namespace table { //........................................................................ + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::graphic::XGraphic; + using ::com::sun::star::style::HorizontalAlignment; + using ::com::sun::star::style::HorizontalAlignment_LEFT; + using ::com::sun::star::style::HorizontalAlignment_CENTER; + using ::com::sun::star::style::HorizontalAlignment_RIGHT; + using ::com::sun::star::style::VerticalAlignment; + using ::com::sun::star::style::VerticalAlignment_TOP; + using ::com::sun::star::style::VerticalAlignment_MIDDLE; + using ::com::sun::star::style::VerticalAlignment_BOTTOM; + struct GridTableRenderer_Impl { ITableModel& rModel; @@ -81,11 +97,11 @@ namespace svt { namespace table _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); Color background = m_pImpl->rModel.getHeaderBackgroundColor(); - if( background != 0xFFFFFF) - _rDevice.SetFillColor(background); + if ( background != COL_TRANSPARENT ) + _rDevice.SetFillColor( background ); else - _rDevice.SetFillColor(_rStyle.GetDialogColor()); - _rDevice.SetLineColor(_rStyle.GetSeparatorColor()); + _rDevice.SetFillColor( _rStyle.GetDialogColor() ); + _rDevice.SetLineColor( _rStyle.GetSeparatorColor() ); _rDevice.DrawRect( _rArea ); // delimiter lines at bottom/right _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); @@ -147,44 +163,44 @@ namespace svt { namespace table _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); Color aRowBackground = m_pImpl->rModel.getOddRowBackgroundColor(); - Color line = m_pImpl->rModel.getLineColor(); + const Color lineColor = m_pImpl->rModel.getLineColor(); Color aRowBackground2 = m_pImpl->rModel.getEvenRowBackgroundColor(); - Color fieldColor = _rStyle.GetFieldColor(); - if(aRowBackground == 0xFFFFFF) + const Color fieldColor = _rStyle.GetFieldColor(); + if ( aRowBackground == COL_TRANSPARENT ) aRowBackground = fieldColor; - if(aRowBackground2 == 0xFFFFFF) + if ( aRowBackground2 == COL_TRANSPARENT ) aRowBackground2 = fieldColor; //if row is selected background color becomes blue, and lines should be also blue //if they aren't user defined - if(_bSelected) + if ( _bSelected ) { - Color aSelected(_rStyle.GetHighlightColor()); + const Color aSelected( _rStyle.GetHighlightColor() ); aRowBackground = aSelected; - if(line == 0xFFFFFF) - _rDevice.SetLineColor(aRowBackground); + if ( lineColor == COL_TRANSPARENT ) + _rDevice.SetLineColor( aRowBackground ); else - _rDevice.SetLineColor(line); + _rDevice.SetLineColor( lineColor ); } - //if row not selected, check the cases whether user defined backgrounds are set - //and set line color to be the same + // if row not selected, check the cases whether user defined backgrounds are set + // and set line color to be the same else { - if(aRowBackground2 != fieldColor && _nRow%2) + if ( ( aRowBackground2 != fieldColor ) && ( _nRow % 2 ) ) { aRowBackground = aRowBackground2; - if(line == 0xFFFFFF) - _rDevice.SetLineColor(aRowBackground); + if ( lineColor == COL_TRANSPARENT ) + _rDevice.SetLineColor( aRowBackground ); else - _rDevice.SetLineColor(line); + _rDevice.SetLineColor( lineColor ); } //fill the rows with alternating background colors if second background color is specified - else if(aRowBackground != fieldColor && line == 0xFFFFFF) - _rDevice.SetLineColor(aRowBackground); + else if ( aRowBackground != fieldColor && lineColor == COL_TRANSPARENT ) + _rDevice.SetLineColor( aRowBackground ); else { //if Line color is set, then it was user defined and should be visible //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible - _rDevice.SetLineColor(line); + _rDevice.SetLineColor( lineColor ); } } _rDevice.SetFillColor( aRowBackground ); @@ -200,96 +216,102 @@ namespace svt { namespace table void GridTableRenderer::PaintRowHeader( RowPos const i_rowPos, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { - _rDevice.Push( PUSH_LINECOLOR); - _rDevice.SetLineColor(_rStyle.GetSeparatorColor()); + _rDevice.Push( PUSH_LINECOLOR | PUSH_TEXTCOLOR ); + + _rDevice.SetLineColor( _rStyle.GetSeparatorColor() ); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); - if(m_pImpl->rModel.getTextColor() != 0x000000) - _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); + + if ( m_pImpl->rModel.getTextColor() != 0x000000 ) + _rDevice.SetTextColor( m_pImpl->rModel.getTextColor() ); else - _rDevice.SetTextColor(_rStyle.GetFieldTextColor()); + _rDevice.SetTextColor( _rStyle.GetFieldTextColor() ); + ULONG nHorFlag = TEXT_DRAW_LEFT; ULONG nVerFlag = TEXT_DRAW_TOP; - if(m_pImpl->rModel.getVerticalAlign() == 1) + if ( m_pImpl->rModel.getVerticalAlign() == 1 ) nVerFlag = TEXT_DRAW_VCENTER; - else if(m_pImpl->rModel.getVerticalAlign() == 2) + else if ( m_pImpl->rModel.getVerticalAlign() == 2 ) nVerFlag = TEXT_DRAW_BOTTOM; - if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 1) + if ( m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 1 ) nHorFlag = TEXT_DRAW_CENTER; - else if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2) + else if ( m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2 ) nHorFlag = TEXT_DRAW_RIGHT; - Rectangle aRect(_rArea); + + Rectangle aRect( _rArea ); aRect.Left()+=4; aRect.Right()-=4; aRect.Bottom()-=2; - _rDevice.DrawText( aRect, m_pImpl->rModel.getRowHeader( i_rowPos ), nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + _rDevice.DrawText( aRect, m_pImpl->rModel.getRowHeader( i_rowPos ), nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); + // TODO: active? selected? (void)_bActive; (void)_bSelected; - //at the moment no special paint for selected row header _rDevice.Pop(); } //-------------------------------------------------------------------- - void GridTableRenderer::PaintCellImage( ColPos _nColumn, bool _bSelected, bool _bActive, - OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, Image* _pCellData ) + struct GridTableRenderer::CellRenderContext + { + OutputDevice& rDevice; + Rectangle const aContentArea; + StyleSettings const & rStyle; + ColPos const nColumn; + bool const bSelected; + + CellRenderContext( OutputDevice& i_device, Rectangle const & i_contentArea, + StyleSettings const & i_style, ColPos const i_column, bool const i_selected ) + :rDevice( i_device ) + ,aContentArea( i_contentArea ) + ,rStyle( i_style ) + ,nColumn( i_column ) + ,bSelected( i_selected ) + { + } + }; + + //-------------------------------------------------------------------- + void GridTableRenderer::PaintCell( ColPos const i_column, bool _bSelected, bool _bActive, + OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { - _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR); + _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); Color background1 = m_pImpl->rModel.getOddRowBackgroundColor(); Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor(); - Color line = m_pImpl->rModel.getLineColor(); - //if row is selected and line color isn't user specified, set it blue - if(_bSelected) + Color lineColor = m_pImpl->rModel.getLineColor(); + + // if row is selected and line color isn't user specified, use the settings' color + if ( _bSelected ) { - if(line == 0xFFFFFF) - _rDevice.SetLineColor(_rStyle.GetHighlightColor()); + if ( lineColor == COL_TRANSPARENT ) + _rDevice.SetLineColor( _rStyle.GetHighlightColor() ); else - _rDevice.SetLineColor(line); + _rDevice.SetLineColor( lineColor ); } - //else set line color to the color of row background + // else set line color to the color of row background else { - if(background2 != 0xFFFFFF && m_pImpl->nCurrentRow%2) + if ( ( background2 != COL_TRANSPARENT ) && ( m_pImpl->nCurrentRow % 2 ) ) { - if(line == 0xFFFFFF) - _rDevice.SetLineColor(background2); + if ( lineColor == COL_TRANSPARENT ) + _rDevice.SetLineColor( background2 ); else - _rDevice.SetLineColor(line); + _rDevice.SetLineColor( lineColor ); } - else if(background1 != 0xFFFFFF && line == 0xFFFFFF) - _rDevice.SetLineColor(background1); + else if ( ( background1 != COL_TRANSPARENT ) && ( lineColor == COL_TRANSPARENT ) ) + _rDevice.SetLineColor( background1 ); else { //if line color is set, then it was user defined and should be visible //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible - _rDevice.SetLineColor(line); + _rDevice.SetLineColor( lineColor ); } } _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); Rectangle aRect( _rArea ); ++aRect.Left(); --aRect.Right(); - aRect.Top(); aRect.Bottom(); - Point imagePos(Point(aRect.Left(), aRect.Top())); - Size imageSize = _pCellData->GetSizePixel(); - if(aRect.GetWidth() > imageSize.Width()) - { - if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 1) - imagePos.X() = aRect.Left()+((double)(aRect.GetWidth() - imageSize.Width()))/2; - else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2) - imagePos.X() = aRect.Right() - imageSize.Width(); - } - else - imageSize.Width() = aRect.GetWidth(); - if(aRect.GetHeight() > imageSize.Height()) - { - if(m_pImpl->rModel.getVerticalAlign() == 1) - imagePos.Y() = aRect.Top()+((double)(aRect.GetHeight() - imageSize.Height()))/2; - else if(m_pImpl->rModel.getVerticalAlign() == 2) - imagePos.Y() = aRect.Bottom() - imageSize.Height(); - } - else - imageSize.Height() = aRect.GetHeight()-1; - Image& image (*_pCellData); - _rDevice.DrawImage(imagePos, imageSize, image, 0); + + const CellRenderContext aRenderContext( _rDevice, aRect, _rStyle, i_column, _bSelected ); + impl_paintCellContent( aRenderContext ); + _rDevice.Pop(); (void)_bActive; @@ -297,69 +319,104 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - void GridTableRenderer::PaintCellString( ColPos _nColumn, bool _bSelected, bool _bActive, - OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText ) - { - _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); - Color background1 = m_pImpl->rModel.getOddRowBackgroundColor(); - Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor(); - Color line = m_pImpl->rModel.getLineColor(); - //if row is selected and line color isn't user specified, set it blue - if(_bSelected) + void GridTableRenderer::impl_paintCellImage( CellRenderContext const & i_context, Image const & i_image ) + { + Point imagePos( Point( i_context.aContentArea.Left(), i_context.aContentArea.Top() ) ); + Size imageSize = i_image.GetSizePixel(); + if ( i_context.aContentArea.GetWidth() > imageSize.Width() ) { - if(line == 0xFFFFFF) - _rDevice.SetLineColor(_rStyle.GetHighlightColor()); - else - _rDevice.SetLineColor(line); + const HorizontalAlignment eHorzAlign = m_pImpl->rModel.getColumnModel( i_context.nColumn )->getHorizontalAlign(); + switch ( eHorzAlign ) + { + case HorizontalAlignment_CENTER: + imagePos.X() += ( i_context.aContentArea.GetWidth() - imageSize.Width() ) / 2; + break; + case HorizontalAlignment_RIGHT: + imagePos.X() = i_context.aContentArea.Right() - imageSize.Width(); + break; + default: + break; + } + } - //else set line color to the color of row background else + imageSize.Width() = i_context.aContentArea.GetWidth(); + + if ( i_context.aContentArea.GetHeight() > imageSize.Height() ) { - if(background2 != 0xFFFFFF && m_pImpl->nCurrentRow%2) + const VerticalAlignment eVertAlign = m_pImpl->rModel.getVerticalAlign(); + switch ( eVertAlign ) { - if(line == 0xFFFFFF) - _rDevice.SetLineColor(background2); - else - _rDevice.SetLineColor(line); - } - else if(background1 != 0xFFFFFF && line == 0xFFFFFF) - _rDevice.SetLineColor(background1); - else - { - //if Line color is set, then it was user defined and should be visible - //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible - _rDevice.SetLineColor(line); + case VerticalAlignment_MIDDLE: + imagePos.Y() += ( i_context.aContentArea.GetHeight() - imageSize.Height() ) / 2; + break; + case VerticalAlignment_BOTTOM: + imagePos.Y() = i_context.aContentArea.Bottom() - imageSize.Height(); + break; + default: + break; } } - _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); + else + imageSize.Height() = i_context.aContentArea.GetHeight() - 1; - Rectangle aRect( _rArea ); - ++aRect.Left(); --aRect.Right(); - aRect.Top(); aRect.Bottom(); - if(_bSelected) - _rDevice.SetTextColor(_rStyle.GetHighlightTextColor()); - else if(m_pImpl->rModel.getTextColor() != 0x000000) - _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); + i_context.rDevice.DrawImage( imagePos, imageSize, i_image, 0 ); + } + + //-------------------------------------------------------------------- + void GridTableRenderer::impl_paintCellContent( CellRenderContext const & i_context ) + { + Any aCellContent; + m_pImpl->rModel.getCellContent( m_pImpl->nCurrentRow, i_context.nColumn, aCellContent ); + + const Reference< XGraphic > xGraphic( aCellContent, UNO_QUERY ); + if ( xGraphic.is() ) + { + const Image aImage( xGraphic ); + impl_paintCellImage( i_context, aImage ); + return; + } + + const ::rtl::OUString sText( CellValueConversion::convertToString( aCellContent ) ); + impl_paintCellText( i_context, sText ); + } + + //-------------------------------------------------------------------- + void GridTableRenderer::impl_paintCellText( CellRenderContext const & i_context, ::rtl::OUString const & i_text ) + { + if ( i_context.bSelected ) + i_context.rDevice.SetTextColor( i_context.rStyle.GetHighlightTextColor() ); + else if ( m_pImpl->rModel.getTextColor() != 0x000000 ) + i_context.rDevice.SetTextColor( m_pImpl->rModel.getTextColor() ); else - _rDevice.SetTextColor(_rStyle.GetFieldTextColor()); - ULONG nHorFlag = TEXT_DRAW_LEFT; + i_context.rDevice.SetTextColor( i_context.rStyle.GetFieldTextColor() ); + + ULONG nVerFlag = TEXT_DRAW_TOP; - if(m_pImpl->rModel.getVerticalAlign() == 1) - nVerFlag = TEXT_DRAW_VCENTER; - else if(m_pImpl->rModel.getVerticalAlign() == 2) - nVerFlag = TEXT_DRAW_BOTTOM; - if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 1) - nHorFlag = TEXT_DRAW_CENTER; - else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2) - nHorFlag = TEXT_DRAW_RIGHT; - Rectangle textRect(_rArea); - textRect.Left()+=4; textRect.Right()-=4; - textRect.Bottom()-=2; - _rDevice.DrawText( textRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + const VerticalAlignment eVertAlign = m_pImpl->rModel.getVerticalAlign(); + switch ( eVertAlign ) + { + case VerticalAlignment_MIDDLE: nVerFlag = TEXT_DRAW_VCENTER; break; + case VerticalAlignment_BOTTOM: nVerFlag = TEXT_DRAW_BOTTOM; break; + default: + break; + } - _rDevice.Pop(); - (void)_bActive; - // no special painting for the active cell at the moment + ULONG nHorFlag = TEXT_DRAW_LEFT; + const HorizontalAlignment eHorzAlign = m_pImpl->rModel.getColumnModel( i_context.nColumn )->getHorizontalAlign(); + switch ( eHorzAlign ) + { + case HorizontalAlignment_CENTER: nHorFlag = TEXT_DRAW_CENTER; break; + case HorizontalAlignment_RIGHT: nHorFlag = TEXT_DRAW_RIGHT; break; + default: + break; + } + + Rectangle textRect( i_context.aContentArea ); + textRect.Left() += 2; textRect.Right() -= 2; + ++textRect.Top(); --textRect.Bottom(); + + i_context.rDevice.DrawText( textRect, i_text, nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); } //-------------------------------------------------------------------- diff --git a/svtools/source/table/makefile.mk b/svtools/source/table/makefile.mk index cf1adc76fe92..7fa1b00d1740 100644 --- a/svtools/source/table/makefile.mk +++ b/svtools/source/table/makefile.mk @@ -45,7 +45,8 @@ SLOFILES=\ $(SLO)$/gridtablerenderer.obj \ $(SLO)$/tablegeometry.obj \ $(SLO)$/defaultinputhandler.obj \ - $(SLO)$/tabledatawindow.obj + $(SLO)$/tabledatawindow.obj \ + $(SLO)$/cellvalueconversion.obj #LIB1TARGET= $(SLB)$/$(TARGET).lib #LIB1OBJFILES= $(SLOFILES) diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 81d188745f69..d8a743d98c9e 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -34,8 +34,7 @@ #include "tablecontrol_impl.hxx" #include "tablegeometry.hxx" - -#include +#include "cellvalueconversion.hxx" #include #include @@ -50,12 +49,6 @@ namespace svt { namespace table { //........................................................................ - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::graphic::XGraphic; - using ::com::sun::star::uno::Any; - /** === end UNO using === **/ - //==================================================================== //= TempHideCursor //==================================================================== @@ -1141,6 +1134,7 @@ namespace svt { namespace table } if ( !colCount ) continue; + // paint all cells in this row for ( TableCellGeometry aCell( aRowIterator, m_nLeftColumn ); aCell.isValid(); @@ -1148,24 +1142,8 @@ namespace svt { namespace table ) { bool isSelectedColumn = false; - - Any aCellContent; - m_pModel->getCellContent( aRowIterator.getRow(), aCell.getColumn(), aCellContent ); - - Reference< XGraphic > xGraphic; - if ( aCellContent >>= xGraphic ) - { - Image* pImage = new Image(xGraphic); - if(pImage!=NULL) - pRenderer->PaintCellImage( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, - *m_pDataWindow, aCell.getRect(), rStyle, pImage ); - } - else - { - ::rtl::OUString sContent = convertToString( aCellContent ); - pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, - *m_pDataWindow, aCell.getRect(), rStyle, sContent ); - } + pRenderer->PaintCell( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow, + *m_pDataWindow, aCell.getRect(), rStyle ); } } } @@ -1872,7 +1850,7 @@ namespace svt { namespace table { ::com::sun::star::uno::Any content; m_pModel->getCellContent( i_row, i_col, content ); - return convertToString( content ); + return CellValueConversion::convertToString( content ); } //-------------------------------------------------------------------- @@ -2304,24 +2282,8 @@ namespace svt { namespace table // TODO: isnt' it that this might be done repeatedly? } + //-------------------------------------------------------------------- - rtl::OUString TableControl_Impl::convertToString(const ::com::sun::star::uno::Any& value) - { - sal_Int32 nInt = 0; - sal_Bool bBool = false; - double fDouble = 0; - ::rtl::OUString sNewString; - ::rtl::OUString sConvertString; - if(value >>= sConvertString) - sNewString = sConvertString; - else if(value >>= nInt) - sNewString = sConvertString.valueOf(nInt); - else if(value >>= bBool) - sNewString = sConvertString.valueOf(bBool); - else if(value >>= fDouble) - sNewString = sConvertString.valueOf(fDouble); - return sNewString; - } Rectangle TableControl_Impl::calcHeaderRect(bool bColHeader) { Rectangle aRectTable, aRectTableWithHeaders; @@ -2334,6 +2296,8 @@ namespace svt { namespace table else return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height())); } + + //-------------------------------------------------------------------- Rectangle TableControl_Impl::calcTableRect() { Rectangle aRect; diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 9276f8ab95c7..024e6915f367 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -266,7 +266,6 @@ namespace svt { namespace table ScrollBar* getHorzScrollbar(); ScrollBar* getVertScrollbar(); - ::rtl::OUString convertToString(const ::com::sun::star::uno::Any& _value); Rectangle calcHeaderRect(bool bColHeader); Rectangle calcTableRect(); diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 8b323648a887..668044ba6b40 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -41,6 +41,7 @@ #include #include #include +#include using ::rtl::OUString; using namespace ::com::sun::star; @@ -199,13 +200,13 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: return uno::makeAny( (sal_Bool)sal_True ); case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND: - return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) ); + return uno::makeAny( com::sun::star::util::Color( COL_TRANSPARENT ) ); case BASEPROPERTY_GRID_HEADER_BACKGROUND: - return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) ); + return uno::makeAny( com::sun::star::util::Color( COL_TRANSPARENT ) ); case BASEPROPERTY_GRID_LINE_COLOR: - return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) ); + return uno::makeAny( com::sun::star::util::Color( COL_TRANSPARENT ) ); case BASEPROPERTY_GRID_ROW_BACKGROUND: - return uno::makeAny(com::sun::star::util::Color(0xFFFFFF) ); + return uno::makeAny(com::sun::star::util::Color( COL_TRANSPARENT ) ); default: return UnoControlModel::ImplGetDefaultValue( nPropId ); } -- cgit v1.2.3 From 5d1ef9978feb9479746f9039f2d6ca17f9e2052e Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 4 Jan 2011 10:37:54 +0100 Subject: gridsort: getCellContent: (col,row) instead of (row,col) parameters --- svtools/inc/svtools/table/tablemodel.hxx | 2 +- svtools/source/table/gridtablerenderer.cxx | 2 +- svtools/source/table/tablecontrol.cxx | 2 +- svtools/source/table/tablecontrol_impl.cxx | 4 ++-- svtools/source/uno/unocontroltablemodel.cxx | 6 +++--- svtools/source/uno/unocontroltablemodel.hxx | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index a9137eab28a2..cdbc1be6a3cd 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -408,7 +408,7 @@ namespace svt { namespace table /** retrieves the content of the given cell */ - virtual void getCellContent( RowPos const i_row, ColPos const i_col, ::com::sun::star::uno::Any& o_cellContent ) = 0; + virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ) = 0; /** retrieves title of a given row */ diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 8eec7b8d437e..9e7a5213c098 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -367,7 +367,7 @@ namespace svt { namespace table void GridTableRenderer::impl_paintCellContent( CellRenderContext const & i_context ) { Any aCellContent; - m_pImpl->rModel.getCellContent( m_pImpl->nCurrentRow, i_context.nColumn, aCellContent ); + m_pImpl->rModel.getCellContent( i_context.nColumn, m_pImpl->nCurrentRow, aCellContent ); const Reference< XGraphic > xGraphic( aCellContent, UNO_QUERY ); if ( xGraphic.is() ) diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 94932fdcdd01..08227b9abd91 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -384,7 +384,7 @@ namespace svt { namespace table ::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos ) const { Any aCellContent; - GetModel()->getCellContent( _nRowPos, _nColPos, aCellContent ); + GetModel()->getCellContent( _nColPos, _nRowPos, aCellContent ); return aCellContent; } diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index d8a743d98c9e..c2f9465bfdd8 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -178,7 +178,7 @@ namespace svt { namespace table { return -1; } - virtual void getCellContent( RowPos const i_row, ColPos const i_col, ::com::sun::star::uno::Any& o_cellContent ) + virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ) { (void)i_row; (void)i_col; @@ -1849,7 +1849,7 @@ namespace svt { namespace table ::rtl::OUString TableControl_Impl::getCellContentAsString( RowPos const i_row, ColPos const i_col ) { ::com::sun::star::uno::Any content; - m_pModel->getCellContent( i_row, i_col, content ); + m_pModel->getCellContent( i_col, i_row, content ); return CellValueConversion::convertToString( content ); } diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index dfbde6cb4058..36532222dfe4 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -503,7 +503,7 @@ using namespace ::com::sun::star::awt::grid; } //-------------------------------------------------------------------- - void UnoControlTableModel::getCellContent( RowPos const i_row, ColPos const i_col, Any& o_cellContent ) + void UnoControlTableModel::getCellContent( ColPos const i_col, RowPos const i_row, Any& o_cellContent ) { ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( i_row < m_pImpl->aCellContent.size() ), "UnoControlTableModel::getCellContent: illegal row index!" ); @@ -517,10 +517,10 @@ using namespace ::com::sun::star::awt::grid; void UnoControlTableModel::updateCellContent( RowPos const i_row, ColPos const i_col, Any const & i_cellContent ) { ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( i_row < m_pImpl->aCellContent.size() ), - "UnoControlTableModel::getCellContent: illegal row index!" ); + "UnoControlTableModel::updateCellContent: illegal row index!" ); ::std::vector< Any >& rRowContent( m_pImpl->aCellContent[ i_row ] ); ENSURE_OR_RETURN_VOID( ( i_col >= 0 ) && ( i_col < rRowContent.size() ), - "UnoControlTableModel::getCellContent: illegal column index" ); + "UnoControlTableModel::updateCellContent: illegal column index" ); rRowContent[ i_col ] = i_cellContent; // TODO: listener notification diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 9eaa202f8cd0..1f13b776a49f 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -132,7 +132,7 @@ class UnoControlTableModel : public ITableModel virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const; virtual void addTableModelListener( const PTableModelListener& i_listener ); virtual void removeTableModelListener( const PTableModelListener& i_listener ); - virtual void getCellContent( RowPos const i_row, ColPos const i_col, ::com::sun::star::uno::Any& o_cellContent ); + virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ); virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const; virtual ::com::sun::star::util::Color getLineColor(); virtual ::com::sun::star::util::Color getHeaderBackgroundColor(); -- cgit v1.2.3 From d3dcce24340e342fb1ab6c7071a0f645130e1ba3 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 4 Jan 2011 15:09:05 +0100 Subject: gridsort: make build on unxlngi6 --- svtools/source/table/tablecontrol_impl.cxx | 2 +- svtools/source/uno/unocontroltablemodel.cxx | 12 ++++++------ toolkit/prj/build.lst | 2 +- toolkit/source/controls/grid/defaultgridcolumnmodel.cxx | 3 ++- toolkit/source/controls/grid/defaultgriddatamodel.cxx | 8 ++++++-- toolkit/source/controls/grid/defaultgriddatamodel.hxx | 3 ++- toolkit/source/controls/grid/gridcolumn.cxx | 3 ++- toolkit/source/controls/grid/grideventforwarder.cxx | 4 ++-- toolkit/source/controls/grid/grideventforwarder.hxx | 4 ++-- 9 files changed, 24 insertions(+), 17 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index c2f9465bfdd8..dab7df674ed2 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -836,7 +836,7 @@ namespace svt { namespace table if ( m_aColumnWidths.empty() ) impl_ni_updateColumnWidths(); - OSL_ENSURE( m_aColumnWidths.size() == m_nColumnCount, "TableControl_Impl::impl_ni_updateScrollbars: inconsistency!" ); + OSL_ENSURE( m_aColumnWidths.size() == size_t( m_nColumnCount ), "TableControl_Impl::impl_ni_updateScrollbars: inconsistency!" ); const long nAllColumnsWidth = m_aColumnWidths.empty() ? 0 : m_aColumnWidths[ m_nColumnCount - 1 ].getEnd() - m_aColumnWidths[ 0 ].getStart(); diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 36532222dfe4..fd40501dce2d 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -349,7 +349,7 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- void UnoControlTableModel::insertColumn( ColPos const i_position, const PColumnModel& i_column ) { - ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( i_position <= m_pImpl->aColumns.size() ), "illegal position!" ); + ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ), "illegal position!" ); ENSURE_OR_RETURN_VOID( !!i_column, "illegal column" ); m_pImpl->aColumns.insert( m_pImpl->aColumns.begin() + i_position, i_column ); @@ -505,10 +505,10 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- void UnoControlTableModel::getCellContent( ColPos const i_col, RowPos const i_row, Any& o_cellContent ) { - ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( i_row < m_pImpl->aCellContent.size() ), + ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( size_t( i_row ) < m_pImpl->aCellContent.size() ), "UnoControlTableModel::getCellContent: illegal row index!" ); ::std::vector< Any >& rRowContent( m_pImpl->aCellContent[ i_row ] ); - ENSURE_OR_RETURN_VOID( ( i_col >= 0 ) && ( i_col < rRowContent.size() ), + ENSURE_OR_RETURN_VOID( ( i_col >= 0 ) && ( size_t( i_col ) < rRowContent.size() ), "UnoControlTableModel::getCellContent: illegal column index" ); o_cellContent = rRowContent[ i_col ]; } @@ -516,10 +516,10 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- void UnoControlTableModel::updateCellContent( RowPos const i_row, ColPos const i_col, Any const & i_cellContent ) { - ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( i_row < m_pImpl->aCellContent.size() ), + ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( size_t( i_row ) < m_pImpl->aCellContent.size() ), "UnoControlTableModel::updateCellContent: illegal row index!" ); ::std::vector< Any >& rRowContent( m_pImpl->aCellContent[ i_row ] ); - ENSURE_OR_RETURN_VOID( ( i_col >= 0 ) && ( i_col < rRowContent.size() ), + ENSURE_OR_RETURN_VOID( ( i_col >= 0 ) && ( size_t( i_col ) < rRowContent.size() ), "UnoControlTableModel::updateCellContent: illegal column index" ); rRowContent[ i_col ] = i_cellContent; @@ -545,7 +545,7 @@ using namespace ::com::sun::star::awt::grid; //-------------------------------------------------------------------- ::rtl::OUString UnoControlTableModel::getRowHeader( RowPos const i_rowPos ) const { - ENSURE_OR_RETURN( ( i_rowPos >= 0 ) && ( i_rowPos < m_pImpl->aRowHeadersTitle.size() ), + ENSURE_OR_RETURN( ( i_rowPos >= 0 ) && ( size_t( i_rowPos ) < m_pImpl->aRowHeadersTitle.size() ), "UnoControlTableModel::getRowHeader: illegal row position!", ::rtl::OUString() ); return m_pImpl->aRowHeadersTitle[ i_rowPos ]; } diff --git a/toolkit/prj/build.lst b/toolkit/prj/build.lst index d7e4b24c8b02..753f25a55666 100644 --- a/toolkit/prj/build.lst +++ b/toolkit/prj/build.lst @@ -1,4 +1,4 @@ -ti toolkit : vcl NULL +ti toolkit : vcl test NULL ti toolkit usr1 - all ti_mkout NULL ti toolkit\prj get - all ti_prj NULL ti toolkit\inc nmake - all ti_inc NULL diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index c1cafd568326..8537a03321aa 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -77,7 +77,8 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ DefaultGridColumnModel::DefaultGridColumnModel( DefaultGridColumnModel const & i_copySource ) - :DefaultGridColumnModel_Base( m_aMutex ) + :cppu::BaseMutex() + ,DefaultGridColumnModel_Base( m_aMutex ) ,m_aContext( i_copySource.m_aContext ) ,m_aContainerListeners( m_aMutex ) ,m_aColumns() diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index eb6f777c3b41..be3dd303a566 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -67,7 +67,9 @@ namespace toolkit //================================================================================================================== //------------------------------------------------------------------------------------------------------------------ DefaultGridDataModel::DefaultGridDataModel() - :m_nRowHeight(0) + :DefaultGridDataModel_Base() + ,MutexAndBroadcastHelper() + ,m_nRowHeight(0) ,m_aRowHeaders() ,m_nRowHeaderWidth(10) { @@ -75,7 +77,9 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ DefaultGridDataModel::DefaultGridDataModel( DefaultGridDataModel const & i_copySource ) - :m_nRowHeight( i_copySource.m_nRowHeight ) + :DefaultGridDataModel_Base() + ,MutexAndBroadcastHelper() + ,m_nRowHeight( i_copySource.m_nRowHeight ) ,m_aData( i_copySource.m_aData ) ,m_aRowHeaders( i_copySource.m_aRowHeaders ) ,m_nRowHeaderWidth( i_copySource.m_nRowHeaderWidth ) diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 242c8ba514ab..bfb67c7fea2a 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -52,7 +52,8 @@ namespace toolkit enum broadcast_type { row_added, row_removed, data_changed}; -class DefaultGridDataModel : public ::cppu::WeakImplHelper2< XGridDataModel, XServiceInfo >, +typedef ::cppu::WeakImplHelper2< XGridDataModel, XServiceInfo > DefaultGridDataModel_Base; +class DefaultGridDataModel : public DefaultGridDataModel_Base, public MutexAndBroadcastHelper { public: diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 576871fc677a..d681a3101b12 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -68,7 +68,8 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ GridColumn::GridColumn( GridColumn const & i_copySource ) - :GridColumn_Base( m_aMutex ) + :cppu::BaseMutex() + ,GridColumn_Base( m_aMutex ) ,m_aIdentifier( i_copySource.m_aIdentifier ) ,m_nIndex( i_copySource.m_nIndex ) ,m_nColumnWidth( i_copySource.m_nColumnWidth ) diff --git a/toolkit/source/controls/grid/grideventforwarder.cxx b/toolkit/source/controls/grid/grideventforwarder.cxx index 2c3d740af04e..2c99acb86959 100755 --- a/toolkit/source/controls/grid/grideventforwarder.cxx +++ b/toolkit/source/controls/grid/grideventforwarder.cxx @@ -69,13 +69,13 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridEventForwarder::acquire() + void SAL_CALL GridEventForwarder::acquire() throw() { m_parent.acquire(); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridEventForwarder::release() + void SAL_CALL GridEventForwarder::release() throw() { m_parent.release(); } diff --git a/toolkit/source/controls/grid/grideventforwarder.hxx b/toolkit/source/controls/grid/grideventforwarder.hxx index 3066ead79c94..93905b06f492 100755 --- a/toolkit/source/controls/grid/grideventforwarder.hxx +++ b/toolkit/source/controls/grid/grideventforwarder.hxx @@ -57,8 +57,8 @@ namespace toolkit public: // XInterface - virtual void SAL_CALL acquire(); - virtual void SAL_CALL release(); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); // XGridDataListener virtual void SAL_CALL rowAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From b198150a3cdb7f1f3838bf39853f2ea680bcaf6c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 4 Jan 2011 22:23:17 +0100 Subject: gridsort: don't let the SVTXGridControl listen for XGridColumn changes. Instead, the non-UNO wrapper around the XGridColumn (UnoControlTableColumn, implementing IColumnModel) should do this, and then multiplex the changes to the TableControl(_Impl) instance. This way, other IColumnModel implementations also properly trigger control updates, provided they simply properly notify their changes. --- svtools/inc/svtools/table/tablemodel.hxx | 22 ++ svtools/source/table/tablecontrol_impl.cxx | 35 +++ svtools/source/table/tablecontrol_impl.hxx | 2 + svtools/source/uno/makefile.mk | 1 + svtools/source/uno/svtxgridcontrol.cxx | 78 +---- svtools/source/uno/svtxgridcontrol.hxx | 10 +- svtools/source/uno/unocontroltablemodel.cxx | 469 +++++++++++++--------------- svtools/source/uno/unocontroltablemodel.hxx | 98 +++--- svtools/source/uno/unogridcolumnfacade.cxx | 362 +++++++++++++++++++++ svtools/source/uno/unogridcolumnfacade.hxx | 104 ++++++ 10 files changed, 792 insertions(+), 389 deletions(-) create mode 100755 svtools/source/uno/unogridcolumnfacade.cxx create mode 100755 svtools/source/uno/unogridcolumnfacade.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index cdbc1be6a3cd..dc25788bc491 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -66,6 +66,18 @@ namespace svt { namespace table ScrollbarShowAlways }; + //==================================================================== + //= ITableModelListener + //==================================================================== + typedef sal_Int32 ColumnAttributeGroup; + #define COL_ATTRS_NONE (0x00000000) + /// denotes column attributes related to the width of the column + #define COL_ATTRS_WIDTH (0x00000001) + /// denotes column attributes related to the appearance of the column, i.e. those relevant for rendering + #define COL_ATTRS_APPEARANCE (0x00000002) + /// denotes the entirety of column attributes + #define COL_ATTRS_ALL (0xFFFFFFFF) + //==================================================================== //= ITableModelListener //==================================================================== @@ -137,6 +149,16 @@ namespace svt { namespace table */ virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ) = 0; + /** notifies the listener that attributes of a given column changed + + @param i_column + the position of the column whose attributes changed + @param i_attributeGroup + a combination of one or more COL_ATTRS_* flags, denoting the attribute group(s) + in which changes occurred. + */ + virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ) = 0; + /// deletes the listener instance virtual ~ITableModelListener(){}; }; diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index dab7df674ed2..dc6dfc352137 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -36,6 +36,7 @@ #include "tablegeometry.hxx" #include "cellvalueconversion.hxx" +#include #include #include #include @@ -381,6 +382,7 @@ namespace svt { namespace table ,m_bResizingColumn ( false ) ,m_nResizingColumn ( 0 ) ,m_bResizingGrid ( false ) + ,m_bUpdatingColWidths ( false ) #if DBG_UTIL ,m_nRequiredInvariants ( INV_SCROLL_POSITION ) #endif @@ -500,6 +502,34 @@ namespace svt { namespace table OSL_UNUSED( lastRow ); } + //-------------------------------------------------------------------- + void TableControl_Impl::columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ) + { + ColumnAttributeGroup nGroup( i_attributeGroup ); + if ( nGroup & COL_ATTRS_APPEARANCE ) + { + Rectangle aAllCellsArea; + impl_getAllVisibleCellsArea( aAllCellsArea ); + + const TableColumnGeometry aColumn( *this, aAllCellsArea, i_column ); + if ( aColumn.isValid() ) + m_rAntiImpl.Invalidate( aColumn.getRect() ); + + nGroup &= ~COL_ATTRS_APPEARANCE; + } + + if ( nGroup & COL_ATTRS_WIDTH ) + { + if ( !m_bUpdatingColWidths ) + impl_ni_updateColumnWidths(); + + nGroup &= ~COL_ATTRS_WIDTH; + } + + OSL_ENSURE( ( nGroup == COL_ATTRS_NONE ) || ( i_attributeGroup == COL_ATTRS_ALL ), + "TableControl_Impl::columnChanged: don't know how to handle this change!" ); + } + //-------------------------------------------------------------------- void TableControl_Impl::impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const { @@ -575,6 +605,8 @@ namespace svt { namespace table //-------------------------------------------------------------------- void TableControl_Impl::impl_ni_updateColumnWidths() { + ENSURE_OR_RETURN_VOID( !m_bUpdatingColWidths, "TableControl_Impl::impl_ni_updateColumnWidths: recursive call detected!" ); + m_aColumnWidths.resize( 0 ); if ( !m_pModel ) return; @@ -583,6 +615,9 @@ namespace svt { namespace table if ( colCount == 0 ) return; + m_bUpdatingColWidths = true; + const ::comphelper::FlagGuard aWidthUpdateFlag( m_bUpdatingColWidths ); + m_aColumnWidths.reserve( colCount ); std::vector aPrePixelWidths(0); diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 024e6915f367..4c5038de2cc0 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -158,6 +158,7 @@ namespace svt { namespace table bool m_bResizingColumn; ColPos m_nResizingColumn; bool m_bResizingGrid; + bool m_bUpdatingColWidths; rtl::OUString m_aTooltipText; #if DBG_UTIL @@ -276,6 +277,7 @@ namespace svt { namespace table virtual void columnsRemoved( ColPos first, ColPos last ); virtual void columnMoved( ColPos oldIndex, ColPos newIndex ); virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ); + virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ); private: /** toggles the cursor visibility diff --git a/svtools/source/uno/makefile.mk b/svtools/source/uno/makefile.mk index 7c1c44006047..e04ea6a9d416 100644 --- a/svtools/source/uno/makefile.mk +++ b/svtools/source/uno/makefile.mk @@ -49,6 +49,7 @@ SLOFILES= \ $(SLO)$/toolboxcontroller.obj \ $(SLO)$/treecontrolpeer.obj \ $(SLO)$/unocontroltablemodel.obj \ + $(SLO)$/unogridcolumnfacade.obj \ $(SLO)$/unoevent.obj \ $(SLO)$/unoiface.obj \ $(SLO)$/unoimap.obj \ diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 5f3dce2668a7..9ba2e8cd6745 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -193,7 +193,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_GRID_HEADER_BACKGROUND: { - sal_Int32 colorHeader = 0xFFFFFF; + sal_Int32 colorHeader = COL_TRANSPARENT; if( aValue >>= colorHeader ) { m_pTableModel->setHeaderBackgroundColor(colorHeader); @@ -202,7 +202,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_GRID_LINE_COLOR: { - sal_Int32 colorLine = 0xFFFFFF; + sal_Int32 colorLine = COL_TRANSPARENT; if( aValue >>= colorLine ) { m_pTableModel->setLineColor(colorLine); @@ -211,7 +211,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND: { - sal_Int32 colorEvenRow = 0xFFFFFF; + sal_Int32 colorEvenRow = COL_TRANSPARENT; if( aValue >>= colorEvenRow ) { m_pTableModel->setEvenRowBackgroundColor(colorEvenRow); @@ -220,7 +220,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_GRID_ROW_BACKGROUND: { - sal_Int32 colorBackground = 0xFFFFFF; + sal_Int32 colorBackground = COL_TRANSPARENT; if( aValue >>= colorBackground ) { m_pTableModel->setOddRowBackgroundColor(colorBackground); @@ -479,52 +479,6 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri } } -void SAL_CALL SVTXGridControl::columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent& Event ) throw (::com::sun::star::uno::RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::columnChanged: no control (anymore)!" ); - - if(Event.valueName == rtl::OUString::createFromAscii("ColumnResize")) - { - bool resizable = m_pTableModel->getColumnModel( Event.index )->isResizable(); - Event.newValue>>=resizable; - m_pTableModel->getColumnModel( Event.index )->setResizable(resizable); - } - else if(Event.valueName == rtl::OUString::createFromAscii("ColWidth")) - { - sal_Int32 colWidth = m_pTableModel->getColumnModel( Event.index )->getWidth(); - Event.newValue>>=colWidth; - m_pTableModel->getColumnModel( Event.index )->setWidth(colWidth); - } - else if(Event.valueName == rtl::OUString::createFromAscii("MaxWidth")) - { - sal_Int32 maxWidth = m_pTableModel->getColumnModel( Event.index )->getMaxWidth(); - Event.newValue>>=maxWidth; - m_pTableModel->getColumnModel( Event.index )->setMaxWidth(maxWidth); - } - else if(Event.valueName == rtl::OUString::createFromAscii("MinWidth")) - { - sal_Int32 minWidth = m_pTableModel->getColumnModel( Event.index )->getMinWidth(); - Event.newValue>>=minWidth; - m_pTableModel->getColumnModel( Event.index )->setMinWidth(minWidth); - } - else if(Event.valueName == rtl::OUString::createFromAscii("PrefWidth")) - { - sal_Int32 prefWidth = m_pTableModel->getColumnModel( Event.index )->getPreferredWidth(); - Event.newValue>>=prefWidth; - m_pTableModel->getColumnModel( Event.index )->setPreferredWidth(prefWidth); - } - else if(Event.valueName == rtl::OUString::createFromAscii("HAlign")) - { - ::com::sun::star::style::HorizontalAlignment hAlign = m_pTableModel->getColumnModel( Event.index )->getHorizontalAlign(); - Event.newValue>>=hAlign; - m_pTableModel->getColumnModel( Event.index )->setHorizontalAlign(hAlign); - } - pTable->Invalidate(); -} - void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -591,26 +545,18 @@ void SAL_CALL SVTXGridControl::elementInserted( const ContainerEvent& i_event ) sal_Int32 nIndex( m_pTableModel->getColumnCount() ); OSL_VERIFY( i_event.Accessor >>= nIndex ); - const PColumnModel tableColumn( new UnoControlTableColumn( xGridColumn ) ); - m_pTableModel->insertColumn( nIndex, tableColumn ); - - impl_setColumnListening( Reference< XGridColumn >( i_event.Element, UNO_QUERY ), true ); + m_pTableModel->insertColumn( nIndex, xGridColumn ); } //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) { - impl_setColumnListening( Reference< XGridColumn >( i_event.Element, UNO_QUERY ), false ); - // TODO: remove the respective column from our table model } //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) { - impl_setColumnListening( Reference< XGridColumn >( i_event.ReplacedElement, UNO_QUERY ), false ); - impl_setColumnListening( Reference< XGridColumn >( i_event.Element, UNO_QUERY ), true ); - // TODO: replace the respective column in our table model } @@ -947,10 +893,7 @@ void SVTXGridControl::impl_updateColumnsFromModel_nothrow() { ENSURE_OR_CONTINUE( colRef->is(), "illegal column!" ); - impl_setColumnListening( *colRef, true ); - - UnoControlTableColumn* tableColumn = new UnoControlTableColumn( *colRef ); - m_pTableModel->appendColumn( PColumnModel( tableColumn ) ); + m_pTableModel->appendColumn( *colRef ); } } @@ -961,12 +904,3 @@ void SVTXGridControl::impl_updateColumnsFromModel_nothrow() } } -void SVTXGridControl::impl_setColumnListening( const Reference< XGridColumn >& i_column, bool const i_start ) -{ - ENSURE_OR_RETURN_VOID( i_column.is(), "SVTXGridControl::impl_setColumnListening: illegal column!" ); - - if ( i_start ) - i_column->addGridColumnListener( this ); - else - i_column->removeGridColumnListener( this ); -} diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index ef4dc7225bf5..ce1b7edd0b09 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -48,10 +47,9 @@ using namespace ::svt::table; -typedef ::cppu::ImplInheritanceHelper4 < VCLXWindow +typedef ::cppu::ImplInheritanceHelper3 < VCLXWindow , ::com::sun::star::awt::grid::XGridControl , ::com::sun::star::awt::grid::XGridDataListener - , ::com::sun::star::awt::grid::XGridColumnListener , ::com::sun::star::container::XContainerListener > SVTXGridControl_Base; class SVTXGridControl : public SVTXGridControl_Base @@ -86,9 +84,6 @@ public: virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); - //XGridColumnListener overridables - virtual void SAL_CALL columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent & Event) throw (::com::sun::star::uno::RuntimeException); - // XEventListener virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); @@ -122,9 +117,6 @@ protected: virtual void SetWindow( Window* pWindow ); private: - void impl_removeAllColumns_nothrow(); void impl_updateColumnsFromModel_nothrow(); - - void impl_setColumnListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn >& i_column, bool const i_start ); }; #endif // _SVT_GRIDCONTROL_HXX_ diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index fd40501dce2d..8bfc1d1400f2 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -27,201 +27,55 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svtools.hxx" +#include "unocontroltablemodel.hxx" +#include "unogridcolumnfacade.hxx" + #include "svtools/table/defaultinputhandler.hxx" #include "svtools/table/gridtablerenderer.hxx" #include "svtools/table/tablecontrol.hxx" -#include "unocontroltablemodel.hxx" +/** === begin UNO includes === **/ #include #include -#include +#include +/** === end UNO includes === **/ -#include #include -#include -#include #include #include - -using ::rtl::OUString; -using namespace ::svt::table; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt::grid; - - //-------------------------------------------------------------------- - namespace - { - template< class ATTRIBUTE_TYPE > - void lcl_set( Reference< XGridColumn > const & i_column, void ( SAL_CALL XGridColumn::*i_setter )( ATTRIBUTE_TYPE ), - ATTRIBUTE_TYPE i_value ) - { - try - { - (i_column.get()->*i_setter) ( i_value ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - template< class ATTRIBUTE_TYPE > - ATTRIBUTE_TYPE lcl_get( Reference< XGridColumn > const & i_column, ATTRIBUTE_TYPE ( SAL_CALL XGridColumn::*i_getter )() ) - { - ATTRIBUTE_TYPE value = ATTRIBUTE_TYPE(); - try - { - value = (i_column.get()->*i_getter)(); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return value; - } - } - - //-------------------------------------------------------------------- - UnoControlTableColumn::UnoControlTableColumn( const Reference< XGridColumn >& i_gridColumn ) - :m_xGridColumn( i_gridColumn, UNO_QUERY_THROW ) - { - } - - //-------------------------------------------------------------------- - Any UnoControlTableColumn::getID() const - { - Any aID; - try - { - aID = m_xGridColumn->getIdentifier(); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return aID; - } - - //-------------------------------------------------------------------- - void UnoControlTableColumn::setID( const Any& i_ID ) - { - try - { - m_xGridColumn->setIdentifier( i_ID ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - //-------------------------------------------------------------------- - String UnoControlTableColumn::getName() const - { - ::rtl::OUString sName; - try - { - sName = m_xGridColumn->getTitle(); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return sName; - } - - //-------------------------------------------------------------------- - void UnoControlTableColumn::setName( const String& _rName ) - { - try - { - m_xGridColumn->setTitle( _rName ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - //-------------------------------------------------------------------- - bool UnoControlTableColumn::isResizable() const - { - return lcl_get( m_xGridColumn, &XGridColumn::getResizeable ); - } - - //-------------------------------------------------------------------- - void UnoControlTableColumn::setResizable( bool _bResizable ) - { - return lcl_set( m_xGridColumn, &XGridColumn::setResizeable, sal_Bool( _bResizable ) ); - } - - //-------------------------------------------------------------------- - TableMetrics UnoControlTableColumn::getWidth() const - { - return lcl_get( m_xGridColumn, &XGridColumn::getColumnWidth ); - } - - //-------------------------------------------------------------------- - void UnoControlTableColumn::setWidth( TableMetrics _nWidth ) - { - lcl_set( m_xGridColumn, &XGridColumn::setColumnWidth, _nWidth ); - } - - //-------------------------------------------------------------------- - TableMetrics UnoControlTableColumn::getMinWidth() const - { - return lcl_get( m_xGridColumn, &XGridColumn::getMinWidth ); - } - - //-------------------------------------------------------------------- - void UnoControlTableColumn::setMinWidth( TableMetrics _nMinWidth ) - { - lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMinWidth ); - } - - //-------------------------------------------------------------------- - TableMetrics UnoControlTableColumn::getMaxWidth() const - { - return lcl_get( m_xGridColumn, &XGridColumn::getMaxWidth ); - } - - //-------------------------------------------------------------------- - void UnoControlTableColumn::setMaxWidth( TableMetrics _nMaxWidth ) - { - lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMaxWidth ); - } - - //-------------------------------------------------------------------- - TableMetrics UnoControlTableColumn::getPreferredWidth() const - { - return lcl_get( m_xGridColumn, &XGridColumn::getPreferredWidth ); - } - - //-------------------------------------------------------------------- - void UnoControlTableColumn::setPreferredWidth( TableMetrics _nPrefWidth ) - { - lcl_set( m_xGridColumn, &XGridColumn::setPreferredWidth, _nPrefWidth ); - } - - //-------------------------------------------------------------------- - ::com::sun::star::style::HorizontalAlignment UnoControlTableColumn::getHorizontalAlign() - { - return lcl_get( m_xGridColumn, &XGridColumn::getHorizontalAlign ); - } - - //-------------------------------------------------------------------- - void UnoControlTableColumn::setHorizontalAlign( com::sun::star::style::HorizontalAlignment _align ) - { - lcl_set( m_xGridColumn, &XGridColumn::setHorizontalAlign, _align ); - } - - //==================================================================== - //= DefaultTableModel_Impl - //==================================================================== +#include +#include + +// ..................................................................................................................... +namespace svt { namespace table +{ +// ..................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::awt::grid::XGridColumn; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::awt::grid::XGridColumnListener; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::awt::grid::GridColumnEvent; + using ::com::sun::star::uno::Any; + using ::com::sun::star::style::HorizontalAlignment_LEFT; + using ::com::sun::star::style::HorizontalAlignment; + /** === end UNO using === **/ + + //================================================================================================================== + //= UnoControlTableModel_Impl + //================================================================================================================== typedef ::std::vector< PTableModelListener > ModellListeners; + typedef ::std::vector< PColumnModel > ColumnModels; struct UnoControlTableModel_Impl { - ::std::vector< PColumnModel > aColumns; + ColumnModels aColumns; TableSize nRowCount; bool bHasColumnHeaders; bool bHasRowHeaders; @@ -256,103 +110,135 @@ using namespace ::com::sun::star::awt::grid; ,nRowHeaderWidth ( 10 ) ,aRowHeadersTitle ( ) ,aCellContent ( ) - ,m_nLineColor ( 0xFFFFFF ) - ,m_nHeaderColor ( 0xFFFFFF ) + ,m_nLineColor ( COL_TRANSPARENT ) + ,m_nHeaderColor ( COL_TRANSPARENT ) ,m_nTextColor ( 0 )//black as default - ,m_nRowColor1 ( 0xFFFFFF ) - ,m_nRowColor2 ( 0xFFFFFF ) + ,m_nRowColor1 ( COL_TRANSPARENT ) + ,m_nRowColor2 ( COL_TRANSPARENT ) ,m_eVerticalAlign ( com::sun::star::style::VerticalAlignment_TOP ) { } }; - //==================================================================== + //================================================================================================================== //= UnoControlTableModel - //==================================================================== - //-------------------------------------------------------------------- + //================================================================================================================== +#ifdef DBG_UTIL + const char* UnoControlTableModel_checkInvariants( const void* _pInstance ) + { + return static_cast< const UnoControlTableModel* >( _pInstance )->checkInvariants(); + } + + //------------------------------------------------------------------------------------------------------------------ + const char* UnoControlTableModel::checkInvariants() const + { + if ( m_pImpl->aRowHeadersTitle.size() != m_pImpl->aCellContent.size() ) + return "inconsistency between data and row header arrays"; + + // TODO: more? + + return NULL; + } +#endif + +#define DBG_CHECK_ME() \ + DBG_TESTSOLARMUTEX(); \ + DBG_CHKTHIS( UnoControlTableModel, UnoControlTableModel_checkInvariants ) + + //------------------------------------------------------------------------------------------------------------------ + DBG_NAME( UnoControlTableModel ) UnoControlTableModel::UnoControlTableModel() :m_pImpl( new UnoControlTableModel_Impl ) { + DBG_CTOR( UnoControlTableModel, UnoControlTableModel_checkInvariants ); m_pImpl->bHasColumnHeaders = true; m_pImpl->bHasRowHeaders = false; m_pImpl->pRenderer.reset( new GridTableRenderer( *this ) ); m_pImpl->pInputHandler.reset( new DefaultInputHandler ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ UnoControlTableModel::~UnoControlTableModel() { + DBG_DTOR( UnoControlTableModel, UnoControlTableModel_checkInvariants ); DELETEZ( m_pImpl ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableSize UnoControlTableModel::getColumnCount() const { + DBG_CHECK_ME(); return (TableSize)m_pImpl->aColumns.size(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableSize UnoControlTableModel::getRowCount() const { + DBG_CHECK_ME(); return m_pImpl->nRowCount; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool UnoControlTableModel::hasColumnHeaders() const { + DBG_CHECK_ME(); return m_pImpl->bHasColumnHeaders; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool UnoControlTableModel::hasRowHeaders() const { + DBG_CHECK_ME(); return m_pImpl->bHasRowHeaders; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setRowHeaders(bool _bRowHeaders) { + DBG_CHECK_ME(); m_pImpl->bHasRowHeaders = _bRowHeaders; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setColumnHeaders(bool _bColumnHeaders) { + DBG_CHECK_ME(); m_pImpl->bHasColumnHeaders = _bColumnHeaders; } - void UnoControlTableModel::setColumnCount(TableSize _nColCount) - { - m_pImpl->aColumns.resize( _nColCount); - } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool UnoControlTableModel::isCellEditable( ColPos col, RowPos row ) const { + DBG_CHECK_ME(); (void)col; (void)row; return false; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ PColumnModel UnoControlTableModel::getColumnModel( ColPos column ) { + DBG_CHECK_ME(); ENSURE_OR_RETURN( ( column >= 0 ) && ( column < getColumnCount() ), "DefaultTableModel::getColumnModel: invalid index!", PColumnModel() ); return m_pImpl->aColumns[ column ]; } - //-------------------------------------------------------------------- - void UnoControlTableModel::appendColumn( const PColumnModel& i_column ) + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::appendColumn( Reference< XGridColumn > const & i_column ) { + DBG_CHECK_ME(); insertColumn( m_pImpl->aColumns.size(), i_column ); } - //-------------------------------------------------------------------- - void UnoControlTableModel::insertColumn( ColPos const i_position, const PColumnModel& i_column ) + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::insertColumn( ColPos const i_position, Reference< XGridColumn > const & i_column ) { - ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ), "illegal position!" ); - ENSURE_OR_RETURN_VOID( !!i_column, "illegal column" ); + DBG_CHECK_ME(); + ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ), "UnoControlTableModel::insertColumn: illegal position!" ); - m_pImpl->aColumns.insert( m_pImpl->aColumns.begin() + i_position, i_column ); + const PColumnModel pColumn( new UnoGridColumnFacade( *this, i_column ) ); + m_pImpl->aColumns.insert( m_pImpl->aColumns.begin() + i_position, pColumn ); // notify listeners ModellListeners aListeners( m_pImpl->m_aListeners ); @@ -365,13 +251,25 @@ using namespace ::com::sun::star::awt::grid; } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::removeAllColumns() { + DBG_CHECK_ME(); if ( m_pImpl->aColumns.empty() ) return; const ColPos nLastIndex = m_pImpl->aColumns.size() - 1; + + // dispose the column instances + for ( ColumnModels::const_iterator col = m_pImpl->aColumns.begin(); + col != m_pImpl->aColumns.end(); + ++col + ) + { + UnoGridColumnFacade* pColumn = dynamic_cast< UnoGridColumnFacade* >( col->get() ); + ENSURE_OR_CONTINUE( pColumn != NULL, "UnoControlTableModel::removeAllColumns: illegal column implementation!" ); + pColumn->dispose(); + } m_pImpl->aColumns.clear(); // notify listeners @@ -385,92 +283,107 @@ using namespace ::com::sun::star::awt::grid; } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ PTableRenderer UnoControlTableModel::getRenderer() const { + DBG_CHECK_ME(); return m_pImpl->pRenderer; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ PTableInputHandler UnoControlTableModel::getInputHandler() const { + DBG_CHECK_ME(); return m_pImpl->pInputHandler; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableMetrics UnoControlTableModel::getRowHeight() const { + DBG_CHECK_ME(); return m_pImpl->nRowHeight; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setRowHeight(TableMetrics _nRowHeight) { + DBG_CHECK_ME(); m_pImpl->nRowHeight = _nRowHeight; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableMetrics UnoControlTableModel::getColumnHeaderHeight() const { + DBG_CHECK_ME(); DBG_ASSERT( hasColumnHeaders(), "DefaultTableModel::getColumnHeaderHeight: invalid call!" ); return m_pImpl->nColumnHeaderHeight; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableMetrics UnoControlTableModel::getRowHeaderWidth() const { + DBG_CHECK_ME(); DBG_ASSERT( hasRowHeaders(), "DefaultTableModel::getRowHeaderWidth: invalid call!" ); return m_pImpl->nRowHeaderWidth; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setColumnHeaderHeight(TableMetrics _nHeight) { + DBG_CHECK_ME(); m_pImpl->nColumnHeaderHeight = _nHeight; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setRowHeaderWidth(TableMetrics _nWidth) { + DBG_CHECK_ME(); m_pImpl->nRowHeaderWidth = _nWidth; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::SetTitleHeight( TableMetrics _nHeight ) { + DBG_CHECK_ME(); DBG_ASSERT( _nHeight > 0, "DefaultTableModel::SetTitleHeight: invalid height value!" ); m_pImpl->nColumnHeaderHeight = _nHeight; // TODO: notification } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::SetHandleWidth( TableMetrics _nWidth ) { + DBG_CHECK_ME(); DBG_ASSERT( _nWidth > 0, "DefaultTableModel::SetHandleWidth: invalid width value!" ); m_pImpl->nRowHeaderWidth = _nWidth; // TODO: notification } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ ScrollbarVisibility UnoControlTableModel::getVerticalScrollbarVisibility() const { + DBG_CHECK_ME(); return m_pImpl->eVScrollMode; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility() const { + DBG_CHECK_ME(); return m_pImpl->eHScrollMode; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::addTableModelListener( const PTableModelListener& i_listener ) { + DBG_CHECK_ME(); ENSURE_OR_RETURN_VOID( !!i_listener, "illegal NULL listener" ); m_pImpl->m_aListeners.push_back( i_listener ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::removeTableModelListener( const PTableModelListener& i_listener ) { + DBG_CHECK_ME(); for ( ModellListeners::iterator lookup = m_pImpl->m_aListeners.begin(); lookup != m_pImpl->m_aListeners.end(); ++lookup @@ -485,26 +398,31 @@ using namespace ::com::sun::star::awt::grid; OSL_ENSURE( false, "UnoControlTableModel::removeTableModelListener: listener is not registered - sure you're doing the right thing here?" ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const { + DBG_CHECK_ME(); m_pImpl->eVScrollMode = i_visibility; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const { + DBG_CHECK_ME(); m_pImpl->eHScrollMode = i_visibility; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setCellContent(const std::vector >& cellContent) { + DBG_CHECK_ME(); m_pImpl->aCellContent = cellContent; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::getCellContent( ColPos const i_col, RowPos const i_row, Any& o_cellContent ) { + DBG_CHECK_ME(); ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( size_t( i_row ) < m_pImpl->aCellContent.size() ), "UnoControlTableModel::getCellContent: illegal row index!" ); ::std::vector< Any >& rRowContent( m_pImpl->aCellContent[ i_row ] ); @@ -513,9 +431,10 @@ using namespace ::com::sun::star::awt::grid; o_cellContent = rRowContent[ i_col ]; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::updateCellContent( RowPos const i_row, ColPos const i_col, Any const & i_cellContent ) { + DBG_CHECK_ME(); ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( size_t( i_row ) < m_pImpl->aCellContent.size() ), "UnoControlTableModel::updateCellContent: illegal row index!" ); ::std::vector< Any >& rRowContent( m_pImpl->aCellContent[ i_row ] ); @@ -526,9 +445,10 @@ using namespace ::com::sun::star::awt::grid; // TODO: listener notification } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setRowHeaderNames( const Sequence< ::rtl::OUString >& i_rowHeaders ) { + DBG_CHECK_ME(); ENSURE_OR_RETURN_VOID( size_t( i_rowHeaders.getLength() ) == m_pImpl->aRowHeadersTitle.size(), "UnoControlTableModel::setRowHeaderNames: illegal number of row headers!" ); // this method is not intended to set a new row count, but only to modify the existing row headers @@ -542,17 +462,19 @@ using namespace ::com::sun::star::awt::grid; // TODO: listener notification } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString UnoControlTableModel::getRowHeader( RowPos const i_rowPos ) const { + DBG_CHECK_ME(); ENSURE_OR_RETURN( ( i_rowPos >= 0 ) && ( size_t( i_rowPos ) < m_pImpl->aRowHeadersTitle.size() ), "UnoControlTableModel::getRowHeader: illegal row position!", ::rtl::OUString() ); return m_pImpl->aRowHeadersTitle[ i_rowPos ]; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::appendRow( Sequence< Any > const & i_rowData, ::rtl::OUString const & i_rowHeader ) { + DBG_CHECK_ME(); ENSURE_OR_RETURN_VOID( i_rowData.getLength() == getColumnCount(), "UnoControlTableModel::appendRow: invalid row data!" ); // add row data @@ -574,9 +496,10 @@ using namespace ::com::sun::star::awt::grid; // TODO: listener notification } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::removeRow( RowPos const i_rowPos ) { + DBG_CHECK_ME(); ENSURE_OR_RETURN_VOID( ( i_rowPos >= 0 ) && ( i_rowPos < getRowCount() ), "UnoControlTableModel::removeRow: illegal row position!" ); if ( hasRowHeaders() ) @@ -590,9 +513,10 @@ using namespace ::com::sun::star::awt::grid; // TODO: listener notification } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::clearAllRows() { + DBG_CHECK_ME(); if ( hasRowHeaders() ) { ::std::vector< ::rtl::OUString > aEmpty; @@ -607,70 +531,123 @@ using namespace ::com::sun::star::awt::grid; // TODO: listener notification } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::util::Color UnoControlTableModel::getLineColor() { + DBG_CHECK_ME(); return m_pImpl->m_nLineColor; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setLineColor( ::com::sun::star::util::Color _rColor ) { + DBG_CHECK_ME(); m_pImpl->m_nLineColor = _rColor; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::util::Color UnoControlTableModel::getHeaderBackgroundColor() { + DBG_CHECK_ME(); return m_pImpl->m_nHeaderColor; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setHeaderBackgroundColor( ::com::sun::star::util::Color _rColor ) { + DBG_CHECK_ME(); m_pImpl->m_nHeaderColor = _rColor; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::util::Color UnoControlTableModel::getTextColor() { + DBG_CHECK_ME(); return m_pImpl->m_nTextColor; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setTextColor( ::com::sun::star::util::Color _rColor ) { + DBG_CHECK_ME(); m_pImpl->m_nTextColor = _rColor; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::util::Color UnoControlTableModel::getOddRowBackgroundColor() { + DBG_CHECK_ME(); return m_pImpl->m_nRowColor1; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setOddRowBackgroundColor( ::com::sun::star::util::Color _rColor ) { + DBG_CHECK_ME(); m_pImpl->m_nRowColor1 = _rColor; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::util::Color UnoControlTableModel::getEvenRowBackgroundColor() { + DBG_CHECK_ME(); return m_pImpl->m_nRowColor2; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setEvenRowBackgroundColor( ::com::sun::star::util::Color _rColor ) { + DBG_CHECK_ME(); m_pImpl->m_nRowColor2 = _rColor; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::style::VerticalAlignment UnoControlTableModel::getVerticalAlign() { + DBG_CHECK_ME(); return m_pImpl->m_eVerticalAlign; } //-------------------------------------------------------------------- void UnoControlTableModel::setVerticalAlign( com::sun::star::style::VerticalAlignment _xAlign ) { - m_pImpl->m_eVerticalAlign = _xAlign; + DBG_CHECK_ME(); + m_pImpl->m_eVerticalAlign = _xAlign; + } + + //-------------------------------------------------------------------- + ColPos UnoControlTableModel::getColumnPos( UnoGridColumnFacade const & i_column ) const + { + DBG_CHECK_ME(); + for ( ColumnModels::const_iterator col = m_pImpl->aColumns.begin(); + col != m_pImpl->aColumns.end(); + ++col + ) + { + if ( &i_column == col->get() ) + return col - m_pImpl->aColumns.begin(); + } + OSL_ENSURE( false, "UnoControlTableModel::getColumnPos: column not found!" ); + return COL_INVALID; + } + + //-------------------------------------------------------------------- + void UnoControlTableModel::notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const + { + DBG_CHECK_ME(); + ENSURE_OR_RETURN_VOID( ( i_columnPos >= 0 ) && ( i_columnPos < getColumnCount() ), + "UnoControlTableModel::notifyColumnChange: invalid column index!" ); + + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->columnChanged( i_columnPos, i_attributeGroup ); + } } +// ..................................................................................................................... +} } // svt::table +// ..................................................................................................................... diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 1f13b776a49f..d6dcf138ccf2 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -28,62 +28,38 @@ #ifndef _UNOCONTROL_TABLEMODEL_HXX_ #define _UNOCONTROL_TABLEMODEL_HXX_ -#include -#include +#include "svtools/table/tablemodel.hxx" +#include "svtools/table/tablecontrol.hxx" + +/** === begin UNO includes === **/ #include #include #include #include #include #include -#include -#include -#include -#include #include #include #include -#include - - -using namespace ::svt::table; - -class UnoControlTableColumn : public IColumnModel -{ - private: - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > - m_xGridColumn; - - public: - UnoControlTableColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn >& i_gridColumn ); - - // IColumnModel overridables - virtual ::com::sun::star::uno::Any - getID() const; - virtual void setID( const ::com::sun::star::uno::Any& i_ID ); - virtual String getName() const; - virtual void setName( const String& _rName ); - virtual bool isResizable() const; - virtual void setResizable( bool _bResizable ); - virtual TableMetrics getWidth() const; - virtual void setWidth( TableMetrics _nWidth ); - virtual TableMetrics getMinWidth() const; - virtual void setMinWidth( TableMetrics _nMinWidth ); - virtual TableMetrics getMaxWidth() const; - virtual void setMaxWidth( TableMetrics _nMaxWidth ); - virtual TableMetrics getPreferredWidth() const; - virtual void setPreferredWidth( TableMetrics _nPrefWidth ); - virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign(); - virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign); +/** === end UNO includes === **/ - private: - UnoControlTableColumn(); // not implemented -}; +#include +#include -struct UnoControlTableModel_Impl; +#include -class UnoControlTableModel : public ITableModel +// ..................................................................................................................... +namespace svt { namespace table { +// ..................................................................................................................... + + //================================================================================================================== + //= UnoControlTableModel + //================================================================================================================== + class UnoGridColumnFacade; + struct UnoControlTableModel_Impl; + class UnoControlTableModel : public ITableModel + { private: UnoControlTableModel_Impl* m_pImpl; @@ -110,11 +86,6 @@ class UnoControlTableModel : public ITableModel /// sets a new width for the handle column (containing the row headers) void SetHandleWidth( TableMetrics _nWidth ); - /// sets the width of a column - inline void SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM ); - /// retrieves the width of a column, in 1/100th millimeters - inline TableMetrics GetColumnWidth( ColPos _nColumn ); - public: // ITableModel overridables virtual TableSize getColumnCount() const; @@ -141,10 +112,9 @@ class UnoControlTableModel : public ITableModel virtual ::com::sun::star::util::Color getEvenRowBackgroundColor(); virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign(); - // column write access - void appendColumn( const PColumnModel& i_column ); - void insertColumn( ColPos const i_position, const PColumnModel& i_column ); + void appendColumn( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); + void insertColumn( ColPos const i_position, ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); void removeAllColumns(); // row write access @@ -160,7 +130,6 @@ class UnoControlTableModel : public ITableModel void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setCellContent(const std::vector >& cellContent); - void setColumnCount(TableSize _nColCount); void setRowHeaders(bool _bRowHeaders); void setColumnHeaders(bool _bColumnHeaders); void setLineColor(::com::sun::star::util::Color _rColor); @@ -169,15 +138,20 @@ class UnoControlTableModel : public ITableModel void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor); void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor); void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); -}; -inline void UnoControlTableModel::SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM ) -{ - getColumnModel( _nColumn )->setWidth( _nWidth100thMM ); -} + /// retrieves the index of a column within the model + ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const; -inline TableMetrics UnoControlTableModel::GetColumnWidth( ColPos _nColumn ) -{ - return getColumnModel( _nColumn )->getWidth(); -} - #endif // _UNOCONTROL_TABLEMODEL_HXX_ + /// notifies a change in a column belonging to the model + void notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const; + +#ifdef DBG_UTIL + const char* checkInvariants() const; +#endif + }; + +// ..................................................................................................................... +} } // svt::table +// ..................................................................................................................... + +#endif // _UNOCONTROL_TABLEMODEL_HXX_ diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx new file mode 100755 index 000000000000..9996d7c6687c --- /dev/null +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -0,0 +1,362 @@ +/************************************************************************* + * + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include "unogridcolumnfacade.hxx" +#include "unocontroltablemodel.hxx" + +#include "svtools/table/defaultinputhandler.hxx" +#include "svtools/table/gridtablerenderer.hxx" +#include "svtools/table/tablecontrol.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include +#include +#include +#include + +// ..................................................................................................................... +namespace svt { namespace table +{ +// ..................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::awt::grid::XGridColumn; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::awt::grid::XGridColumnListener; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::awt::grid::GridColumnEvent; + using ::com::sun::star::uno::Any; + using ::com::sun::star::style::HorizontalAlignment_LEFT; + using ::com::sun::star::style::HorizontalAlignment; + /** === end UNO using === **/ + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + template< class ATTRIBUTE_TYPE > + void lcl_set( Reference< XGridColumn > const & i_column, void ( SAL_CALL XGridColumn::*i_setter )( ATTRIBUTE_TYPE ), + ATTRIBUTE_TYPE i_value ) + { + try + { + (i_column.get()->*i_setter) ( i_value ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + template< class ATTRIBUTE_TYPE > + ATTRIBUTE_TYPE lcl_get( Reference< XGridColumn > const & i_column, ATTRIBUTE_TYPE ( SAL_CALL XGridColumn::*i_getter )() ) + { + ATTRIBUTE_TYPE value = ATTRIBUTE_TYPE(); + try + { + value = (i_column.get()->*i_getter)(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return value; + } + } + + //================================================================================================================== + //= ColumnChangeMultiplexer + //================================================================================================================== + typedef ::cppu::WeakImplHelper1 < XGridColumnListener + > ColumnChangeMultiplexer_Base; + class ColumnChangeMultiplexer :public ColumnChangeMultiplexer_Base + ,public ::boost::noncopyable + { + public: + ColumnChangeMultiplexer( UnoGridColumnFacade& i_colImpl ); + + void dispose(); + + protected: + ~ColumnChangeMultiplexer(); + + // XGridColumnListener + virtual void SAL_CALL columnChanged( const GridColumnEvent& i_event ) throw (RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const EventObject& i_event ) throw (RuntimeException); + + private: + UnoGridColumnFacade* m_pColumnImplementation; + }; + + //------------------------------------------------------------------------------------------------------------------ + ColumnChangeMultiplexer::ColumnChangeMultiplexer( UnoGridColumnFacade& i_colImpl ) + :m_pColumnImplementation( &i_colImpl ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + ColumnChangeMultiplexer::~ColumnChangeMultiplexer() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void ColumnChangeMultiplexer::dispose() + { + DBG_TESTSOLARMUTEX(); + m_pColumnImplementation = NULL; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ColumnChangeMultiplexer::columnChanged( const GridColumnEvent& i_event ) throw (RuntimeException) + { + ColumnAttributeGroup nChangedAttributes( COL_ATTRS_NONE ); + + if ( i_event.valueName.equalsAscii( "HAlign" ) ) + nChangedAttributes |= COL_ATTRS_APPEARANCE; + + if ( i_event.valueName.equalsAscii( "ColWidth" ) + || i_event.valueName.equalsAscii( "MaxWidth" ) + || i_event.valueName.equalsAscii( "MinWidth" ) + || i_event.valueName.equalsAscii( "PrefWidth" ) + || i_event.valueName.equalsAscii( "ColumnResize" ) + ) + nChangedAttributes |= COL_ATTRS_WIDTH; + + OSL_ENSURE( nChangedAttributes != COL_ATTRS_NONE, + "ColumnChangeMultiplexer::columnChanged: unknown column attributed changed!" ); + + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + if ( m_pColumnImplementation != NULL ) + m_pColumnImplementation->columnChanged( nChangedAttributes ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ColumnChangeMultiplexer::disposing( const EventObject& i_event ) throw (RuntimeException) + { + OSL_UNUSED( i_event ); + } + + //================================================================================================================== + //= UnoGridColumnFacade + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + UnoGridColumnFacade::UnoGridColumnFacade( UnoControlTableModel const & i_owner, Reference< XGridColumn > const & i_gridColumn ) + :m_pOwner( &i_owner ) + ,m_xGridColumn( i_gridColumn, UNO_QUERY_THROW ) + ,m_pChangeMultiplexer( new ColumnChangeMultiplexer( *this ) ) + { + m_xGridColumn->addGridColumnListener( m_pChangeMultiplexer.get() ); + } + + //------------------------------------------------------------------------------------------------------------------ + UnoGridColumnFacade::~UnoGridColumnFacade() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::dispose() + { + DBG_TESTSOLARMUTEX(); + ENSURE_OR_RETURN_VOID( m_pOwner != NULL, "UnoGridColumnFacade::dispose: already disposed!" ); + + m_xGridColumn->removeGridColumnListener( m_pChangeMultiplexer.get() ); + m_pChangeMultiplexer->dispose(); + m_pChangeMultiplexer.clear(); + m_xGridColumn.clear(); + m_pOwner = NULL; + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::columnChanged( ColumnAttributeGroup const i_attributeGroup ) + { + DBG_TESTSOLARMUTEX(); + if ( m_pOwner != NULL ) + m_pOwner->notifyColumnChange( m_pOwner->getColumnPos( *this ), i_attributeGroup ); + } + + //------------------------------------------------------------------------------------------------------------------ + Any UnoGridColumnFacade::getID() const + { + Any aID; + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", aID ); + try + { + aID = m_xGridColumn->getIdentifier(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return aID; + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setID( const Any& i_ID ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + try + { + m_xGridColumn->setIdentifier( i_ID ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + String UnoGridColumnFacade::getName() const + { + ::rtl::OUString sName; + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", sName ); + try + { + sName = m_xGridColumn->getTitle(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sName; + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setName( const String& _rName ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + try + { + m_xGridColumn->setTitle( _rName ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + bool UnoGridColumnFacade::isResizable() const + { + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", false ); + return lcl_get( m_xGridColumn, &XGridColumn::getResizeable ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setResizable( bool _bResizable ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + return lcl_set( m_xGridColumn, &XGridColumn::setResizeable, sal_Bool( _bResizable ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + TableMetrics UnoGridColumnFacade::getWidth() const + { + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 0 ); + return lcl_get( m_xGridColumn, &XGridColumn::getColumnWidth ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setWidth( TableMetrics _nWidth ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + lcl_set( m_xGridColumn, &XGridColumn::setColumnWidth, _nWidth ); + } + + //------------------------------------------------------------------------------------------------------------------ + TableMetrics UnoGridColumnFacade::getMinWidth() const + { + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 0 ); + return lcl_get( m_xGridColumn, &XGridColumn::getMinWidth ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setMinWidth( TableMetrics _nMinWidth ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMinWidth ); + } + + //------------------------------------------------------------------------------------------------------------------ + TableMetrics UnoGridColumnFacade::getMaxWidth() const + { + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 0 ); + return lcl_get( m_xGridColumn, &XGridColumn::getMaxWidth ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setMaxWidth( TableMetrics _nMaxWidth ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMaxWidth ); + } + + //------------------------------------------------------------------------------------------------------------------ + TableMetrics UnoGridColumnFacade::getPreferredWidth() const + { + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 0 ); + return lcl_get( m_xGridColumn, &XGridColumn::getPreferredWidth ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setPreferredWidth( TableMetrics _nPrefWidth ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + lcl_set( m_xGridColumn, &XGridColumn::setPreferredWidth, _nPrefWidth ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::style::HorizontalAlignment UnoGridColumnFacade::getHorizontalAlign() + { + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", HorizontalAlignment_LEFT ); + return lcl_get( m_xGridColumn, &XGridColumn::getHorizontalAlign ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setHorizontalAlign( com::sun::star::style::HorizontalAlignment _align ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + lcl_set( m_xGridColumn, &XGridColumn::setHorizontalAlign, _align ); + } + +// ..................................................................................................................... +} } // svt::table +// ..................................................................................................................... diff --git a/svtools/source/uno/unogridcolumnfacade.hxx b/svtools/source/uno/unogridcolumnfacade.hxx new file mode 100755 index 000000000000..a49f1c8963e7 --- /dev/null +++ b/svtools/source/uno/unogridcolumnfacade.hxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SVTOOLS_GRIDCOLUMNFACADE_HXX +#define SVTOOLS_GRIDCOLUMNFACADE_HXX + +#include "svtools/table/tablemodel.hxx" +#include "svtools/table/tablecontrol.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include + +#include + +// ..................................................................................................................... +namespace svt { namespace table +{ +// ..................................................................................................................... + + //================================================================================================================== + //= UnoGridColumnFacade + //================================================================================================================== + class ColumnChangeMultiplexer; + class UnoControlTableModel; + class UnoGridColumnFacade :public IColumnModel + ,public ::boost::noncopyable + { + public: + UnoGridColumnFacade( + UnoControlTableModel const & i_owner, + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_gridColumn + ); + ~UnoGridColumnFacade(); + + // IColumnModel overridables + virtual ::com::sun::star::uno::Any + getID() const; + virtual void setID( const ::com::sun::star::uno::Any& i_ID ); + virtual String getName() const; + virtual void setName( const String& _rName ); + virtual bool isResizable() const; + virtual void setResizable( bool _bResizable ); + virtual TableMetrics getWidth() const; + virtual void setWidth( TableMetrics _nWidth ); + virtual TableMetrics getMinWidth() const; + virtual void setMinWidth( TableMetrics _nMinWidth ); + virtual TableMetrics getMaxWidth() const; + virtual void setMaxWidth( TableMetrics _nMaxWidth ); + virtual TableMetrics getPreferredWidth() const; + virtual void setPreferredWidth( TableMetrics _nPrefWidth ); + virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign(); + virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign); + + /** disposes the column wrapper + + Note that the XGridColumn which is wrapped by the instance is not disposed, as we + do not own it. + */ + void dispose(); + + // callback for the XGridColumnListener + void columnChanged( ColumnAttributeGroup const i_attributeGroup ); + + private: + const UnoControlTableModel* m_pOwner; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > m_xGridColumn; + ::rtl::Reference< ColumnChangeMultiplexer > m_pChangeMultiplexer; + }; + +// ..................................................................................................................... +} } // svt::table +// ..................................................................................................................... + +#endif // SVTOOLS_GRIDCOLUMNFACADE_HXX -- cgit v1.2.3 From 60312aa1f8fc2030fdd5c9eeb2815c5fc6f843ca Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 5 Jan 2011 12:16:37 +0100 Subject: gridsort: member names usually start with UpperCase - corrected this for GridColumn/DataEvent, for sake of consistency --- svtools/source/uno/svtxgridcontrol.cxx | 48 ++++++++++++++--------------- svtools/source/uno/unogridcolumnfacade.cxx | 12 ++++---- toolkit/source/controls/grid/gridcolumn.cxx | 4 +-- toolkit/source/controls/grid/gridcolumn.hxx | 4 +-- 4 files changed, 34 insertions(+), 34 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 9ba2e8cd6745..805cff7aca98 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -403,7 +403,7 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD { ::vos::OGuard aGuard( GetMutex() ); - const TableSize rowDataLength = (TableSize)Event.rowData.getLength(); + const TableSize rowDataLength = (TableSize)Event.RowData.getLength(); const TableSize colCount = m_xColumnModel->getColumnCount(); if ( colCount == 0 ) { @@ -413,7 +413,7 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD if ( rowDataLength != colCount ) throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), *this ); - m_pTableModel->appendRow( Event.rowData, Event.headerName ); + m_pTableModel->appendRow( Event.RowData, Event.HeaderName ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowAdded: no control (anymore)!" ); @@ -444,7 +444,7 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowRemoved: no control (anymore)!" ); - if(Event.index == -1) + if(Event.RowIndex == -1) { if ( !isSelectionEmpty() ) deselectAllRows(); @@ -460,21 +460,21 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri Any()); } } - else if ( Event.index >= 0 && Event.index < m_pTableModel->getRowCount() ) + else if ( Event.RowIndex >= 0 && Event.RowIndex < m_pTableModel->getRowCount() ) { - if ( isSelectedIndex( Event.index ) ) + if ( isSelectedIndex( Event.RowIndex ) ) { Sequence< sal_Int32 > selected(1); - selected[0]=Event.index; + selected[0]=Event.RowIndex; deselectRows( selected ); } - m_pTableModel->removeRow( Event.index ); + m_pTableModel->removeRow( Event.RowIndex ); } - pTable->InvalidateDataWindow(Event.index, Event.index, true); + pTable->InvalidateDataWindow(Event.RowIndex, Event.RowIndex, true); if(pTable->isAccessibleAlive()) { pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange(DELETE, Event.index, Event.index+1, 0, m_pTableModel->getColumnCount())), + makeAny( AccessibleTableModelChange(DELETE, Event.RowIndex, Event.RowIndex+1, 0, m_pTableModel->getColumnCount())), Any()); } } @@ -486,42 +486,42 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::Gr TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" ); - if ( Event.valueName.equalsAscii( "RowHeight" ) ) + if ( Event.AttributeName.equalsAscii( "RowHeight" ) ) { sal_Int32 rowHeight = m_pTableModel->getRowHeight(); - Event.newValue>>=rowHeight; + Event.NewValue>>=rowHeight; m_pTableModel->setRowHeight(rowHeight); pTable->Invalidate(); } - else if ( Event.valueName.equalsAscii( "RowHeaderWidth" ) ) + else if ( Event.AttributeName.equalsAscii( "RowHeaderWidth" ) ) { sal_Int32 rowHeaderWidth = m_pTableModel->getRowHeaderWidth(); - Event.newValue>>=rowHeaderWidth; + Event.NewValue>>=rowHeaderWidth; m_pTableModel->setRowHeaderWidth(rowHeaderWidth); pTable->Invalidate(); } - else if ( Event.valueName.equalsAscii( "RowHeaders" ) ) + else if ( Event.AttributeName.equalsAscii( "RowHeaders" ) ) { Sequence< rtl::OUString > rowHeaders; - OSL_VERIFY( Event.newValue >>= rowHeaders ); + OSL_VERIFY( Event.NewValue >>= rowHeaders ); m_pTableModel->setRowHeaderNames( rowHeaders ); pTable->Invalidate(); } - else if ( Event.valueName.equalsAscii( "CellUpdated" ) ) + else if ( Event.AttributeName.equalsAscii( "CellUpdated" ) ) { sal_Int32 col = -1; - OSL_VERIFY( Event.oldValue >>= col ); + OSL_VERIFY( Event.OldValue >>= col ); - m_pTableModel->updateCellContent( Event.index, col, Event.newValue ); - pTable->InvalidateDataWindow( Event.index, Event.index, false ); + m_pTableModel->updateCellContent( Event.RowIndex, col, Event.NewValue ); + pTable->InvalidateDataWindow( Event.RowIndex, Event.RowIndex, false ); } - else if ( Event.valueName.equalsAscii( "RowUpdated" ) ) + else if ( Event.AttributeName.equalsAscii( "RowUpdated" ) ) { Sequence< sal_Int32 > cols; - OSL_VERIFY( Event.oldValue >>= cols ); + OSL_VERIFY( Event.OldValue >>= cols ); Sequence< Any > values; - OSL_VERIFY( Event.newValue >>= values ); + OSL_VERIFY( Event.NewValue >>= values ); ENSURE_OR_RETURN_VOID( cols.getLength() == values.getLength(), "SVTXGridControl::dataChanged: inconsistent array lengths!" ); @@ -531,10 +531,10 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::Gr for ( ColPos i = 0; i< cols.getLength(); ++i ) { ENSURE_OR_CONTINUE( ( cols[i] >= 0 ) && ( cols[i] < columnCount ), "illegal column index" ); - m_pTableModel->updateCellContent( Event.index, cols[i], values[i] ); + m_pTableModel->updateCellContent( Event.RowIndex, cols[i], values[i] ); } - pTable->InvalidateDataWindow( Event.index, Event.index, false ); + pTable->InvalidateDataWindow( Event.RowIndex, Event.RowIndex, false ); } } diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index 9996d7c6687c..4e094bbd6523 100755 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -150,14 +150,14 @@ namespace svt { namespace table { ColumnAttributeGroup nChangedAttributes( COL_ATTRS_NONE ); - if ( i_event.valueName.equalsAscii( "HAlign" ) ) + if ( i_event.AttributeName.equalsAscii( "HAlign" ) ) nChangedAttributes |= COL_ATTRS_APPEARANCE; - if ( i_event.valueName.equalsAscii( "ColWidth" ) - || i_event.valueName.equalsAscii( "MaxWidth" ) - || i_event.valueName.equalsAscii( "MinWidth" ) - || i_event.valueName.equalsAscii( "PrefWidth" ) - || i_event.valueName.equalsAscii( "ColumnResize" ) + if ( i_event.AttributeName.equalsAscii( "ColWidth" ) + || i_event.AttributeName.equalsAscii( "MaxWidth" ) + || i_event.AttributeName.equalsAscii( "MinWidth" ) + || i_event.AttributeName.equalsAscii( "PrefWidth" ) + || i_event.AttributeName.equalsAscii( "ColumnResize" ) ) nChangedAttributes |= COL_ATTRS_WIDTH; diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index d681a3101b12..cc0790beb651 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -87,10 +87,10 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void GridColumn::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue, ::osl::ClearableMutexGuard& i_Guard ) + void GridColumn::broadcast_changed( ::rtl::OUString name, Any i_oldValue, Any i_newValue, ::osl::ClearableMutexGuard& i_Guard ) { Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridColumnEvent aEvent( xSource, name, oldValue, newValue, m_nIndex); + GridColumnEvent aEvent( xSource, name, i_oldValue, i_newValue, m_nIndex); ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() ); diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index b8d70551032a..a099e9c2c01d 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -91,8 +91,8 @@ public: private: void broadcast_changed( ::rtl::OUString name, - ::com::sun::star::uno::Any oldValue, - ::com::sun::star::uno::Any newValue, + ::com::sun::star::uno::Any i_oldValue, + ::com::sun::star::uno::Any i_newValue, ::osl::ClearableMutexGuard& i_Guard ); -- cgit v1.2.3 From adebaa24f8ee734ed5694feee1ba225b4b1dcf95 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 6 Jan 2011 14:16:36 +0100 Subject: gridsort: allow inserting columns into the column model while the control is already alive (unfinished) Missing: Adjustments to the data model. Probably we need to change the API here: It does not make sense that the only method to retrieve actual data from the data model is "any[][] getData" - this doesn't scale at all, and blocks all dynamic changes to the columns. I suppose we need some "any getCellData( col, row )" here. --- svtools/source/table/tablecontrol_impl.cxx | 101 ++++++++++----------- svtools/source/table/tablecontrol_impl.hxx | 7 +- .../controls/grid/defaultgridcolumnmodel.cxx | 10 +- 3 files changed, 62 insertions(+), 56 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index dc6dfc352137..295c811edb84 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -467,19 +467,25 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - void TableControl_Impl::columnsInserted( ColPos first, ColPos last ) + void TableControl_Impl::columnsInserted( ColPos i_first, ColPos i_last ) { + m_nColumnCount = m_pModel->getColumnCount(); impl_ni_updateColumnWidths(); - (void)first; - (void)last; - } + impl_ni_updateScrollbars(); + + impl_invalidateColumnsAfter( i_first ); + OSL_UNUSED( i_last ); + } //-------------------------------------------------------------------- - void TableControl_Impl::columnsRemoved( ColPos first, ColPos last ) + void TableControl_Impl::columnsRemoved( ColPos i_first, ColPos i_last ) { + m_nColumnCount = m_pModel->getColumnCount(); impl_ni_updateColumnWidths(); - (void)first; - (void)last; + impl_ni_updateScrollbars(); + + impl_invalidateColumnsAfter( i_first ); + OSL_UNUSED( i_last ); } //-------------------------------------------------------------------- @@ -502,19 +508,45 @@ namespace svt { namespace table OSL_UNUSED( lastRow ); } + //-------------------------------------------------------------------- + void TableControl_Impl::impl_invalidateColumn( ColPos const i_column ) + { + DBG_CHECK_ME(); + + Rectangle aAllCellsArea; + impl_getAllVisibleCellsArea( aAllCellsArea ); + + const TableColumnGeometry aColumn( *this, aAllCellsArea, i_column ); + if ( aColumn.isValid() ) + m_rAntiImpl.Invalidate( aColumn.getRect() ); + } + + //-------------------------------------------------------------------- + void TableControl_Impl::impl_invalidateColumnsAfter( ColPos const i_column ) + { + DBG_CHECK_ME(); + + const ColPos nFirstVisibleCol = m_nLeftColumn; + const ColPos nLastVisibleCol = m_nLeftColumn + impl_getVisibleColumns( true ) - 1; + if ( ( i_column >= nFirstVisibleCol ) && ( i_column <= nLastVisibleCol ) ) + { + Rectangle aInvalidateArea; + impl_getAllVisibleCellsArea( aInvalidateArea ); + + const TableColumnGeometry aColumn( *this, aInvalidateArea, i_column ); + aInvalidateArea.Left() = aColumn.getRect().Left(); + + m_rAntiImpl.Invalidate( aInvalidateArea ); + } + } + //-------------------------------------------------------------------- void TableControl_Impl::columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ) { ColumnAttributeGroup nGroup( i_attributeGroup ); if ( nGroup & COL_ATTRS_APPEARANCE ) { - Rectangle aAllCellsArea; - impl_getAllVisibleCellsArea( aAllCellsArea ); - - const TableColumnGeometry aColumn( *this, aAllCellsArea, i_column ); - if ( aColumn.isValid() ) - m_rAntiImpl.Invalidate( aColumn.getRect() ); - + impl_invalidateColumn( i_column ); nGroup &= ~COL_ATTRS_APPEARANCE; } @@ -1812,7 +1844,7 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - TableSize TableControl_Impl::impl_getVisibleColumns( bool _bAcceptPartialRow ) const + TableSize TableControl_Impl::impl_getVisibleColumns( bool _bAcceptPartialCol ) const { DBG_CHECK_ME(); @@ -1822,7 +1854,7 @@ namespace svt { namespace table Rectangle( Point( 0, 0 ), m_pDataWindow->GetOutputSizePixel() ), m_nLeftColumn, *this, - _bAcceptPartialRow + _bAcceptPartialCol ); } @@ -2260,10 +2292,6 @@ namespace svt { namespace table // column has become smaller, check against minimum width if ( ( minWidthLogical != 0 ) && ( requestedWidthLogical < minWidthLogical ) ) requestedWidthLogical = minWidthLogical; - - // impl_updateLeftColumn(); - // does this make sense here? We didn't call impl_ni_updateColumnWidths, yet, so m_aColumnWidths - // still contains the old values } else if ( oldEnd < requestedEnd ) { @@ -2285,39 +2313,6 @@ namespace svt { namespace table return m_bResizingColumn; } - //------------------------------------------------------------------------------- - void TableControl_Impl::impl_updateLeftColumn() - { - DBG_CHECK_ME(); - if ( m_nLeftColumn == 0 ) - return; - - // the right end of the last column - const long lastColumnEnd = m_aColumnWidths[ m_nColumnCount - 1 ].getEnd(); - - // free space at the right of the last column - const long freeSpace = m_pDataWindow->GetOutputSizePixel().Width() - lastColumnEnd; - - // if the columnd left of the currently-left-most column would fit into the free - // space, then implicitly scroll - const long leftNeighbourWidth = m_aColumnWidths[ m_nLeftColumn - 1 ].getWidth(); - if ( leftNeighbourWidth < freeSpace ) - { - for ( ColumnPositions::iterator colPos = m_aColumnWidths.begin(); - colPos != m_aColumnWidths.end(); - ++colPos - ) - { - colPos->move( leftNeighbourWidth ); - } - - --m_nLeftColumn; - // TODO: wouldn't this require updating the scrollbar? - } - - // TODO: isnt' it that this might be done repeatedly? - } - //-------------------------------------------------------------------- Rectangle TableControl_Impl::calcHeaderRect(bool bColHeader) { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 4c5038de2cc0..65532065ae67 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -307,7 +307,7 @@ namespace svt { namespace table specifies whether a possible only partially visible last row is counted, too. */ - TableSize impl_getVisibleColumns( bool _bAcceptPartialRow ) const; + TableSize impl_getVisibleColumns( bool _bAcceptPartialCol ) const; /** determines the rectangle occupied by the given cell */ @@ -394,7 +394,10 @@ namespace svt { namespace table */ ColPos impl_getColumnForOrdinate( long const i_ordinate ) const; - void impl_updateLeftColumn(); + /// invalidates the window area occupied by the given column + void impl_invalidateColumn( ColPos const i_column ); + /// invalidates the window area occupied by the given column, and everything at the right side of it + void impl_invalidateColumnsAfter( ColPos const i_column ); DECL_LINK( OnScroll, ScrollBar* ); DECL_LINK( OnUpdateScrollbars, void* ); diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 8537a03321aa..34d610ef5661 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -119,12 +119,20 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn( const Reference< XGridColumn > & i_column ) throw (RuntimeException) { - ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + ::osl::ClearableMutexGuard aGuard( m_aMutex ); m_aColumns.push_back( i_column ); sal_Int32 index = m_aColumns.size() - 1; i_column->setIndex( index ); + // fire insertion notifications + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= index; + aEvent.Element <<= i_column; + aGuard.clear(); + m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); + return index; } -- cgit v1.2.3 From f167cee01ffd13e949e68f8395050dc1264f9ab5 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 6 Jan 2011 16:28:45 +0100 Subject: gridsort: XGridDataModel: do not provide access to all data at once, instead use cell-based access --- svtools/source/uno/svtxgridcontrol.cxx | 94 +++---------- svtools/source/uno/unocontroltablemodel.cxx | 152 +++++++-------------- svtools/source/uno/unocontroltablemodel.hxx | 11 +- .../source/controls/grid/defaultgriddatamodel.cxx | 31 +++-- .../source/controls/grid/defaultgriddatamodel.hxx | 5 +- 5 files changed, 83 insertions(+), 210 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 805cff7aca98..06b0576d169b 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -268,48 +268,13 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An if ( !m_xDataModel.is() ) throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The data model isn't set!"), *this ); - Sequence< Sequence< Any > > cellData = m_xDataModel->getData(); - if ( cellData.getLength() != 0 ) - { - const sal_Int32 nDataRowCount = cellData.getLength(); - - const Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); - const sal_Int32 nRowHeaderCount = rowHeaders.getLength(); - - if ( ( nRowHeaderCount != 0 ) && ( nRowHeaderCount != nDataRowCount ) ) - throw GridInvalidDataException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "row header / content data inconsistency" ) ), *this ); - - // check data consistency - sal_Int32 nDataColumnCount = 0; - for ( sal_Int32 i=0; i& rRawRowData = cellData[i]; - if ( ( i > 0 ) && ( rRawRowData.getLength() != nDataColumnCount ) ) - throw GridInvalidDataException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "inconsistent column counts in the row data" ) ), *this ); - nDataColumnCount = rRawRowData.getLength(); - } - - // ensure default columns exist, if they have not previously been added - if ( ( nDataColumnCount > 0 ) && ( m_xColumnModel->getColumnCount() == 0 ) ) - m_xColumnModel->setDefaultColumns( nDataColumnCount ); - // this will trigger notifications, which in turn will let us update our m_pTableModel - - // ensure the row data has as much columns as indicate by our model - if ( nDataColumnCount != m_pTableModel->getColumnCount() ) - throw GridInvalidDataException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Grid model's column count doesn't match the row data's column count." ) ), - *this ); - - // finally add the rows - // TODO: suspend the model's notifications for the single rows, do one notification after all - // rows have been inserted - for ( TableSize i = 0; i < nDataRowCount; ++i ) - { - m_pTableModel->appendRow( cellData[i], rowHeaders[i] ); - } - } + m_pTableModel->setDataModel( m_xDataModel ); + + // ensure default columns exist, if they have not previously been added + sal_Int32 const nDataColumnCount = m_xDataModel->getColumnCount(); + if ( ( nDataColumnCount > 0 ) && ( m_xColumnModel->getColumnCount() == 0 ) ) + m_xColumnModel->setDefaultColumns( nDataColumnCount ); + // this will trigger notifications, which in turn will let us update our m_pTableModel sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); if ( m_xDataModel->getRowHeight() == 0 ) @@ -413,8 +378,6 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD if ( rowDataLength != colCount ) throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), *this ); - m_pTableModel->appendRow( Event.RowData, Event.HeaderName ); - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowAdded: no control (anymore)!" ); @@ -449,8 +412,6 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri if ( !isSelectionEmpty() ) deselectAllRows(); - m_pTableModel->clearAllRows(); - pTable->clearSelection(); if ( pTable->isAccessibleAlive() ) @@ -468,10 +429,10 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri selected[0]=Event.RowIndex; deselectRows( selected ); } - m_pTableModel->removeRow( Event.RowIndex ); } - pTable->InvalidateDataWindow(Event.RowIndex, Event.RowIndex, true); - if(pTable->isAccessibleAlive()) + + pTable->InvalidateDataWindow( Event.RowIndex, Event.RowIndex, true ); + if ( pTable->isAccessibleAlive() ) { pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, makeAny( AccessibleTableModelChange(DELETE, Event.RowIndex, Event.RowIndex+1, 0, m_pTableModel->getColumnCount())), @@ -502,38 +463,15 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::Gr } else if ( Event.AttributeName.equalsAscii( "RowHeaders" ) ) { - Sequence< rtl::OUString > rowHeaders; - OSL_VERIFY( Event.NewValue >>= rowHeaders ); - m_pTableModel->setRowHeaderNames( rowHeaders ); + // TODO: we could do better than this - invalidate the header area only pTable->Invalidate(); } - else if ( Event.AttributeName.equalsAscii( "CellUpdated" ) ) + else if ( ( Event.AttributeName.equalsAscii( "CellUpdated" ) ) + || ( Event.AttributeName.equalsAscii( "RowUpdated" ) ) + ) { - sal_Int32 col = -1; - OSL_VERIFY( Event.OldValue >>= col ); - - m_pTableModel->updateCellContent( Event.RowIndex, col, Event.NewValue ); - pTable->InvalidateDataWindow( Event.RowIndex, Event.RowIndex, false ); - } - else if ( Event.AttributeName.equalsAscii( "RowUpdated" ) ) - { - Sequence< sal_Int32 > cols; - OSL_VERIFY( Event.OldValue >>= cols ); - - Sequence< Any > values; - OSL_VERIFY( Event.NewValue >>= values ); - - ENSURE_OR_RETURN_VOID( cols.getLength() == values.getLength(), "SVTXGridControl::dataChanged: inconsistent array lengths!" ); - - const TableSize columnCount = m_pTableModel->getColumnCount(); - // TODO: suspend listener notification, so that the table model doesn't notify |cols.size()| different events. - // Instead, only one event should be broadcasted. - for ( ColPos i = 0; i< cols.getLength(); ++i ) - { - ENSURE_OR_CONTINUE( ( cols[i] >= 0 ) && ( cols[i] < columnCount ), "illegal column index" ); - m_pTableModel->updateCellContent( Event.RowIndex, cols[i], values[i] ); - } - + // TODO: Our UnoControlTableModel should be a listener at the data model, and multiplex those events, + // so the TableControl/_Impl can react on it. pTable->InvalidateDataWindow( Event.RowIndex, Event.RowIndex, false ); } } diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 8bfc1d1400f2..4bdfa0ebdabd 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -41,6 +41,7 @@ /** === end UNO includes === **/ #include +#include #include #include #include @@ -63,9 +64,11 @@ namespace svt { namespace table using ::com::sun::star::awt::grid::XGridColumnListener; using ::com::sun::star::lang::EventObject; using ::com::sun::star::awt::grid::GridColumnEvent; + using ::com::sun::star::awt::grid::XGridDataModel; using ::com::sun::star::uno::Any; using ::com::sun::star::style::HorizontalAlignment_LEFT; using ::com::sun::star::style::HorizontalAlignment; + using ::com::sun::star::uno::WeakReference; /** === end UNO using === **/ //================================================================================================================== @@ -76,7 +79,6 @@ namespace svt { namespace table struct UnoControlTableModel_Impl { ColumnModels aColumns; - TableSize nRowCount; bool bHasColumnHeaders; bool bHasRowHeaders; ScrollbarVisibility eVScrollMode; @@ -86,8 +88,6 @@ namespace svt { namespace table TableMetrics nRowHeight; TableMetrics nColumnHeaderHeight; TableMetrics nRowHeaderWidth; - ::std::vector< ::rtl::OUString > aRowHeadersTitle; - ::std::vector< ::std::vector< Any > > aCellContent; ::com::sun::star::util::Color m_nLineColor; ::com::sun::star::util::Color m_nHeaderColor; ::com::sun::star::util::Color m_nTextColor; @@ -95,10 +95,10 @@ namespace svt { namespace table ::com::sun::star::util::Color m_nRowColor2; ::com::sun::star::style::VerticalAlignment m_eVerticalAlign; ModellListeners m_aListeners; + WeakReference< XGridDataModel > m_aDataModel; UnoControlTableModel_Impl() :aColumns ( ) - ,nRowCount ( 0 ) ,bHasColumnHeaders ( true ) ,bHasRowHeaders ( false ) ,eVScrollMode ( ScrollbarShowNever ) @@ -108,8 +108,6 @@ namespace svt { namespace table ,nRowHeight ( 10 ) ,nColumnHeaderHeight( 10 ) ,nRowHeaderWidth ( 10 ) - ,aRowHeadersTitle ( ) - ,aCellContent ( ) ,m_nLineColor ( COL_TRANSPARENT ) ,m_nHeaderColor ( COL_TRANSPARENT ) ,m_nTextColor ( 0 )//black as default @@ -132,8 +130,9 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ const char* UnoControlTableModel::checkInvariants() const { - if ( m_pImpl->aRowHeadersTitle.size() != m_pImpl->aCellContent.size() ) - return "inconsistency between data and row header arrays"; + Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); + if ( !xDataModel.is() ) + return "data model anymore"; // TODO: more? @@ -175,7 +174,19 @@ namespace svt { namespace table TableSize UnoControlTableModel::getRowCount() const { DBG_CHECK_ME(); - return m_pImpl->nRowCount; + + TableSize nRowCount = 0; + try + { + Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); + ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" ); + nRowCount = xDataModel->getRowCount(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return nRowCount; } //------------------------------------------------------------------------------------------------------------------ @@ -413,122 +424,53 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::setCellContent(const std::vector >& cellContent) + void UnoControlTableModel::setDataModel( Reference< XGridDataModel > const & i_gridDataModel ) { DBG_CHECK_ME(); - m_pImpl->aCellContent = cellContent; + m_pImpl->m_aDataModel = i_gridDataModel; + // TODO: register as listener, so we're notified of row/data changes, and can multiplex them to our + // own listeners } //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::getCellContent( ColPos const i_col, RowPos const i_row, Any& o_cellContent ) { DBG_CHECK_ME(); - ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( size_t( i_row ) < m_pImpl->aCellContent.size() ), - "UnoControlTableModel::getCellContent: illegal row index!" ); - ::std::vector< Any >& rRowContent( m_pImpl->aCellContent[ i_row ] ); - ENSURE_OR_RETURN_VOID( ( i_col >= 0 ) && ( size_t( i_col ) < rRowContent.size() ), - "UnoControlTableModel::getCellContent: illegal column index" ); - o_cellContent = rRowContent[ i_col ]; - } - - //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::updateCellContent( RowPos const i_row, ColPos const i_col, Any const & i_cellContent ) - { - DBG_CHECK_ME(); - ENSURE_OR_RETURN_VOID( ( i_row >= 0 ) && ( size_t( i_row ) < m_pImpl->aCellContent.size() ), - "UnoControlTableModel::updateCellContent: illegal row index!" ); - ::std::vector< Any >& rRowContent( m_pImpl->aCellContent[ i_row ] ); - ENSURE_OR_RETURN_VOID( ( i_col >= 0 ) && ( size_t( i_col ) < rRowContent.size() ), - "UnoControlTableModel::updateCellContent: illegal column index" ); - rRowContent[ i_col ] = i_cellContent; - - // TODO: listener notification - } - - //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::setRowHeaderNames( const Sequence< ::rtl::OUString >& i_rowHeaders ) - { - DBG_CHECK_ME(); - ENSURE_OR_RETURN_VOID( size_t( i_rowHeaders.getLength() ) == m_pImpl->aRowHeadersTitle.size(), - "UnoControlTableModel::setRowHeaderNames: illegal number of row headers!" ); - // this method is not intended to set a new row count, but only to modify the existing row headers - - ::std::copy( - ::comphelper::stl_begin( i_rowHeaders ), - ::comphelper::stl_end( i_rowHeaders ), - m_pImpl->aRowHeadersTitle.begin() - ); - // TODO: listener notification + try + { + Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); + ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" ); + o_cellContent = xDataModel->getCellData( i_col, i_row ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString UnoControlTableModel::getRowHeader( RowPos const i_rowPos ) const { DBG_CHECK_ME(); - ENSURE_OR_RETURN( ( i_rowPos >= 0 ) && ( size_t( i_rowPos ) < m_pImpl->aRowHeadersTitle.size() ), - "UnoControlTableModel::getRowHeader: illegal row position!", ::rtl::OUString() ); - return m_pImpl->aRowHeadersTitle[ i_rowPos ]; - } - //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::appendRow( Sequence< Any > const & i_rowData, ::rtl::OUString const & i_rowHeader ) - { - DBG_CHECK_ME(); - ENSURE_OR_RETURN_VOID( i_rowData.getLength() == getColumnCount(), "UnoControlTableModel::appendRow: invalid row data!" ); - - // add row data - ::std::vector< Any > newRow( i_rowData.getLength() ); - if ( !newRow.empty() ) - ::std::copy( - ::comphelper::stl_begin( i_rowData ), - ::comphelper::stl_end( i_rowData ), - newRow.begin() - ); - - m_pImpl->aCellContent.push_back( newRow ); - - if ( hasRowHeaders() ) - m_pImpl->aRowHeadersTitle.push_back( i_rowHeader ); - - ++m_pImpl->nRowCount; - - // TODO: listener notification - } - - //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::removeRow( RowPos const i_rowPos ) - { - DBG_CHECK_ME(); - ENSURE_OR_RETURN_VOID( ( i_rowPos >= 0 ) && ( i_rowPos < getRowCount() ), "UnoControlTableModel::removeRow: illegal row position!" ); - - if ( hasRowHeaders() ) - m_pImpl->aRowHeadersTitle.erase( m_pImpl->aRowHeadersTitle.begin() + i_rowPos ); + ::rtl::OUString sRowHeader; - const ::std::vector< ::std::vector< Any > >::iterator contentPos = m_pImpl->aCellContent.begin() + i_rowPos; - m_pImpl->aCellContent.erase( contentPos ); + Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); + ENSURE_OR_RETURN( xDataModel.is(), "UnoControlTableModel::getRowHeader: no data model anymore!", sRowHeader ); - --m_pImpl->nRowCount; - - // TODO: listener notification - } - - //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::clearAllRows() - { - DBG_CHECK_ME(); - if ( hasRowHeaders() ) + try { - ::std::vector< ::rtl::OUString > aEmpty; - m_pImpl->aRowHeadersTitle.swap( aEmpty ); + Sequence< ::rtl::OUString > const aRowHeaders( xDataModel->getRowHeaders() ); + ENSURE_OR_RETURN( ( i_rowPos >= 0 ) && ( i_rowPos < aRowHeaders.getLength() ), + "UnoControlTableModel::getRowHeader: illegal row position!", sRowHeader ); + sRowHeader = aRowHeaders[ i_rowPos ]; } - - ::std::vector< ::std::vector< Any > > aEmptyContent; - m_pImpl->aCellContent.swap( aEmptyContent ); - - m_pImpl->nRowCount = 0; - - // TODO: listener notification + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sRowHeader; } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index d6dcf138ccf2..2cb107b3551d 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -117,19 +117,10 @@ namespace svt { namespace table void insertColumn( ColPos const i_position, ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); void removeAllColumns(); - // row write access - void setRowHeaderNames( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_rowHeaders ); - void appendRow( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > const & i_rowData, ::rtl::OUString const & i_rowHeader ); - void removeRow( RowPos const i_rowPos ); - void clearAllRows(); - - // cell data write access - void updateCellContent( RowPos const i_rowPos, ColPos const i_colPos, ::com::sun::star::uno::Any const & i_cellContent ); - // other operations void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; - void setCellContent(const std::vector >& cellContent); + void setDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > const & i_gridDataModel ); void setRowHeaders(bool _bRowHeaders); void setColumnHeaders(bool _bColumnHeaders); void setLineColor(::com::sun::star::util::Color _rColor); diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index be3dd303a566..c2fca18dee61 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -158,6 +158,14 @@ namespace toolkit return m_aData.size(); } + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridDataModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException) + { + if ( m_aData.empty() ) + return 0; + return m_aData[0].size(); + } + //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getRowHeaders() throw (::com::sun::star::uno::RuntimeException) { @@ -222,21 +230,19 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL DefaultGridDataModel::getData() throw (::com::sun::star::uno::RuntimeException) + Any SAL_CALL DefaultGridDataModel::getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) { + ::osl::MutexGuard aGuard( GetMutex() ); - std::vector< std::vector< Any > >::iterator iterator; - std::vector< Sequence< Any > > dummyContainer(0); + if ( ( i_row < 0 ) || ( size_t( i_row ) > m_aData.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + ::std::vector< Any > const & rRow( m_aData[ i_row ] ); - for(iterator = m_aData.begin(); iterator != m_aData.end(); iterator++) - { - Sequence< Any > cols(comphelper::containerToSequence(*iterator)); - dummyContainer.push_back( cols ); - } - Sequence< Sequence< Any > > dataSequence(comphelper::containerToSequence(dummyContainer)); + if ( ( i_column < 0 ) || ( size_t( i_column ) > rRow.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - return dataSequence; + return rRow[ i_column ]; } //------------------------------------------------------------------------------------------------------------------ @@ -305,8 +311,6 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL DefaultGridDataModel::dispose() throw (RuntimeException) { - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - ::com::sun::star::lang::EventObject aEvent; aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); BrdcstHelper.aLC.disposeAndClear( aEvent ); @@ -328,7 +332,6 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL DefaultGridDataModel::getImplementationName( ) throw (RuntimeException) { - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridDataModel" ) ); return aImplName; } @@ -336,14 +339,12 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ sal_Bool SAL_CALL DefaultGridDataModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) { - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); return ServiceName.equalsAscii( szServiceName_DefaultGridDataModel ); } //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getSupportedServiceNames( ) throw (RuntimeException) { - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); static const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridDataModel ) ); static const Sequence< OUString > aSeq( &aServiceName, 1 ); return aSeq; diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index bfb67c7fea2a..66260d49ae6d 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -65,10 +65,11 @@ public: virtual ::sal_Int32 SAL_CALL getRowHeight() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setRowHeight(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowHeaders() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & value) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & m_aData) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & _aData) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL removeGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); -- cgit v1.2.3 From 9cb54ddb6ee986202829eab834cb856a4df5c45f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 7 Jan 2011 10:31:19 +0100 Subject: gridsort: RowHeaderWidth/ColumnHeaderHeight do not belong to the GridData/ColumnModel, but to the GridControlModel --- svtools/source/uno/svtxgridcontrol.cxx | 70 ++++++++++++---------- toolkit/inc/toolkit/helper/property.hxx | 2 + .../controls/grid/defaultgridcolumnmodel.cxx | 20 +------ .../controls/grid/defaultgridcolumnmodel.hxx | 3 - .../source/controls/grid/defaultgriddatamodel.cxx | 17 ------ .../source/controls/grid/defaultgriddatamodel.hxx | 3 - toolkit/source/controls/grid/gridcontrol.cxx | 6 ++ toolkit/source/helper/property.cxx | 6 +- 8 files changed, 51 insertions(+), 76 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 06b0576d169b..c4a524ac5e87 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -131,6 +131,36 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An switch( GetPropertyId( PropertyName ) ) { + case BASEPROPERTY_ROW_HEADER_WIDTH: + { + sal_Int32 rowHeaderWidth( m_pTableModel->getRowHeaderWidth() ); + aValue >>= rowHeaderWidth; + ENSURE_OR_BREAK( rowHeaderWidth > 0, "SVTXGridControl::setProperty: illegal row header width!" ); + m_pTableModel->setRowHeaderWidth( rowHeaderWidth ); + // TODO: the model should broadcast this change itself, and the table should invalidate itself as needed + pTable->Invalidate(); + } + break; + + case BASEPROPERTY_COLUMN_HEADER_HEIGHT: + { + if ( !aValue.hasValue() ) + { + sal_Int32 const fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() + 3 ), MAP_APPFONT ).Height(); + m_pTableModel->setColumnHeaderHeight( fontHeight ); + } + else + { + sal_Int32 nColumnHeaderHeight = 0; + aValue >>= nColumnHeaderHeight; + ENSURE_OR_BREAK( nColumnHeaderHeight > 0, "SVTXGridControl::setProperty: illegal column header height!" ); + m_pTableModel->setColumnHeaderHeight( nColumnHeaderHeight ); + } + // TODO: the model should broadcast this change itself, and the table should invalidate itself as needed + pTable->Invalidate(); + } + break; + case BASEPROPERTY_BACKGROUNDCOLOR: { // let the base class handle this for the TableControl @@ -275,13 +305,6 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An if ( ( nDataColumnCount > 0 ) && ( m_xColumnModel->getColumnCount() == 0 ) ) m_xColumnModel->setDefaultColumns( nDataColumnCount ); // this will trigger notifications, which in turn will let us update our m_pTableModel - - sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height(); - if ( m_xDataModel->getRowHeight() == 0 ) - m_pTableModel->setRowHeight( fontHeight ); - else - m_pTableModel->setRowHeight( m_xDataModel->getRowHeight() ); - m_pTableModel->setRowHeaderWidth( m_xDataModel->getRowHeaderWidth() ); } break; } @@ -454,13 +477,6 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::Gr m_pTableModel->setRowHeight(rowHeight); pTable->Invalidate(); } - else if ( Event.AttributeName.equalsAscii( "RowHeaderWidth" ) ) - { - sal_Int32 rowHeaderWidth = m_pTableModel->getRowHeaderWidth(); - Event.NewValue>>=rowHeaderWidth; - m_pTableModel->setRowHeaderWidth(rowHeaderWidth); - pTable->Invalidate(); - } else if ( Event.AttributeName.equalsAscii( "RowHeaders" ) ) { // TODO: we could do better than this - invalidate the header area only @@ -813,28 +829,16 @@ void SVTXGridControl::impl_updateColumnsFromModel_nothrow() try { - if ( m_xColumnModel->getColumnCount() != 0 ) + const Sequence< Reference< XGridColumn > > columns = m_xColumnModel->getColumns(); + for ( const Reference< XGridColumn >* colRef = columns.getConstArray(); + colRef != columns.getConstArray() + columns.getLength(); + ++colRef + ) { - if ( m_xColumnModel->getColumnHeaderHeight() == 0 ) - { - sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() + 3 ), MAP_APPFONT ).Height(); - m_pTableModel->setColumnHeaderHeight( fontHeight ); - } - else - m_pTableModel->setColumnHeaderHeight( m_xColumnModel->getColumnHeaderHeight() ); + ENSURE_OR_CONTINUE( colRef->is(), "illegal column!" ); - const Sequence< Reference< XGridColumn > > columns = m_xColumnModel->getColumns(); - for ( const Reference< XGridColumn >* colRef = columns.getConstArray(); - colRef != columns.getConstArray() + columns.getLength(); - ++colRef - ) - { - ENSURE_OR_CONTINUE( colRef->is(), "illegal column!" ); - - m_pTableModel->appendColumn( *colRef ); - } + m_pTableModel->appendColumn( *colRef ); } - } catch( const Exception& ) { diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index 837d283f4e8c..164071f5a39b 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -202,6 +202,8 @@ namespace rtl { #define BASEPROPERTY_GRID_ROW_BACKGROUND 151 #define BASEPROPERTY_MULTISELECTION_SIMPLEMODE 152 #define BASEPROPERTY_ITEM_SEPARATOR_POS 153 +#define BASEPROPERTY_ROW_HEADER_WIDTH 154 +#define BASEPROPERTY_COLUMN_HEADER_HEIGHT 155 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 7383fc958dae..00bbbf9d6c1b 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -71,7 +71,6 @@ namespace toolkit ,m_aContext( i_factory ) ,m_aContainerListeners( m_aMutex ) ,m_aColumns() - ,m_nColumnHeaderHeight(0) { } @@ -82,7 +81,6 @@ namespace toolkit ,m_aContext( i_copySource.m_aContext ) ,m_aContainerListeners( m_aMutex ) ,m_aColumns() - ,m_nColumnHeaderHeight( i_copySource.m_nColumnHeaderHeight ) { Columns aColumns; aColumns.reserve( i_copySource.m_aColumns.size() ); @@ -139,14 +137,14 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ Sequence< Reference< XGridColumn > > SAL_CALL DefaultGridColumnModel::getColumns() throw (RuntimeException) { - ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + ::osl::MutexGuard aGuard( m_aMutex ); return ::comphelper::containerToSequence( m_aColumns ); } //------------------------------------------------------------------------------------------------------------------ Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (IndexOutOfBoundsException, RuntimeException) { - ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + ::osl::MutexGuard aGuard( m_aMutex ); if ( index >=0 && index < ((sal_Int32)m_aColumns.size())) return m_aColumns[index]; @@ -154,20 +152,6 @@ namespace toolkit throw IndexOutOfBoundsException(); } - //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (RuntimeException) - { - ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); - m_nColumnHeaderHeight = _value; - } - - //------------------------------------------------------------------------------------------------------------------ - sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnHeaderHeight() throw (RuntimeException) - { - ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); - return m_nColumnHeaderHeight; - } - //------------------------------------------------------------------------------------------------------------------ void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (RuntimeException) { diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx index 118d6bbf3240..102da190486e 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx @@ -62,8 +62,6 @@ public: virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setColumnHeaderHeight( sal_Int32 _value) throw (com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getColumnHeaderHeight() throw (com::sun::star::uno::RuntimeException); virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException); // XServiceInfo @@ -87,7 +85,6 @@ private: ::comphelper::ComponentContext m_aContext; ::cppu::OInterfaceContainerHelper m_aContainerListeners; Columns m_aColumns; - sal_Int32 m_nColumnHeaderHeight; }; } diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index c2fca18dee61..ed6d124b4c8b 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -43,7 +43,6 @@ using namespace ::com::sun::star::lang; #define ROWHEADERS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaders" )) #define CELLUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellUpdated" )) #define ROWUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowUpdated" )) -#define ROWHEADERWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaderWidth" )) //...................................................................................................................... namespace toolkit @@ -71,7 +70,6 @@ namespace toolkit ,MutexAndBroadcastHelper() ,m_nRowHeight(0) ,m_aRowHeaders() - ,m_nRowHeaderWidth(10) { } @@ -82,7 +80,6 @@ namespace toolkit ,m_nRowHeight( i_copySource.m_nRowHeight ) ,m_aData( i_copySource.m_aData ) ,m_aRowHeaders( i_copySource.m_aRowHeaders ) - ,m_nRowHeaderWidth( i_copySource.m_nRowHeaderWidth ) { } @@ -265,20 +262,6 @@ namespace toolkit broadcast_remove( -1, ::rtl::OUString(), 0); } - //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) - { - sal_Int32 oldValue = m_nRowHeaderWidth; - m_nRowHeaderWidth = _value; - broadcast_changed( ROWHEADERWIDTH, 0, Any(oldValue), Any(_value) ); - } - - //------------------------------------------------------------------------------------------------------------------ - sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException) - { - return m_nRowHeaderWidth; - } - //------------------------------------------------------------------------------------------------------------------ void SAL_CALL DefaultGridDataModel::updateCell(::sal_Int32 row, ::sal_Int32 column, const Any& value) throw (::com::sun::star::uno::RuntimeException) { diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 66260d49ae6d..6d0afb15bd87 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -74,8 +74,6 @@ public: virtual void SAL_CALL addGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL removeGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL removeAll() throw (RuntimeException); - virtual void SAL_CALL setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateCell( ::sal_Int32 row, ::sal_Int32 column, const ::com::sun::star::uno::Any& value ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateRow( ::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& values ) throw (::com::sun::star::uno::RuntimeException); @@ -102,7 +100,6 @@ private: sal_Int32 m_nRowHeight; std::vector< std::vector < Any > > m_aData; std::vector< ::rtl::OUString > m_aRowHeaders; - sal_Int32 m_nRowHeaderWidth; }; } diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index fe8e894a65ed..8194536544b1 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -75,7 +75,9 @@ UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun:: ImplRegisterProperty( BASEPROPERTY_VSCROLL ); ImplRegisterProperty( BASEPROPERTY_TABSTOP ); ImplRegisterProperty( BASEPROPERTY_GRID_SHOWROWHEADER ); + ImplRegisterProperty( BASEPROPERTY_ROW_HEADER_WIDTH ); ImplRegisterProperty( BASEPROPERTY_GRID_SHOWCOLUMNHEADER ); + ImplRegisterProperty( BASEPROPERTY_COLUMN_HEADER_HEIGHT ); ImplRegisterProperty( BASEPROPERTY_GRID_DATAMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridDataModel" ) ) ); ImplRegisterProperty( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridColumnModel" ) ) ); ImplRegisterProperty( BASEPROPERTY_GRID_SELECTIONMODE ); @@ -196,8 +198,12 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return uno::makeAny( SelectionType(1) ); case BASEPROPERTY_GRID_SHOWROWHEADER: return uno::makeAny( (sal_Bool)sal_False ); + case BASEPROPERTY_ROW_HEADER_WIDTH: + return uno::makeAny( sal_Int32( 10 ) ); case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: return uno::makeAny( (sal_Bool)sal_True ); + case BASEPROPERTY_COLUMN_HEADER_HEIGHT: + return Any(); case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND: return uno::makeAny( com::sun::star::util::Color( COL_TRANSPARENT ) ); case BASEPROPERTY_GRID_HEADER_BACKGROUND: diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index 1b08c33a9219..0f91dcd3e9cf 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -276,8 +276,10 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_2 ( "URL", URL, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "WritingMode", WRITING_MODE, sal_Int16, BOUND, MAYBEDEFAULT ), DECL_PROP_3 ( "ContextWritingMode", CONTEXT_WRITING_MODE, sal_Int16, BOUND, MAYBEDEFAULT, TRANSIENT ), - DECL_PROP_2 ( "ShowRowHeader", GRID_SHOWROWHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), - DECL_PROP_2 ( "ShowColumnHeader", GRID_SHOWCOLUMNHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "ShowRowHeader", GRID_SHOWROWHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "RowHeaderWidth", ROW_HEADER_WIDTH, sal_Int32, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "ShowColumnHeader", GRID_SHOWCOLUMNHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_3 ( "ColumnHeaderHeight", COLUMN_HEADER_HEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_1 ( "GridDataModel", GRID_DATAMODEL, Reference< ::com::sun::star::awt::grid::XGridDataModel >, BOUND ), DECL_PROP_1 ( "ColumnModel", GRID_COLUMNMODEL, Reference< ::com::sun::star::awt::grid::XGridColumnModel >, BOUND ), DECL_PROP_3 ( "SelectionModel", GRID_SELECTIONMODE, ::com::sun::star::view::SelectionType, BOUND, MAYBEDEFAULT, MAYBEVOID ), -- cgit v1.2.3 From c36c24d7c4396dff864b77e91fe36cd7890a5342 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 7 Jan 2011 10:51:57 +0100 Subject: gridsort: RowHeight belongs to the GridControlModel (not the GridDataModel), too --- svtools/source/uno/svtxgridcontrol.cxx | 38 ++++++++++++++-------- svtools/source/uno/treecontrolpeer.cxx | 4 +-- toolkit/inc/toolkit/helper/property.hxx | 2 +- .../source/controls/grid/defaultgriddatamodel.cxx | 18 ---------- .../source/controls/grid/defaultgriddatamodel.hxx | 3 -- toolkit/source/controls/grid/gridcontrol.cxx | 2 ++ toolkit/source/controls/tree/treecontrol.cxx | 4 +-- toolkit/source/helper/property.cxx | 2 +- 8 files changed, 32 insertions(+), 41 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index c4a524ac5e87..a1cae97b64ff 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -144,18 +144,35 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An case BASEPROPERTY_COLUMN_HEADER_HEIGHT: { + sal_Int32 columnHeaderHeight = 0; if ( !aValue.hasValue() ) { - sal_Int32 const fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() + 3 ), MAP_APPFONT ).Height(); - m_pTableModel->setColumnHeaderHeight( fontHeight ); + columnHeaderHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() + 3 ), MAP_APPFONT ).Height(); } else { - sal_Int32 nColumnHeaderHeight = 0; - aValue >>= nColumnHeaderHeight; - ENSURE_OR_BREAK( nColumnHeaderHeight > 0, "SVTXGridControl::setProperty: illegal column header height!" ); - m_pTableModel->setColumnHeaderHeight( nColumnHeaderHeight ); + aValue >>= columnHeaderHeight; } + ENSURE_OR_BREAK( columnHeaderHeight > 0, "SVTXGridControl::setProperty: illegal column header height!" ); + m_pTableModel->setColumnHeaderHeight( columnHeaderHeight ); + // TODO: the model should broadcast this change itself, and the table should invalidate itself as needed + pTable->Invalidate(); + } + break; + + case BASEPROPERTY_ROW_HEIGHT: + { + sal_Int32 rowHeight = 0; + if ( !aValue.hasValue() ) + { + rowHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() + 3 ), MAP_APPFONT ).Height(); + } + else + { + aValue >>= rowHeight; + } + m_pTableModel->setRowHeight( rowHeight ); + ENSURE_OR_BREAK( rowHeight > 0, "SVTXGridControl::setProperty: illegal row height!" ); // TODO: the model should broadcast this change itself, and the table should invalidate itself as needed pTable->Invalidate(); } @@ -470,14 +487,7 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::Gr TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" ); - if ( Event.AttributeName.equalsAscii( "RowHeight" ) ) - { - sal_Int32 rowHeight = m_pTableModel->getRowHeight(); - Event.NewValue>>=rowHeight; - m_pTableModel->setRowHeight(rowHeight); - pTable->Invalidate(); - } - else if ( Event.AttributeName.equalsAscii( "RowHeaders" ) ) + if ( Event.AttributeName.equalsAscii( "RowHeaders" ) ) { // TODO: we could do better than this - invalidate the header area only pTable->Invalidate(); diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index f37d5f80ed68..c796352c373d 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -1360,7 +1360,7 @@ void TreeControlPeer::setProperty( const ::rtl::OUString& PropertyName, const An case BASEPROPERTY_TREE_DATAMODEL: onChangeDataModel( rTree, Reference< XTreeDataModel >( aValue, UNO_QUERY ) ); break; - case BASEPROPERTY_TREE_ROWHEIGHT: + case BASEPROPERTY_ROW_HEIGHT: { sal_Int32 nHeight = 0; if( aValue >>= nHeight ) @@ -1445,7 +1445,7 @@ Any TreeControlPeer::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru } return Any( eSelectionType ); } - case BASEPROPERTY_TREE_ROWHEIGHT: + case BASEPROPERTY_ROW_HEIGHT: return Any( (sal_Int32)rTree.GetEntryHeight() ); case BASEPROPERTY_TREE_DATAMODEL: return Any( mxDataModel ); diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index 164071f5a39b..405b6ac44053 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -177,7 +177,7 @@ namespace rtl { #define BASEPROPERTY_TREE_ROOTDISPLAYED 127 #define BASEPROPERTY_TREE_SHOWSHANDLES 128 #define BASEPROPERTY_TREE_SHOWSROOTHANDLES 129 -#define BASEPROPERTY_TREE_ROWHEIGHT 130 +#define BASEPROPERTY_ROW_HEIGHT 130 #define BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING 131 #define BASEPROPERTY_TREE_END 131 #define BASEPROPERTY_DIALOGSOURCEURL 132 diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index ed6d124b4c8b..7a04b77c2574 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -39,7 +39,6 @@ using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; -#define ROWHEIGHT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeight" )) #define ROWHEADERS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaders" )) #define CELLUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellUpdated" )) #define ROWUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowUpdated" )) @@ -68,7 +67,6 @@ namespace toolkit DefaultGridDataModel::DefaultGridDataModel() :DefaultGridDataModel_Base() ,MutexAndBroadcastHelper() - ,m_nRowHeight(0) ,m_aRowHeaders() { } @@ -77,7 +75,6 @@ namespace toolkit DefaultGridDataModel::DefaultGridDataModel( DefaultGridDataModel const & i_copySource ) :DefaultGridDataModel_Base() ,MutexAndBroadcastHelper() - ,m_nRowHeight( i_copySource.m_nRowHeight ) ,m_aData( i_copySource.m_aData ) ,m_aRowHeaders( i_copySource.m_aRowHeaders ) { @@ -134,21 +131,6 @@ namespace toolkit broadcast( row_removed, aEvent); } - //------------------------------------------------------------------------------------------------------------------ - ::sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeight() throw (::com::sun::star::uno::RuntimeException) - { - return m_nRowHeight; - } - - //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::setRowHeight(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) - { - sal_Int32 oldValue = m_nRowHeight; - m_nRowHeight = value; - - broadcast_changed( ROWHEIGHT, 0, Any(oldValue), Any(value)); - } - //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL DefaultGridDataModel::getRowCount() throw (::com::sun::star::uno::RuntimeException) { diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 6d0afb15bd87..43bb43a005a8 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -62,8 +62,6 @@ public: virtual ~DefaultGridDataModel(); // XGridDataModel - virtual ::sal_Int32 SAL_CALL getRowHeight() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRowHeight(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowHeaders() throw (::com::sun::star::uno::RuntimeException); @@ -97,7 +95,6 @@ private: void broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); void broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); - sal_Int32 m_nRowHeight; std::vector< std::vector < Any > > m_aData; std::vector< ::rtl::OUString > m_aRowHeaders; }; diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 8194536544b1..76bf33768776 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -78,6 +78,7 @@ UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun:: ImplRegisterProperty( BASEPROPERTY_ROW_HEADER_WIDTH ); ImplRegisterProperty( BASEPROPERTY_GRID_SHOWCOLUMNHEADER ); ImplRegisterProperty( BASEPROPERTY_COLUMN_HEADER_HEIGHT ); + ImplRegisterProperty( BASEPROPERTY_ROW_HEIGHT ); ImplRegisterProperty( BASEPROPERTY_GRID_DATAMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridDataModel" ) ) ); ImplRegisterProperty( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridColumnModel" ) ) ); ImplRegisterProperty( BASEPROPERTY_GRID_SELECTIONMODE ); @@ -203,6 +204,7 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: return uno::makeAny( (sal_Bool)sal_True ); case BASEPROPERTY_COLUMN_HEADER_HEIGHT: + case BASEPROPERTY_ROW_HEIGHT: return Any(); case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND: return uno::makeAny( com::sun::star::util::Color( COL_TRANSPARENT ) ); diff --git a/toolkit/source/controls/tree/treecontrol.cxx b/toolkit/source/controls/tree/treecontrol.cxx index 1dae4a3456d7..d2c66c64b41a 100644 --- a/toolkit/source/controls/tree/treecontrol.cxx +++ b/toolkit/source/controls/tree/treecontrol.cxx @@ -75,7 +75,7 @@ UnoTreeModel::UnoTreeModel( const ::com::sun::star::uno::Reference< ::com::sun:: ImplRegisterProperty( BASEPROPERTY_TREE_ROOTDISPLAYED ); ImplRegisterProperty( BASEPROPERTY_TREE_SHOWSHANDLES ); ImplRegisterProperty( BASEPROPERTY_TREE_SHOWSROOTHANDLES ); - ImplRegisterProperty( BASEPROPERTY_TREE_ROWHEIGHT ); + ImplRegisterProperty( BASEPROPERTY_ROW_HEIGHT ); ImplRegisterProperty( BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING ); ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION ); } @@ -101,7 +101,7 @@ Any UnoTreeModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const { case BASEPROPERTY_TREE_SELECTIONTYPE: return Any( SelectionType_NONE ); - case BASEPROPERTY_TREE_ROWHEIGHT: + case BASEPROPERTY_ROW_HEIGHT: return Any( sal_Int32( 0 ) ); case BASEPROPERTY_TREE_DATAMODEL: return Any( Reference< XTreeDataModel >( 0 ) ); diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index 0f91dcd3e9cf..e2849c60cc58 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -270,7 +270,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_2 ( "RootDisplayed", TREE_ROOTDISPLAYED, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ShowsHandles", TREE_SHOWSHANDLES, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ShowsRootHandles", TREE_SHOWSROOTHANDLES, sal_Bool, BOUND, MAYBEDEFAULT ), - DECL_PROP_3 ( "RowHeight", TREE_ROWHEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "RowHeight", ROW_HEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_2 ( "InvokesStopNodeEditing", TREE_INVOKESSTOPNODEEDITING, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "DialogSourceURL", DIALOGSOURCEURL, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "URL", URL, ::rtl::OUString, BOUND, MAYBEDEFAULT ), -- cgit v1.2.3 From 4f39e56b002026409d52d0caeabda97c81961b91 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 7 Jan 2011 14:39:27 +0100 Subject: gridsort: allow the non-UNO table model to retrieve data which is not known to the UNO DataModel --- svtools/source/uno/svtxgridcontrol.cxx | 5 ++++- svtools/source/uno/unocontroltablemodel.cxx | 29 ++++++++++++++++++++++++++++- svtools/source/uno/unocontroltablemodel.hxx | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index a1cae97b64ff..9c2dbbc448e9 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -333,7 +333,10 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An // obtain new col model m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY_THROW ); - // remove new columns + // announce to the TableModel + m_pTableModel->setColumnModel( m_xColumnModel ); + + // add new columns impl_updateColumnsFromModel_nothrow(); break; diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 4bdfa0ebdabd..0c2fb73181aa 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -65,6 +65,7 @@ namespace svt { namespace table using ::com::sun::star::lang::EventObject; using ::com::sun::star::awt::grid::GridColumnEvent; using ::com::sun::star::awt::grid::XGridDataModel; + using ::com::sun::star::awt::grid::XGridColumnModel; using ::com::sun::star::uno::Any; using ::com::sun::star::style::HorizontalAlignment_LEFT; using ::com::sun::star::style::HorizontalAlignment; @@ -96,6 +97,7 @@ namespace svt { namespace table ::com::sun::star::style::VerticalAlignment m_eVerticalAlign; ModellListeners m_aListeners; WeakReference< XGridDataModel > m_aDataModel; + WeakReference< XGridColumnModel > m_aColumnModel; UnoControlTableModel_Impl() :aColumns ( ) @@ -432,6 +434,13 @@ namespace svt { namespace table // own listeners } + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::setColumnModel( Reference< XGridColumnModel > const & i_gridColumnModel ) + { + DBG_CHECK_ME(); + m_pImpl->m_aColumnModel = i_gridColumnModel; + } + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::getCellContent( ColPos const i_col, RowPos const i_row, Any& o_cellContent ) { @@ -441,7 +450,25 @@ namespace svt { namespace table { Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" ); - o_cellContent = xDataModel->getCellData( i_col, i_row ); + + if ( i_col >= xDataModel->getColumnCount() ) + { + // this is allowed, in case the column model has been dynamically extended, but the data model does + // not (yet?) know about it. + // So, handle it gracefully. + #if OSL_DEBUG_LEVEL > 0 + { + Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel ); + OSL_ENSURE( xColumnModel.is() && i_col < xColumnModel->getColumnCount(), + "UnoControlTableModel::getCellContent: request a column's value which the ColumnModel doesn't know about!" ); + } + #endif + o_cellContent.clear(); + } + else + { + o_cellContent = xDataModel->getCellData( i_col, i_row ); + } } catch( const Exception& ) { diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 2cb107b3551d..a5f67aa98bfa 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -121,6 +121,7 @@ namespace svt { namespace table void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > const & i_gridDataModel ); + void setColumnModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > const & i_gridColumnModel ); void setRowHeaders(bool _bRowHeaders); void setColumnHeaders(bool _bColumnHeaders); void setLineColor(::com::sun::star::util::Color _rColor); -- cgit v1.2.3 From 075ffa4ea267ae143c9c6c583073451ace1d57b3 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 7 Jan 2011 15:28:22 +0100 Subject: gridsort: alllow removing columns from a grid control column model --- svtools/source/table/tablecontrol_impl.cxx | 2 +- svtools/source/uno/svtxgridcontrol.cxx | 97 +++++++++++++--------- svtools/source/uno/svtxgridcontrol.hxx | 5 +- svtools/source/uno/unocontroltablemodel.cxx | 46 +++++++++- svtools/source/uno/unocontroltablemodel.hxx | 3 + .../controls/grid/defaultgridcolumnmodel.cxx | 27 +++++- .../controls/grid/defaultgridcolumnmodel.hxx | 3 +- 7 files changed, 136 insertions(+), 47 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 295c811edb84..7140da39ba8f 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -484,7 +484,7 @@ namespace svt { namespace table impl_ni_updateColumnWidths(); impl_ni_updateScrollbars(); - impl_invalidateColumnsAfter( i_first ); + impl_invalidateColumnsAfter( i_first - 1 ); OSL_UNUSED( i_last ); } diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 9c2dbbc448e9..1ad45308aa97 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -54,6 +54,7 @@ using namespace ::svt::table; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::view; +using namespace ::com::sun::star::style; using namespace ::com::sun::star::container; using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::accessibility::AccessibleEventId; @@ -62,16 +63,14 @@ using ::com::sun::star::accessibility::AccessibleTableModelChange; SVTXGridControl::SVTXGridControl() - :m_pTableModel (new UnoControlTableModel()), - m_xDataModel(0), - m_xColumnModel(0), - m_bHasColumnHeaders(false), - m_bHasRowHeaders(false), - m_bVScroll(false), - m_bHScroll(false), - m_bUpdate(false), - m_nSelectedRowCount(0), - m_aSelectionListeners( *this ) + :m_pTableModel( new UnoControlTableModel() ) + ,m_xDataModel( 0 ) + ,m_xColumnModel( 0 ) + ,m_bHasColumnHeaders( false ) + ,m_bHasRowHeaders( false ) + ,m_bTableModelInitCompleted( false ) + ,m_nSelectedRowCount( 0 ) + ,m_aSelectionListeners( *this ) { } @@ -83,13 +82,8 @@ SVTXGridControl::~SVTXGridControl() // --------------------------------------------------------------------------------------------------------------------- void SVTXGridControl::SetWindow( Window* pWindow ) { - TableControl* pTable = dynamic_cast< TableControl* >( pWindow ); - ENSURE_OR_THROW( ( pTable != NULL ) || ( pWindow == NULL ), "SVTXGridControl::SetWindow: illegal window!" ); - SVTXGridControl_Base::SetWindow( pWindow ); - - if ( pTable ) - pTable->SetModel( PTableModel( m_pTableModel ) ); + impl_checkTableModelInit(); } // --------------------------------------------------------------------------------------------------------------------- @@ -133,7 +127,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An { case BASEPROPERTY_ROW_HEADER_WIDTH: { - sal_Int32 rowHeaderWidth( m_pTableModel->getRowHeaderWidth() ); + sal_Int32 rowHeaderWidth( -1 ); aValue >>= rowHeaderWidth; ENSURE_OR_BREAK( rowHeaderWidth > 0, "SVTXGridControl::setProperty: illegal row header width!" ); m_pTableModel->setRowHeaderWidth( rowHeaderWidth ); @@ -212,10 +206,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An { sal_Bool bHScroll = true; if( aValue >>= bHScroll ) - { - m_bHScroll = bHScroll; m_pTableModel->setHorizontalScrollbarVisibility( bHScroll ? ScrollbarShowAlways : ScrollbarShowSmart ); - } break; } case BASEPROPERTY_VSCROLL: @@ -223,7 +214,6 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An sal_Bool bVScroll = true; if( aValue >>= bVScroll ) { - m_bVScroll = bVScroll; m_pTableModel->setVerticalScrollbarVisibility( bVScroll ? ScrollbarShowAlways : ScrollbarShowSmart ); } break; @@ -285,17 +275,9 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_VERTICALALIGN: { - com::sun::star::style::VerticalAlignment vAlign(com::sun::star::style::VerticalAlignment(0)); - if( aValue >>= vAlign ) - { - switch( vAlign ) - { - case com::sun::star::style::VerticalAlignment_TOP: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(0)); break; - case com::sun::star::style::VerticalAlignment_MIDDLE: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(1)); break; - case com::sun::star::style::VerticalAlignment_BOTTOM: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(2)); break; - default: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(0)); break; - } - } + VerticalAlignment eAlign( VerticalAlignment_TOP ); + if ( aValue >>= eAlign ) + m_pTableModel->setVerticalAlign( eAlign ); break; } @@ -316,6 +298,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The data model isn't set!"), *this ); m_pTableModel->setDataModel( m_xDataModel ); + impl_checkTableModelInit(); // ensure default columns exist, if they have not previously been added sal_Int32 const nDataColumnCount = m_xDataModel->getColumnCount(); @@ -336,6 +319,9 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An // announce to the TableModel m_pTableModel->setColumnModel( m_xColumnModel ); + // announce the table model to the table control, if we have everything which is needed + impl_checkTableModelInit(); + // add new columns impl_updateColumnsFromModel_nothrow(); @@ -347,6 +333,20 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } } + +void SVTXGridControl::impl_checkTableModelInit() +{ + if ( !m_bTableModelInitCompleted && m_pTableModel->hasColumnModel() && m_pTableModel->hasDataModel() ) + { + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + if ( pTable ) + { + pTable->SetModel( PTableModel( m_pTableModel ) ); + m_bTableModelInitCompleted = true; + } + } +} + Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -372,19 +372,28 @@ Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru return Any( eSelectionType ); } case BASEPROPERTY_GRID_SHOWROWHEADER: - { return Any ((sal_Bool) m_pTableModel->hasRowHeaders()); - } + case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: return Any ((sal_Bool) m_pTableModel->hasColumnHeaders()); + case BASEPROPERTY_GRID_DATAMODEL: return Any ( m_xDataModel ); + case BASEPROPERTY_GRID_COLUMNMODEL: return Any ( m_xColumnModel); + case BASEPROPERTY_HSCROLL: - return Any ( m_bHScroll); + { + sal_Bool const bHasScrollbar = ( m_pTableModel->getHorizontalScrollbarVisibility() != ScrollbarShowNever ); + return makeAny( bHasScrollbar ); + } + case BASEPROPERTY_VSCROLL: - return Any ( m_bVScroll); + { + sal_Bool const bHasScrollbar = ( m_pTableModel->getVerticalScrollbarVisibility() != ScrollbarShowNever ); + return makeAny( bHasScrollbar ); + } } return VCLXWindow::getProperty( PropertyName ); @@ -508,31 +517,41 @@ void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::Gr //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) { - const Reference< XGridColumn > xGridColumn( i_event.Element, UNO_QUERY_THROW ); + ::vos::OGuard aGuard( GetMutex() ); + + Reference< XGridColumn > const xGridColumn( i_event.Element, UNO_QUERY_THROW ); + sal_Int32 nIndex( m_pTableModel->getColumnCount() ); OSL_VERIFY( i_event.Accessor >>= nIndex ); - m_pTableModel->insertColumn( nIndex, xGridColumn ); } //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) { - // TODO: remove the respective column from our table model + ::vos::OGuard aGuard( GetMutex() ); + + sal_Int32 nIndex( -1 ); + OSL_VERIFY( i_event.Accessor >>= nIndex ); + m_pTableModel->removeColumn( nIndex ); } //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) { + OSL_ENSURE( false, "SVTXGridControl::elementReplaced: not implemented!" ); + // at the moment, the XGridColumnModel API does not allow replacing columns // TODO: replace the respective column in our table model } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) { VCLXWindow::disposing( Source ); } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Int32 SAL_CALL SVTXGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index ce1b7edd0b09..fadeae325b3b 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -60,9 +60,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > m_xColumnModel; bool m_bHasColumnHeaders; bool m_bHasRowHeaders; - bool m_bVScroll; - bool m_bHScroll; - bool m_bUpdate; + bool m_bTableModelInitCompleted; sal_Int32 m_nSelectedRowCount; SelectionListenerMultiplexer m_aSelectionListeners; @@ -118,5 +116,6 @@ protected: private: void impl_updateColumnsFromModel_nothrow(); + void impl_checkTableModelInit(); }; #endif // _SVT_GRIDCONTROL_HXX_ diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 0c2fb73181aa..91ad989a26c1 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -248,7 +248,8 @@ namespace svt { namespace table void UnoControlTableModel::insertColumn( ColPos const i_position, Reference< XGridColumn > const & i_column ) { DBG_CHECK_ME(); - ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ), "UnoControlTableModel::insertColumn: illegal position!" ); + ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ), + "UnoControlTableModel::insertColumn: illegal position!" ); const PColumnModel pColumn( new UnoGridColumnFacade( *this, i_column ) ); m_pImpl->aColumns.insert( m_pImpl->aColumns.begin() + i_position, pColumn ); @@ -264,6 +265,35 @@ namespace svt { namespace table } } + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::removeColumn( ColPos const i_position ) + { + DBG_CHECK_ME(); + ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ), + "UnoControlTableModel::removeColumn: illegal position!" ); + + // remove the column + ColumnModels::iterator pos = m_pImpl->aColumns.begin() + i_position; + const PColumnModel pColumn = *pos; + m_pImpl->aColumns.erase( pos ); + + // notify listeners + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->columnsRemoved( i_position, i_position ); + } + + // dispose the column + UnoGridColumnFacade* pColumnImpl = dynamic_cast< UnoGridColumnFacade* >( pColumn.get() ); + OSL_ENSURE( pColumnImpl != NULL, "UnoControlTableModel::removeColumn: illegal column implementation!" ); + if ( pColumnImpl ) + pColumnImpl->dispose(); + } + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::removeAllColumns() { @@ -434,6 +464,13 @@ namespace svt { namespace table // own listeners } + //------------------------------------------------------------------------------------------------------------------ + bool UnoControlTableModel::hasDataModel() const + { + Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); + return xDataModel.is(); + } + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setColumnModel( Reference< XGridColumnModel > const & i_gridColumnModel ) { @@ -441,6 +478,13 @@ namespace svt { namespace table m_pImpl->m_aColumnModel = i_gridColumnModel; } + //------------------------------------------------------------------------------------------------------------------ + bool UnoControlTableModel::hasColumnModel() const + { + Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel ); + return xColumnModel.is(); + } + //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::getCellContent( ColPos const i_col, RowPos const i_row, Any& o_cellContent ) { diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index a5f67aa98bfa..ba15c3042949 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -115,13 +115,16 @@ namespace svt { namespace table // column write access void appendColumn( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); void insertColumn( ColPos const i_position, ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); + void removeColumn( ColPos const i_position ); void removeAllColumns(); // other operations void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > const & i_gridDataModel ); + bool hasDataModel() const; void setColumnModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > const & i_gridColumnModel ); + bool hasColumnModel() const; void setRowHeaders(bool _bRowHeaders); void setColumnHeaders(bool _bColumnHeaders); void setLineColor(::com::sun::star::util::Color _rColor); diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index eecb530aae55..acd02f37db1c 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -116,6 +116,12 @@ namespace toolkit return m_aColumns.size(); } + //------------------------------------------------------------------------------------------------------------------ + Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::createColumn( ) throw (RuntimeException) + { + return new GridColumn(); + } + //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn( const Reference< XGridColumn > & i_column ) throw (RuntimeException, IllegalArgumentException) { @@ -133,6 +139,7 @@ namespace toolkit aEvent.Source = *this; aEvent.Accessor <<= index; aEvent.Element <<= i_column; + aGuard.clear(); m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); @@ -140,9 +147,25 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::createColumn( ) throw (RuntimeException) + void SAL_CALL DefaultGridColumnModel::removeColumn( ::sal_Int32 i_columnIndex ) throw (RuntimeException, IndexOutOfBoundsException) { - return new GridColumn(); + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + if ( ( i_columnIndex < 0 ) || ( size_t( i_columnIndex ) >= m_aColumns.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + Columns::iterator pos = m_aColumns.begin() + i_columnIndex; + Reference< XGridColumn > const xColumn( *pos ); + m_aColumns.erase( pos ); + + // fire removal notifications + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= i_columnIndex; + aEvent.Element <<= xColumn; + + aGuard.clear(); + m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx index 99751f37c25c..31b3c45afd67 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx @@ -59,8 +59,9 @@ public: // XGridColumnModel virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL createColumn( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL removeColumn( ::sal_Int32 i_columnIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From ce87fad0a9eba1247450d34140d44e234523cdf5 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 7 Jan 2011 15:34:09 +0100 Subject: gridsort: when columns are removed from or inserted into the model, invalidate the complete control - since columns are auto-resized, effectively all columns might need a repaint --- svtools/source/table/tablecontrol_impl.cxx | 27 ++++++--------------------- svtools/source/table/tablecontrol_impl.hxx | 2 -- 2 files changed, 6 insertions(+), 23 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 7140da39ba8f..d4de4bc0d3ef 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -473,7 +473,9 @@ namespace svt { namespace table impl_ni_updateColumnWidths(); impl_ni_updateScrollbars(); - impl_invalidateColumnsAfter( i_first ); + m_rAntiImpl.Invalidate(); + + OSL_UNUSED( i_first ); OSL_UNUSED( i_last ); } @@ -484,7 +486,9 @@ namespace svt { namespace table impl_ni_updateColumnWidths(); impl_ni_updateScrollbars(); - impl_invalidateColumnsAfter( i_first - 1 ); + m_rAntiImpl.Invalidate(); + + OSL_UNUSED( i_first ); OSL_UNUSED( i_last ); } @@ -521,25 +525,6 @@ namespace svt { namespace table m_rAntiImpl.Invalidate( aColumn.getRect() ); } - //-------------------------------------------------------------------- - void TableControl_Impl::impl_invalidateColumnsAfter( ColPos const i_column ) - { - DBG_CHECK_ME(); - - const ColPos nFirstVisibleCol = m_nLeftColumn; - const ColPos nLastVisibleCol = m_nLeftColumn + impl_getVisibleColumns( true ) - 1; - if ( ( i_column >= nFirstVisibleCol ) && ( i_column <= nLastVisibleCol ) ) - { - Rectangle aInvalidateArea; - impl_getAllVisibleCellsArea( aInvalidateArea ); - - const TableColumnGeometry aColumn( *this, aInvalidateArea, i_column ); - aInvalidateArea.Left() = aColumn.getRect().Left(); - - m_rAntiImpl.Invalidate( aInvalidateArea ); - } - } - //-------------------------------------------------------------------- void TableControl_Impl::columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ) { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 65532065ae67..73819327f0ae 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -396,8 +396,6 @@ namespace svt { namespace table /// invalidates the window area occupied by the given column void impl_invalidateColumn( ColPos const i_column ); - /// invalidates the window area occupied by the given column, and everything at the right side of it - void impl_invalidateColumnsAfter( ColPos const i_column ); DECL_LINK( OnScroll, ScrollBar* ); DECL_LINK( OnUpdateScrollbars, void* ); -- cgit v1.2.3 From ee6e84390f6ed66e26aec1a6f41aa870b4637ee7 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 7 Jan 2011 15:52:55 +0100 Subject: gridsort: do not retrieve all row headers at once, this doesn't scale. Instead, allow to retrieve the header/title of a row given by index --- svtools/source/uno/unocontroltablemodel.cxx | 5 +---- toolkit/source/controls/grid/defaultgriddatamodel.cxx | 9 +++++++-- toolkit/source/controls/grid/defaultgriddatamodel.hxx | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 91ad989a26c1..29d33d0526ee 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -532,10 +532,7 @@ namespace svt { namespace table try { - Sequence< ::rtl::OUString > const aRowHeaders( xDataModel->getRowHeaders() ); - ENSURE_OR_RETURN( ( i_rowPos >= 0 ) && ( i_rowPos < aRowHeaders.getLength() ), - "UnoControlTableModel::getRowHeader: illegal row position!", sRowHeader ); - sRowHeader = aRowHeaders[ i_rowPos ]; + sRowHeader = xDataModel->getRowTitle( i_rowPos ); } catch( const Exception& ) { diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 7a04b77c2574..8e12260be7d2 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -146,9 +146,14 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getRowHeaders() throw (::com::sun::star::uno::RuntimeException) + ::rtl::OUString SAL_CALL DefaultGridDataModel::getRowTitle( ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) { - return comphelper::containerToSequence(m_aRowHeaders); + ::osl::MutexGuard aGuard( GetMutex() ); + + if ( ( i_row < 0 ) || ( size_t( i_row ) >= m_aRowHeaders.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + return m_aRowHeaders[ i_row ]; } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 43bb43a005a8..c44c02fb0227 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -64,9 +64,9 @@ public: // XGridDataModel virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowHeaders() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getRowTitle( ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & value) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException); virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & _aData) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); -- cgit v1.2.3 From 34f93e97f28bdfc6ee731fd7213588fe505cbd2f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 10 Jan 2011 15:47:51 +0100 Subject: gridsort: XGridDataModel: moved modifying functionality into XMutableGridDataModel. --- svtools/source/uno/svtxgridcontrol.cxx | 157 ++++++---- svtools/source/uno/svtxgridcontrol.hxx | 7 +- svtools/source/uno/unocontroltablemodel.cxx | 10 +- svtools/source/uno/unocontroltablemodel.hxx | 3 +- .../source/controls/grid/defaultgriddatamodel.cxx | 341 ++++++++++++++------- .../source/controls/grid/defaultgriddatamodel.hxx | 43 +-- toolkit/source/controls/grid/gridcontrol.cxx | 17 +- .../source/controls/grid/grideventforwarder.cxx | 16 +- .../source/controls/grid/grideventforwarder.hxx | 5 +- 9 files changed, 389 insertions(+), 210 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 1ad45308aa97..de4fe1c02e17 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -64,12 +64,12 @@ using ::com::sun::star::accessibility::AccessibleTableModelChange; SVTXGridControl::SVTXGridControl() :m_pTableModel( new UnoControlTableModel() ) - ,m_xDataModel( 0 ) ,m_xColumnModel( 0 ) ,m_bHasColumnHeaders( false ) ,m_bHasRowHeaders( false ) ,m_bTableModelInitCompleted( false ) ,m_nSelectedRowCount( 0 ) + ,m_nKnowRowCount( 0 ) ,m_aSelectionListeners( *this ) { } @@ -292,22 +292,21 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } case BASEPROPERTY_GRID_DATAMODEL: { - { - m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); - if ( !m_xDataModel.is() ) - throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The data model isn't set!"), *this ); - - m_pTableModel->setDataModel( m_xDataModel ); - impl_checkTableModelInit(); - - // ensure default columns exist, if they have not previously been added - sal_Int32 const nDataColumnCount = m_xDataModel->getColumnCount(); - if ( ( nDataColumnCount > 0 ) && ( m_xColumnModel->getColumnCount() == 0 ) ) - m_xColumnModel->setDefaultColumns( nDataColumnCount ); - // this will trigger notifications, which in turn will let us update our m_pTableModel - } - break; + Reference< XGridDataModel > const xDataModel( aValue, UNO_QUERY ); + if ( !xDataModel.is() ) + throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The data model isn't set!"), *this ); + + m_pTableModel->setDataModel( xDataModel ); + impl_checkTableModelInit(); + + // ensure default columns exist, if they have not previously been added + sal_Int32 const nDataColumnCount = xDataModel->getColumnCount(); + if ( ( nDataColumnCount > 0 ) && ( m_xColumnModel->getColumnCount() == 0 ) ) + m_xColumnModel->setDefaultColumns( nDataColumnCount ); + // this will trigger notifications, which in turn will let us update our m_pTableModel } + break; + case BASEPROPERTY_GRID_COLUMNMODEL: { // remove all old columns @@ -342,6 +341,7 @@ void SVTXGridControl::impl_checkTableModelInit() if ( pTable ) { pTable->SetModel( PTableModel( m_pTableModel ) ); + m_nKnowRowCount = m_pTableModel->getRowCount(); m_bTableModelInitCompleted = true; } } @@ -378,7 +378,7 @@ Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru return Any ((sal_Bool) m_pTableModel->hasColumnHeaders()); case BASEPROPERTY_GRID_DATAMODEL: - return Any ( m_xDataModel ); + return Any ( m_pTableModel->getDataModel() ); case BASEPROPERTY_GRID_COLUMNMODEL: return Any ( m_xColumnModel); @@ -416,22 +416,26 @@ void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) VCLXWindow::ImplGetPropertyIds( rIds, true ); } -void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL SVTXGridControl::rowsAdded( const GridDataEvent& i_event ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - const TableSize rowDataLength = (TableSize)Event.RowData.getLength(); - const TableSize colCount = m_xColumnModel->getColumnCount(); - if ( colCount == 0 ) + sal_Int32 const affectedRows = i_event.Rows.getLength(); + ENSURE_OR_RETURN_VOID( affectedRows > 0, "SVTXGridControl::rowsAdded: invalid row count!" ); + + Reference< XGridDataModel > const xDataModel( m_pTableModel->getDataModel(), UNO_QUERY_THROW ); + sal_Int32 const affectedColumns = i_event.Columns.getLength() ? i_event.Columns.getLength() : xDataModel->getColumnCount(); + ENSURE_OR_RETURN_VOID( affectedColumns > 0, "SVTXGridControl::rowsAdded: no columns at all?" ); + TableSize const columnCount = m_xColumnModel->getColumnCount(); + if ( columnCount == 0 ) { - m_xColumnModel->setDefaultColumns( rowDataLength ); + m_xColumnModel->setDefaultColumns( affectedColumns ); // this will trigger notifications, which in turn will let us update our m_pTableModel } - if ( rowDataLength != colCount ) - throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), *this ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowAdded: no control (anymore)!" ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowsAdded: no control (anymore)!" ); pTable->InvalidateDataWindow( m_pTableModel->getRowCount() - 1, 0, false ); if ( pTable->isAccessibleAlive() ) @@ -452,14 +456,15 @@ void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridD } } -void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL SVTXGridControl::rowsRemoved( const GridDataEvent& i_event ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowRemoved: no control (anymore)!" ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowsRemoved: no control (anymore)!" ); - if(Event.RowIndex == -1) + if ( i_event.Rows.getLength() == 0 ) { if ( !isSelectionEmpty() ) deselectAllRows(); @@ -468,52 +473,88 @@ void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::Gri if ( pTable->isAccessibleAlive() ) { - pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange(DELETE, 0, m_pTableModel->getColumnCount(), 0, m_pTableModel->getColumnCount())), - Any()); + pTable->commitGridControlEvent( + TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange( DELETE, 0, m_pTableModel->getColumnCount(), 0, m_pTableModel->getColumnCount() ) ), + Any() + ); } } - else if ( Event.RowIndex >= 0 && Event.RowIndex < m_pTableModel->getRowCount() ) + else { - if ( isSelectedIndex( Event.RowIndex ) ) + #if OSL_DEBUG_LEVEL > 0 + for ( sal_Int32 row = 0; row < i_event.Rows.getLength() - 1; ++row ) { - Sequence< sal_Int32 > selected(1); - selected[0]=Event.RowIndex; - deselectRows( selected ); + OSL_ENSURE( i_event.Rows[row] < i_event.Rows[row], "SVTXGridControl::rowsRemoved: row indexes not sorted!" ); } - } + #endif + sal_Int32 removedRowCount = 0; + for ( sal_Int32 row = 0; row < i_event.Rows.getLength(); ++row ) + { + sal_Int32 const rowIndex = i_event.Rows[row]; + ENSURE_OR_CONTINUE( ( rowIndex >= 0 ) && ( rowIndex < m_nKnowRowCount ), + "SVTXGridControl::rowsRemoved: illegal row index!" ); - pTable->InvalidateDataWindow( Event.RowIndex, Event.RowIndex, true ); - if ( pTable->isAccessibleAlive() ) - { - pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange(DELETE, Event.RowIndex, Event.RowIndex+1, 0, m_pTableModel->getColumnCount())), - Any()); + if ( isSelectedIndex( rowIndex ) ) + { + Sequence< sal_Int32 > selected(1); + selected[0] = rowIndex; + deselectRows( selected ); + } + + if ( pTable->isAccessibleAlive() ) + { + pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange( + DELETE, rowIndex - removedRowCount, rowIndex - removedRowCount + 1, 0, m_pTableModel->getColumnCount() + // the adjustment via removedRowCount is necessary here, since with every removed row, the + // *actual* index of all subsequent rows changes, but i_event.Rows still contains the original row indexes + ) ), + Any() + ); + } + ++removedRowCount; + } + + // TODO: I don't think that the selected rows of the TableControl properly survive this - they might contain + // too large indexes now. + // Really, the ITableModel should broadcast the "rowsRemoved" event to its listeners, and the TableControl/_Impl + // should do all necessary adjustments, including for its selection, itself. } + + m_nKnowRowCount = m_pTableModel->getRowCount(); + pTable->InvalidateDataWindow( 0, m_nKnowRowCount, true ); } -void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL SVTXGridControl::dataChanged( const GridDataEvent& i_event ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" ); - if ( Event.AttributeName.equalsAscii( "RowHeaders" ) ) - { - // TODO: we could do better than this - invalidate the header area only - pTable->Invalidate(); - } - else if ( ( Event.AttributeName.equalsAscii( "CellUpdated" ) ) - || ( Event.AttributeName.equalsAscii( "RowUpdated" ) ) - ) - { - // TODO: Our UnoControlTableModel should be a listener at the data model, and multiplex those events, - // so the TableControl/_Impl can react on it. - pTable->InvalidateDataWindow( Event.RowIndex, Event.RowIndex, false ); - } + // TODO: Our UnoControlTableModel should be a listener at the data model, and multiplex those events, + // so the TableControl/_Impl can react on it. + if ( i_event.Rows.getLength() == 0 ) + pTable->InvalidateDataWindow( 0, m_pTableModel->getRowCount(), false ); + else + pTable->InvalidateDataWindow( i_event.Rows[0], i_event.Rows[ i_event.Rows.getLength() - 1 ], false ); } +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL SVTXGridControl::rowTitleChanged( const GridDataEvent& Event ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowTitleChanged: no control (anymore)!" ); + + // TODO: we could do better than this - invalidate the header area only + pTable->Invalidate(); +} + + //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) { @@ -721,7 +762,7 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R return sal_False; } -::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) +::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex( ::sal_Int32 index ) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index fadeae325b3b..19b52c183295 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -56,12 +56,12 @@ class SVTXGridControl : public SVTXGridControl_Base { private: ::boost::shared_ptr< UnoControlTableModel > m_pTableModel; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > m_xDataModel; ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > m_xColumnModel; bool m_bHasColumnHeaders; bool m_bHasRowHeaders; bool m_bTableModelInitCompleted; sal_Int32 m_nSelectedRowCount; + sal_Int32 m_nKnowRowCount; SelectionListenerMultiplexer m_aSelectionListeners; protected: @@ -73,9 +73,10 @@ public: ~SVTXGridControl(); // XGridDataListener - virtual void SAL_CALL rowAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rowRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowTitleChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); // XContainerListener virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 29d33d0526ee..8a6658578569 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -465,10 +465,16 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - bool UnoControlTableModel::hasDataModel() const + Reference< XGridDataModel > UnoControlTableModel::getDataModel() const { Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); - return xDataModel.is(); + return xDataModel; + } + + //------------------------------------------------------------------------------------------------------------------ + bool UnoControlTableModel::hasDataModel() const + { + return getDataModel().is(); } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index ba15c3042949..1f3f7f075264 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -33,7 +33,6 @@ /** === begin UNO includes === **/ #include -#include #include #include #include @@ -123,6 +122,8 @@ namespace svt { namespace table void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > const & i_gridDataModel ); bool hasDataModel() const; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > + getDataModel() const; void setColumnModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > const & i_gridColumnModel ); bool hasColumnModel() const; void setRowHeaders(bool _bRowHeaders); diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 8e12260be7d2..698e64c4429c 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -28,21 +28,23 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" #include "defaultgriddatamodel.hxx" -#include + +#include #include +#include #include +#include + using ::rtl::OUString; +using ::comphelper::stl_begin; +using ::comphelper::stl_end; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; -#define ROWHEADERS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaders" )) -#define CELLUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellUpdated" )) -#define ROWUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowUpdated" )) - //...................................................................................................................... namespace toolkit //...................................................................................................................... @@ -68,6 +70,7 @@ namespace toolkit :DefaultGridDataModel_Base() ,MutexAndBroadcastHelper() ,m_aRowHeaders() + ,m_nColumnCount(0) { } @@ -86,196 +89,304 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException) + namespace { - ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridDataListener::static_type() ); - if( pIter ) + Sequence< sal_Int32 > lcl_buildSingleElementSequence( sal_Int32 const i_index ) { - ::cppu::OInterfaceIteratorHelper aListIter(*pIter); - while(aListIter.hasMoreElements()) - { - XGridDataListener* pListener = static_cast(aListIter.next()); - switch( eType ) - { - case row_added: pListener->rowAdded(aEvent); break; - case row_removed: pListener->rowRemoved(aEvent); break; - case data_changed: pListener->dataChanged(aEvent); break; - } - } + Sequence< sal_Int32 > aIndexes(1); + aIndexes[0] = i_index; + return aIndexes; } - } + Sequence< sal_Int32 > lcl_buildIndexSequence( sal_Int32 const i_start, sal_Int32 const i_end ) + { + Sequence< sal_Int32 > aIndexes; + ENSURE_OR_RETURN( i_end >= i_start, "lcl_buildIndexSequence: illegal indexes!", aIndexes ); - //------------------------------------------------------------------------------------------------------------------ - void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue) throw (::com::sun::star::uno::RuntimeException) - { - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, name, oldValue, newValue, index, ::rtl::OUString(), Sequence< Any >()); - broadcast( data_changed, aEvent); - } + aIndexes.realloc( i_end - i_start + 1 ); + for ( sal_Int32 i = i_start; i <= i_end; ++i ) + aIndexes[ i - i_start ] = i; - //------------------------------------------------------------------------------------------------------------------ - void DefaultGridDataModel::broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, - ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) - { - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, (const ::com::sun::star::uno::Sequence< Any >&)rowData ); - broadcast( row_added, aEvent); + return aIndexes; + } } //------------------------------------------------------------------------------------------------------------------ - void DefaultGridDataModel::broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, - ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) + void DefaultGridDataModel::broadcast( GridDataEvent const & i_event, + void ( SAL_CALL XGridDataListener::*i_listenerMethod )( GridDataEvent const & ), ::osl::ClearableMutexGuard & i_instanceLock ) { - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, rowData ); - broadcast( row_removed, aEvent); + ::cppu::OInterfaceContainerHelper* pListeners = BrdcstHelper.getContainer( XGridDataListener::static_type() ); + if ( !pListeners ) + return; + + i_instanceLock.clear(); + pListeners->notifyEach( i_listenerMethod, i_event ); } //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL DefaultGridDataModel::getRowCount() throw (::com::sun::star::uno::RuntimeException) { + ::osl::MutexGuard aGuard( GetMutex() ); return m_aData.size(); } //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL DefaultGridDataModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException) { - if ( m_aData.empty() ) - return 0; - return m_aData[0].size(); + ::osl::MutexGuard aGuard( GetMutex() ); + return m_nColumnCount; } //------------------------------------------------------------------------------------------------------------------ - ::rtl::OUString SAL_CALL DefaultGridDataModel::getRowTitle( ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) + Any SAL_CALL DefaultGridDataModel::getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) { ::osl::MutexGuard aGuard( GetMutex() ); - if ( ( i_row < 0 ) || ( size_t( i_row ) >= m_aRowHeaders.size() ) ) + if ( ( i_row < 0 ) || ( size_t( i_row ) > m_aData.size() ) + || ( i_column < 0 ) || ( i_column > m_nColumnCount ) + ) throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - return m_aRowHeaders[ i_row ]; + ::std::vector< Any > const & rRow( m_aData[ i_row ] ); + if ( size_t( i_column ) < rRow.size() ) + return rRow[ i_column ]; + + return Any(); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & i_rowHeaders ) throw (::com::sun::star::uno::RuntimeException) + ::rtl::OUString SAL_CALL DefaultGridDataModel::getRowTitle( ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) { - ::com::sun::star::uno::Sequence< ::rtl::OUString > oldValue( comphelper::containerToSequence( m_aRowHeaders ) ); - - const sal_Int32 sequenceSize = i_rowHeaders.getLength(); + ::osl::MutexGuard aGuard( GetMutex() ); - sal_Int32 i = 0; - for ( std::vector< rtl::OUString >::iterator iterator = m_aRowHeaders.begin(); - iterator != m_aRowHeaders.end(); - ++iterator, ++i - ) - { - if ( sequenceSize > i ) - *iterator = i_rowHeaders[i]; - else - *iterator = ::rtl::OUString(); - } + if ( ( i_row < 0 ) || ( size_t( i_row ) >= m_aRowHeaders.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - broadcast_changed( ROWHEADERS, 0, Any( oldValue ), Any( comphelper::containerToSequence( m_aRowHeaders ) ) ); + return m_aRowHeaders[ i_row ]; } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & rRowdata) throw (::com::sun::star::uno::RuntimeException) + void SAL_CALL DefaultGridDataModel::addRow( const ::rtl::OUString& i_title, const Sequence< Any >& i_data ) throw (RuntimeException) { + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + + sal_Int32 const columnCount = i_data.getLength(); + // store header name - m_aRowHeaders.push_back(headername); + m_aRowHeaders.push_back( i_title ); // store row m_aData - std::vector< Any > newRow; - for ( int i = 0; i < rRowdata.getLength();i++) - { - newRow.push_back(rRowdata[i]); - } - + ::std::vector< Any > newRow( columnCount ); + ::std::copy( i_data.getConstArray(), i_data.getConstArray() + columnCount, newRow.begin() ); m_aData.push_back( newRow ); - broadcast_add( m_aData.size()-1, headername, comphelper::containerToSequence(newRow)); + // update column count + if ( columnCount > m_nColumnCount ) + m_nColumnCount = columnCount; + broadcast( + GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildSingleElementSequence( m_aData.size() - 1 ) ), + &XGridDataListener::rowsAdded, + aGuard + ); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) + void SAL_CALL DefaultGridDataModel::addRows( const Sequence< ::rtl::OUString >& i_titles, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException) { - if ( index >= 0 && index <= getRowCount()-1) + if ( i_titles.getLength() != i_data.getLength() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, -1 ); + + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + + sal_Int32 const rowCount = i_titles.getLength(); + if ( rowCount == 0 ) + return; + + // determine max col count in the new data + sal_Int32 maxColCount = 0; + for ( sal_Int32 row=0; row maxColCount ) + maxColCount = i_data[row].getLength(); + + if ( maxColCount < m_nColumnCount ) + maxColCount = m_nColumnCount; + + for ( sal_Int32 row=0; row& rowData ( (Sequence< Any >&)m_aData[index] ); - m_aData.erase(m_aData.begin() + index); - broadcast_remove( index, headerName, rowData); + ::std::vector< Any > newRow( maxColCount ); + Sequence< Any > const & rRowData = i_data[row]; + ::std::copy( rRowData.getConstArray(), rRowData.getConstArray() + rRowData.getLength(), newRow.begin() ); + m_aData.push_back( newRow ); } - else - return; + + if ( maxColCount > m_nColumnCount ) + m_nColumnCount = maxColCount; + + broadcast( + GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildIndexSequence( m_aData.size() - rowCount, m_aData.size() - 1 ) ), + &XGridDataListener::rowsAdded, + aGuard + ); } //------------------------------------------------------------------------------------------------------------------ - Any SAL_CALL DefaultGridDataModel::getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) + void SAL_CALL DefaultGridDataModel::removeRow( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) { - ::osl::MutexGuard aGuard( GetMutex() ); + ::osl::ClearableMutexGuard aGuard( GetMutex() ); - if ( ( i_row < 0 ) || ( size_t( i_row ) > m_aData.size() ) ) + if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) ) throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - ::std::vector< Any > const & rRow( m_aData[ i_row ] ); + m_aRowHeaders.erase( m_aRowHeaders.begin() + i_rowIndex ); + m_aData.erase( m_aData.begin() + i_rowIndex ); - if ( ( i_column < 0 ) || ( size_t( i_column ) > rRow.size() ) ) - throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - - return rRow[ i_column ]; + broadcast( + GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildSingleElementSequence( i_rowIndex ) ), + &XGridDataListener::rowsRemoved, + aGuard + ); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::addGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException) + void SAL_CALL DefaultGridDataModel::removeRows( const Sequence< ::sal_Int32 >& i_rowIndexes ) throw (IndexOutOfBoundsException, RuntimeException) { - BrdcstHelper.addListener( XGridDataListener::static_type(), xListener ); + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + + sal_Int32 const rowCount = i_rowIndexes.getLength(); + if ( rowCount == 0 ) + return; + + for ( sal_Int32 row=0; row= m_aData.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + } + + Sequence< sal_Int32 > rowIndexes( i_rowIndexes ); + ::std::sort( stl_begin( rowIndexes ), stl_end( rowIndexes ) ); + + for ( sal_Int32 row = rowCount; row > 0; ) + { + sal_Int32 const rowIndex = rowIndexes[--row]; + m_aRowHeaders.erase( m_aRowHeaders.begin() + rowIndex ); + m_aData.erase( m_aData.begin() + rowIndex ); + } + + broadcast( + GridDataEvent( *this, Sequence< sal_Int32 >(), rowIndexes ), + &XGridDataListener::rowsRemoved, + aGuard + ); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::removeGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException) + void SAL_CALL DefaultGridDataModel::removeAllRows( ) throw (RuntimeException) { - BrdcstHelper.removeListener( XGridDataListener::static_type(), xListener ); + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + + m_aRowHeaders.clear(); + m_aData.clear(); + + broadcast( + GridDataEvent( *this, Sequence< sal_Int32 >(), Sequence< sal_Int32 >() ), + &XGridDataListener::rowsRemoved, + aGuard + ); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::removeAll() throw (RuntimeException) + void SAL_CALL DefaultGridDataModel::updateCell( ::sal_Int32 i_rowIndex, ::sal_Int32 i_columnIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) { - m_aRowHeaders.clear(); - m_aData.clear(); - broadcast_remove( -1, ::rtl::OUString(), 0); + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + + if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) + || ( i_columnIndex < 0 ) || ( i_columnIndex >= m_nColumnCount ) + ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + ::std::vector< Any >& rRowData( m_aData[ i_rowIndex ] ); + if ( size_t( i_columnIndex ) >= rRowData.size() ) + rRowData.resize( i_columnIndex + 1 ); + rRowData[ i_columnIndex ] = i_value; + + broadcast( + GridDataEvent( *this, lcl_buildSingleElementSequence( i_columnIndex ), lcl_buildSingleElementSequence( i_rowIndex ) ), + &XGridDataListener::dataChanged, + aGuard + ); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::updateCell(::sal_Int32 row, ::sal_Int32 column, const Any& value) throw (::com::sun::star::uno::RuntimeException) + void SAL_CALL DefaultGridDataModel::updateRow( const Sequence< ::sal_Int32 >& i_columnIndexes, ::sal_Int32 i_rowIndex, const Sequence< Any >& i_values ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException) { - if(row >= 0 && row < (signed)m_aData.size()) + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + + if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + if ( i_columnIndexes.getLength() != i_values.getLength() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + + sal_Int32 const columnCount = i_columnIndexes.getLength(); + if ( columnCount == 0 ) + return; + + for ( sal_Int32 col = 0; col < columnCount; ++col ) + { + if ( ( i_columnIndexes[col] < 0 ) || ( i_columnIndexes[col] > m_nColumnCount ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + } + + ::std::vector< Any >& rDataRow = m_aData[ i_rowIndex ]; + for ( sal_Int32 col = 0; col < columnCount; ++col ) { - if(column >= 0 && column < (signed)m_aData[0].size()) - { - m_aData[row][column] = value; - Sequence< Any >dataSeq(comphelper::containerToSequence(m_aData[row])); - broadcast_changed( CELLUPDATED, row, Any(column), value ); - } + sal_Int32 const columnIndex = i_columnIndexes[ col ]; + if ( size_t( columnIndex ) >= rDataRow.size() ) + rDataRow.resize( columnIndex + 1 ); + + rDataRow[ columnIndex ] = i_values[ col ]; } + + // by definition, the indexes in the notified sequences shall be sorted + Sequence< sal_Int32 > columnIndexes( i_columnIndexes ); + ::std::sort( stl_begin( columnIndexes ), stl_end( columnIndexes ) ); + + broadcast( + GridDataEvent( *this, columnIndexes, lcl_buildSingleElementSequence( i_rowIndex ) ), + &XGridDataListener::dataChanged, + aGuard + ); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::updateRow(::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 > & columns, const ::com::sun::star::uno::Sequence< Any > & values) throw (::com::sun::star::uno::RuntimeException) + void SAL_CALL DefaultGridDataModel::setRowTitle( ::sal_Int32 i_rowIndex, const ::rtl::OUString& i_title ) throw (IndexOutOfBoundsException, RuntimeException) { - if(row >= 0 && row < (signed)m_aData.size()) - { - if(columns.getLength() == values.getLength()) - { - for(int i = 0; i < columns.getLength(); i++) - m_aData[row][i] = values[i]; - Sequence< Any >dataSeq(comphelper::containerToSequence(m_aData[row])); - broadcast_changed( ROWUPDATED, row, Any(columns), Any(values) ); - } - } + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + + if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + m_aRowHeaders[ i_rowIndex ] = i_title; + + broadcast( + GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildSingleElementSequence( i_rowIndex ) ), + &XGridDataListener::rowTitleChanged, + aGuard + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::addGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException) + { + BrdcstHelper.addListener( XGridDataListener::static_type(), i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::removeGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException) + { + BrdcstHelper.removeListener( XGridDataListener::static_type(), i_listener ); } //------------------------------------------------------------------------------------------------------------------ @@ -313,7 +424,7 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getSupportedServiceNames( ) throw (RuntimeException) + Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getSupportedServiceNames( ) throw (RuntimeException) { static const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridDataModel ) ); static const Sequence< OUString > aSeq( &aServiceName, 1 ); diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index c44c02fb0227..6dd81b8453ae 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -27,7 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" -#include +#include #include #include #include @@ -52,7 +52,7 @@ namespace toolkit enum broadcast_type { row_added, row_removed, data_changed}; -typedef ::cppu::WeakImplHelper2< XGridDataModel, XServiceInfo > DefaultGridDataModel_Base; +typedef ::cppu::WeakImplHelper2< XMutableGridDataModel, XServiceInfo > DefaultGridDataModel_Base; class DefaultGridDataModel : public DefaultGridDataModel_Base, public MutexAndBroadcastHelper { @@ -61,19 +61,23 @@ public: DefaultGridDataModel( DefaultGridDataModel const & i_copySource ); virtual ~DefaultGridDataModel(); + // XMutableGridDataModel + virtual void SAL_CALL addRow( const ::rtl::OUString& Title, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Data ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRows( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& Titles, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& Data ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRow( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRows( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& RowIndexes ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeAllRows( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCell( ::sal_Int32 RowIndex, ::sal_Int32 ColumnIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRow( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRowTitle( ::sal_Int32 RowIndex, const ::rtl::OUString& Title ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + // XGridDataModel virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getRowTitle( ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & value) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException); - virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & _aData) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL removeGridDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL removeAll() throw (RuntimeException); - virtual void SAL_CALL updateCell( ::sal_Int32 row, ::sal_Int32 column, const ::com::sun::star::uno::Any& value ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateRow( ::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& values ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getRowTitle( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); // XComponent virtual void SAL_CALL dispose( ) throw (RuntimeException); @@ -89,14 +93,15 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); private: + void broadcast( + GridDataEvent const & i_event, + void ( SAL_CALL ::com::sun::star::awt::grid::XGridDataListener::*i_listenerMethod )( ::com::sun::star::awt::grid::GridDataEvent const & ), + ::osl::ClearableMutexGuard & i_instanceLock + ); - void broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); - void broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue ) throw (::com::sun::star::uno::RuntimeException); - void broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); - void broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); - - std::vector< std::vector < Any > > m_aData; - std::vector< ::rtl::OUString > m_aRowHeaders; + ::std::vector< ::std::vector < Any > > m_aData; + ::std::vector< ::rtl::OUString > m_aRowHeaders; + sal_Int32 m_nColumnCount; }; } diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 76bf33768776..b2322b69df69 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -293,7 +294,7 @@ namespace try { - const Reference< XContainer > xColModel( + Reference< XContainer > const xColModel( xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnModel" ) ) ), UNO_QUERY_THROW ); if ( i_add ) @@ -301,14 +302,18 @@ namespace else xColModel->removeContainerListener( i_listener.get() ); - const Reference< XGridDataModel > xDataModel( + Reference< XGridDataModel > const xDataModel( xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridDataModel" ) ) ), UNO_QUERY_THROW ); - if ( i_add ) - xDataModel->addGridDataListener( i_listener.get() ); - else - xDataModel->removeGridDataListener( i_listener.get() ); + Reference< XMutableGridDataModel > const xMutableDataModel( xDataModel, UNO_QUERY ); + if ( xMutableDataModel.is() ) + { + if ( i_add ) + xMutableDataModel->addGridDataListener( i_listener.get() ); + else + xMutableDataModel->removeGridDataListener( i_listener.get() ); + } } catch( const Exception& ) { diff --git a/toolkit/source/controls/grid/grideventforwarder.cxx b/toolkit/source/controls/grid/grideventforwarder.cxx index 2c99acb86959..b3d17a897bad 100755 --- a/toolkit/source/controls/grid/grideventforwarder.cxx +++ b/toolkit/source/controls/grid/grideventforwarder.cxx @@ -81,19 +81,19 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridEventForwarder::rowAdded( const GridDataEvent& i_event ) throw (RuntimeException) + void SAL_CALL GridEventForwarder::rowsAdded( const GridDataEvent& i_event ) throw (RuntimeException) { Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); if ( xPeer.is() ) - xPeer->rowAdded( i_event ); + xPeer->rowsAdded( i_event ); } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridEventForwarder::rowRemoved( const GridDataEvent& i_event ) throw (RuntimeException) + void SAL_CALL GridEventForwarder::rowsRemoved( const GridDataEvent& i_event ) throw (RuntimeException) { Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); if ( xPeer.is() ) - xPeer->rowRemoved( i_event ); + xPeer->rowsRemoved( i_event ); } //------------------------------------------------------------------------------------------------------------------ @@ -104,6 +104,14 @@ namespace toolkit xPeer->dataChanged( i_event ); } + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::rowTitleChanged( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->rowTitleChanged( i_event ); + } + //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridEventForwarder::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) { diff --git a/toolkit/source/controls/grid/grideventforwarder.hxx b/toolkit/source/controls/grid/grideventforwarder.hxx index 93905b06f492..c0c09a7cc95d 100755 --- a/toolkit/source/controls/grid/grideventforwarder.hxx +++ b/toolkit/source/controls/grid/grideventforwarder.hxx @@ -61,9 +61,10 @@ namespace toolkit virtual void SAL_CALL release() throw(); // XGridDataListener - virtual void SAL_CALL rowAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rowRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowTitleChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); // XContainerListener virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From 5a256f4486e4b9875ea62c9a8f65ad110fda71b9 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 11 Jan 2011 10:58:26 +0100 Subject: gridsort: removed XGridControl::setTooltip. It had a rather strange semantics, seems to be unused in the current OOo code base, and would belong to the model, if at all. Still one thing to do: do not unconditionally display the cell content as tooltip, but make this dependent on whether or not the cell content fits into the cell. --- svtools/inc/svtools/table/abstracttablecontrol.hxx | 2 - svtools/inc/svtools/table/tablecontrol.hxx | 13 ++-- svtools/inc/svtools/table/tabledatawindow.hxx | 1 + svtools/inc/svtools/table/tablemodel.hxx | 17 +++++ svtools/source/table/cellvalueconversion.cxx | 6 +- svtools/source/table/tablecontrol.cxx | 27 +------- svtools/source/table/tablecontrol_impl.cxx | 75 +--------------------- svtools/source/table/tablecontrol_impl.hxx | 3 - svtools/source/table/tabledatawindow.cxx | 68 ++++++++++++++++---- svtools/source/uno/svtxgridcontrol.cxx | 15 +---- svtools/source/uno/svtxgridcontrol.hxx | 1 - svtools/source/uno/unocontroltablemodel.cxx | 9 +++ svtools/source/uno/unocontroltablemodel.hxx | 1 + toolkit/source/controls/grid/gridcontrol.cxx | 6 -- toolkit/source/controls/grid/gridcontrol.hxx | 1 - 15 files changed, 98 insertions(+), 147 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx index ac91006e42f5..eb70a6967e6f 100644 --- a/svtools/inc/svtools/table/abstracttablecontrol.hxx +++ b/svtools/inc/svtools/table/abstracttablecontrol.hxx @@ -116,8 +116,6 @@ namespace svt { namespace table /** returns selection engine*/ virtual SelectionEngine* getSelEngine() = 0; virtual void activateCellAt( const Point& rPoint ) = 0; - virtual bool isTooltipActive() = 0; - virtual rtl::OUString& setTooltip(const Point& rPoint ) = 0; virtual RowPos getRowAtPoint( const Point& rPoint ) = 0; virtual ColPos getColAtPoint( const Point& rPoint ) = 0; virtual void resizeColumn(const Point& rPoint ) = 0; diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index b75ebe0dcc88..d557597b6ff8 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -77,11 +77,8 @@ namespace svt { namespace table DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); ::boost::shared_ptr< TableControl_Impl > m_pImpl; - ::com::sun::star::uno::Sequence< sal_Int32 > m_nCols; - ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aText; Link m_aSelectHdl; bool m_bSelectionChanged; - bool m_bTooltip; public: ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable; @@ -110,8 +107,8 @@ namespace svt { namespace table */ sal_Int32 GetCurrentRow() const; - /** returns the row, which contains the input point*/ - ColPos GetRowAtPoint( const Point& rPoint ); + IAbstractTableControl& + getTableControlInterface(); /** retrieves the current column @@ -194,6 +191,7 @@ namespace svt { namespace table virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet, AccessibleTableControlObjType eObjType ) const; + //// Window virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; virtual void GrabFocus(); @@ -224,12 +222,9 @@ namespace svt { namespace table virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); virtual void RemoveSelectedRow(RowPos _nRowPos); virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; - ::com::sun::star::uno::Sequence< sal_Int32 >& getColumnsForTooltip(); - ::com::sun::star::uno::Sequence< ::rtl::OUString >& getTextForTooltip(); - void setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols); + void clearSelection(); void selectionChanged(bool _bChanged); - bool isTooltip(); protected: ::svt::IAccessibleFactory& getAccessibleFactory(); diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/inc/svtools/table/tabledatawindow.hxx index 829feecd5836..1cc030be512b 100644 --- a/svtools/inc/svtools/table/tabledatawindow.hxx +++ b/svtools/inc/svtools/table/tabledatawindow.hxx @@ -75,6 +75,7 @@ namespace svt { namespace table virtual long Notify(NotifyEvent& rNEvt); virtual void SetControlBackground(const Color& rColor); virtual void SetControlBackground(); + virtual void RequestHelp( const HelpEvent& rHEvt ); void SetBackground(const Wallpaper& rColor); void SetBackground(); diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index dc25788bc491..b8c13822a460 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -432,6 +432,23 @@ namespace svt { namespace table */ virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ) = 0; + /** returns an object which should be displayed as tooltip for the given cell + + At the moment, only string-convertible values are supported here. In the future, one might imagine displaying + scaled-down versions of a graphic in a cell, and a larger version of that very graphic as tooltip. + + If no tooltip object is provided, then the cell content is used, and displayed as tooltip for the cell + if and only if it doesn't fit into the cell's space itself. + + @param i_col + The column index of the cell in question. COL_ROW_HEADERS is a valid argument here. + @param i_row + The row index of the cell in question. ROW_COL_HEADERS is a valid argument. + @param o_cellToolTip + takes the tooltip object upon return. + */ + virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ) = 0; + /** retrieves title of a given row */ virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const = 0; diff --git a/svtools/source/table/cellvalueconversion.cxx b/svtools/source/table/cellvalueconversion.cxx index 9b36ad095203..286ca505bb30 100755 --- a/svtools/source/table/cellvalueconversion.cxx +++ b/svtools/source/table/cellvalueconversion.cxx @@ -46,12 +46,16 @@ namespace svt //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString CellValueConversion::convertToString( const Any& i_value ) { + ::rtl::OUString sConvertString; + if ( !i_value.hasValue() ) + return sConvertString; + + // TODO: use css.script.XTypeConverter? sal_Int32 nInt = 0; sal_Bool bBool = false; double fDouble = 0; - ::rtl::OUString sConvertString; ::rtl::OUString sStringValue; if ( i_value >>= sConvertString ) diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 08227b9abd91..1b6027b71324 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -70,7 +70,6 @@ namespace svt { namespace table :Control( _pParent, _nStyle ) ,m_pImpl( new TableControl_Impl( *this ) ) ,m_bSelectionChanged(false) - ,m_bTooltip(false) { TableDataWindow* aTableData = m_pImpl->getDataWindow(); aTableData->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); @@ -245,9 +244,9 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - RowPos TableControl::GetRowAtPoint( const Point& rPoint ) + IAbstractTableControl& TableControl::getTableControlInterface() { - return m_pImpl->getRowAtPoint( rPoint ); + return *m_pImpl; } //-------------------------------------------------------------------- @@ -574,34 +573,12 @@ Rectangle TableControl::calcTableRect(BOOL _bOnScreen) (void)_bOnScreen; return m_pImpl->calcTableRect(); } -//-------------------------------------------------------------------- -::com::sun::star::uno::Sequence< sal_Int32 >& TableControl::getColumnsForTooltip() -{ - return m_nCols; -} -//-------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::rtl::OUString >& TableControl::getTextForTooltip() -{ - return m_aText; -} -//-------------------------------------------------------------------- -void TableControl::setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols ) -{ - m_aText = aText; - m_nCols = nCols; - m_bTooltip = true; -} // ----------------------------------------------------------------------- void TableControl::selectionChanged(bool _bChanged) { m_bSelectionChanged = _bChanged; } // ----------------------------------------------------------------------- -bool TableControl::isTooltip() -{ - return m_bTooltip; -} -// ----------------------------------------------------------------------- IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG ) { Select(); diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index d4de4bc0d3ef..ef217527cdff 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -185,6 +185,9 @@ namespace svt { namespace table (void)i_col; o_cellContent.clear(); } + virtual void getCellToolTip( ColPos const, RowPos const, ::com::sun::star::uno::Any& ) + { + } virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const { (void)i_rowPos; @@ -2071,78 +2074,6 @@ namespace svt { namespace table } return -1; } - //------------------------------------------------------------------------------- - bool TableControl_Impl::isTooltipActive() - { - return m_rAntiImpl.isTooltip(); - } - //------------------------------------------------------------------------------- - ::rtl::OUString& TableControl_Impl::setTooltip(const Point& rPoint ) - { - ::rtl::OUString aTooltipText; - const RowPos hitRow = getRowAtPoint( rPoint ); - const ColPos hitCol = getColAtPoint( rPoint ); - com::sun::star::uno::Sequence< sal_Int32 > cols = m_rAntiImpl.getColumnsForTooltip(); - com::sun::star::uno::Sequence< ::rtl::OUString > text = m_rAntiImpl.getTextForTooltip(); - if(text.getLength()==0 && cols.getLength()==0) - { - aTooltipText = getCellContentAsString( hitRow, hitCol ); - } - else if(text.getLength() == 0) - { - for(int i=0; i i) - { - aTooltipText += getCellContentAsString( hitRow, cols[i] ); - } - } - } - } - return m_aTooltipText = aTooltipText; - } //-------------------------------------------------------------------- ColPos TableControl_Impl::impl_getColumnForOrdinate( long const i_ordinate ) const diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 73819327f0ae..730b00b638b8 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -159,7 +159,6 @@ namespace svt { namespace table ColPos m_nResizingColumn; bool m_bResizingGrid; bool m_bUpdatingColWidths; - rtl::OUString m_aTooltipText; #if DBG_UTIL #define INV_SCROLL_POSITION 1 @@ -255,8 +254,6 @@ namespace svt { namespace table virtual bool dispatchAction( TableControlAction _eAction ); virtual SelectionEngine* getSelEngine(); virtual void activateCellAt( const Point& rPoint ); - virtual bool isTooltipActive(); - virtual rtl::OUString& setTooltip(const Point& rPoint ); virtual RowPos getRowAtPoint( const Point& rPoint ); virtual ColPos getColAtPoint( const Point& rPoint ); virtual void resizeColumn(const Point& rPoint); diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 41bd851e6b82..2fc08b13742e 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -29,15 +29,22 @@ #include "svtools/table/tablecontrol.hxx" #include "svtools/table/tabledatawindow.hxx" + #include "tablecontrol_impl.hxx" +#include "tablegeometry.hxx" +#include "cellvalueconversion.hxx" + #include //........................................................................ namespace svt { namespace table { - class TableControl_Impl; //........................................................................ + /** === begin UNO using === **/ + using ::com::sun::star::uno::Any; + /** === end UNO using === **/ + //==================================================================== //= TableDataWindow //==================================================================== @@ -77,29 +84,62 @@ namespace svt { namespace table { Window::SetControlBackground(); } + + //-------------------------------------------------------------------- + void TableDataWindow::RequestHelp( const HelpEvent& rHEvt ) + { + USHORT const nHelpMode = rHEvt.GetMode(); + if ( ( nHelpMode & HELPMODE_QUICK ) != 0 ) + { + Point const aMousePos( m_rTableControl.getAntiImpl().ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ); + + RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos ); + ColPos const hitCol = m_rTableControl.getColAtPoint( aMousePos ); + if ( ( hitRow >= 0 ) && ( hitRow < m_rTableControl.getRowCount() ) + && ( hitCol >= 0 ) && ( hitCol < m_rTableControl.getColumnCount() ) + ) + { + PTableModel const pTableModel( m_rTableControl.getAntiImpl().GetModel() ); + + Any aCellToolTip; + pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip ); + if ( !aCellToolTip.hasValue() ) + { + // use the cell content + pTableModel->getCellContent( hitCol, hitRow, aCellToolTip ); + // TODO: use the cell content as tool tip only if it doesn't fit into the cell. Need to + // ask the renderer for this. + } + + ::rtl::OUString const sHelpText( CellValueConversion::convertToString( aCellToolTip ) ); + if ( sHelpText.getLength() > 0 ) + { + Rectangle const aControlScreenRect( + m_rTableControl.getAntiImpl().OutputToScreenPixel( Point( 0, 0 ) ), + m_rTableControl.getAntiImpl().GetOutputSizePixel() + ); + Help::ShowQuickHelp( &m_rTableControl.getAntiImpl(), aControlScreenRect, sHelpText ); + } + } + } + else + { + Window::RequestHelp( rHEvt ); + } + } + //-------------------------------------------------------------------- void TableDataWindow::MouseMove( const MouseEvent& rMEvt ) { Point aPoint = rMEvt.GetPosPixel(); if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) ) { - if ( m_rTableControl.isTooltipActive() && m_rTableControl.getRowAtPoint( aPoint ) >= 0 ) - { - SetPointer(POINTER_ARROW); - const ::rtl::OUString& rHelpText = m_rTableControl.setTooltip(aPoint); - Help::EnableBalloonHelp(); - Window::SetHelpText( rHelpText ); - } - else if ( m_rTableControl.getRowAtPoint( aPoint ) == ROW_COL_HEADERS ) + if ( m_rTableControl.getRowAtPoint( aPoint ) == ROW_COL_HEADERS ) { - if(Help::IsBalloonHelpEnabled()) - Help::DisableBalloonHelp(); - m_rTableControl.resizeColumn(aPoint); + m_rTableControl.resizeColumn( aPoint ); } else { - if(Help::IsBalloonHelpEnabled()) - Help::DisableBalloonHelp(); Window::MouseMove( rMEvt ); } } diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index de4fe1c02e17..d4ab00868ec9 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -30,8 +30,7 @@ #include "svtxgridcontrol.hxx" #include "accessibletableimp.hxx" #include -#include "svtools/table/gridtablerenderer.hxx" -#include "svtools/table/defaultinputhandler.hxx" +#include "svtools/table/abstracttablecontrol.hxx" #include "svtools/table/tablecontrol.hxx" #include "unocontroltablemodel.hxx" #include @@ -93,17 +92,7 @@ sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getItemIndexAtPoint: no control (anymore)!", -1 ); - return pTable->GetRowAtPoint( Point( x, y ) ); -} - -// --------------------------------------------------------------------------------------------------------------------- -void SAL_CALL SVTXGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable != NULL, "SVTXGridControl::setToolTip: no control (anymore)!" ); - pTable->setTooltip(text, columns); + return pTable->getTableControlInterface().getRowAtPoint( Point( x, y ) ); } void SAL_CALL SVTXGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index 19b52c183295..361e7d41cad7 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -102,7 +102,6 @@ public: 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); virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException); void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 8a6658578569..f7b2ca07eb22 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -526,6 +526,15 @@ namespace svt { namespace table } } + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::getCellToolTip( ColPos const i_col, RowPos const i_row, Any& o_cellToolTip ) + { + DBG_CHECK_ME(); + OSL_UNUSED( i_col ); + OSL_UNUSED( i_row ); + OSL_UNUSED( o_cellToolTip ); + } + //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString UnoControlTableModel::getRowHeader( RowPos const i_rowPos ) const { diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 1f3f7f075264..a6cd858ed34f 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -103,6 +103,7 @@ namespace svt { namespace table virtual void addTableModelListener( const PTableModelListener& i_listener ); virtual void removeTableModelListener( const PTableModelListener& i_listener ); virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ); + virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ); virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const; virtual ::com::sun::star::util::Color getLineColor(); virtual ::com::sun::star::util::Color getHeaderBackgroundColor(); diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index b2322b69df69..3623bb64bd27 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -339,12 +339,6 @@ sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_ return xGrid->getItemIndexAtPoint( x, y ); } -//---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UnoGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->setToolTip( text, columns ); -} - //---------------------------------------------------------------------------------------------------------------------- ::sal_Int32 SAL_CALL UnoGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index ce651a4061a9..65410d465730 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -98,7 +98,6 @@ public: // ::com::sun::star::awt::grid::XGridControl virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridSelection virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From 012b72f48860433345989eedc9cd1ccb9350b455 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 11 Jan 2011 11:42:27 +0100 Subject: gridsort: +XGridColumn::HelpText, to be displayed as tooltip for the column header --- svtools/inc/svtools/table/tablemodel.hxx | 10 ++- svtools/source/table/tabledatawindow.cxx | 31 ++++++--- svtools/source/uno/unogridcolumnfacade.cxx | 38 +++++++++-- svtools/source/uno/unogridcolumnfacade.hxx | 2 + .../controls/grid/defaultgridcolumnmodel.cxx | 2 +- toolkit/source/controls/grid/gridcolumn.cxx | 78 ++++++++-------------- toolkit/source/controls/grid/gridcolumn.hxx | 18 ++++- 7 files changed, 109 insertions(+), 70 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index b8c13822a460..3eb87f1eb40e 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -213,6 +213,14 @@ namespace svt { namespace table */ virtual void setName( const String& _rName ) = 0; + /** retrieves the help text to be displayed for the column. + */ + virtual String getHelpText() const = 0; + + /** sets a new the help text to be displayed for the column. + */ + virtual void setHelpText( const String& i_helpText ) = 0; + /** determines whether the column can be resized @see getMinWidth @@ -443,7 +451,7 @@ namespace svt { namespace table @param i_col The column index of the cell in question. COL_ROW_HEADERS is a valid argument here. @param i_row - The row index of the cell in question. ROW_COL_HEADERS is a valid argument. + The row index of the cell in question. @param o_cellToolTip takes the tooltip object upon return. */ diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 2fc08b13742e..2092a4bccdc9 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -95,23 +95,32 @@ namespace svt { namespace table RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos ); ColPos const hitCol = m_rTableControl.getColAtPoint( aMousePos ); - if ( ( hitRow >= 0 ) && ( hitRow < m_rTableControl.getRowCount() ) - && ( hitCol >= 0 ) && ( hitCol < m_rTableControl.getColumnCount() ) - ) + + if ( ( hitCol >= 0 ) && ( hitCol < m_rTableControl.getColumnCount() ) ) { + ::rtl::OUString sHelpText; + PTableModel const pTableModel( m_rTableControl.getAntiImpl().GetModel() ); - Any aCellToolTip; - pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip ); - if ( !aCellToolTip.hasValue() ) + if ( hitRow == ROW_COL_HEADERS ) { - // use the cell content - pTableModel->getCellContent( hitCol, hitRow, aCellToolTip ); - // TODO: use the cell content as tool tip only if it doesn't fit into the cell. Need to - // ask the renderer for this. + sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText(); + } + else if ( ( hitRow >= 0 ) && ( hitRow < m_rTableControl.getRowCount() ) ) + { + Any aCellToolTip; + pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip ); + if ( !aCellToolTip.hasValue() ) + { + // use the cell content + pTableModel->getCellContent( hitCol, hitRow, aCellToolTip ); + // TODO: use the cell content as tool tip only if it doesn't fit into the cell. Need to + // ask the renderer for this. + } + + sHelpText = CellValueConversion::convertToString( aCellToolTip ); } - ::rtl::OUString const sHelpText( CellValueConversion::convertToString( aCellToolTip ) ); if ( sHelpText.getLength() > 0 ) { Rectangle const aControlScreenRect( diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index 4e094bbd6523..00fa72199815 100755 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -150,14 +150,14 @@ namespace svt { namespace table { ColumnAttributeGroup nChangedAttributes( COL_ATTRS_NONE ); - if ( i_event.AttributeName.equalsAscii( "HAlign" ) ) + if ( i_event.AttributeName.equalsAscii( "HorizontalAlign" ) ) nChangedAttributes |= COL_ATTRS_APPEARANCE; - if ( i_event.AttributeName.equalsAscii( "ColWidth" ) + if ( i_event.AttributeName.equalsAscii( "ColumnWidth" ) || i_event.AttributeName.equalsAscii( "MaxWidth" ) || i_event.AttributeName.equalsAscii( "MinWidth" ) - || i_event.AttributeName.equalsAscii( "PrefWidth" ) - || i_event.AttributeName.equalsAscii( "ColumnResize" ) + || i_event.AttributeName.equalsAscii( "PreferredWidth" ) + || i_event.AttributeName.equalsAscii( "Resizeable" ) ) nChangedAttributes |= COL_ATTRS_WIDTH; @@ -273,6 +273,36 @@ namespace svt { namespace table } } + //------------------------------------------------------------------------------------------------------------------ + String UnoGridColumnFacade::getHelpText() const + { + ::rtl::OUString sHelpText; + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", sHelpText ); + try + { + sHelpText = m_xGridColumn->getHelpText(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sHelpText; + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setHelpText( const String& i_helpText ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + try + { + m_xGridColumn->setHelpText( i_helpText ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + //------------------------------------------------------------------------------------------------------------------ bool UnoGridColumnFacade::isResizable() const { diff --git a/svtools/source/uno/unogridcolumnfacade.hxx b/svtools/source/uno/unogridcolumnfacade.hxx index a49f1c8963e7..6f606bb6f86b 100755 --- a/svtools/source/uno/unogridcolumnfacade.hxx +++ b/svtools/source/uno/unogridcolumnfacade.hxx @@ -68,6 +68,8 @@ namespace svt { namespace table virtual void setID( const ::com::sun::star::uno::Any& i_ID ); virtual String getName() const; virtual void setName( const String& _rName ); + virtual String getHelpText() const; + virtual void setHelpText( const String& i_helpText ); virtual bool isResizable() const; virtual void setResizable( bool _bResizable ); virtual TableMetrics getWidth() const; diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index d417a1432bd2..04ecf93d9bc5 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -217,7 +217,7 @@ namespace toolkit Reference< XGridColumn > const xColumn( pGridColumn.get() ); ::rtl::OUStringBuffer colTitle; colTitle.appendAscii( "Column " ); - colTitle.append( i ); + colTitle.append( i + 1 ); pGridColumn->setTitle( colTitle.makeStringAndClear() ); pGridColumn->setPreferredWidth( 80 /* APPFONT */ ); diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 711affab8017..25272f4e489a 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -32,14 +32,6 @@ #include #include -#define COLWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColWidth" )) -#define MAXWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MaxWidth" )) -#define MINWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MinWidth" )) -#define PREFWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PrefWidth" )) -#define HALIGN ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "HAlign" )) -#define TITLE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" )) -#define COLRESIZE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResize" )) - namespace toolkit { using namespace ::com::sun::star; @@ -88,10 +80,13 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void GridColumn::broadcast_changed( ::rtl::OUString name, Any i_oldValue, Any i_newValue, ::osl::ClearableMutexGuard& i_Guard ) + void GridColumn::broadcast_changed( sal_Char const * const i_asciiAttributeName, Any i_oldValue, Any i_newValue, ::osl::ClearableMutexGuard& i_Guard ) { Reference< XInterface > const xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridColumnEvent const aEvent( xSource, name, i_oldValue, i_newValue, m_nIndex); + GridColumnEvent const aEvent( + xSource, ::rtl::OUString::createFromAscii( i_asciiAttributeName ), + i_oldValue, i_newValue, m_nIndex + ); ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() ); @@ -110,7 +105,8 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException) { - value >>= m_aIdentifier; + ::osl::MutexGuard aGuard( m_aMutex ); + m_aIdentifier = value; } //------------------------------------------------------------------------------------------------------------------ @@ -123,12 +119,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_nColumnWidth == value ) - return; - - m_nColumnWidth = value; - broadcast_changed( COLWIDTH, Any( m_nColumnWidth ), Any( value ), aGuard ); + impl_set( m_nColumnWidth, value, "ColumnWidth" ); } //------------------------------------------------------------------------------------------------------------------ @@ -141,12 +132,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_nPreferredWidth == value ) - return; - - m_nPreferredWidth = value; - broadcast_changed( PREFWIDTH, Any( m_nPreferredWidth ), Any( value ), aGuard ); + impl_set( m_nPreferredWidth, value, "PreferredWidth" ); } //------------------------------------------------------------------------------------------------------------------ @@ -159,12 +145,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_nMaxWidth == value ) - return; - - m_nMaxWidth = value; - broadcast_changed( MAXWIDTH, Any( m_nMaxWidth ), Any( value ), aGuard ); + impl_set( m_nMaxWidth, value, "MaxWidth" ); } //------------------------------------------------------------------------------------------------------------------ @@ -177,12 +158,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_nMinWidth == value ) - return; - - m_nMinWidth = value; - broadcast_changed( MINWIDTH, Any( m_nMinWidth ), Any( value ), aGuard ); + impl_set( m_nMinWidth, value, "MinWidth" ); } //------------------------------------------------------------------------------------------------------------------ @@ -195,12 +171,20 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_sTitle == value ) - return; + impl_set( m_sTitle, value, "Title" ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL GridColumn::getHelpText() throw (RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + return m_sHelpText; + } - m_sTitle = value; - broadcast_changed( TITLE, Any( m_sTitle ), Any( value ), aGuard ); + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setHelpText( const ::rtl::OUString & value ) throw (RuntimeException) + { + impl_set( m_sHelpText, value, "HelpText" ); } //------------------------------------------------------------------------------------------------------------------ @@ -213,12 +197,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_bResizeable == value ) - return; - - m_bResizeable = value; - broadcast_changed( COLRESIZE, Any( m_bResizeable ), Any( value ), aGuard ); + impl_set( m_bResizeable, value, "Resizeable" ); } //------------------------------------------------------------------------------------------------------------------ @@ -231,12 +210,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_eHorizontalAlign == align ) - return; - - m_eHorizontalAlign = align; - broadcast_changed( HALIGN, Any( m_eHorizontalAlign ), Any( align ), aGuard ); + impl_set( m_eHorizontalAlign, value, "HorizontalAlign" ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index 89d6da0c8cd2..a46b18a84fce 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -70,6 +70,8 @@ public: virtual void SAL_CALL setResizeable(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getHelpText() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHelpText(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); @@ -99,12 +101,25 @@ public: private: void broadcast_changed( - ::rtl::OUString name, + sal_Char const * const i_asciiAttributeName, ::com::sun::star::uno::Any i_oldValue, ::com::sun::star::uno::Any i_newValue, ::osl::ClearableMutexGuard& i_Guard ); + template< class TYPE > + void impl_set( TYPE & io_attribute, TYPE const & i_newValue, sal_Char const * i_attributeName ) + { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( io_attribute == i_newValue ) + return; + + TYPE const aOldValue( io_attribute ); + io_attribute = i_newValue; + broadcast_changed( i_attributeName, ::com::sun::star::uno::makeAny( aOldValue ), ::com::sun::star::uno::makeAny( io_attribute ), aGuard ); + } + + ::com::sun::star::uno::Any m_aIdentifier; sal_Int32 m_nIndex; sal_Int32 m_nColumnWidth; @@ -113,6 +128,7 @@ private: sal_Int32 m_nMinWidth; sal_Bool m_bResizeable; ::rtl::OUString m_sTitle; + ::rtl::OUString m_sHelpText; ::com::sun::star::style::HorizontalAlignment m_eHorizontalAlign; }; -- cgit v1.2.3 From 16028c42b11486c7a407736c78202eda88934e13 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 11 Jan 2011 12:36:41 +0100 Subject: gridsort: XGridControl::getItemIndexAtPoint renamed to getRowAtPoint; introduced getColumnAtPoint --- svtools/source/uno/svtxgridcontrol.cxx | 21 ++++++++++++++++++--- svtools/source/uno/svtxgridcontrol.hxx | 7 +++++-- toolkit/source/controls/grid/gridcolumn.cxx | 2 +- toolkit/source/controls/grid/gridcontrol.cxx | 13 ++++++++++--- toolkit/source/controls/grid/gridcontrol.hxx | 3 ++- 5 files changed, 36 insertions(+), 10 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index d4ab00868ec9..c2cf8faac548 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -86,25 +86,40 @@ void SVTXGridControl::SetWindow( Window* pWindow ) } // --------------------------------------------------------------------------------------------------------------------- -sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) +sal_Int32 SAL_CALL SVTXGridControl::getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getItemIndexAtPoint: no control (anymore)!", -1 ); - return pTable->getTableControlInterface().getRowAtPoint( Point( x, y ) ); + ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getRowAtPoint: no control (anymore)!", -1 ); + sal_Int32 const nRow = pTable->getTableControlInterface().getRowAtPoint( Point( x, y ) ); + return ( nRow >= 0 ) ? nRow : -1; } +// --------------------------------------------------------------------------------------------------------------------- +sal_Int32 SAL_CALL SVTXGridControl::getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getColumnAtPoint: no control (anymore)!", -1 ); + sal_Int32 const nColumn = pTable->getTableControlInterface().getColAtPoint( Point( x, y ) ); + return ( nColumn >= 0 ) ? nColumn : -1; +} + +// --------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { m_aSelectionListeners.addInterface(listener); } +// --------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { m_aSelectionListeners.removeInterface(listener); } +// --------------------------------------------------------------------------------------------------------------------- void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const Any& aValue) throw(RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index 361e7d41cad7..c3d1f909126b 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -86,7 +86,7 @@ public: // XEventListener virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); - //::com::sun::star::awt::grid::XGridControl + // XGridSelection virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); @@ -101,7 +101,10 @@ public: virtual void SAL_CALL selectColumn(::sal_Int32 x) 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); - virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + + // XGridControl + virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 25272f4e489a..09fb053ce152 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -210,7 +210,7 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) { - impl_set( m_eHorizontalAlign, value, "HorizontalAlign" ); + impl_set( m_eHorizontalAlign, align, "HorizontalAlign" ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 3623bb64bd27..70afcc5c3a13 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -333,10 +333,17 @@ sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_ } //---------------------------------------------------------------------------------------------------------------------- -::sal_Int32 UnoGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) +::sal_Int32 UnoGridControl::getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl > xGrid ( getPeer(), UNO_QUERY_THROW ); - return xGrid->getItemIndexAtPoint( x, y ); + Reference< XGridControl > const xGrid ( getPeer(), UNO_QUERY_THROW ); + return xGrid->getRowAtPoint( x, y ); +} + +//---------------------------------------------------------------------------------------------------------------------- +::sal_Int32 UnoGridControl::getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) +{ + Reference< XGridControl > const xGrid ( getPeer(), UNO_QUERY_THROW ); + return xGrid->getColumnAtPoint( x, y ); } //---------------------------------------------------------------------------------------------------------------------- diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index 65410d465730..6dfc5d71e639 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -97,7 +97,8 @@ public: sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel ) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridControl - virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridSelection virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From 3d7ca63d0efdc25200133c4086b48982b3a20eca Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 11 Jan 2011 13:26:40 +0100 Subject: gridsort: IAbstractTableControl renamed to ITableControl, added a few more methods previously found at the TableControl_Impl only --- svtools/inc/svtools/table/abstracttablecontrol.hxx | 133 ----- svtools/inc/svtools/table/defaultinputhandler.hxx | 20 +- svtools/inc/svtools/table/tablecontrol.hxx | 6 +- .../inc/svtools/table/tablecontrolinterface.hxx | 143 +++++ svtools/inc/svtools/table/tableinputhandler.hxx | 22 +- svtools/source/table/defaultinputhandler.cxx | 22 +- svtools/source/table/tablecontrol.cxx | 641 +++++++++++---------- svtools/source/table/tablecontrol_impl.cxx | 137 +++-- svtools/source/table/tablecontrol_impl.hxx | 10 +- svtools/source/table/tabledatawindow.cxx | 15 +- svtools/source/uno/svtxgridcontrol.cxx | 2 +- 11 files changed, 603 insertions(+), 548 deletions(-) delete mode 100644 svtools/inc/svtools/table/abstracttablecontrol.hxx create mode 100644 svtools/inc/svtools/table/tablecontrolinterface.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx deleted file mode 100644 index eb70a6967e6f..000000000000 --- a/svtools/inc/svtools/table/abstracttablecontrol.hxx +++ /dev/null @@ -1,133 +0,0 @@ -/************************************************************************* - * 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 - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * -************************************************************************/ - -#ifndef SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX -#define SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX - -#include -#include -#include -#include "tabletypes.hxx" -//........................................................................ -namespace svt { namespace table -{ -//........................................................................ - - enum TableControlAction - { - /// moves the cursor in the table control one row up, if possible, by keeping the current column - cursorUp, - /// moves the cursor in the table control one row down, if possible, by keeping the current column - cursorDown, - /// moves the cursor in the table control one column to the left, if possible, by keeping the current row - cursorLeft, - /// moves the cursor in the table control one column to the right, if possible, by keeping the current row - cursorRight, - /// moves the cursor to the beginning of the current line - cursorToLineStart, - /// moves the cursor to the end of the current line - cursorToLineEnd, - /// moves the cursor to the first row, keeping the current column - cursorToFirstLine, - /// moves the cursor to the last row, keeping the current column - cursorToLastLine, - /// moves the cursor one page up, keeping the current column - cursorPageUp, - /// moves the cursor one page down, keeping the current column - cursorPageDown, - /// moves the cursor to the top-most, left-most cell - cursorTopLeft, - /// moves the cursor to the bottom-most, right-most cell - cursorBottomRight, - /// selects the row, where the actual cursor is - cursorSelectRow, - /// selects the rows, above the actual cursor is - cursorSelectRowUp, - /// selects the row, beneath the actual cursor is - cursorSelectRowDown, - /// selects the row, from the actual cursor till top - cursorSelectRowAreaTop, - /// selects the row, from the actual cursor till bottom - cursorSelectRowAreaBottom, - - /// invalid and final enumeration value, not to be actually used - invalidTableControlAction - }; - - //==================================================================== - //= IAbstractTableControl - //==================================================================== - /** defines a callback interface to be implemented by a concrete table control - */ - class SAL_NO_VTABLE IAbstractTableControl - { - public: - /** hides the cell cursor - - The method cares for successive calls, that is, for every call to - ->hideCursor(), you need one call to ->showCursor. Only if the number - of both calls matches, the cursor is really shown. - - @see showCursor - */ - virtual void hideCursor() = 0; - - /** shows the cell cursor - - @see hideCursor - */ - virtual void showCursor() = 0; - - /** dispatches an action to the table control - - @return - if the action could be dispatched successfully, otherwise. Usual - failure conditions include some other instance vetoing the action, or impossibility - to execute the action at all (for instance moving up one row when already positioned - on the very first row). - - @see TableControlAction - */ - virtual bool dispatchAction( TableControlAction _eAction ) = 0; - - /** returns selection engine*/ - virtual SelectionEngine* getSelEngine() = 0; - virtual void activateCellAt( const Point& rPoint ) = 0; - virtual RowPos getRowAtPoint( const Point& rPoint ) = 0; - virtual ColPos getColAtPoint( const Point& rPoint ) = 0; - virtual void resizeColumn(const Point& rPoint ) = 0; - virtual bool checkResizeColumn(const Point& rPoint) = 0; - virtual bool endResizeColumn(const Point& rPoint) = 0; - virtual bool isRowSelected(RowPos _nRow) = 0; - - virtual ~IAbstractTableControl() {}; - }; - -//........................................................................ -} } // namespace svt::table -//........................................................................ - -#endif // SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX diff --git a/svtools/inc/svtools/table/defaultinputhandler.hxx b/svtools/inc/svtools/table/defaultinputhandler.hxx index ca760896d539..31b5db319290 100644 --- a/svtools/inc/svtools/table/defaultinputhandler.hxx +++ b/svtools/inc/svtools/table/defaultinputhandler.hxx @@ -50,16 +50,16 @@ namespace svt { namespace table DefaultInputHandler(); ~DefaultInputHandler(); - virtual bool MouseMove ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ); - virtual bool MouseButtonDown ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ); - virtual bool MouseButtonUp ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ); - virtual bool KeyInput ( IAbstractTableControl& _rControl, const KeyEvent& rKEvt ); - virtual bool GetFocus ( IAbstractTableControl& _rControl ); - virtual bool LoseFocus ( IAbstractTableControl& _rControl ); - virtual bool RequestHelp ( IAbstractTableControl& _rControl, const HelpEvent& rHEvt ); - virtual bool Command ( IAbstractTableControl& _rControl, const CommandEvent& rCEvt ); - virtual bool PreNotify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ); - virtual bool Notify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ); + virtual bool MouseMove ( ITableControl& _rControl, const MouseEvent& rMEvt ); + virtual bool MouseButtonDown ( ITableControl& _rControl, const MouseEvent& rMEvt ); + virtual bool MouseButtonUp ( ITableControl& _rControl, const MouseEvent& rMEvt ); + virtual bool KeyInput ( ITableControl& _rControl, const KeyEvent& rKEvt ); + virtual bool GetFocus ( ITableControl& _rControl ); + virtual bool LoseFocus ( ITableControl& _rControl ); + virtual bool RequestHelp ( ITableControl& _rControl, const HelpEvent& rHEvt ); + virtual bool Command ( ITableControl& _rControl, const CommandEvent& rCEvt ); + virtual bool PreNotify ( ITableControl& _rControl, NotifyEvent& rNEvt ); + virtual bool Notify ( ITableControl& _rControl, NotifyEvent& rNEvt ); }; //........................................................................ diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index d557597b6ff8..259b390071bb 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -107,7 +107,7 @@ namespace svt { namespace table */ sal_Int32 GetCurrentRow() const; - IAbstractTableControl& + ITableControl& getTableControlInterface(); /** retrieves the current column @@ -192,7 +192,8 @@ namespace svt { namespace table ::utl::AccessibleStateSetHelper& rStateSet, AccessibleTableControlObjType eObjType ) const; - //// Window + // ............................................................................................................. + // IAccessibleTable virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; virtual void GrabFocus(); virtual XACC GetAccessible( BOOL bCreate = TRUE ); @@ -222,6 +223,7 @@ namespace svt { namespace table virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); virtual void RemoveSelectedRow(RowPos _nRowPos); virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; + // ............................................................................................................. void clearSelection(); void selectionChanged(bool _bChanged); diff --git a/svtools/inc/svtools/table/tablecontrolinterface.hxx b/svtools/inc/svtools/table/tablecontrolinterface.hxx new file mode 100644 index 000000000000..c1ed1bf432b6 --- /dev/null +++ b/svtools/inc/svtools/table/tablecontrolinterface.hxx @@ -0,0 +1,143 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX +#define SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX + +#include +#include +#include + +#include "svtools/table/tabletypes.hxx" +#include "svtools/table/tablemodel.hxx" + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + enum TableControlAction + { + /// moves the cursor in the table control one row up, if possible, by keeping the current column + cursorUp, + /// moves the cursor in the table control one row down, if possible, by keeping the current column + cursorDown, + /// moves the cursor in the table control one column to the left, if possible, by keeping the current row + cursorLeft, + /// moves the cursor in the table control one column to the right, if possible, by keeping the current row + cursorRight, + /// moves the cursor to the beginning of the current line + cursorToLineStart, + /// moves the cursor to the end of the current line + cursorToLineEnd, + /// moves the cursor to the first row, keeping the current column + cursorToFirstLine, + /// moves the cursor to the last row, keeping the current column + cursorToLastLine, + /// moves the cursor one page up, keeping the current column + cursorPageUp, + /// moves the cursor one page down, keeping the current column + cursorPageDown, + /// moves the cursor to the top-most, left-most cell + cursorTopLeft, + /// moves the cursor to the bottom-most, right-most cell + cursorBottomRight, + /// selects the row, where the actual cursor is + cursorSelectRow, + /// selects the rows, above the actual cursor is + cursorSelectRowUp, + /// selects the row, beneath the actual cursor is + cursorSelectRowDown, + /// selects the row, from the actual cursor till top + cursorSelectRowAreaTop, + /// selects the row, from the actual cursor till bottom + cursorSelectRowAreaBottom, + + /// invalid and final enumeration value, not to be actually used + invalidTableControlAction + }; + + //==================================================================== + //= ITableControl + //==================================================================== + /** defines a callback interface to be implemented by a concrete table control + */ + class SAL_NO_VTABLE ITableControl + { + public: + /** hides the cell cursor + + The method cares for successive calls, that is, for every call to + ->hideCursor(), you need one call to ->showCursor. Only if the number + of both calls matches, the cursor is really shown. + + @see showCursor + */ + virtual void hideCursor() = 0; + + /** shows the cell cursor + + @see hideCursor + */ + virtual void showCursor() = 0; + + /** dispatches an action to the table control + + @return + if the action could be dispatched successfully, otherwise. Usual + failure conditions include some other instance vetoing the action, or impossibility + to execute the action at all (for instance moving up one row when already positioned + on the very first row). + + @see TableControlAction + */ + virtual bool dispatchAction( TableControlAction _eAction ) = 0; + + /** returns selection engine*/ + virtual SelectionEngine* getSelEngine() = 0; + + /** returns the table model + + The returned model is guaranteed to not be . + */ + virtual PTableModel getModel() const = 0; + + virtual void activateCellAt( const Point& rPoint ) = 0; + virtual RowPos getRowAtPoint( const Point& rPoint ) = 0; + virtual ColPos getColAtPoint( const Point& rPoint ) = 0; + virtual void resizeColumn(const Point& rPoint ) = 0; + virtual bool checkResizeColumn(const Point& rPoint) = 0; + virtual bool endResizeColumn(const Point& rPoint) = 0; + virtual bool isRowSelected(RowPos _nRow) = 0; + + virtual ~ITableControl() {}; + }; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX diff --git a/svtools/inc/svtools/table/tableinputhandler.hxx b/svtools/inc/svtools/table/tableinputhandler.hxx index 6d6af9f641bb..87803f03e240 100644 --- a/svtools/inc/svtools/table/tableinputhandler.hxx +++ b/svtools/inc/svtools/table/tableinputhandler.hxx @@ -40,7 +40,7 @@ namespace svt { namespace table { //........................................................................ - class IAbstractTableControl; + class ITableControl; //==================================================================== //= ITableInputHandler @@ -56,16 +56,16 @@ namespace svt { namespace table // or whether it has been sufficiently handled by the ->ITableInputHandler instance // (). - virtual bool MouseMove ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ) = 0; - virtual bool MouseButtonDown ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ) = 0; - virtual bool MouseButtonUp ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ) = 0; - virtual bool KeyInput ( IAbstractTableControl& _rControl, const KeyEvent& rKEvt ) = 0; - virtual bool GetFocus ( IAbstractTableControl& _rControl ) = 0; - virtual bool LoseFocus ( IAbstractTableControl& _rControl ) = 0; - virtual bool RequestHelp ( IAbstractTableControl& _rControl, const HelpEvent& rHEvt ) = 0; - virtual bool Command ( IAbstractTableControl& _rControl, const CommandEvent& rCEvt ) = 0; - virtual bool PreNotify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ) = 0; - virtual bool Notify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ) = 0; + virtual bool MouseMove ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0; + virtual bool MouseButtonDown ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0; + virtual bool MouseButtonUp ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0; + virtual bool KeyInput ( ITableControl& _rControl, const KeyEvent& rKEvt ) = 0; + virtual bool GetFocus ( ITableControl& _rControl ) = 0; + virtual bool LoseFocus ( ITableControl& _rControl ) = 0; + virtual bool RequestHelp ( ITableControl& _rControl, const HelpEvent& rHEvt ) = 0; + virtual bool Command ( ITableControl& _rControl, const CommandEvent& rCEvt ) = 0; + virtual bool PreNotify ( ITableControl& _rControl, NotifyEvent& rNEvt ) = 0; + virtual bool Notify ( ITableControl& _rControl, NotifyEvent& rNEvt ) = 0; virtual ~ITableInputHandler() { } }; diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index 9f170c929eba..e8e4c3e178d0 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -28,7 +28,7 @@ #include "precompiled_svtools.hxx" #include "svtools/table/defaultinputhandler.hxx" -#include "svtools/table/abstracttablecontrol.hxx" +#include "svtools/table/tablecontrolinterface.hxx" #include #include @@ -61,7 +61,7 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - bool DefaultInputHandler::MouseMove( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt ) + bool DefaultInputHandler::MouseMove( ITableControl& _rControl, const MouseEvent& _rMEvt ) { Point aPoint = _rMEvt.GetPosPixel(); if ( m_bResize ) @@ -73,7 +73,7 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - bool DefaultInputHandler::MouseButtonDown( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt ) + bool DefaultInputHandler::MouseButtonDown( ITableControl& _rControl, const MouseEvent& _rMEvt ) { bool bHandled = false; Point aPoint = _rMEvt.GetPosPixel(); @@ -111,7 +111,7 @@ namespace svt { namespace table return bHandled; } //-------------------------------------------------------------------- - bool DefaultInputHandler::MouseButtonUp( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt ) + bool DefaultInputHandler::MouseButtonUp( ITableControl& _rControl, const MouseEvent& _rMEvt ) { bool bHandled = false; const Point aPoint = _rMEvt.GetPosPixel(); @@ -135,7 +135,7 @@ namespace svt { namespace table return bHandled; } //-------------------------------------------------------------------- - bool DefaultInputHandler::KeyInput( IAbstractTableControl& _rControl, const KeyEvent& rKEvt ) + bool DefaultInputHandler::KeyInput( ITableControl& _rControl, const KeyEvent& rKEvt ) { bool bHandled = false; @@ -184,21 +184,21 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - bool DefaultInputHandler::GetFocus( IAbstractTableControl& _rControl ) + bool DefaultInputHandler::GetFocus( ITableControl& _rControl ) { _rControl.showCursor(); return false; // continue processing } //-------------------------------------------------------------------- - bool DefaultInputHandler::LoseFocus( IAbstractTableControl& _rControl ) + bool DefaultInputHandler::LoseFocus( ITableControl& _rControl ) { _rControl.hideCursor(); return false; // continue processing } //-------------------------------------------------------------------- - bool DefaultInputHandler::RequestHelp( IAbstractTableControl& _rControl, const HelpEvent& _rHEvt ) + bool DefaultInputHandler::RequestHelp( ITableControl& _rControl, const HelpEvent& _rHEvt ) { (void)_rControl; (void)_rHEvt; @@ -207,7 +207,7 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - bool DefaultInputHandler::Command( IAbstractTableControl& _rControl, const CommandEvent& _rCEvt ) + bool DefaultInputHandler::Command( ITableControl& _rControl, const CommandEvent& _rCEvt ) { (void)_rControl; (void)_rCEvt; @@ -216,7 +216,7 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - bool DefaultInputHandler::PreNotify( IAbstractTableControl& _rControl, NotifyEvent& _rNEvt ) + bool DefaultInputHandler::PreNotify( ITableControl& _rControl, NotifyEvent& _rNEvt ) { (void)_rControl; (void)_rNEvt; @@ -225,7 +225,7 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - bool DefaultInputHandler::Notify( IAbstractTableControl& _rControl, NotifyEvent& _rNEvt ) + bool DefaultInputHandler::Notify( ITableControl& _rControl, NotifyEvent& _rNEvt ) { (void)_rControl; (void)_rNEvt; diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 1b6027b71324..74f4a901ecb8 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -27,34 +27,40 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svtools.hxx" -#include "svtools/table/tablecontrol.hxx" #include "tablegeometry.hxx" #include "tablecontrol_impl.hxx" #include "accessibletableimp.hxx" + +#include "svtools/table/tablecontrol.hxx" #include "svtools/table/tabledatawindow.hxx" + #include #include +#include + using namespace ::com::sun::star::uno; using ::com::sun::star::accessibility::XAccessible; using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::lang; using namespace utl; -//using namespace rtl; -//........................................................................ + +//...................................................................................................................... namespace svt { namespace table { - //==================================================================== +//...................................................................................................................... + + //================================================================================================================== //= AccessibleTableControl_Impl - //==================================================================== - // ---------------------------------------------------------------------------- + //================================================================================================================== + // ----------------------------------------------------------------------------------------------------------------- Reference< XAccessible > AccessibleTableControl_Impl::getAccessibleTableHeader( AccessibleTableControlObjType _eObjType ) { if ( m_pAccessible && m_pAccessible->isAlive() ) return m_pAccessible->getTableHeader( _eObjType ); return NULL; } - // ---------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- Reference< XAccessible > AccessibleTableControl_Impl::getAccessibleTable( ) { if ( m_pAccessible && m_pAccessible->isAlive() ) @@ -62,10 +68,10 @@ namespace svt { namespace table return NULL; } - //==================================================================== + //================================================================================================================== //= TableControl - //==================================================================== - //-------------------------------------------------------------------- + //================================================================================================================== + // ----------------------------------------------------------------------------------------------------------------- TableControl::TableControl( Window* _pParent, WinBits _nStyle ) :Control( _pParent, _nStyle ) ,m_pImpl( new TableControl_Impl( *this ) ) @@ -83,7 +89,7 @@ namespace svt { namespace table SetFillColor( aWindowColor ); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- TableControl::~TableControl() { ImplCallEventListeners( VCLEVENT_OBJECT_DYING ); @@ -95,21 +101,21 @@ namespace svt { namespace table m_pAccessTable->m_pAccessible->dispose(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- void TableControl::GetFocus() { if ( !m_pImpl->getInputHandler()->GetFocus( *m_pImpl ) ) Control::GetFocus(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- void TableControl::LoseFocus() { if ( !m_pImpl->getInputHandler()->LoseFocus( *m_pImpl ) ) Control::LoseFocus(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- void TableControl::KeyInput( const KeyEvent& rKEvt ) { if ( !m_pImpl->getInputHandler()->KeyInput( *m_pImpl, rKEvt ) ) @@ -125,7 +131,7 @@ namespace svt { namespace table } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- void TableControl::StateChanged( StateChangedType i_nStateChange ) { Control::StateChanged( i_nStateChange ); @@ -156,66 +162,69 @@ namespace svt { namespace table } } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- void TableControl::Resize() { Control::Resize(); m_pImpl->onResize(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- void TableControl::SetModel( PTableModel _pModel ) { m_pImpl->setModel( _pModel ); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- PTableModel TableControl::GetModel() const { return m_pImpl->getModel(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- RowPos TableControl::GetTopRow() const { return m_pImpl->getTopRow(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- void TableControl::SetTopRow( RowPos _nRow ) { - // TODO - (void)_nRow; + OSL_ENSURE( false, "TableControl::SetTopRow: not implemented!" ); + OSL_UNUSED( _nRow ); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- sal_Int32 TableControl::GetCurrentRow() const { return m_pImpl->getCurRow(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- sal_Int32 TableControl::GetCurrentColumn() const { return m_pImpl->getCurColumn(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- bool TableControl::GoTo( ColPos _nColumn, RowPos _nRow ) { return m_pImpl->goTo( _nColumn, _nRow ); } - //-------------------------------------------------------------------- + + // ----------------------------------------------------------------------------------------------------------------- sal_Bool TableControl::GoToCell(sal_Int32 _nColPos, sal_Int32 _nRowPos) { return m_pImpl->goTo( _nColPos, _nRowPos ); } - //-------------------------------------------------------------------- + + // ----------------------------------------------------------------------------------------------------------------- void TableControl::clearSelection() { m_pImpl->clearSelection(); } - //-------------------------------------------------------------------- + + // ----------------------------------------------------------------------------------------------------------------- void TableControl::InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved) { Rectangle _rRect; @@ -232,36 +241,38 @@ namespace svt { namespace table m_pImpl->invalidateRow(_nRowStart, _rRect); } } - //-------------------------------------------------------------------- + + // ----------------------------------------------------------------------------------------------------------------- std::vector& TableControl::GetSelectedRows() { return m_pImpl->getSelectedRows(); } - //-------------------------------------------------------------------- + + // ----------------------------------------------------------------------------------------------------------------- void TableControl::RemoveSelectedRow(RowPos _nRowPos) { m_pImpl->removeSelectedRow(_nRowPos); } - //-------------------------------------------------------------------- - IAbstractTableControl& TableControl::getTableControlInterface() + // ----------------------------------------------------------------------------------------------------------------- + ITableControl& TableControl::getTableControlInterface() { return *m_pImpl; } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- SelectionEngine* TableControl::getSelEngine() { return m_pImpl->getSelEngine(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- TableDataWindow* TableControl::getDataWindow() { return m_pImpl->getDataWindow(); } - //-------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------- Reference< XAccessible > TableControl::CreateAccessible() { Window* pParent = GetAccessibleParentWindow(); @@ -320,285 +331,321 @@ namespace svt { namespace table } return aRetText; } -// ----------------------------------------------------------------------------- -::rtl::OUString TableControl::GetAccessibleObjectDescription( AccessibleTableControlObjType eObjType, sal_Int32 ) const -{ - ::rtl::OUString aRetText; - switch( eObjType ) + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString TableControl::GetAccessibleObjectDescription( AccessibleTableControlObjType eObjType, sal_Int32 ) const { - case TCTYPE_GRIDCONTROL: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridControl description" ) ); - break; - case TCTYPE_TABLE: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLE description" ) ); - break; - case TCTYPE_ROWHEADERBAR: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERBAR description" ) ); - break; - case TCTYPE_COLUMNHEADERBAR: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERBAR description" ) ); - break; - case TCTYPE_TABLECELL: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLECELL description" ) ); - break; - case TCTYPE_ROWHEADERCELL: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERCELL description" ) ); - break; - case TCTYPE_COLUMNHEADERCELL: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERCELL description" ) ); - break; + ::rtl::OUString aRetText; + switch( eObjType ) + { + case TCTYPE_GRIDCONTROL: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridControl description" ) ); + break; + case TCTYPE_TABLE: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLE description" ) ); + break; + case TCTYPE_ROWHEADERBAR: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERBAR description" ) ); + break; + case TCTYPE_COLUMNHEADERBAR: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERBAR description" ) ); + break; + case TCTYPE_TABLECELL: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLECELL description" ) ); + break; + case TCTYPE_ROWHEADERCELL: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERCELL description" ) ); + break; + case TCTYPE_COLUMNHEADERCELL: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERCELL description" ) ); + break; + } + return aRetText; } - return aRetText; -} -// ----------------------------------------------------------------------------- -::rtl::OUString TableControl::GetRowDescription( sal_Int32 _nRow) const -{ - (void)_nRow; - return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "row description" ) ); -} -// ----------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString TableControl::GetRowDescription( sal_Int32 _nRow) const + { + (void)_nRow; + return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "row description" ) ); + } -::rtl::OUString TableControl::GetRowName( sal_Int32 _nIndex) const -{ - return GetModel()->getRowHeader( _nIndex ); -} -// ----------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString TableControl::GetRowName( sal_Int32 _nIndex) const + { + return GetModel()->getRowHeader( _nIndex ); + } -::rtl::OUString TableControl::GetColumnDescription( sal_uInt16 _nColumn) const -{ - (void)_nColumn; - return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "col description" ) ); -} -// ----------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString TableControl::GetColumnDescription( sal_uInt16 _nColumn) const + { + (void)_nColumn; + return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "col description" ) ); + } -::rtl::OUString TableControl::GetColumnName( sal_Int32 _nIndex) const -{ - return GetModel()->getColumnModel(_nIndex)->getName(); -} + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString TableControl::GetColumnName( sal_Int32 _nIndex) const + { + return GetModel()->getColumnModel(_nIndex)->getName(); + } -// ----------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos ) const + { + Any aCellContent; + GetModel()->getCellContent( _nColPos, _nRowPos, aCellContent ); + return aCellContent; + } -::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos ) const -{ - Any aCellContent; - GetModel()->getCellContent( _nColPos, _nRowPos, aCellContent ); - return aCellContent; -} + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString TableControl::GetAccessibleCellText( sal_Int32 _nRowPos, sal_Int32 _nColPos) const + { + return m_pImpl->getCellContentAsString( _nRowPos, _nColPos ); + } -// ----------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void TableControl::FillAccessibleStateSet( + ::utl::AccessibleStateSetHelper& rStateSet, + AccessibleTableControlObjType eObjType ) const + { + switch( eObjType ) + { + case TCTYPE_GRIDCONTROL: + case TCTYPE_TABLE: -::rtl::OUString TableControl::GetAccessibleCellText( sal_Int32 _nRowPos, sal_Int32 _nColPos) const -{ - return m_pImpl->getCellContentAsString( _nRowPos, _nColPos ); -} -// ----------------------------------------------------------------------------- + rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE); + if ( HasFocus() ) + rStateSet.AddState( AccessibleStateType::FOCUSED ); + if ( IsActive() ) + rStateSet.AddState( AccessibleStateType::ACTIVE ); + if ( IsEnabled() ) + rStateSet.AddState( AccessibleStateType::ENABLED ); + if ( IsReallyVisible() ) + rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); -void TableControl::FillAccessibleStateSet( - ::utl::AccessibleStateSetHelper& rStateSet, - AccessibleTableControlObjType eObjType ) const -{ - switch( eObjType ) - { - case TCTYPE_GRIDCONTROL: - case TCTYPE_TABLE: - - rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE); - if ( HasFocus() ) - rStateSet.AddState( AccessibleStateType::FOCUSED ); - if ( IsActive() ) - rStateSet.AddState( AccessibleStateType::ACTIVE ); - if ( IsEnabled() ) - rStateSet.AddState( AccessibleStateType::ENABLED ); - if ( IsReallyVisible() ) + break; + case TCTYPE_ROWHEADERBAR: + rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); + break; + case TCTYPE_COLUMNHEADERBAR: + rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); + break; + case TCTYPE_TABLECELL: + { + rStateSet.AddState( AccessibleStateType::TRANSIENT ); + rStateSet.AddState( AccessibleStateType::SELECTABLE); + if( GetSelectedRowCount()>0) + rStateSet.AddState( AccessibleStateType::SELECTED); + } + break; + case TCTYPE_ROWHEADERCELL: rStateSet.AddState( AccessibleStateType::VISIBLE ); - rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); - - break; - case TCTYPE_ROWHEADERBAR: - rStateSet.AddState( AccessibleStateType::VISIBLE ); - rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); - break; - case TCTYPE_COLUMNHEADERBAR: - rStateSet.AddState( AccessibleStateType::VISIBLE ); - rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); - break; - case TCTYPE_TABLECELL: - { rStateSet.AddState( AccessibleStateType::TRANSIENT ); - rStateSet.AddState( AccessibleStateType::SELECTABLE); - if( GetSelectedRowCount()>0) - rStateSet.AddState( AccessibleStateType::SELECTED); - } - break; - case TCTYPE_ROWHEADERCELL: - rStateSet.AddState( AccessibleStateType::VISIBLE ); - rStateSet.AddState( AccessibleStateType::TRANSIENT ); - break; - case TCTYPE_COLUMNHEADERCELL: - rStateSet.AddState( AccessibleStateType::VISIBLE ); - break; + break; + case TCTYPE_COLUMNHEADERCELL: + rStateSet.AddState( AccessibleStateType::VISIBLE ); + break; + } } -} -Rectangle TableControl::GetWindowExtentsRelative( Window *pRelativeWindow ) const -{ - return Control::GetWindowExtentsRelative( pRelativeWindow ); -} -//----------------------------------------------------------------------------- -void TableControl::GrabFocus() -{ - Control::GrabFocus(); -} -// ----------------------------------------------------------------------------- -Reference< XAccessible > TableControl::GetAccessible( BOOL bCreate ) -{ - return Control::GetAccessible( bCreate ); -} -// ----------------------------------------------------------------------------- -Window* TableControl::GetAccessibleParentWindow() const -{ - return Control::GetAccessibleParentWindow(); -} -// ----------------------------------------------------------------------------- -Window* TableControl::GetWindowInstance() -{ - return this; -} + //------------------------------------------------------------------------------------------------------------------ + Rectangle TableControl::GetWindowExtentsRelative( Window *pRelativeWindow ) const + { + return Control::GetWindowExtentsRelative( pRelativeWindow ); + } -sal_Bool TableControl::HasRowHeader() -{ - return GetModel()->hasRowHeaders(); -} -//-------------------------------------------------------------------------------- -sal_Bool TableControl::HasColHeader() -{ - return GetModel()->hasColumnHeaders(); -} -//-------------------------------------------------------------------------------- -sal_Int32 TableControl::GetAccessibleControlCount() const -{ - sal_Int32 count = 0; - if(GetRowCount()>0) - count+=1; - if(GetModel()->hasRowHeaders()) - count+=1; - if(GetModel()->hasColumnHeaders()) - count+=1; - return count; -} -sal_Bool TableControl::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) -{ - sal_Int32 nRow = m_pImpl->getRowAtPoint( _rPoint ); - sal_Int32 nCol = m_pImpl->getColAtPoint( _rPoint ); - _rnIndex = nRow * GetColumnCount() + nCol; - return nRow >= 0 ? sal_True : sal_False; -} + //------------------------------------------------------------------------------------------------------------------ + void TableControl::GrabFocus() + { + Control::GrabFocus(); + } -long TableControl::GetRowCount() const -{ - return m_pImpl->getRowCount(); -} -long TableControl::GetColumnCount() const -{ - return m_pImpl->getColumnCount(); -} -sal_Bool TableControl::HasRowHeader() const -{ - PTableModel pModel = GetModel(); - return pModel->hasRowHeaders(); -} -sal_Int32 TableControl::GetSelectedRowCount() const -{ - return m_pImpl->getSelectedRows().size(); -} -bool TableControl::IsRowSelected( long _nRow ) const -{ - return m_pImpl->isRowSelected(m_pImpl->getSelectedRows(), _nRow); -} -sal_Bool TableControl::ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ) -{ - _rnRow = m_pImpl->getRowAtPoint( _rPoint ); - _rnColPos = m_pImpl->getColAtPoint( _rPoint ); - return _rnRow >= 0 ? sal_True : sal_False; -} -void TableControl::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const -{ - if ( GetCurrentRow() == _nRow && GetCurrentColumn() == _nColumnPos ) - _rStateSet.AddState( AccessibleStateType::FOCUSED ); - else // only transient when column is not focused - _rStateSet.AddState( AccessibleStateType::TRANSIENT ); -} -Rectangle TableControl::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) -{ - (void)_nRow; - (void)_nColumnPos; - return GetCharacterBounds(nIndex); -} -sal_Int32 TableControl::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) -{ - (void)_nRow; - (void)_nColumnPos; - return GetIndexForPoint(_rPoint); -; -} - // ----------------------------------------------------------------------------- -sal_Bool TableControl::isAccessibleAlive( ) const -{ - return ( NULL != m_pAccessTable->m_pAccessible ) && m_pAccessTable->m_pAccessible->isAlive(); -} + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > TableControl::GetAccessible( BOOL bCreate ) + { + return Control::GetAccessible( bCreate ); + } -// ----------------------------------------------------------------------------- -::svt::IAccessibleFactory& TableControl::getAccessibleFactory() -{ - return m_pAccessTable->m_aFactoryAccess.getFactory(); -} -// ----------------------------------------------------------------------------- -void TableControl::commitGridControlEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) -{ - if ( isAccessibleAlive() ) - m_pAccessTable->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue); -} -// ----------------------------------------------------------------------------- -Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,BOOL _bOnScreen) -{ - (void)_bOnScreen; - return m_pImpl->calcHeaderRect(_bIsColumnBar); -} -// ----------------------------------------------------------------------------- -Rectangle TableControl::calcTableRect(BOOL _bOnScreen) -{ - (void)_bOnScreen; - return m_pImpl->calcTableRect(); -} -// ----------------------------------------------------------------------- -void TableControl::selectionChanged(bool _bChanged) -{ - m_bSelectionChanged = _bChanged; -} -// ----------------------------------------------------------------------- -IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG ) -{ - Select(); - return 1; -} -IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData ) -{ - CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData ); - return 1; -} -IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData ) -{ - CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData ); - return 1; -} -// ----------------------------------------------------------------------- -void TableControl::Select() -{ - ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_aSelectHdl, this ); -} -//........................................................................ + //------------------------------------------------------------------------------------------------------------------ + Window* TableControl::GetAccessibleParentWindow() const + { + return Control::GetAccessibleParentWindow(); + } + + //------------------------------------------------------------------------------------------------------------------ + Window* TableControl::GetWindowInstance() + { + return this; + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool TableControl::HasRowHeader() + { + return GetModel()->hasRowHeaders(); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool TableControl::HasColHeader() + { + return GetModel()->hasColumnHeaders(); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 TableControl::GetAccessibleControlCount() const + { + sal_Int32 count = 0; + if(GetRowCount()>0) + count+=1; + if(GetModel()->hasRowHeaders()) + count+=1; + if(GetModel()->hasColumnHeaders()) + count+=1; + return count; + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool TableControl::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) + { + sal_Int32 nRow = m_pImpl->getRowAtPoint( _rPoint ); + sal_Int32 nCol = m_pImpl->getColAtPoint( _rPoint ); + _rnIndex = nRow * GetColumnCount() + nCol; + return nRow >= 0 ? sal_True : sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + long TableControl::GetRowCount() const + { + return GetModel()->getRowCount(); + } + + //------------------------------------------------------------------------------------------------------------------ + long TableControl::GetColumnCount() const + { + return GetModel()->getColumnCount(); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool TableControl::HasRowHeader() const + { + return GetModel()->hasRowHeaders(); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 TableControl::GetSelectedRowCount() const + { + return m_pImpl->getSelectedRows().size(); + } + + //------------------------------------------------------------------------------------------------------------------ + bool TableControl::IsRowSelected( long _nRow ) const + { + return m_pImpl->isRowSelected(m_pImpl->getSelectedRows(), _nRow); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool TableControl::ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ) + { + _rnRow = m_pImpl->getRowAtPoint( _rPoint ); + _rnColPos = m_pImpl->getColAtPoint( _rPoint ); + return _rnRow >= 0 ? sal_True : sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const + { + if ( GetCurrentRow() == _nRow && GetCurrentColumn() == _nColumnPos ) + _rStateSet.AddState( AccessibleStateType::FOCUSED ); + else // only transient when column is not focused + _rStateSet.AddState( AccessibleStateType::TRANSIENT ); + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle TableControl::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) + { + (void)_nRow; + (void)_nColumnPos; + return GetCharacterBounds(nIndex); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 TableControl::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) + { + (void)_nRow; + (void)_nColumnPos; + return GetIndexForPoint(_rPoint); + ; + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool TableControl::isAccessibleAlive( ) const + { + return ( NULL != m_pAccessTable->m_pAccessible ) && m_pAccessTable->m_pAccessible->isAlive(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::svt::IAccessibleFactory& TableControl::getAccessibleFactory() + { + return m_pAccessTable->m_aFactoryAccess.getFactory(); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl::commitGridControlEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) + { + if ( isAccessibleAlive() ) + m_pAccessTable->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue); + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,BOOL _bOnScreen) + { + (void)_bOnScreen; + return m_pImpl->calcHeaderRect(_bIsColumnBar); + } + + //------------------------------------------------------------------------------------------------------------------ + Rectangle TableControl::calcTableRect(BOOL _bOnScreen) + { + (void)_bOnScreen; + return m_pImpl->calcTableRect(); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl::selectionChanged(bool _bChanged) + { + m_bSelectionChanged = _bChanged; + } + + //------------------------------------------------------------------------------------------------------------------ + IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG ) + { + Select(); + return 1; + } + + //------------------------------------------------------------------------------------------------------------------ + IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData ) + { + CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData ); + return 1; + } + + //------------------------------------------------------------------------------------------------------------------ + IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData ) + { + CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData ); + return 1; + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl::Select() + { + ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_aSelectHdl, this ); + } + +//...................................................................................................................... }} // namespace svt::table -//........................................................................ +//...................................................................................................................... diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index ef217527cdff..4a4b087fcaf3 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -45,10 +45,10 @@ #include -//........................................................................ +//...................................................................................................................... namespace svt { namespace table { -//........................................................................ +//...................................................................................................................... //==================================================================== //= TempHideCursor @@ -56,10 +56,10 @@ namespace svt { namespace table class TempHideCursor { private: - IAbstractTableControl& m_rTable; + ITableControl& m_rTable; public: - TempHideCursor( IAbstractTableControl& _rTable ) + TempHideCursor( ITableControl& _rTable ) :m_rTable( _rTable ) { m_rTable.hideCursor(); @@ -258,7 +258,7 @@ namespace svt { namespace table } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ const sal_Char* TableControl_Impl::impl_checkInvariants() const { if ( !m_pModel ) @@ -359,7 +359,7 @@ namespace svt { namespace table #define DBG_CHECK_ME() \ DBG_CHKTHIS( TableControl_Impl, TableControl_Impl_checkInvariants ) - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableControl_Impl::TableControl_Impl( TableControl& _rAntiImpl ) :m_rAntiImpl ( _rAntiImpl ) ,m_pModel ( new EmptyTableModel ) @@ -397,7 +397,7 @@ namespace svt { namespace table m_pDataWindow->Show(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableControl_Impl::~TableControl_Impl() { DBG_DTOR( TableControl_Impl, TableControl_Impl_checkInvariants ); @@ -410,17 +410,7 @@ namespace svt { namespace table DELETEZ( m_pDataWindow ); } - //-------------------------------------------------------------------- - PTableModel TableControl_Impl::getModel() const - { - if ( dynamic_cast< const EmptyTableModel* >( m_pModel.get() ) != NULL ) - // if it's an EmptyTableModel, pretend that there is no model - return PTableModel(); - - return m_pModel; - } - - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::setModel( PTableModel _pModel ) { DBG_CHECK_ME(); @@ -451,7 +441,7 @@ namespace svt { namespace table if ( m_nColumnCount ) m_nCurColumn = 0; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::rowsInserted( RowPos first, RowPos last ) { OSL_ENSURE( false, "TableControl_Impl::rowsInserted: not implemented!" ); @@ -460,7 +450,7 @@ namespace svt { namespace table OSL_UNUSED( last ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::rowsRemoved( RowPos first, RowPos last ) { OSL_ENSURE( false, "TableControl_Impl::rowsRemoved: not implemented!" ); @@ -469,7 +459,7 @@ namespace svt { namespace table OSL_UNUSED( last ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::columnsInserted( ColPos i_first, ColPos i_last ) { m_nColumnCount = m_pModel->getColumnCount(); @@ -482,7 +472,7 @@ namespace svt { namespace table OSL_UNUSED( i_last ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::columnsRemoved( ColPos i_first, ColPos i_last ) { m_nColumnCount = m_pModel->getColumnCount(); @@ -495,7 +485,7 @@ namespace svt { namespace table OSL_UNUSED( i_last ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::columnMoved( ColPos oldIndex, ColPos newIndex ) { OSL_ENSURE( false, "TableControl_Impl::columnMoved: not implemented!" ); @@ -504,7 +494,7 @@ namespace svt { namespace table OSL_UNUSED( newIndex ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ) { OSL_ENSURE( false, "TableControl_Impl::cellsUpdated: not implemented!" ); @@ -515,7 +505,7 @@ namespace svt { namespace table OSL_UNUSED( lastRow ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_invalidateColumn( ColPos const i_column ) { DBG_CHECK_ME(); @@ -528,7 +518,7 @@ namespace svt { namespace table m_rAntiImpl.Invalidate( aColumn.getRect() ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ) { ColumnAttributeGroup nGroup( i_attributeGroup ); @@ -550,7 +540,7 @@ namespace svt { namespace table "TableControl_Impl::columnChanged: don't know how to handle this change!" ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const { DBG_CHECK_ME(); @@ -587,7 +577,7 @@ namespace svt { namespace table - 1; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const { DBG_CHECK_ME(); @@ -597,7 +587,7 @@ namespace svt { namespace table _rCellArea.Top() = m_nColHeaderHeightPixel; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_ni_updateCachedModelValues() { m_nRowHeightPixel = 15; @@ -622,7 +612,7 @@ namespace svt { namespace table m_nRowCount = m_pModel->getRowCount(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_ni_updateColumnWidths() { ENSURE_OR_RETURN_VOID( !m_bUpdatingColWidths, "TableControl_Impl::impl_ni_updateColumnWidths: recursive call detected!" ); @@ -765,10 +755,10 @@ namespace svt { namespace table } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ namespace { - //................................................................ + //.............................................................................................................. /// determines whether a scrollbar is needed for the given values bool lcl_determineScrollbarNeed( long const i_position, ScrollbarVisibility const i_visibility, long const i_availableSpace, long const i_neededSpace ) @@ -784,7 +774,7 @@ namespace svt { namespace table return true; } - //................................................................ + //.............................................................................................................. void lcl_setButtonRepeat( Window& _rWindow, ULONG _nDelay ) { AllSettings aSettings = _rWindow.GetSettings(); @@ -796,7 +786,7 @@ namespace svt { namespace table _rWindow.SetSettings( aSettings, TRUE ); } - //................................................................ + //.............................................................................................................. void lcl_updateScrollbar( Window& _rParent, ScrollBar*& _rpBar, bool const i_needBar, long _nVisibleUnits, long _nPosition, long _nLineSize, long _nRange, @@ -834,7 +824,7 @@ namespace svt { namespace table } } - //................................................................ + //.............................................................................................................. /** returns the number of rows fitting into the given range, for the given row height. Partially fitting rows are counted, too, if the respective parameter says so. @@ -846,7 +836,7 @@ namespace svt { namespace table : _nOverallHeight / _nRowHeightPixel; } - //................................................................ + //.............................................................................................................. /** returns the number of columns fitting into the given area, with the first visible column as given. Partially fitting columns are counted, too, if the respective parameter says so. @@ -871,7 +861,7 @@ namespace svt { namespace table } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_ni_updateScrollbars() { TempHideCursor aHideCursor( *this ); @@ -1013,7 +1003,7 @@ namespace svt { namespace table ) ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::onResize() { DBG_CHECK_ME(); @@ -1046,7 +1036,7 @@ namespace svt { namespace table } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::doPaintContent( const Rectangle& _rUpdateRect ) { DBG_CHECK_ME(); @@ -1202,7 +1192,7 @@ namespace svt { namespace table } } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::hideCursor() { DBG_CHECK_ME(); @@ -1211,7 +1201,7 @@ namespace svt { namespace table impl_ni_doSwitchCursor( false ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::showCursor() { DBG_CHECK_ME(); @@ -1221,7 +1211,7 @@ namespace svt { namespace table impl_ni_doSwitchCursor( true ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool TableControl_Impl::dispatchAction( TableControlAction _eAction ) { DBG_CHECK_ME(); @@ -1600,7 +1590,7 @@ namespace svt { namespace table return bSuccess; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_ni_doSwitchCursor( bool _bShow ) { PTableRenderer pRenderer = !!m_pModel ? m_pModel->getRenderer() : PTableRenderer(); @@ -1617,7 +1607,7 @@ namespace svt { namespace table } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_getCellRect( ColPos _nColumn, RowPos _nRow, Rectangle& _rCellRect ) const { DBG_CHECK_ME(); @@ -1638,7 +1628,8 @@ namespace svt { namespace table _rCellRect = aCell.getRect(); _rCellRect.Top()--;_rCellRect.Left()--; } - //------------------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ RowPos TableControl_Impl::getRowAtPoint( const Point& rPoint ) { DBG_CHECK_ME(); @@ -1659,7 +1650,7 @@ namespace svt { namespace table return ROW_INVALID; } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ ColPos TableControl_Impl::getColAtPoint( const Point& rPoint ) { DBG_CHECK_ME(); @@ -1681,7 +1672,13 @@ namespace svt { namespace table return COL_INVALID; } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + PTableModel TableControl_Impl::getModel() const + { + return m_pModel; + } + + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::activateCellAt(const Point& rPoint) { DBG_CHECK_ME(); @@ -1698,7 +1695,7 @@ namespace svt { namespace table ensureVisible( m_nCurColumn, m_nCurRow, true ); } } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect) { DBG_CHECK_ME(); @@ -1735,7 +1732,7 @@ namespace svt { namespace table } m_pDataWindow->Invalidate(_rCellRect); } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ //this method is to be called, when a new row is added void TableControl_Impl::invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect) { @@ -1748,7 +1745,7 @@ namespace svt { namespace table impl_ni_updateScrollbars(); m_pDataWindow->Invalidate(_rRow.getRect()); } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ std::vector& TableControl_Impl::getSelectedRows() { return m_nRowSelected; @@ -1759,7 +1756,7 @@ namespace svt { namespace table m_nRowSelected.clear(); } //-------------------------------------------------------------------- - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::removeSelectedRow(RowPos _nRowPos) { int i =0; @@ -2027,44 +2024,44 @@ namespace svt { namespace table return (TableSize)( m_nLeftColumn - nOldLeftColumn ); } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableSize TableControl_Impl::impl_scrollColumns( TableSize const i_columnDelta ) { DBG_CHECK_ME(); return impl_ni_ScrollColumns( i_columnDelta ); } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ SelectionEngine* TableControl_Impl::getSelEngine() { return m_pSelEngine; } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableDataWindow* TableControl_Impl::getDataWindow() { return m_pDataWindow; } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ ScrollBar* TableControl_Impl::getHorzScrollbar() { return m_pHScroll; } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ ScrollBar* TableControl_Impl::getVertScrollbar() { return m_pVScroll; } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ BOOL TableControl_Impl::isRowSelected(const ::std::vector& selectedRows, RowPos current) { return ::std::find(selectedRows.begin(),selectedRows.end(),current) != selectedRows.end(); } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool TableControl_Impl::isRowSelected(RowPos current) { return ::std::find(m_nRowSelected.begin(),m_nRowSelected.end(),current) != m_nRowSelected.end(); } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ int TableControl_Impl::getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current) { std::vector::const_iterator it = ::std::find(selectedRows.begin(),selectedRows.end(),current); @@ -2272,31 +2269,31 @@ namespace svt { namespace table return 0L; } - //--------------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableFunctionSet::TableFunctionSet(TableControl_Impl* _pTableControl) :m_pTableControl( _pTableControl) ,m_nCurrentRow (-2) { } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ TableFunctionSet::~TableFunctionSet() { } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::BeginDrag() { } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::CreateAnchor() { m_pTableControl->m_nAnchor = m_pTableControl->m_nCurRow; } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::DestroyAnchor() { m_pTableControl->m_nAnchor = -1; } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ BOOL TableFunctionSet::SetCursorAtPoint(const Point& rPoint, BOOL bDontSelectAtCursor) { BOOL bHandled = FALSE; @@ -2379,7 +2376,7 @@ namespace svt { namespace table m_pTableControl->ensureVisible( newCol, newRow, true ); return bHandled; } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ BOOL TableFunctionSet::IsSelectionAtPoint( const Point& rPoint ) { m_pTableControl->m_pSelEngine->AddAlways(FALSE); @@ -2394,7 +2391,7 @@ namespace svt { namespace table return selected; } } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::DeselectAtPoint( const Point& rPoint ) { (void)rPoint; @@ -2413,7 +2410,7 @@ namespace svt { namespace table } m_pTableControl->m_nRowSelected.erase(m_pTableControl->m_nRowSelected.begin()+pos); } - //------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::DeselectAll() { if(!m_pTableControl->m_nRowSelected.empty()) @@ -2428,6 +2425,6 @@ namespace svt { namespace table } } -//........................................................................ +//...................................................................................................................... } } // namespace svt::table -//........................................................................ +//...................................................................................................................... diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 730b00b638b8..4f2a626324b2 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -28,7 +28,7 @@ #define SVTOOLS_TABLECONTROL_IMPL_HXX #include -#include +#include #include #include @@ -98,7 +98,7 @@ namespace svt { namespace table //==================================================================== //= TableControl_Impl //==================================================================== - class TableControl_Impl :public IAbstractTableControl + class TableControl_Impl :public ITableControl ,public ITableModelListener { friend class TableGeometry; @@ -173,7 +173,6 @@ namespace svt { namespace table public: - PTableModel getModel() const; void setModel( PTableModel _pModel ); inline const PTableInputHandler& getInputHandler() const { return m_pInputHandler; } @@ -182,8 +181,6 @@ namespace svt { namespace table inline RowPos getCurRow() const { return m_nCurRow; } inline void setCurRow(RowPos curRow){ m_nCurRow = curRow; } inline RowPos getTopRow() const { return m_nTopRow; } - inline long getRowCount() const { return m_nRowCount; } - inline long getColumnCount() const { return m_nColumnCount; } inline const TableControl& getAntiImpl() const { return m_rAntiImpl; } inline TableControl& getAntiImpl() { return m_rAntiImpl; } @@ -248,11 +245,12 @@ namespace svt { namespace table void invalidateRows(); void clearSelection(); - // IAbstractTableControl + // ITableControl virtual void hideCursor(); virtual void showCursor(); virtual bool dispatchAction( TableControlAction _eAction ); virtual SelectionEngine* getSelEngine(); + virtual PTableModel getModel() const; virtual void activateCellAt( const Point& rPoint ); virtual RowPos getRowAtPoint( const Point& rPoint ); virtual ColPos getColAtPoint( const Point& rPoint ); diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 2092a4bccdc9..456f6061bbbb 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -51,7 +51,7 @@ namespace svt { namespace table //-------------------------------------------------------------------- TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl ) :Window( &_rTableControl.getAntiImpl() ) - ,m_rTableControl ( _rTableControl ) + ,m_rTableControl( _rTableControl ) { // by default, use the background as determined by the style settings const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() ); @@ -91,22 +91,23 @@ namespace svt { namespace table USHORT const nHelpMode = rHEvt.GetMode(); if ( ( nHelpMode & HELPMODE_QUICK ) != 0 ) { + ITableControl& rTableControl = m_rTableControl; + PTableModel const pTableModel( rTableControl.getModel() ); + Point const aMousePos( m_rTableControl.getAntiImpl().ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ); - RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos ); - ColPos const hitCol = m_rTableControl.getColAtPoint( aMousePos ); + RowPos const hitRow = rTableControl.getRowAtPoint( aMousePos ); + ColPos const hitCol = rTableControl.getColAtPoint( aMousePos ); - if ( ( hitCol >= 0 ) && ( hitCol < m_rTableControl.getColumnCount() ) ) + if ( ( hitCol >= 0 ) && ( hitCol < pTableModel->getColumnCount() ) ) { ::rtl::OUString sHelpText; - PTableModel const pTableModel( m_rTableControl.getAntiImpl().GetModel() ); - if ( hitRow == ROW_COL_HEADERS ) { sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText(); } - else if ( ( hitRow >= 0 ) && ( hitRow < m_rTableControl.getRowCount() ) ) + else if ( ( hitRow >= 0 ) && ( hitRow < pTableModel->getRowCount() ) ) { Any aCellToolTip; pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip ); diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index c2cf8faac548..ef714f16a780 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -30,7 +30,7 @@ #include "svtxgridcontrol.hxx" #include "accessibletableimp.hxx" #include -#include "svtools/table/abstracttablecontrol.hxx" +#include "svtools/table/tablecontrolinterface.hxx" #include "svtools/table/tablecontrol.hxx" #include "unocontroltablemodel.hxx" #include -- cgit v1.2.3 From e73cc303e5201dc04c61a30572b80d3da13a2699 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 11 Jan 2011 13:35:20 +0100 Subject: gridsort: Help::ShowQuickHelp: new flag QUICKHELP_FORCE_REPOSITION, which re-positions the window even if the quick help text didn't change. Use this in the table control, this prevents the help text appearing too far from the mouse position --- svtools/source/table/tabledatawindow.cxx | 2 +- vcl/inc/vcl/help.hxx | 21 +++++++++++---------- vcl/source/app/help.cxx | 16 ++++++++++------ 3 files changed, 22 insertions(+), 17 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 456f6061bbbb..b357fd91abda 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -128,7 +128,7 @@ namespace svt { namespace table m_rTableControl.getAntiImpl().OutputToScreenPixel( Point( 0, 0 ) ), m_rTableControl.getAntiImpl().GetOutputSizePixel() ); - Help::ShowQuickHelp( &m_rTableControl.getAntiImpl(), aControlScreenRect, sHelpText ); + Help::ShowQuickHelp( &m_rTableControl.getAntiImpl(), aControlScreenRect, sHelpText, String(), QUICKHELP_FORCE_REPOSITION ); } } } diff --git a/vcl/inc/vcl/help.hxx b/vcl/inc/vcl/help.hxx index 1f4ba36d8f43..e4f9aa45b139 100644 --- a/vcl/inc/vcl/help.hxx +++ b/vcl/inc/vcl/help.hxx @@ -40,16 +40,17 @@ class Window; // - Help-Types - // -------------- -#define QUICKHELP_LEFT ((USHORT)0x0001) -#define QUICKHELP_CENTER ((USHORT)0x0002) -#define QUICKHELP_RIGHT ((USHORT)0x0004) -#define QUICKHELP_TOP ((USHORT)0x0008) -#define QUICKHELP_VCENTER ((USHORT)0x0010) -#define QUICKHELP_BOTTOM ((USHORT)0x0020) -#define QUICKHELP_NOAUTOPOS (QUICKHELP_LEFT | QUICKHELP_CENTER | QUICKHELP_RIGHT | QUICKHELP_TOP | QUICKHELP_VCENTER | QUICKHELP_BOTTOM) -#define QUICKHELP_CTRLTEXT ((USHORT)0x0040) -#define QUICKHELP_NOEVADEPOINTER ((USHORT)0x4000) -#define QUICKHELP_BIDI_RTL ((USHORT)0x8000) +#define QUICKHELP_LEFT ((USHORT)0x0001) +#define QUICKHELP_CENTER ((USHORT)0x0002) +#define QUICKHELP_RIGHT ((USHORT)0x0004) +#define QUICKHELP_TOP ((USHORT)0x0008) +#define QUICKHELP_VCENTER ((USHORT)0x0010) +#define QUICKHELP_BOTTOM ((USHORT)0x0020) +#define QUICKHELP_NOAUTOPOS (QUICKHELP_LEFT | QUICKHELP_CENTER | QUICKHELP_RIGHT | QUICKHELP_TOP | QUICKHELP_VCENTER | QUICKHELP_BOTTOM) +#define QUICKHELP_CTRLTEXT ((USHORT)0x0040) +#define QUICKHELP_FORCE_REPOSITION ((USHORT)0x0080) +#define QUICKHELP_NOEVADEPOINTER ((USHORT)0x4000) +#define QUICKHELP_BIDI_RTL ((USHORT)0x8000) // By changes you must also change: rsc/vclrsc.hxx #define OOO_HELP_INDEX ".help:index" diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index 2c7ad2fa9c3e..37e7917d5e78 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -590,10 +590,14 @@ void ImplShowHelpWindow( Window* pParent, USHORT nHelpWinStyle, USHORT nStyle, { DBG_ASSERT( pHelpWin != pParent, "HelpInHelp ?!" ); - if ( (( pHelpWin->GetHelpText() != rHelpText ) || - ( pHelpWin->GetWinStyle() != nHelpWinStyle ) || - ( pHelpArea && ( pHelpWin->GetHelpArea() != *pHelpArea ) ) ) - && pSVData->maHelpData.mbRequestingHelp ) + if ( ( ( pHelpWin->GetHelpText() != rHelpText ) + || ( pHelpWin->GetWinStyle() != nHelpWinStyle ) + || ( pHelpArea + && ( pHelpWin->GetHelpArea() != *pHelpArea ) + ) + ) + && pSVData->maHelpData.mbRequestingHelp + ) { // remove help window if no HelpText or other HelpText or // other help mode. but keep it if we are scrolling, ie not requesting help @@ -605,8 +609,8 @@ void ImplShowHelpWindow( Window* pParent, USHORT nHelpWinStyle, USHORT nStyle, } else { - bool bTextChanged = rHelpText != pHelpWin->GetHelpText(); - if( bTextChanged ) + bool const bTextChanged = rHelpText != pHelpWin->GetHelpText(); + if ( bTextChanged || ( ( nStyle & QUICKHELP_FORCE_REPOSITION ) != 0 ) ) { Window * pWindow = pHelpWin->GetParent()->ImplGetFrameWindow(); Rectangle aInvRect( pHelpWin->GetWindowExtentsRelative( pWindow ) ); -- cgit v1.2.3 From 0bbace39b3f04c82ec8d38ef6aedef7d14fcafc4 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 11 Jan 2011 14:00:09 +0100 Subject: gridsort: XGridControl: add methods to retrieve the current row/col --- .../inc/svtools/table/tablecontrolinterface.hxx | 12 +- svtools/source/table/tablecontrol.cxx | 6 +- svtools/source/table/tablecontrol_impl.cxx | 198 +++++++++++---------- svtools/source/table/tablecontrol_impl.hxx | 17 +- svtools/source/uno/svtxgridcontrol.cxx | 26 +++ svtools/source/uno/svtxgridcontrol.hxx | 2 + toolkit/source/controls/grid/gridcontrol.cxx | 14 ++ toolkit/source/controls/grid/gridcontrol.hxx | 4 +- 8 files changed, 168 insertions(+), 111 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablecontrolinterface.hxx b/svtools/inc/svtools/table/tablecontrolinterface.hxx index c1ed1bf432b6..359fd65815ef 100644 --- a/svtools/inc/svtools/table/tablecontrolinterface.hxx +++ b/svtools/inc/svtools/table/tablecontrolinterface.hxx @@ -125,13 +125,19 @@ namespace svt { namespace table */ virtual PTableModel getModel() const = 0; + /// returns the index of the currently active column + virtual ColPos getCurrentColumn() const = 0; + + /// returns the index of the currently active row + virtual RowPos getCurrentRow() const = 0; + virtual void activateCellAt( const Point& rPoint ) = 0; - virtual RowPos getRowAtPoint( const Point& rPoint ) = 0; - virtual ColPos getColAtPoint( const Point& rPoint ) = 0; + virtual RowPos getRowAtPoint( const Point& rPoint ) const = 0; + virtual ColPos getColAtPoint( const Point& rPoint ) const = 0; virtual void resizeColumn(const Point& rPoint ) = 0; virtual bool checkResizeColumn(const Point& rPoint) = 0; virtual bool endResizeColumn(const Point& rPoint) = 0; - virtual bool isRowSelected(RowPos _nRow) = 0; + virtual bool isRowSelected( RowPos _nRow ) const = 0; virtual ~ITableControl() {}; }; diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 74f4a901ecb8..4c94be7f01f4 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -197,13 +197,13 @@ namespace svt { namespace table // ----------------------------------------------------------------------------------------------------------------- sal_Int32 TableControl::GetCurrentRow() const { - return m_pImpl->getCurRow(); + return m_pImpl->getCurrentRow(); } // ----------------------------------------------------------------------------------------------------------------- sal_Int32 TableControl::GetCurrentColumn() const { - return m_pImpl->getCurColumn(); + return m_pImpl->getCurrentColumn(); } // ----------------------------------------------------------------------------------------------------------------- @@ -543,7 +543,7 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ bool TableControl::IsRowSelected( long _nRow ) const { - return m_pImpl->isRowSelected(m_pImpl->getSelectedRows(), _nRow); + return m_pImpl->isRowSelected( _nRow ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 4a4b087fcaf3..ac2d41c122a4 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -379,7 +379,7 @@ namespace svt { namespace table ,m_pHScroll ( NULL ) ,m_pScrollCorner ( NULL ) ,m_pSelEngine ( ) - ,m_nRowSelected ( ) + ,m_aSelectedRows ( ) ,m_pTableFunctionSet ( new TableFunctionSet( this ) ) ,m_nAnchor (-1 ) ,m_bResizingColumn ( false ) @@ -1085,7 +1085,7 @@ namespace svt { namespace table if ( _rUpdateRect.GetIntersection( aCell.getRect() ).IsEmpty() ) continue; - bool isActiveColumn = ( aCell.getColumn() == getCurColumn() ); + bool isActiveColumn = ( aCell.getColumn() == getCurrentColumn() ); bool isSelectedColumn = false; pRenderer->PaintColumnHeader( aCell.getColumn(), isActiveColumn, isSelectedColumn, *m_pDataWindow, aCell.getRect(), rStyle ); @@ -1142,12 +1142,12 @@ namespace svt { namespace table { if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() ) continue; - bool isActiveRow = ( aRowIterator.getRow() == getCurRow() ); + bool isActiveRow = ( aRowIterator.getRow() == getCurrentRow() ); bool isSelectedRow = false; - if(!m_nRowSelected.empty()) + if(!m_aSelectedRows.empty()) { - for(std::vector::iterator itSel=m_nRowSelected.begin(); - itSel!=m_nRowSelected.end();++itSel) + for(std::vector::iterator itSel=m_aSelectedRows.begin(); + itSel!=m_aSelectedRows.end();++itSel) { if(*itSel == aRowIterator.getRow()) isSelectedRow = true; @@ -1224,22 +1224,22 @@ namespace svt { namespace table if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) { //if other rows already selected, deselect them - if(m_nRowSelected.size()>0) + if(m_aSelectedRows.size()>0) { - for(std::vector::iterator it=m_nRowSelected.begin(); - it!=m_nRowSelected.end();++it) + for(std::vector::iterator it=m_aSelectedRows.begin(); + it!=m_aSelectedRows.end();++it) { invalidateSelectedRegion(*it, *it, rCells); } - m_nRowSelected.clear(); + m_aSelectedRows.clear(); } if(m_nCurRow < m_nRowCount-1) { ++m_nCurRow; - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); } else - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); ensureVisible(m_nCurColumn,m_nCurRow,false); m_rAntiImpl.selectionChanged(true); @@ -1255,24 +1255,24 @@ namespace svt { namespace table case cursorUp: if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) { - if(m_nRowSelected.size()>0) + if(m_aSelectedRows.size()>0) { - for(std::vector::iterator it=m_nRowSelected.begin(); - it!=m_nRowSelected.end();++it) + for(std::vector::iterator it=m_aSelectedRows.begin(); + it!=m_aSelectedRows.end();++it) { invalidateSelectedRegion(*it, *it, rCells); } - m_nRowSelected.clear(); + m_aSelectedRows.clear(); } if(m_nCurRow>0) { --m_nCurRow; - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } else { - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } ensureVisible(m_nCurColumn,m_nCurRow,false); @@ -1343,17 +1343,17 @@ namespace svt { namespace table if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) return bSuccess = false; //pos is the position of the current row in the vector of selected rows, if current row is selected - int pos = getRowSelectedNumber(m_nRowSelected, m_nCurRow); + int pos = getRowSelectedNumber(m_aSelectedRows, m_nCurRow); //if current row is selected, it should be deselected, when ALT+SPACE are pressed if(pos>-1) { - m_nRowSelected.erase(m_nRowSelected.begin()+pos); - if(m_nRowSelected.empty() && m_nAnchor != -1) + m_aSelectedRows.erase(m_aSelectedRows.begin()+pos); + if(m_aSelectedRows.empty() && m_nAnchor != -1) m_nAnchor = -1; } //else select the row->put it in the vector else - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); m_rAntiImpl.selectionChanged(true); bSuccess = true; @@ -1371,26 +1371,26 @@ namespace svt { namespace table else { //there are other selected rows - if(m_nRowSelected.size()>0) + if(m_aSelectedRows.size()>0) { //the anchor wasn't set -> a region is not selected, that's why clear all selection //and select the current row if(m_nAnchor==-1) { - for(std::vector::iterator it=m_nRowSelected.begin(); - it!=m_nRowSelected.end();++it) + for(std::vector::iterator it=m_aSelectedRows.begin(); + it!=m_aSelectedRows.end();++it) { invalidateSelectedRegion(*it, *it, rCells); } - m_nRowSelected.clear(); - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.clear(); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } else { //a region is already selected, prevRow is last selected row and the row above - nextRow - should be selected - int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow); - int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow-1); + int prevRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow); + int nextRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow-1); if(prevRow>-1) { //if m_nCurRow isn't the upper one, can move up, otherwise not @@ -1399,14 +1399,14 @@ namespace svt { namespace table else return bSuccess = true; //if nextRow already selected, deselect it, otherwise select it - if(nextRow>-1 && m_nRowSelected[nextRow] == m_nCurRow) + if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow) { - m_nRowSelected.erase(m_nRowSelected.begin()+prevRow); + m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow); invalidateSelectedRegion(m_nCurRow+1, m_nCurRow+1, rCells); } else { - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } } @@ -1414,9 +1414,9 @@ namespace svt { namespace table { if(m_nCurRow>0) { - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); m_nCurRow--; - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells); } } @@ -1429,14 +1429,14 @@ namespace svt { namespace table //otherwise select only the upper row if(m_nCurRow>0) { - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); m_nCurRow--; - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells); } else { - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } } @@ -1458,26 +1458,26 @@ namespace svt { namespace table } else { - if(m_nRowSelected.size()>0) + if(m_aSelectedRows.size()>0) { //the anchor wasn't set -> a region is not selected, that's why clear all selection //and select the current row if(m_nAnchor==-1) { - for(std::vector::iterator it=m_nRowSelected.begin(); - it!=m_nRowSelected.end();++it) + for(std::vector::iterator it=m_aSelectedRows.begin(); + it!=m_aSelectedRows.end();++it) { invalidateSelectedRegion(*it, *it, rCells); } - m_nRowSelected.clear(); - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.clear(); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } else { //a region is already selected, prevRow is last selected row and the row beneath - nextRow - should be selected - int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow); - int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow+1); + int prevRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow); + int nextRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow+1); if(prevRow>-1) { //if m_nCurRow isn't the last one, can move down, otherwise not @@ -1486,14 +1486,14 @@ namespace svt { namespace table else return bSuccess = true; //if next row already selected, deselect it, otherwise select it - if(nextRow>-1 && m_nRowSelected[nextRow] == m_nCurRow) + if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow) { - m_nRowSelected.erase(m_nRowSelected.begin()+prevRow); + m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow); invalidateSelectedRegion(m_nCurRow-1, m_nCurRow-1, rCells); } else { - m_nRowSelected.push_back(m_nCurRow); + m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } } @@ -1501,9 +1501,9 @@ namespace svt { namespace table { if(m_nCurRow=0) { - if(!isRowSelected(m_nRowSelected, iter)) - m_nRowSelected.push_back(iter); + if ( !isRowSelected( iter ) ) + m_aSelectedRows.push_back(iter); --iter; } m_nCurRow = 0; @@ -1572,8 +1572,8 @@ namespace svt { namespace table //put the rows in the vector while(iter<=m_nRowCount) { - if(!isRowSelected(m_nRowSelected, iter)) - m_nRowSelected.push_back(iter); + if ( !isRowSelected( iter ) ) + m_aSelectedRows.push_back(iter); ++iter; } m_nCurRow = m_nRowCount-1; @@ -1630,7 +1630,7 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - RowPos TableControl_Impl::getRowAtPoint( const Point& rPoint ) + RowPos TableControl_Impl::getRowAtPoint( const Point& rPoint ) const { DBG_CHECK_ME(); @@ -1651,7 +1651,7 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - ColPos TableControl_Impl::getColAtPoint( const Point& rPoint ) + ColPos TableControl_Impl::getColAtPoint( const Point& rPoint ) const { DBG_CHECK_ME(); @@ -1678,6 +1678,18 @@ namespace svt { namespace table return m_pModel; } + //------------------------------------------------------------------------------------------------------------------ + RowPos TableControl_Impl::getCurrentColumn() const + { + return m_nCurColumn; + } + + //------------------------------------------------------------------------------------------------------------------ + RowPos TableControl_Impl::getCurrentRow() const + { + return m_nCurRow; + } + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::activateCellAt(const Point& rPoint) { @@ -1748,12 +1760,12 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ std::vector& TableControl_Impl::getSelectedRows() { - return m_nRowSelected; + return m_aSelectedRows; } //-------------------------------------------------------------------- void TableControl_Impl::clearSelection() { - m_nRowSelected.clear(); + m_aSelectedRows.clear(); } //-------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------ @@ -1761,20 +1773,20 @@ namespace svt { namespace table { int i =0; //if the row is selected, remove it from the selection vector - if(isRowSelected(m_nRowSelected, _nRowPos)) + if ( isRowSelected( _nRowPos ) ) { - if(m_nRowSelected.size()>1) - m_nRowSelected.erase(m_nRowSelected.begin()+_nRowPos); + if(m_aSelectedRows.size()>1) + m_aSelectedRows.erase(m_aSelectedRows.begin()+_nRowPos); else - m_nRowSelected.clear(); + m_aSelectedRows.clear(); } //after removing a row, row positions must be updated, so selected rows could stay selected - if(m_nRowSelected.size()>1) + if(m_aSelectedRows.size()>1) { - for(std::vector::iterator it=m_nRowSelected.begin();it!=m_nRowSelected.end();++it) + for(std::vector::iterator it=m_aSelectedRows.begin();it!=m_aSelectedRows.end();++it) { if(*it > _nRowPos) - m_nRowSelected[i]=*it-1; + m_aSelectedRows[i]=*it-1; ++i; } } @@ -2046,21 +2058,19 @@ namespace svt { namespace table { return m_pHScroll; } + //------------------------------------------------------------------------------------------------------------------ ScrollBar* TableControl_Impl::getVertScrollbar() { return m_pVScroll; } + //------------------------------------------------------------------------------------------------------------------ - BOOL TableControl_Impl::isRowSelected(const ::std::vector& selectedRows, RowPos current) + bool TableControl_Impl::isRowSelected( RowPos i_row ) const { - return ::std::find(selectedRows.begin(),selectedRows.end(),current) != selectedRows.end(); - } - //------------------------------------------------------------------------------------------------------------------ - bool TableControl_Impl::isRowSelected(RowPos current) - { - return ::std::find(m_nRowSelected.begin(),m_nRowSelected.end(),current) != m_nRowSelected.end(); + return ::std::find( m_aSelectedRows.begin(), m_aSelectedRows.end(), i_row ) != m_aSelectedRows.end(); } + //------------------------------------------------------------------------------------------------------------------ int TableControl_Impl::getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current) { @@ -2305,7 +2315,7 @@ namespace svt { namespace table if ( bDontSelectAtCursor ) { - if ( m_pTableControl->m_nRowSelected.size()>1 ) + if ( m_pTableControl->m_aSelectedRows.size()>1 ) m_pTableControl->m_pSelEngine->AddAlways(TRUE); bHandled = TRUE; } @@ -2319,10 +2329,10 @@ namespace svt { namespace table //put selected rows in vector while ( m_pTableControl->m_nAnchor >= newRow ) { - bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, m_pTableControl->m_nAnchor); + bool isAlreadySelected = m_pTableControl->isRowSelected( m_pTableControl->m_nAnchor ); //if row isn't selected, put it in vector, otherwise don't put it there, because it will be twice there if(!isAlreadySelected) - m_pTableControl->m_nRowSelected.push_back(m_pTableControl->m_nAnchor); + m_pTableControl->m_aSelectedRows.push_back(m_pTableControl->m_nAnchor); m_pTableControl->m_nAnchor--; diff--; } @@ -2333,9 +2343,9 @@ namespace svt { namespace table { while ( m_pTableControl->m_nAnchor <= newRow ) { - bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, m_pTableControl->m_nAnchor); + bool isAlreadySelected = m_pTableControl->isRowSelected( m_pTableControl->m_nAnchor ); if(!isAlreadySelected) - m_pTableControl->m_nRowSelected.push_back(m_pTableControl->m_nAnchor); + m_pTableControl->m_aSelectedRows.push_back(m_pTableControl->m_nAnchor); m_pTableControl->m_nAnchor++; diff++; } @@ -2348,23 +2358,23 @@ namespace svt { namespace table //no region selected else { - if(m_pTableControl->m_nRowSelected.empty()) - m_pTableControl->m_nRowSelected.push_back( newRow ); + if(m_pTableControl->m_aSelectedRows.empty()) + m_pTableControl->m_aSelectedRows.push_back( newRow ); else { if(m_pTableControl->m_pSelEngine->GetSelectionMode()==SINGLE_SELECTION) { DeselectAll(); - m_pTableControl->m_nRowSelected.push_back( newRow ); + m_pTableControl->m_aSelectedRows.push_back( newRow ); } else { - bool isAlreadySelected = m_pTableControl->isRowSelected( m_pTableControl->m_nRowSelected, newRow ); + bool isAlreadySelected = m_pTableControl->isRowSelected( newRow ); if ( !isAlreadySelected ) - m_pTableControl->m_nRowSelected.push_back( newRow ); + m_pTableControl->m_aSelectedRows.push_back( newRow ); } } - if(m_pTableControl->m_nRowSelected.size()>1 && m_pTableControl->m_pSelEngine->GetSelectionMode()!=SINGLE_SELECTION) + if(m_pTableControl->m_aSelectedRows.size()>1 && m_pTableControl->m_pSelEngine->GetSelectionMode()!=SINGLE_SELECTION) m_pTableControl->m_pSelEngine->AddAlways(TRUE); Rectangle aCellRect; @@ -2380,13 +2390,13 @@ namespace svt { namespace table BOOL TableFunctionSet::IsSelectionAtPoint( const Point& rPoint ) { m_pTableControl->m_pSelEngine->AddAlways(FALSE); - if(m_pTableControl->m_nRowSelected.empty()) + if(m_pTableControl->m_aSelectedRows.empty()) return FALSE; else { RowPos curRow = m_pTableControl->getRowAtPoint( rPoint ); m_pTableControl->m_nAnchor = -1; - bool selected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, curRow); + bool selected = m_pTableControl->isRowSelected( curRow ); m_nCurrentRow = curRow; return selected; } @@ -2398,8 +2408,8 @@ namespace svt { namespace table long pos = 0; long i = 0; Rectangle rCells; - for(std::vector::iterator it=m_pTableControl->m_nRowSelected.begin(); - it!=m_pTableControl->m_nRowSelected.end();++it) + for(std::vector::iterator it=m_pTableControl->m_aSelectedRows.begin(); + it!=m_pTableControl->m_aSelectedRows.end();++it) { if(*it == m_nCurrentRow) { @@ -2408,20 +2418,20 @@ namespace svt { namespace table } ++i; } - m_pTableControl->m_nRowSelected.erase(m_pTableControl->m_nRowSelected.begin()+pos); + m_pTableControl->m_aSelectedRows.erase(m_pTableControl->m_aSelectedRows.begin()+pos); } //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::DeselectAll() { - if(!m_pTableControl->m_nRowSelected.empty()) + if(!m_pTableControl->m_aSelectedRows.empty()) { Rectangle rCells; - for(std::vector::iterator it=m_pTableControl->m_nRowSelected.begin(); - it!=m_pTableControl->m_nRowSelected.end();++it) + for(std::vector::iterator it=m_pTableControl->m_aSelectedRows.begin(); + it!=m_pTableControl->m_aSelectedRows.end();++it) { m_pTableControl->invalidateSelectedRegion(*it, *it, rCells); } - m_pTableControl->m_nRowSelected.clear(); + m_pTableControl->m_aSelectedRows.clear(); } } diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 4f2a626324b2..1987dd96e6f5 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -150,7 +150,7 @@ namespace svt { namespace table //selection engine - for determining selection range, e.g. single, multiple SelectionEngine* m_pSelEngine; //vector which contains the selected rows - std::vector m_nRowSelected; + std::vector m_aSelectedRows; //part of selection engine TableFunctionSet* m_pTableFunctionSet; //part of selection engine @@ -177,8 +177,6 @@ namespace svt { namespace table inline const PTableInputHandler& getInputHandler() const { return m_pInputHandler; } - inline ColPos getCurColumn() const { return m_nCurColumn; } - inline RowPos getCurRow() const { return m_nCurRow; } inline void setCurRow(RowPos curRow){ m_nCurRow = curRow; } inline RowPos getTopRow() const { return m_nTopRow; } @@ -223,11 +221,6 @@ namespace svt { namespace table */ ::rtl::OUString getCellContentAsString( RowPos const i_row, ColPos const i_col ); - /** checks whether the vector with the selected rows contains the current row*/ - BOOL isRowSelected(const ::std::vector& selectedRows, RowPos current); - - bool isRowSelected(RowPos current); - /** returns the position of the current row in the selection vector */ int getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current); @@ -251,12 +244,16 @@ namespace svt { namespace table virtual bool dispatchAction( TableControlAction _eAction ); virtual SelectionEngine* getSelEngine(); virtual PTableModel getModel() const; + virtual ColPos getCurrentColumn() const; + virtual RowPos getCurrentRow() const; virtual void activateCellAt( const Point& rPoint ); - virtual RowPos getRowAtPoint( const Point& rPoint ); - virtual ColPos getColAtPoint( const Point& rPoint ); + virtual RowPos getRowAtPoint( const Point& rPoint ) const; + virtual ColPos getColAtPoint( const Point& rPoint ) const; virtual void resizeColumn(const Point& rPoint); virtual bool checkResizeColumn(const Point& rPoint); virtual bool endResizeColumn(const Point& rPoint); + virtual bool isRowSelected( RowPos i_row ) const; + TableDataWindow* getDataWindow(); ScrollBar* getHorzScrollbar(); diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index ef714f16a780..69df1c929218 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -92,6 +92,7 @@ sal_Int32 SAL_CALL SVTXGridControl::getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getRowAtPoint: no control (anymore)!", -1 ); + sal_Int32 const nRow = pTable->getTableControlInterface().getRowAtPoint( Point( x, y ) ); return ( nRow >= 0 ) ? nRow : -1; } @@ -103,10 +104,35 @@ sal_Int32 SAL_CALL SVTXGridControl::getColumnAtPoint(::sal_Int32 x, ::sal_Int32 TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getColumnAtPoint: no control (anymore)!", -1 ); + sal_Int32 const nColumn = pTable->getTableControlInterface().getColAtPoint( Point( x, y ) ); return ( nColumn >= 0 ) ? nColumn : -1; } +// --------------------------------------------------------------------------------------------------------------------- +sal_Int32 SAL_CALL SVTXGridControl::getCurrentColumn( ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getCurrentColumn: no control (anymore)!", -1 ); + + sal_Int32 const nColumn = pTable->GetCurrentColumn(); + return ( nColumn >= 0 ) ? nColumn : -1; +} + +// --------------------------------------------------------------------------------------------------------------------- +sal_Int32 SAL_CALL SVTXGridControl::getCurrentRow( ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getCurrentRow: no control (anymore)!", -1 ); + + sal_Int32 const nRow = pTable->GetCurrentRow(); + return ( nRow >= 0 ) ? nRow : -1; +} + // --------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index c3d1f909126b..8ebeb09374ec 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -105,6 +105,8 @@ public: // XGridControl virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); 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); void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 70afcc5c3a13..28a203b81c03 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -346,6 +346,20 @@ sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_ return xGrid->getColumnAtPoint( x, y ); } +//---------------------------------------------------------------------------------------------------------------------- +::sal_Int32 SAL_CALL UnoGridControl::getCurrentColumn( ) throw (RuntimeException) +{ + Reference< XGridControl > const xGrid ( getPeer(), UNO_QUERY_THROW ); + return xGrid->getCurrentColumn(); +} + +//---------------------------------------------------------------------------------------------------------------------- +::sal_Int32 SAL_CALL UnoGridControl::getCurrentRow( ) throw (RuntimeException) +{ + Reference< XGridControl > const xGrid ( getPeer(), UNO_QUERY_THROW ); + return xGrid->getCurrentRow(); +} + //---------------------------------------------------------------------------------------------------------------------- ::sal_Int32 SAL_CALL UnoGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index 6dfc5d71e639..cf832cb80705 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -97,8 +97,10 @@ public: sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel ) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridControl - virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getRowAtPoint(::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); // ::com::sun::star::awt::grid::XGridSelection virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From 5e725b448fcb0f732b2b492d7452b9304de0bbce Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 11 Jan 2011 17:21:55 +0100 Subject: gridsort: PaintRowHeader's RowPos argument was superfluous - removed --- svtools/inc/svtools/table/gridtablerenderer.hxx | 1 - svtools/inc/svtools/table/tablerenderer.hxx | 3 ++- svtools/source/table/gridtablerenderer.cxx | 4 ++-- svtools/source/table/tablecontrol_impl.cxx | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/gridtablerenderer.hxx b/svtools/inc/svtools/table/gridtablerenderer.hxx index 01492ae26fc4..72dfa503fea0 100644 --- a/svtools/inc/svtools/table/gridtablerenderer.hxx +++ b/svtools/inc/svtools/table/gridtablerenderer.hxx @@ -84,7 +84,6 @@ namespace svt { namespace table OutputDevice& _rDevice, const Rectangle& _rRowArea, const StyleSettings& _rStyle ); virtual void PaintRowHeader( - RowPos const i_rowPos, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ); diff --git a/svtools/inc/svtools/table/tablerenderer.hxx b/svtools/inc/svtools/table/tablerenderer.hxx index 4477f7065001..7490afae35b4 100644 --- a/svtools/inc/svtools/table/tablerenderer.hxx +++ b/svtools/inc/svtools/table/tablerenderer.hxx @@ -46,6 +46,7 @@ namespace svt { namespace table class SAL_NO_VTABLE ITableRenderer { public: + /** paints a (part of) header area There are two header areas in a table control: @@ -176,7 +177,7 @@ namespace svt { namespace table @param _rStyle the style to be used for drawing */ - virtual void PaintRowHeader( RowPos const i_rowPos, bool _bActive, bool _bSelected, + virtual void PaintRowHeader( bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) = 0; diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 9e7a5213c098..67fec8310964 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -213,7 +213,7 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - void GridTableRenderer::PaintRowHeader( RowPos const i_rowPos, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, + void GridTableRenderer::PaintRowHeader( bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { _rDevice.Push( PUSH_LINECOLOR | PUSH_TEXTCOLOR ); @@ -240,7 +240,7 @@ namespace svt { namespace table Rectangle aRect( _rArea ); aRect.Left()+=4; aRect.Right()-=4; aRect.Bottom()-=2; - _rDevice.DrawText( aRect, m_pImpl->rModel.getRowHeader( i_rowPos ), nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); + _rDevice.DrawText( aRect, m_pImpl->rModel.getRowHeader( m_pImpl->nCurrentRow ), nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); // TODO: active? selected? (void)_bActive; diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index ac2d41c122a4..bfa5485fdaed 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -1174,7 +1174,7 @@ namespace svt { namespace table if ( m_pModel->hasRowHeaders() ) { const Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) ); - pRenderer->PaintRowHeader( aRowIterator.getRow(), isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, + pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, rStyle ); } if ( !colCount ) -- cgit v1.2.3 From 76365bac02b0ee3ffc3755699034b8d790d2c97a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 11 Jan 2011 21:45:47 +0100 Subject: gridsort: don't display cell tooltips unconditionally. Instead, when we use the cell content as tooltip, display it if and only if the renderer tells us it would not fit into the cell --- svtools/inc/svtools/table/gridtablerenderer.hxx | 6 +++ svtools/inc/svtools/table/tablerenderer.hxx | 35 ++++++++++++++ svtools/source/table/gridtablerenderer.cxx | 64 ++++++++++++++++++++++--- svtools/source/table/tabledatawindow.cxx | 31 +++++++----- 4 files changed, 118 insertions(+), 18 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/gridtablerenderer.hxx b/svtools/inc/svtools/table/gridtablerenderer.hxx index 72dfa503fea0..3b4160b1fd6a 100644 --- a/svtools/inc/svtools/table/gridtablerenderer.hxx +++ b/svtools/inc/svtools/table/gridtablerenderer.hxx @@ -93,6 +93,12 @@ namespace svt { namespace table const StyleSettings& _rStyle ); virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect); virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect); + virtual bool FitsIntoCell( + ::com::sun::star::uno::Any const & i_cellContent, + ColPos const i_colPos, RowPos const i_rowPos, + bool const i_active, bool const i_selected, + OutputDevice& i_targetDevice, Rectangle const & i_targetArea + ); private: struct CellRenderContext; diff --git a/svtools/inc/svtools/table/tablerenderer.hxx b/svtools/inc/svtools/table/tablerenderer.hxx index 7490afae35b4..3d50c9d70ee7 100644 --- a/svtools/inc/svtools/table/tablerenderer.hxx +++ b/svtools/inc/svtools/table/tablerenderer.hxx @@ -226,6 +226,41 @@ namespace svt { namespace table */ virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect) = 0; + /** checks whether a given cell content fits into a given target area on a given device. + + @param i_colPos + denotes the column which the cell content would be painted into. Your renderer implementation + would only need this parameter if rendering is done differently for different columns. + + @param i_rowPos + denotes the row which the cell content would be painted into. Your renderer implementation + would only need this parameter if rendering is done differently for different rows. + + @param i_active + is if and only if the renderer should assume the cell content would be painted for the active + cell. + + @param i_selected + is if and only if the renderer should assume the cell content would be painted for a selected + cell. + + @param i_targetDevice + denotes the target device for the assumed rendering operation + + @param i_targetArea + denotes the area within the target device for the assumed rendering operation. + + @return + if and only if the given cell content could be rendered into the given device and the + given area. + */ + virtual bool FitsIntoCell( + ::com::sun::star::uno::Any const & i_cellContent, + ColPos const i_colPos, RowPos const i_rowPos, + bool const i_active, bool const i_selected, + OutputDevice& i_targetDevice, Rectangle const & i_targetArea + ) = 0; + /// deletes the renderer instance virtual ~ITableRenderer() { } }; diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 67fec8310964..60628ffba95d 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -268,10 +269,28 @@ namespace svt { namespace table } }; + //-------------------------------------------------------------------- + namespace + { + /** transforms a rectangle denoting a cell area so that afterwards, it denotes the area we + can use for rendering the cell's content. + */ + static void lcl_convertCellToContentArea( Rectangle & io_area ) + { + ++io_area.Left(); --io_area.Right(); + } + + static void lcl_convertContentToTextRenderingArea( Rectangle & io_area ) + { + io_area.Left() += 2; io_area.Right() -= 2; + ++io_area.Top(); --io_area.Bottom(); + } + } + //-------------------------------------------------------------------- void GridTableRenderer::PaintCell( ColPos const i_column, bool _bSelected, bool _bActive, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) - { + { _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); Color background1 = m_pImpl->rModel.getOddRowBackgroundColor(); Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor(); @@ -299,15 +318,15 @@ namespace svt { namespace table _rDevice.SetLineColor( background1 ); else { - //if line color is set, then it was user defined and should be visible - //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible + // if line color is set, then it was user defined and should be visible + // if it wasn't set, it'll be the same as the default background color, so lines still won't be visible _rDevice.SetLineColor( lineColor ); } } _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); Rectangle aRect( _rArea ); - ++aRect.Left(); --aRect.Right(); + lcl_convertCellToContentArea( aRect ); const CellRenderContext aRenderContext( _rDevice, aRect, _rStyle, i_column, _bSelected ); impl_paintCellContent( aRenderContext ); @@ -413,8 +432,7 @@ namespace svt { namespace table } Rectangle textRect( i_context.aContentArea ); - textRect.Left() += 2; textRect.Right() -= 2; - ++textRect.Top(); --textRect.Bottom(); + lcl_convertContentToTextRenderingArea( textRect ); i_context.rDevice.DrawText( textRect, i_text, nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); } @@ -428,9 +446,41 @@ namespace svt { namespace table //-------------------------------------------------------------------- void GridTableRenderer::HideCellCursor( Window& _rView, const Rectangle& _rCursorRect) { - (void)_rCursorRect; + (void)_rCursorRect; _rView.HideFocus(); + } + + //-------------------------------------------------------------------- + bool GridTableRenderer::FitsIntoCell( Any const & i_cellContent, ColPos const i_colPos, RowPos const i_rowPos, + bool const i_active, bool const i_selected, OutputDevice& i_targetDevice, Rectangle const & i_targetArea ) + { + if ( !i_cellContent.hasValue() ) + return true; + + Reference< XGraphic > const xGraphic( i_cellContent, UNO_QUERY ); + if ( xGraphic.is() ) + // for the moment, assume it fits. We can always scale it down during painting ... + return true; + + ::rtl::OUString const sText( CellValueConversion::convertToString( i_cellContent ) ); + if ( sText.getLength() == 0 ) + return true; + + Rectangle aTargetArea( i_targetArea ); + lcl_convertCellToContentArea( aTargetArea ); + lcl_convertContentToTextRenderingArea( aTargetArea ); + + long const nTextHeight = i_targetDevice.GetTextHeight(); + if ( nTextHeight > aTargetArea.GetHeight() ) + return false; + + long const nTextWidth = i_targetDevice.GetTextWidth( sText ); + if ( nTextWidth > aTargetArea.GetWidth() ) + return false; + OSL_UNUSED( i_active ); + OSL_UNUSED( i_selected ); + return true; } //........................................................................ diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index b357fd91abda..ed7b3f8478b3 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -94,7 +94,7 @@ namespace svt { namespace table ITableControl& rTableControl = m_rTableControl; PTableModel const pTableModel( rTableControl.getModel() ); - Point const aMousePos( m_rTableControl.getAntiImpl().ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ); + Point const aMousePos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ); RowPos const hitRow = rTableControl.getRowAtPoint( aMousePos ); ColPos const hitCol = rTableControl.getColAtPoint( aMousePos ); @@ -115,21 +115,30 @@ namespace svt { namespace table { // use the cell content pTableModel->getCellContent( hitCol, hitRow, aCellToolTip ); - // TODO: use the cell content as tool tip only if it doesn't fit into the cell. Need to - // ask the renderer for this. + + // use the cell content as tool tip only if it doesn't fit into the cell. + bool const activeCell = ( hitRow == rTableControl.getCurrentRow() ) && ( hitCol == rTableControl.getCurrentColumn() ); + bool const selectedCell = rTableControl.isRowSelected( hitRow ); + + Rectangle const aWindowRect( Point( 0, 0 ), GetOutputSizePixel() ); + TableCellGeometry const aCell( m_rTableControl, aWindowRect, hitCol, hitRow ); + Rectangle const aCellRect( aCell.getRect() ); + + PTableRenderer const pRenderer = pTableModel->getRenderer(); + if ( pRenderer->FitsIntoCell( aCellToolTip, hitCol, hitRow, activeCell, selectedCell, *this, aCellRect ) ) + aCellToolTip.clear(); } sHelpText = CellValueConversion::convertToString( aCellToolTip ); } - if ( sHelpText.getLength() > 0 ) - { - Rectangle const aControlScreenRect( - m_rTableControl.getAntiImpl().OutputToScreenPixel( Point( 0, 0 ) ), - m_rTableControl.getAntiImpl().GetOutputSizePixel() - ); - Help::ShowQuickHelp( &m_rTableControl.getAntiImpl(), aControlScreenRect, sHelpText, String(), QUICKHELP_FORCE_REPOSITION ); - } + Rectangle const aControlScreenRect( + OutputToScreenPixel( Point( 0, 0 ) ), + GetOutputSizePixel() + ); + Help::ShowQuickHelp( this, aControlScreenRect, sHelpText, String(), QUICKHELP_FORCE_REPOSITION | QUICKHELP_NO_DELAY ); + // also do this when the help text is empty - in this case, a previously active tip help window + // (possible displaying the tooltip for another cell) will be hidden, which is intended here. } } else -- cgit v1.2.3 From 6c8d7babb69985bf3f676b59cf767952c971ebc5 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 12 Jan 2011 12:34:24 +0100 Subject: gridsort: reworked the color model for grid controls. Now supporting more than two alternating colors, having more reasonable defaults for the colors (VOID instead of some hard-coded values, which thus are unusable). Also, introduced new property UseGridLines controlling whether or not to paint the table grid. --- svtools/inc/svtools/table/gridtablerenderer.hxx | 14 +- svtools/inc/svtools/table/tablemodel.hxx | 52 +++++- svtools/source/table/gridtablerenderer.cxx | 235 +++++++++++++----------- svtools/source/table/tablecontrol_impl.cxx | 28 +-- svtools/source/uno/svtxgridcontrol.cxx | 169 ++++++++++++----- svtools/source/uno/unocontroltablemodel.cxx | 161 ++++++++++------ svtools/source/uno/unocontroltablemodel.hxx | 66 ++++--- toolkit/inc/toolkit/helper/property.hxx | 9 +- toolkit/source/controls/grid/gridcontrol.cxx | 21 +-- toolkit/source/helper/property.cxx | 9 +- 10 files changed, 484 insertions(+), 280 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/gridtablerenderer.hxx b/svtools/inc/svtools/table/gridtablerenderer.hxx index 3b4160b1fd6a..c472fa408574 100644 --- a/svtools/inc/svtools/table/gridtablerenderer.hxx +++ b/svtools/inc/svtools/table/gridtablerenderer.hxx @@ -29,6 +29,8 @@ #include +#include + //........................................................................ namespace svt { namespace table { @@ -47,7 +49,7 @@ namespace svt { namespace table class GridTableRenderer : public ITableRenderer { private: - GridTableRenderer_Impl* m_pImpl; + ::boost::scoped_ptr< GridTableRenderer_Impl > m_pImpl; public: /** creates a table renderer associated with the given model @@ -69,7 +71,15 @@ namespace svt { namespace table This method returns the index of the last row which has been prepared */ - RowPos getCurrentRow(); + RowPos getCurrentRow() const; + + /** determines whether or not to paint grid lines + */ + bool useGridLines() const; + + /** controls whether or not to paint grid lines + */ + void useGridLines( bool const i_use ); public: // ITableRenderer overridables diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 3eb87f1eb40e..50030de7a31d 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -40,6 +40,7 @@ #include #include +#include #include //........................................................................ @@ -461,12 +462,51 @@ namespace svt { namespace table */ virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const = 0; - virtual ::com::sun::star::util::Color getLineColor() = 0; - virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0; - virtual ::com::sun::star::util::Color getTextColor() = 0; - virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0; - virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0; - virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0; + /** returns the color to be used for rendering the grid lines. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getLineColor() const = 0; + + /** returns the color to be used for rendering the header background. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const = 0; + + /** returns the color to be used for rendering the header text. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getHeaderTextColor() const = 0; + + /** returns the color to be used for rendering cell texts. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getTextColor() const = 0; + + /** returns the color to be used for text lines (underline, strikethrough) when rendering cell text. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getTextLineColor() const = 0; + + /** returns the colors to be used for the row backgrounds. + + If this value is not set, every second row will have a background color derived from the style settings's + selection color, the other rows will not have a special background at all. + + If this value is an empty sequence, the rows will not have a special background at all, instead the + normal background of the complete control will be used. + + If value is a non-empty sequence, then rows will have the background colors as specified in the sequence, + in alternating order. + */ + virtual ::boost::optional< ::std::vector< ::Color > > + getRowBackgroundColors() const = 0; + + virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() const = 0; /// destroys the table model instance virtual ~ITableModel() { } diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 60628ffba95d..3163cc54174c 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -29,19 +29,23 @@ #include "cellvalueconversion.hxx" #include "svtools/table/gridtablerenderer.hxx" +#include "svtools/colorcfg.hxx" +/** === begin UNO includes === **/ #include +/** === end UNO includes === **/ #include #include #include #include -//........................................................................ +//...................................................................................................................... namespace svt { namespace table { -//........................................................................ +//...................................................................................................................... + /** === begin UNO using === **/ using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::UNO_QUERY; @@ -54,41 +58,70 @@ namespace svt { namespace table using ::com::sun::star::style::VerticalAlignment_TOP; using ::com::sun::star::style::VerticalAlignment_MIDDLE; using ::com::sun::star::style::VerticalAlignment_BOTTOM; + /** === end UNO using === **/ struct GridTableRenderer_Impl { ITableModel& rModel; RowPos nCurrentRow; + bool bUseGridLines; GridTableRenderer_Impl( ITableModel& _rModel ) :rModel( _rModel ) ,nCurrentRow( ROW_INVALID ) + ,bUseGridLines( true ) { } }; - //==================================================================== + //================================================================================================================== //= GridTableRenderer - //==================================================================== - //-------------------------------------------------------------------- + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ GridTableRenderer::GridTableRenderer( ITableModel& _rModel ) :m_pImpl( new GridTableRenderer_Impl( _rModel ) ) { } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ GridTableRenderer::~GridTableRenderer() { - DELETEZ( m_pImpl ); } - //-------------------------------------------------------------------- - RowPos GridTableRenderer::getCurrentRow() + //------------------------------------------------------------------------------------------------------------------ + RowPos GridTableRenderer::getCurrentRow() const { return m_pImpl->nCurrentRow; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + bool GridTableRenderer::useGridLines() const + { + return m_pImpl->bUseGridLines; + } + + //------------------------------------------------------------------------------------------------------------------ + void GridTableRenderer::useGridLines( bool const i_use ) + { + m_pImpl->bUseGridLines = i_use; + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + Color lcl_getEffectiveColor( + ::boost::optional< ::Color > const & i_modelColor, + StyleSettings const & i_styleSettings, + ::Color const & ( StyleSettings::*i_getDefaultColor ) () const + ) + { + if ( !!i_modelColor ) + return *i_modelColor; + return ( i_styleSettings.*i_getDefaultColor )(); + } + } + + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::PaintHeaderArea( OutputDevice& _rDevice, const Rectangle& _rArea, bool _bIsColHeaderArea, bool _bIsRowHeaderArea, const StyleSettings& _rStyle ) @@ -97,12 +130,11 @@ namespace svt { namespace table "GridTableRenderer::PaintHeaderArea: invalid area flags!" ); _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); - Color background = m_pImpl->rModel.getHeaderBackgroundColor(); - if ( background != COL_TRANSPARENT ) - _rDevice.SetFillColor( background ); - else - _rDevice.SetFillColor( _rStyle.GetDialogColor() ); - _rDevice.SetLineColor( _rStyle.GetSeparatorColor() ); + + Color const background = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderBackgroundColor(), _rStyle, &StyleSettings::GetDialogColor ); + _rDevice.SetFillColor( background ); + + m_pImpl->bUseGridLines ? _rDevice.SetLineColor( _rStyle.GetSeparatorColor() ) : _rDevice.SetLineColor(); _rDevice.DrawRect( _rArea ); // delimiter lines at bottom/right _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); @@ -113,7 +145,7 @@ namespace svt { namespace table (void)_bIsRowHeaderArea; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { @@ -126,24 +158,26 @@ namespace svt { namespace table DBG_ASSERT( !!pColumn, "GridTableRenderer::PaintColumnHeader: invalid column model object!" ); if ( !!pColumn ) sHeaderText = pColumn->getName(); - if(m_pImpl->rModel.getTextColor() != 0x000000) - _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); - else - _rDevice.SetTextColor(_rStyle.GetFieldTextColor()); + + ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getTextColor(), _rStyle, &StyleSettings::GetFieldTextColor ); + _rDevice.SetTextColor( textColor ); + ULONG nHorFlag = TEXT_DRAW_LEFT; ULONG nVerFlag = TEXT_DRAW_TOP; - if(m_pImpl->rModel.getVerticalAlign() == 1) + if ( m_pImpl->rModel.getVerticalAlign() == 1 ) nVerFlag = TEXT_DRAW_VCENTER; - else if(m_pImpl->rModel.getVerticalAlign() == 2) + else if ( m_pImpl->rModel.getVerticalAlign() == 2 ) nVerFlag = TEXT_DRAW_BOTTOM; - if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 1) + if ( m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 1 ) nHorFlag = TEXT_DRAW_CENTER; - else if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2) + else if ( m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2 ) nHorFlag = TEXT_DRAW_RIGHT; + Rectangle aRect(_rArea); aRect.Left()+=4; aRect.Right()-=4; aRect.Bottom()-=2; - _rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + + _rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); _rDevice.Pop(); @@ -151,10 +185,10 @@ namespace svt { namespace table // no special painting for the active column at the moment (void)_bSelected; - //selection for column header not yet implemented + // selection for column header not yet implemented } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::PrepareRow( RowPos _nRow, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rRowArea, const StyleSettings& _rStyle ) { @@ -163,69 +197,74 @@ namespace svt { namespace table _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); - Color aRowBackground = m_pImpl->rModel.getOddRowBackgroundColor(); - const Color lineColor = m_pImpl->rModel.getLineColor(); - Color aRowBackground2 = m_pImpl->rModel.getEvenRowBackgroundColor(); - const Color fieldColor = _rStyle.GetFieldColor(); - if ( aRowBackground == COL_TRANSPARENT ) - aRowBackground = fieldColor; - if ( aRowBackground2 == COL_TRANSPARENT ) - aRowBackground2 = fieldColor; - //if row is selected background color becomes blue, and lines should be also blue - //if they aren't user defined + ::Color backgroundColor = _rStyle.GetFieldColor(); + + ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); + ::Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; + if ( _bSelected ) { - const Color aSelected( _rStyle.GetHighlightColor() ); - aRowBackground = aSelected; - if ( lineColor == COL_TRANSPARENT ) - _rDevice.SetLineColor( aRowBackground ); - else - _rDevice.SetLineColor( lineColor ); + // selected rows use the background color from the style + backgroundColor = _rStyle.GetHighlightColor(); + if ( !aLineColor ) + lineColor = backgroundColor; } - // if row not selected, check the cases whether user defined backgrounds are set - // and set line color to be the same else { - if ( ( aRowBackground2 != fieldColor ) && ( _nRow % 2 ) ) + ::boost::optional< ::std::vector< ::Color > > aRowColors = m_pImpl->rModel.getRowBackgroundColors(); + if ( !aRowColors ) { - aRowBackground = aRowBackground2; - if ( lineColor == COL_TRANSPARENT ) - _rDevice.SetLineColor( aRowBackground ); + // use alternating default colors + if ( ( m_pImpl->nCurrentRow % 2 ) == 0 ) + { + backgroundColor = _rStyle.GetFieldColor(); + } else - _rDevice.SetLineColor( lineColor ); + { + Color hilightColor = _rStyle.GetHighlightColor(); + USHORT const luminance = hilightColor.GetLuminance(); + hilightColor.SetRed( 9 * ( 255 - hilightColor.GetRed() ) / 10 + hilightColor.GetRed() ); + hilightColor.SetGreen( 9 * ( 255 - hilightColor.GetGreen() ) / 10 + hilightColor.GetGreen() ); + hilightColor.SetBlue( 9 * ( 255 - hilightColor.GetBlue() ) / 10 + hilightColor.GetBlue() ); + backgroundColor = hilightColor; + } } - //fill the rows with alternating background colors if second background color is specified - else if ( aRowBackground != fieldColor && lineColor == COL_TRANSPARENT ) - _rDevice.SetLineColor( aRowBackground ); else { - //if Line color is set, then it was user defined and should be visible - //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible - _rDevice.SetLineColor( lineColor ); + if ( aRowColors->empty() ) + { + // all colors have the same background color + backgroundColor = _rStyle.GetFieldColor(); + } + else + { + backgroundColor = aRowColors->at( m_pImpl->nCurrentRow % aRowColors->size() ); + } } } - _rDevice.SetFillColor( aRowBackground ); - _rDevice.DrawRect( _rRowArea ); - // TODO: active? + m_pImpl->bUseGridLines ? _rDevice.SetLineColor( lineColor ) : _rDevice.SetLineColor(); + _rDevice.SetFillColor( backgroundColor ); + _rDevice.DrawRect( _rRowArea ); _rDevice.Pop(); + (void)_bActive; + // row containing the active cell not rendered any special at the moment } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::PaintRowHeader( bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { _rDevice.Push( PUSH_LINECOLOR | PUSH_TEXTCOLOR ); - _rDevice.SetLineColor( _rStyle.GetSeparatorColor() ); + ::boost::optional< ::Color > const aLineColor( m_pImpl->rModel.getLineColor() ); + ::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); - if ( m_pImpl->rModel.getTextColor() != 0x000000 ) - _rDevice.SetTextColor( m_pImpl->rModel.getTextColor() ); - else - _rDevice.SetTextColor( _rStyle.GetFieldTextColor() ); + ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderTextColor(), _rStyle, &StyleSettings::GetFieldTextColor ); + _rDevice.SetTextColor( textColor ); ULONG nHorFlag = TEXT_DRAW_LEFT; ULONG nVerFlag = TEXT_DRAW_TOP; @@ -249,7 +288,7 @@ namespace svt { namespace table _rDevice.Pop(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ struct GridTableRenderer::CellRenderContext { OutputDevice& rDevice; @@ -269,7 +308,7 @@ namespace svt { namespace table } }; - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ namespace { /** transforms a rectangle denoting a cell area so that afterwards, it denotes the area we @@ -287,42 +326,23 @@ namespace svt { namespace table } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::PaintCell( ColPos const i_column, bool _bSelected, bool _bActive, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); - Color background1 = m_pImpl->rModel.getOddRowBackgroundColor(); - Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor(); - Color lineColor = m_pImpl->rModel.getLineColor(); - // if row is selected and line color isn't user specified, use the settings' color + ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); + ::Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; + if ( _bSelected ) { - if ( lineColor == COL_TRANSPARENT ) - _rDevice.SetLineColor( _rStyle.GetHighlightColor() ); - else - _rDevice.SetLineColor( lineColor ); - } - // else set line color to the color of row background - else - { - if ( ( background2 != COL_TRANSPARENT ) && ( m_pImpl->nCurrentRow % 2 ) ) - { - if ( lineColor == COL_TRANSPARENT ) - _rDevice.SetLineColor( background2 ); - else - _rDevice.SetLineColor( lineColor ); - } - else if ( ( background1 != COL_TRANSPARENT ) && ( lineColor == COL_TRANSPARENT ) ) - _rDevice.SetLineColor( background1 ); - else - { - // if line color is set, then it was user defined and should be visible - // if it wasn't set, it'll be the same as the default background color, so lines still won't be visible - _rDevice.SetLineColor( lineColor ); - } + // if no line color is specified by the model, use the usual selection color for lines + if ( !aLineColor ) + lineColor = _rStyle.GetHighlightColor(); } + + m_pImpl->bUseGridLines ? _rDevice.SetLineColor( lineColor ) : _rDevice.SetLineColor(); _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); Rectangle aRect( _rArea ); @@ -337,7 +357,7 @@ namespace svt { namespace table // no special painting for the active cell at the moment } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::impl_paintCellImage( CellRenderContext const & i_context, Image const & i_image ) { Point imagePos( Point( i_context.aContentArea.Left(), i_context.aContentArea.Top() ) ); @@ -382,7 +402,7 @@ namespace svt { namespace table i_context.rDevice.DrawImage( imagePos, imageSize, i_image, 0 ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::impl_paintCellContent( CellRenderContext const & i_context ) { Any aCellContent; @@ -400,15 +420,16 @@ namespace svt { namespace table impl_paintCellText( i_context, sText ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::impl_paintCellText( CellRenderContext const & i_context, ::rtl::OUString const & i_text ) { if ( i_context.bSelected ) i_context.rDevice.SetTextColor( i_context.rStyle.GetHighlightTextColor() ); - else if ( m_pImpl->rModel.getTextColor() != 0x000000 ) - i_context.rDevice.SetTextColor( m_pImpl->rModel.getTextColor() ); else - i_context.rDevice.SetTextColor( i_context.rStyle.GetFieldTextColor() ); + { + ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getTextColor(), i_context.rStyle, &StyleSettings::GetFieldTextColor ); + i_context.rDevice.SetTextColor( textColor ); + } ULONG nVerFlag = TEXT_DRAW_TOP; @@ -437,20 +458,20 @@ namespace svt { namespace table i_context.rDevice.DrawText( textRect, i_text, nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect) { _rView.ShowFocus( _rCursorRect ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::HideCellCursor( Window& _rView, const Rectangle& _rCursorRect) { (void)_rCursorRect; _rView.HideFocus(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool GridTableRenderer::FitsIntoCell( Any const & i_cellContent, ColPos const i_colPos, RowPos const i_rowPos, bool const i_active, bool const i_selected, OutputDevice& i_targetDevice, Rectangle const & i_targetArea ) { @@ -483,7 +504,7 @@ namespace svt { namespace table return true; } -//........................................................................ +//...................................................................................................................... } } // namespace svt::table -//........................................................................ +//...................................................................................................................... diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index bfa5485fdaed..feaf79c166fa 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -155,29 +155,33 @@ namespace svt { namespace table { (void)i_listener; } - virtual ::com::sun::star::util::Color getLineColor() + virtual ::boost::optional< ::Color > getLineColor() const { - return 0; + return ::boost::optional< ::Color >(); } - virtual ::com::sun::star::util::Color getHeaderBackgroundColor() + virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const { - return -1; + return ::boost::optional< ::Color >(); } - virtual ::com::sun::star::util::Color getTextColor() + virtual ::boost::optional< ::Color > getHeaderTextColor() const { - return 0; + return ::boost::optional< ::Color >(); } - virtual ::com::sun::star::util::Color getOddRowBackgroundColor() + virtual ::boost::optional< ::Color > getTextColor() const { - return -1; + return ::boost::optional< ::Color >(); } - virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() + virtual ::boost::optional< ::Color > getTextLineColor() const { - return com::sun::star::style::VerticalAlignment(0); + return ::boost::optional< ::Color >(); } - virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() + virtual ::boost::optional< ::std::vector< ::Color > > getRowBackgroundColors() const { - return -1; + return ::boost::optional< ::std::vector< ::Color > >(); + } + virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() const + { + return com::sun::star::style::VerticalAlignment(0); } virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ) { diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 69df1c929218..ea0a41688355 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -31,6 +31,7 @@ #include "accessibletableimp.hxx" #include #include "svtools/table/tablecontrolinterface.hxx" +#include "svtools/table/gridtablerenderer.hxx" #include "svtools/table/tablecontrol.hxx" #include "unocontroltablemodel.hxx" #include @@ -155,7 +156,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An switch( GetPropertyId( PropertyName ) ) { - case BASEPROPERTY_ROW_HEADER_WIDTH: + case BASEPROPERTY_ROW_HEADER_WIDTH: { sal_Int32 rowHeaderWidth( -1 ); aValue >>= rowHeaderWidth; @@ -184,6 +185,18 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } break; + case BASEPROPERTY_USE_GRID_LINES: + { + GridTableRenderer* pGridRenderer = dynamic_cast< GridTableRenderer* >( + m_pTableModel->getRenderer().get() ); + ENSURE_OR_BREAK( pGridRenderer != NULL, "SVTXGridControl::setProperty(UseGridLines): invalid renderer!" ); + sal_Bool bUseGridLines = sal_False; + OSL_VERIFY( aValue >>= bUseGridLines ); + pGridRenderer->useGridLines( bUseGridLines ); + pTable->Invalidate(); + } + break; + case BASEPROPERTY_ROW_HEIGHT: { sal_Int32 rowHeight = 0; @@ -239,6 +252,7 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An m_pTableModel->setHorizontalScrollbarVisibility( bHScroll ? ScrollbarShowAlways : ScrollbarShowSmart ); break; } + case BASEPROPERTY_VSCROLL: { sal_Bool bVScroll = true; @@ -258,51 +272,37 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An } break; } - case BASEPROPERTY_GRID_HEADER_BACKGROUND: - { - sal_Int32 colorHeader = COL_TRANSPARENT; - if( aValue >>= colorHeader ) - { - m_pTableModel->setHeaderBackgroundColor(colorHeader); - } + + case BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS: + m_pTableModel->setRowBackgroundColors( aValue ); + pTable->Invalidate(); break; - } + case BASEPROPERTY_GRID_LINE_COLOR: - { - sal_Int32 colorLine = COL_TRANSPARENT; - if( aValue >>= colorLine ) - { - m_pTableModel->setLineColor(colorLine); - } + m_pTableModel->setLineColor( aValue ); + pTable->Invalidate(); break; - } - case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND: - { - sal_Int32 colorEvenRow = COL_TRANSPARENT; - if( aValue >>= colorEvenRow ) - { - m_pTableModel->setEvenRowBackgroundColor(colorEvenRow); - } + + case BASEPROPERTY_GRID_HEADER_BACKGROUND: + m_pTableModel->setHeaderBackgroundColor( aValue ); + pTable->Invalidate(); break; - } - case BASEPROPERTY_GRID_ROW_BACKGROUND: - { - sal_Int32 colorBackground = COL_TRANSPARENT; - if( aValue >>= colorBackground ) - { - m_pTableModel->setOddRowBackgroundColor(colorBackground); - } + + case BASEPROPERTY_GRID_HEADER_TEXT_COLOR: + m_pTableModel->setHeaderTextColor( aValue ); + pTable->Invalidate(); break; - } + case BASEPROPERTY_TEXTCOLOR: - { - sal_Int32 colorText = 0x000000; - if( aValue >>= colorText ) - { - m_pTableModel->setTextColor(colorText); - } + m_pTableModel->setTextColor( aValue ); + pTable->Invalidate(); break; - } + + case BASEPROPERTY_TEXTLINECOLOR: + m_pTableModel->setTextLineColor( aValue ); + pTable->Invalidate(); + break; + case BASEPROPERTY_VERTICALALIGN: { VerticalAlignment eAlign( VerticalAlignment_TOP ); @@ -377,6 +377,17 @@ void SVTXGridControl::impl_checkTableModelInit() } } +namespace +{ + void lcl_convertColor( ::boost::optional< ::Color > const & i_color, Any & o_colorValue ) + { + if ( !i_color ) + o_colorValue.clear(); + else + o_colorValue <<= i_color->GetColor(); + } +} + Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -384,6 +395,8 @@ Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getProperty: no control (anymore)!", Any() ); + Any aPropertyValue; + const sal_uInt16 nPropId = GetPropertyId( PropertyName ); switch(nPropId) { @@ -399,34 +412,92 @@ Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru case MULTIPLE_SELECTION:eSelectionType = SelectionType_MULTI; break; default: eSelectionType = SelectionType_NONE; break; } - return Any( eSelectionType ); + aPropertyValue <<= eSelectionType; + break; } + case BASEPROPERTY_GRID_SHOWROWHEADER: - return Any ((sal_Bool) m_pTableModel->hasRowHeaders()); + aPropertyValue <<= sal_Bool( m_pTableModel->hasRowHeaders() ); + break; case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: - return Any ((sal_Bool) m_pTableModel->hasColumnHeaders()); + aPropertyValue <<= sal_Bool( m_pTableModel->hasColumnHeaders() ); + break; case BASEPROPERTY_GRID_DATAMODEL: - return Any ( m_pTableModel->getDataModel() ); + aPropertyValue <<= m_pTableModel->getDataModel(); + break; case BASEPROPERTY_GRID_COLUMNMODEL: - return Any ( m_xColumnModel); + aPropertyValue <<= m_xColumnModel; + break; case BASEPROPERTY_HSCROLL: { sal_Bool const bHasScrollbar = ( m_pTableModel->getHorizontalScrollbarVisibility() != ScrollbarShowNever ); - return makeAny( bHasScrollbar ); + aPropertyValue <<= bHasScrollbar; + break; } case BASEPROPERTY_VSCROLL: { sal_Bool const bHasScrollbar = ( m_pTableModel->getVerticalScrollbarVisibility() != ScrollbarShowNever ); - return makeAny( bHasScrollbar ); + aPropertyValue <<= bHasScrollbar; + break; + } + + case BASEPROPERTY_USE_GRID_LINES: + { + GridTableRenderer* pGridRenderer = dynamic_cast< GridTableRenderer* >( + m_pTableModel->getRenderer().get() ); + ENSURE_OR_BREAK( pGridRenderer != NULL, "SVTXGridControl::getProperty(UseGridLines): invalid renderer!" ); + aPropertyValue <<= pGridRenderer->useGridLines(); + } + break; + + case BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS: + { + ::boost::optional< ::std::vector< ::Color > > aColors( m_pTableModel->getRowBackgroundColors() ); + if ( !aColors ) + aPropertyValue.clear(); + else + { + Sequence< ::com::sun::star::util::Color > aAPIColors( aColors->size() ); + for ( size_t i=0; isize(); ++i ) + { + aAPIColors[i] = aColors->at(i).GetColor(); + } + aPropertyValue <<= aAPIColors; } } + break; + + case BASEPROPERTY_GRID_LINE_COLOR: + lcl_convertColor( m_pTableModel->getLineColor(), aPropertyValue ); + break; + + case BASEPROPERTY_GRID_HEADER_BACKGROUND: + lcl_convertColor( m_pTableModel->getHeaderBackgroundColor(), aPropertyValue ); + break; + + case BASEPROPERTY_GRID_HEADER_TEXT_COLOR: + lcl_convertColor( m_pTableModel->getHeaderTextColor(), aPropertyValue ); + break; + + case BASEPROPERTY_TEXTCOLOR: + lcl_convertColor( m_pTableModel->getTextColor(), aPropertyValue ); + break; + + case BASEPROPERTY_TEXTLINECOLOR: + lcl_convertColor( m_pTableModel->getTextLineColor(), aPropertyValue ); + break; + + default: + aPropertyValue = VCLXWindow::getProperty( PropertyName ); + break; + } - return VCLXWindow::getProperty( PropertyName ); + return aPropertyValue; } void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) @@ -437,10 +508,10 @@ void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_GRID_DATAMODEL, BASEPROPERTY_GRID_COLUMNMODEL, BASEPROPERTY_GRID_SELECTIONMODE, - BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND, BASEPROPERTY_GRID_HEADER_BACKGROUND, + BASEPROPERTY_GRID_HEADER_TEXT_COLOR, BASEPROPERTY_GRID_LINE_COLOR, - BASEPROPERTY_GRID_ROW_BACKGROUND, + BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS, 0 ); VCLXWindow::ImplGetPropertyIds( rIds, true ); diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index f7b2ca07eb22..66f7f518dab4 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -79,43 +79,45 @@ namespace svt { namespace table typedef ::std::vector< PColumnModel > ColumnModels; struct UnoControlTableModel_Impl { - ColumnModels aColumns; - bool bHasColumnHeaders; - bool bHasRowHeaders; - ScrollbarVisibility eVScrollMode; - ScrollbarVisibility eHScrollMode; - PTableRenderer pRenderer; - PTableInputHandler pInputHandler; - TableMetrics nRowHeight; - TableMetrics nColumnHeaderHeight; - TableMetrics nRowHeaderWidth; - ::com::sun::star::util::Color m_nLineColor; - ::com::sun::star::util::Color m_nHeaderColor; - ::com::sun::star::util::Color m_nTextColor; - ::com::sun::star::util::Color m_nRowColor1; - ::com::sun::star::util::Color m_nRowColor2; - ::com::sun::star::style::VerticalAlignment m_eVerticalAlign; - ModellListeners m_aListeners; - WeakReference< XGridDataModel > m_aDataModel; - WeakReference< XGridColumnModel > m_aColumnModel; + ColumnModels aColumns; + bool bHasColumnHeaders; + bool bHasRowHeaders; + ScrollbarVisibility eVScrollMode; + ScrollbarVisibility eHScrollMode; + PTableRenderer pRenderer; + PTableInputHandler pInputHandler; + TableMetrics nRowHeight; + TableMetrics nColumnHeaderHeight; + TableMetrics nRowHeaderWidth; + ::boost::optional< ::Color > m_aGridLineColor; + ::boost::optional< ::Color > m_aHeaderBackgroundColor; + ::boost::optional< ::Color > m_aHeaderTextColor; + ::boost::optional< ::Color > m_aTextColor; + ::boost::optional< ::Color > m_aTextLineColor; + ::boost::optional< ::std::vector< ::Color > > m_aRowColors; + ::com::sun::star::style::VerticalAlignment m_eVerticalAlign; + ModellListeners m_aListeners; + WeakReference< XGridDataModel > m_aDataModel; + WeakReference< XGridColumnModel > m_aColumnModel; UnoControlTableModel_Impl() - :aColumns ( ) - ,bHasColumnHeaders ( true ) - ,bHasRowHeaders ( false ) - ,eVScrollMode ( ScrollbarShowNever ) - ,eHScrollMode ( ScrollbarShowNever ) - ,pRenderer ( ) - ,pInputHandler ( ) - ,nRowHeight ( 10 ) - ,nColumnHeaderHeight( 10 ) - ,nRowHeaderWidth ( 10 ) - ,m_nLineColor ( COL_TRANSPARENT ) - ,m_nHeaderColor ( COL_TRANSPARENT ) - ,m_nTextColor ( 0 )//black as default - ,m_nRowColor1 ( COL_TRANSPARENT ) - ,m_nRowColor2 ( COL_TRANSPARENT ) - ,m_eVerticalAlign ( com::sun::star::style::VerticalAlignment_TOP ) + :aColumns ( ) + ,bHasColumnHeaders ( true ) + ,bHasRowHeaders ( false ) + ,eVScrollMode ( ScrollbarShowNever ) + ,eHScrollMode ( ScrollbarShowNever ) + ,pRenderer ( ) + ,pInputHandler ( ) + ,nRowHeight ( 10 ) + ,nColumnHeaderHeight ( 10 ) + ,nRowHeaderWidth ( 10 ) + ,m_aGridLineColor ( ) + ,m_aHeaderBackgroundColor ( ) + ,m_aHeaderTextColor ( ) + ,m_aTextColor ( ) + ,m_aTextLineColor ( ) + ,m_aRowColors ( ) + ,m_eVerticalAlign ( com::sun::star::style::VerticalAlignment_TOP ) { } }; @@ -557,77 +559,124 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::util::Color UnoControlTableModel::getLineColor() + namespace + { + void lcl_setColor( Any const & i_color, ::boost::optional< ::Color > & o_convertedColor ) + { + if ( !i_color.hasValue() ) + o_convertedColor.reset(); + else + { + sal_Int32 nColor = COL_TRANSPARENT; + if ( i_color >>= nColor ) + { + o_convertedColor.reset( ::Color( nColor ) ); + } + else + { + OSL_ENSURE( false, "lcl_setColor: could not extract color value!" ); + } + } + } + } + + //------------------------------------------------------------------------------------------------------------------ + ::boost::optional< ::Color > UnoControlTableModel::getLineColor() const { DBG_CHECK_ME(); - return m_pImpl->m_nLineColor; + return m_pImpl->m_aGridLineColor; } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::setLineColor( ::com::sun::star::util::Color _rColor ) + void UnoControlTableModel::setLineColor( Any const & i_color ) { DBG_CHECK_ME(); - m_pImpl->m_nLineColor = _rColor; + lcl_setColor( i_color, m_pImpl->m_aGridLineColor ); } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::util::Color UnoControlTableModel::getHeaderBackgroundColor() + ::boost::optional< ::Color > UnoControlTableModel::getHeaderBackgroundColor() const { DBG_CHECK_ME(); - return m_pImpl->m_nHeaderColor; + return m_pImpl->m_aHeaderBackgroundColor; } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::setHeaderBackgroundColor( ::com::sun::star::util::Color _rColor ) + void UnoControlTableModel::setHeaderBackgroundColor( Any const & i_color ) { DBG_CHECK_ME(); - m_pImpl->m_nHeaderColor = _rColor; + lcl_setColor( i_color, m_pImpl->m_aHeaderBackgroundColor ); } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::util::Color UnoControlTableModel::getTextColor() + ::boost::optional< ::Color > UnoControlTableModel::getHeaderTextColor() const { DBG_CHECK_ME(); - return m_pImpl->m_nTextColor; + return m_pImpl->m_aHeaderTextColor; } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::setTextColor( ::com::sun::star::util::Color _rColor ) + void UnoControlTableModel::setHeaderTextColor( Any const & i_color ) { DBG_CHECK_ME(); - m_pImpl->m_nTextColor = _rColor; + lcl_setColor( i_color, m_pImpl->m_aHeaderTextColor ); } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::util::Color UnoControlTableModel::getOddRowBackgroundColor() + ::boost::optional< ::Color > UnoControlTableModel::getTextColor() const { DBG_CHECK_ME(); - return m_pImpl->m_nRowColor1; + return m_pImpl->m_aTextColor; } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::setOddRowBackgroundColor( ::com::sun::star::util::Color _rColor ) + void UnoControlTableModel::setTextColor( Any const & i_color ) { DBG_CHECK_ME(); - m_pImpl->m_nRowColor1 = _rColor; + lcl_setColor( i_color, m_pImpl->m_aTextColor ); } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::util::Color UnoControlTableModel::getEvenRowBackgroundColor() + ::boost::optional< ::Color > UnoControlTableModel::getTextLineColor() const { DBG_CHECK_ME(); - return m_pImpl->m_nRowColor2; + return m_pImpl->m_aTextColor; } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::setEvenRowBackgroundColor( ::com::sun::star::util::Color _rColor ) + void UnoControlTableModel::setTextLineColor( Any const & i_color ) { DBG_CHECK_ME(); - m_pImpl->m_nRowColor2 = _rColor; + lcl_setColor( i_color, m_pImpl->m_aTextLineColor ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::boost::optional< ::std::vector< ::Color > > UnoControlTableModel::getRowBackgroundColors() const + { + DBG_CHECK_ME(); + return m_pImpl->m_aRowColors; + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::setRowBackgroundColors( ::com::sun::star::uno::Any const & i_APIValue ) + { + DBG_CHECK_ME(); + Sequence< ::com::sun::star::util::Color > aAPIColors; + if ( !( i_APIValue >>= aAPIColors ) ) + m_pImpl->m_aRowColors.reset(); + else + { + ::std::vector< ::Color > aColors( aAPIColors.getLength() ); + for ( sal_Int32 i=0; im_aRowColors.reset( aColors ); + } } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::style::VerticalAlignment UnoControlTableModel::getVerticalAlign() + ::com::sun::star::style::VerticalAlignment UnoControlTableModel::getVerticalAlign() const { DBG_CHECK_ME(); return m_pImpl->m_eVerticalAlign; diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index a6cd858ed34f..c1abe2c88e3a 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -87,30 +87,33 @@ namespace svt { namespace table public: // ITableModel overridables - virtual TableSize getColumnCount() const; - virtual TableSize getRowCount() const; - virtual bool hasColumnHeaders() const; - virtual bool hasRowHeaders() const; - virtual bool isCellEditable( ColPos col, RowPos row ) const; - virtual PColumnModel getColumnModel( ColPos column ); - virtual PTableRenderer getRenderer() const; - virtual PTableInputHandler getInputHandler() const; - virtual TableMetrics getRowHeight() const; - virtual TableMetrics getColumnHeaderHeight() const; - virtual TableMetrics getRowHeaderWidth() const; - virtual ScrollbarVisibility getVerticalScrollbarVisibility() const; - virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const; - virtual void addTableModelListener( const PTableModelListener& i_listener ); - virtual void removeTableModelListener( const PTableModelListener& i_listener ); - virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ); - virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ); - virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const; - virtual ::com::sun::star::util::Color getLineColor(); - virtual ::com::sun::star::util::Color getHeaderBackgroundColor(); - virtual ::com::sun::star::util::Color getTextColor(); - virtual ::com::sun::star::util::Color getOddRowBackgroundColor(); - virtual ::com::sun::star::util::Color getEvenRowBackgroundColor(); - virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign(); + virtual TableSize getColumnCount() const; + virtual TableSize getRowCount() const; + virtual bool hasColumnHeaders() const; + virtual bool hasRowHeaders() const; + virtual bool isCellEditable( ColPos col, RowPos row ) const; + virtual PColumnModel getColumnModel( ColPos column ); + virtual PTableRenderer getRenderer() const; + virtual PTableInputHandler getInputHandler() const; + virtual TableMetrics getRowHeight() const; + virtual TableMetrics getColumnHeaderHeight() const; + virtual TableMetrics getRowHeaderWidth() const; + virtual ScrollbarVisibility getVerticalScrollbarVisibility() const; + virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const; + virtual void addTableModelListener( const PTableModelListener& i_listener ); + virtual void removeTableModelListener( const PTableModelListener& i_listener ); + virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ); + virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ); + virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const; + virtual ::boost::optional< ::Color > getLineColor() const; + virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const; + virtual ::boost::optional< ::Color > getHeaderTextColor() const; + virtual ::boost::optional< ::Color > getTextColor() const; + virtual ::boost::optional< ::Color > getTextLineColor() const; + virtual ::boost::optional< ::std::vector< ::Color > > + getRowBackgroundColors() const; + virtual ::com::sun::star::style::VerticalAlignment + getVerticalAlign() const; // column write access void appendColumn( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); @@ -121,19 +124,24 @@ namespace svt { namespace table // other operations void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; + void setDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > const & i_gridDataModel ); bool hasDataModel() const; ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > getDataModel() const; void setColumnModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > const & i_gridColumnModel ); bool hasColumnModel() const; + void setRowHeaders(bool _bRowHeaders); void setColumnHeaders(bool _bColumnHeaders); - void setLineColor(::com::sun::star::util::Color _rColor); - void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor); - void setTextColor(::com::sun::star::util::Color _rColor); - void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor); - void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor); + + void setLineColor( ::com::sun::star::uno::Any const & i_color ); + void setHeaderBackgroundColor( ::com::sun::star::uno::Any const & i_color ); + void setHeaderTextColor( ::com::sun::star::uno::Any const & i_color ); + void setTextColor( ::com::sun::star::uno::Any const & i_color ); + void setTextLineColor( ::com::sun::star::uno::Any const & i_color ); + void setRowBackgroundColors( ::com::sun::star::uno::Any const & i_APIValue ); + void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); /// retrieves the index of a column within the model diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index 405b6ac44053..861ed18df847 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -196,14 +196,15 @@ namespace rtl { #define BASEPROPERTY_ENABLEVISIBLE 145 // sal_Bool #define BASEPROPERTY_REFERENCE_DEVICE 146 #define BASEPROPERTY_HIGHCONTRASTMODE 147 -#define BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND 148 -#define BASEPROPERTY_GRID_HEADER_BACKGROUND 149 -#define BASEPROPERTY_GRID_LINE_COLOR 150 -#define BASEPROPERTY_GRID_ROW_BACKGROUND 151 +#define BASEPROPERTY_GRID_HEADER_BACKGROUND 148 +#define BASEPROPERTY_GRID_HEADER_TEXT_COLOR 149 +#define BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS 150 +#define BASEPROPERTY_GRID_LINE_COLOR 151 #define BASEPROPERTY_MULTISELECTION_SIMPLEMODE 152 #define BASEPROPERTY_ITEM_SEPARATOR_POS 153 #define BASEPROPERTY_ROW_HEADER_WIDTH 154 #define BASEPROPERTY_COLUMN_HEADER_HEIGHT 155 +#define BASEPROPERTY_USE_GRID_LINES 156 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 28a203b81c03..33d0bf048bfd 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -87,11 +87,13 @@ UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun:: ImplRegisterProperty( BASEPROPERTY_FONTEMPHASISMARK ); ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR ); ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR ); - ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN ); - ImplRegisterProperty( BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND ); - ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_BACKGROUND ); + ImplRegisterProperty( BASEPROPERTY_TEXTLINECOLOR ); + ImplRegisterProperty( BASEPROPERTY_USE_GRID_LINES ); ImplRegisterProperty( BASEPROPERTY_GRID_LINE_COLOR ); - ImplRegisterProperty( BASEPROPERTY_GRID_ROW_BACKGROUND ); + ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_BACKGROUND ); + ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_TEXT_COLOR ); + ImplRegisterProperty( BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS ); + ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN ); } //---------------------------------------------------------------------------------------------------------------------- @@ -199,6 +201,7 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const case BASEPROPERTY_GRID_SELECTIONMODE: return uno::makeAny( SelectionType(1) ); case BASEPROPERTY_GRID_SHOWROWHEADER: + case BASEPROPERTY_USE_GRID_LINES: return uno::makeAny( (sal_Bool)sal_False ); case BASEPROPERTY_ROW_HEADER_WIDTH: return uno::makeAny( sal_Int32( 10 ) ); @@ -206,15 +209,11 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return uno::makeAny( (sal_Bool)sal_True ); case BASEPROPERTY_COLUMN_HEADER_HEIGHT: case BASEPROPERTY_ROW_HEIGHT: - return Any(); - case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND: - return uno::makeAny( com::sun::star::util::Color( COL_TRANSPARENT ) ); case BASEPROPERTY_GRID_HEADER_BACKGROUND: - return uno::makeAny( com::sun::star::util::Color( COL_TRANSPARENT ) ); + case BASEPROPERTY_GRID_HEADER_TEXT_COLOR: case BASEPROPERTY_GRID_LINE_COLOR: - return uno::makeAny( com::sun::star::util::Color( COL_TRANSPARENT ) ); - case BASEPROPERTY_GRID_ROW_BACKGROUND: - return uno::makeAny(com::sun::star::util::Color( COL_TRANSPARENT ) ); + case BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS: + return Any(); default: return UnoControlModel::ImplGetDefaultValue( nPropId ); } diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index e2849c60cc58..97ba72c41f50 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -285,10 +285,11 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_3 ( "SelectionModel", GRID_SELECTIONMODE, ::com::sun::star::view::SelectionType, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_2 ( "EnableVisible", ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_3 ( "ReferenceDevice", REFERENCE_DEVICE, Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT ), - DECL_PROP_3 ( "EvenRowBackgroundColor", GRID_EVEN_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "HeaderBackgroundColor", GRID_HEADER_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "GridLineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "RowBackgroundColor", GRID_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ) + DECL_PROP_3 ( "HeaderBackgroundColor", GRID_HEADER_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "HeaderTextColor", GRID_HEADER_TEXT_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "GridLineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "RowBackgroundColors", GRID_ROW_BACKGROUND_COLORS, Sequence< sal_Int32 >, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_2 ( "UseGridLines", USE_GRID_LINES, sal_Bool, BOUND, MAYBEDEFAULT ), }; pPropertyInfos = aImplPropertyInfos; nElements = sizeof( aImplPropertyInfos ) / sizeof( ImplPropertyInfo ); -- cgit v1.2.3 From 8578ba4dc736b53c3ca8461516e4024d276b3b05 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 12 Jan 2011 14:00:45 +0100 Subject: gridsort: consolidated and fixed table cell rendering. Instead of tampering with the target areas for cell rendering in various different places, do this in the renderer only, in a single defined way. --- svtools/source/table/gridtablerenderer.cxx | 106 +++++++++++++++-------------- svtools/source/table/tablecontrol_impl.cxx | 53 ++++----------- 2 files changed, 67 insertions(+), 92 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 3163cc54174c..fa84e6be6fdf 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -73,6 +73,26 @@ namespace svt { namespace table { } }; + namespace + { + static Rectangle lcl_getContentArea( GridTableRenderer_Impl const & i_impl, Rectangle const & i_cellArea ) + { + Rectangle aContentArea( i_cellArea ); + if ( i_impl.bUseGridLines ) + { + --aContentArea.Right(); + --aContentArea.Bottom(); + } + return aContentArea; + } + static Rectangle lcl_getTextRenderingArea( Rectangle const & i_contentArea ) + { + Rectangle aTextArea( i_contentArea ); + aTextArea.Left() += 2; aTextArea.Right() -= 2; + ++aTextArea.Top(); --aTextArea.Bottom(); + return aTextArea; + } + } //================================================================================================================== //= GridTableRenderer @@ -129,14 +149,18 @@ namespace svt { namespace table OSL_PRECOND( _bIsColHeaderArea || _bIsRowHeaderArea, "GridTableRenderer::PaintHeaderArea: invalid area flags!" ); - _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR); + _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR ); Color const background = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderBackgroundColor(), _rStyle, &StyleSettings::GetDialogColor ); _rDevice.SetFillColor( background ); - m_pImpl->bUseGridLines ? _rDevice.SetLineColor( _rStyle.GetSeparatorColor() ) : _rDevice.SetLineColor(); + _rDevice.SetLineColor(); _rDevice.DrawRect( _rArea ); + // delimiter lines at bottom/right + ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); + ::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; + _rDevice.SetLineColor( lineColor ); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); @@ -150,8 +174,6 @@ namespace svt { namespace table OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { _rDevice.Push( PUSH_LINECOLOR); - _rDevice.SetLineColor(_rStyle.GetSeparatorColor()); - _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight()); String sHeaderText; PColumnModel pColumn = m_pImpl->rModel.getColumnModel( _nCol ); @@ -173,12 +195,15 @@ namespace svt { namespace table else if ( m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2 ) nHorFlag = TEXT_DRAW_RIGHT; - Rectangle aRect(_rArea); - aRect.Left()+=4; aRect.Right()-=4; - aRect.Bottom()-=2; + Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) ); + _rDevice.DrawText( aTextRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); - _rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); + ::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; + _rDevice.SetLineColor( lineColor ); + _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight()); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); + _rDevice.Pop(); (void)_bActive; @@ -243,7 +268,8 @@ namespace svt { namespace table } } - m_pImpl->bUseGridLines ? _rDevice.SetLineColor( lineColor ) : _rDevice.SetLineColor(); + //m_pImpl->bUseGridLines ? _rDevice.SetLineColor( lineColor ) : _rDevice.SetLineColor(); + _rDevice.SetLineColor(); _rDevice.SetFillColor( backgroundColor ); _rDevice.DrawRect( _rRowArea ); @@ -261,6 +287,7 @@ namespace svt { namespace table ::boost::optional< ::Color > const aLineColor( m_pImpl->rModel.getLineColor() ); ::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; + _rDevice.SetLineColor( lineColor ); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderTextColor(), _rStyle, &StyleSettings::GetFieldTextColor ); @@ -277,10 +304,8 @@ namespace svt { namespace table else if ( m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2 ) nHorFlag = TEXT_DRAW_RIGHT; - Rectangle aRect( _rArea ); - aRect.Left()+=4; aRect.Right()-=4; - aRect.Bottom()-=2; - _rDevice.DrawText( aRect, m_pImpl->rModel.getRowHeader( m_pImpl->nCurrentRow ), nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); + Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) ); + _rDevice.DrawText( aTextRect, m_pImpl->rModel.getRowHeader( m_pImpl->nCurrentRow ), nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); // TODO: active? selected? (void)_bActive; @@ -308,48 +333,31 @@ namespace svt { namespace table } }; - //------------------------------------------------------------------------------------------------------------------ - namespace - { - /** transforms a rectangle denoting a cell area so that afterwards, it denotes the area we - can use for rendering the cell's content. - */ - static void lcl_convertCellToContentArea( Rectangle & io_area ) - { - ++io_area.Left(); --io_area.Right(); - } - - static void lcl_convertContentToTextRenderingArea( Rectangle & io_area ) - { - io_area.Left() += 2; io_area.Right() -= 2; - ++io_area.Top(); --io_area.Bottom(); - } - } - //------------------------------------------------------------------------------------------------------------------ void GridTableRenderer::PaintCell( ColPos const i_column, bool _bSelected, bool _bActive, OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle ) { _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); - ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); - ::Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; + Rectangle const aContentArea( lcl_getContentArea( *m_pImpl, _rArea ) ); + CellRenderContext const aRenderContext( _rDevice, aContentArea, _rStyle, i_column, _bSelected ); + impl_paintCellContent( aRenderContext ); - if ( _bSelected ) + if ( m_pImpl->bUseGridLines ) { - // if no line color is specified by the model, use the usual selection color for lines - if ( !aLineColor ) - lineColor = _rStyle.GetHighlightColor(); - } + ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); + ::Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; - m_pImpl->bUseGridLines ? _rDevice.SetLineColor( lineColor ) : _rDevice.SetLineColor(); - _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); - - Rectangle aRect( _rArea ); - lcl_convertCellToContentArea( aRect ); + if ( _bSelected && !aLineColor ) + { + // if no line color is specified by the model, use the usual selection color for lines in selected cells + lineColor = _rStyle.GetHighlightColor(); + } - const CellRenderContext aRenderContext( _rDevice, aRect, _rStyle, i_column, _bSelected ); - impl_paintCellContent( aRenderContext ); + _rDevice.SetLineColor( lineColor ); + _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); + _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() ); + } _rDevice.Pop(); @@ -452,9 +460,7 @@ namespace svt { namespace table break; } - Rectangle textRect( i_context.aContentArea ); - lcl_convertContentToTextRenderingArea( textRect ); - + Rectangle const textRect( lcl_getTextRenderingArea( i_context.aContentArea ) ); i_context.rDevice.DrawText( textRect, i_text, nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); } @@ -487,9 +493,7 @@ namespace svt { namespace table if ( sText.getLength() == 0 ) return true; - Rectangle aTargetArea( i_targetArea ); - lcl_convertCellToContentArea( aTargetArea ); - lcl_convertContentToTextRenderingArea( aTargetArea ); + Rectangle const aTargetArea( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, i_targetArea ) ) ); long const nTextHeight = i_targetDevice.GetTextHeight(); if ( nTextHeight > aTargetArea.GetHeight() ) diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index feaf79c166fa..d528f46d8fe6 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -1071,9 +1071,6 @@ namespace svt { namespace table TableRowGeometry aHeaderRow( *this, Rectangle( Point( 0, 0 ), aAllCellsWithHeaders.BottomRight() ), ROW_COL_HEADERS ); Rectangle aColRect(aHeaderRow.getRect()); - // to avoid double lines when scrolling horizontally - if ( m_nLeftColumn != 0 ) - --aColRect.Left(); pRenderer->PaintHeaderArea( *m_pDataWindow, aColRect, true, false, rStyle ); @@ -1101,31 +1098,20 @@ namespace svt { namespace table { aRowHeaderArea = aAllCellsWithHeaders; aRowHeaderArea.Right() = m_nRowHeaderWidthPixel - 1; - if(m_nTopRow+nActualRows>m_nRowCount) - aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows -1)+ m_nColHeaderHeightPixel - 1; + if ( m_nTopRow + nActualRows > m_nRowCount ) + aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows - 1 ) + m_nColHeaderHeightPixel - 1; else aRowHeaderArea.Bottom() = m_nRowHeightPixel * nActualRows + m_nColHeaderHeightPixel - 1; - //to avoid double lines when scrolling vertically - if(m_nTopRow != 0) - --aRowHeaderArea.Top(); - --aRowHeaderArea.Right(); - pRenderer->PaintHeaderArea(*m_pDataWindow, aRowHeaderArea, false, true, rStyle); + pRenderer->PaintHeaderArea( *m_pDataWindow, aRowHeaderArea, false, true, rStyle ); // Note that strictly, aRowHeaderArea also contains the intersection between column // and row header area. However, below we go to paint this intersection, again, // so this hopefully doesn't hurt if we already paint it here. if ( m_pModel->hasColumnHeaders() ) { - TableCellGeometry aIntersection( *this, Rectangle( Point( 0, 0 ), + TableCellGeometry const aIntersection( *this, Rectangle( Point( 0, 0 ), aAllCellsWithHeaders.BottomRight() ), COL_ROW_HEADERS, ROW_COL_HEADERS ); - Rectangle aInters(aIntersection.getRect()); - //to avoid double line when scrolling vertically - if( m_nTopRow != 0 ) - { - --aInters.Top(); - --aInters.Bottom(); - } - --aInters.Right(); + Rectangle const aInters( aIntersection.getRect() ); pRenderer->PaintHeaderArea( *m_pDataWindow, aInters, true, true, rStyle ); @@ -1146,28 +1132,12 @@ namespace svt { namespace table { if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() ) continue; - bool isActiveRow = ( aRowIterator.getRow() == getCurrentRow() ); - bool isSelectedRow = false; - if(!m_aSelectedRows.empty()) - { - for(std::vector::iterator itSel=m_aSelectedRows.begin(); - itSel!=m_aSelectedRows.end();++itSel) - { - if(*itSel == aRowIterator.getRow()) - isSelectedRow = true; - } - } - Rectangle aRect = aRowIterator.getRect().GetIntersection( aAllDataCellsArea ); - // to avoid double lines - if ( aRowIterator.getRow() != 0 ) - --aRect.Top(); - if ( m_nLeftColumn != 0 ) - --aRect.Left(); - else - { - if ( m_pModel->hasRowHeaders( )) - --aRect.Left(); - } + + bool const isActiveRow = ( aRowIterator.getRow() == getCurrentRow() ); + bool const isSelectedRow = isRowSelected( aRowIterator.getRow() ); + + Rectangle const aRect = aRowIterator.getRect().GetIntersection( aAllDataCellsArea ); + // give the redenderer a chance to prepare the row pRenderer->PrepareRow( aRowIterator.getRow(), isActiveRow, isSelectedRow, @@ -1181,6 +1151,7 @@ namespace svt { namespace table pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader, rStyle ); } + if ( !colCount ) continue; -- cgit v1.2.3 From c2718415ea6fdc1181e25168a8c394a60699384e Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 12 Jan 2011 14:09:38 +0100 Subject: gridsort: consolidated retrieval of text draw flags - on incarnation of those 10 lines of code is enough, isn't it? --- svtools/source/table/gridtablerenderer.cxx | 79 +++++++++++++----------------- 1 file changed, 33 insertions(+), 46 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index fa84e6be6fdf..35220576e5c0 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -92,6 +92,32 @@ namespace svt { namespace table ++aTextArea.Top(); --aTextArea.Bottom(); return aTextArea; } + + static ULONG lcl_getAlignmentTextDrawFlags( GridTableRenderer_Impl const & i_impl, ColPos const i_columnPos ) + { + ULONG nVertFlag = TEXT_DRAW_TOP; + VerticalAlignment const eVertAlign = i_impl.rModel.getVerticalAlign(); + switch ( eVertAlign ) + { + case VerticalAlignment_MIDDLE: nVertFlag = TEXT_DRAW_VCENTER; break; + case VerticalAlignment_BOTTOM: nVertFlag = TEXT_DRAW_BOTTOM; break; + default: + break; + } + + ULONG nHorzFlag = TEXT_DRAW_LEFT; + HorizontalAlignment const eHorzAlign = i_impl.rModel.getColumnModel( i_columnPos )->getHorizontalAlign(); + switch ( eHorzAlign ) + { + case HorizontalAlignment_CENTER: nHorzFlag = TEXT_DRAW_CENTER; break; + case HorizontalAlignment_RIGHT: nHorzFlag = TEXT_DRAW_RIGHT; break; + default: + break; + } + + return nVertFlag | nHorzFlag; + } + } //================================================================================================================== @@ -184,19 +210,9 @@ namespace svt { namespace table ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getTextColor(), _rStyle, &StyleSettings::GetFieldTextColor ); _rDevice.SetTextColor( textColor ); - ULONG nHorFlag = TEXT_DRAW_LEFT; - ULONG nVerFlag = TEXT_DRAW_TOP; - if ( m_pImpl->rModel.getVerticalAlign() == 1 ) - nVerFlag = TEXT_DRAW_VCENTER; - else if ( m_pImpl->rModel.getVerticalAlign() == 2 ) - nVerFlag = TEXT_DRAW_BOTTOM; - if ( m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 1 ) - nHorFlag = TEXT_DRAW_CENTER; - else if ( m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2 ) - nHorFlag = TEXT_DRAW_RIGHT; - Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) ); - _rDevice.DrawText( aTextRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); + ULONG const nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, _nCol ) | TEXT_DRAW_CLIP; + _rDevice.DrawText( aTextRect, sHeaderText, nDrawTextFlags ); ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); ::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; @@ -293,19 +309,10 @@ namespace svt { namespace table ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderTextColor(), _rStyle, &StyleSettings::GetFieldTextColor ); _rDevice.SetTextColor( textColor ); - ULONG nHorFlag = TEXT_DRAW_LEFT; - ULONG nVerFlag = TEXT_DRAW_TOP; - if ( m_pImpl->rModel.getVerticalAlign() == 1 ) - nVerFlag = TEXT_DRAW_VCENTER; - else if ( m_pImpl->rModel.getVerticalAlign() == 2 ) - nVerFlag = TEXT_DRAW_BOTTOM; - if ( m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 1 ) - nHorFlag = TEXT_DRAW_CENTER; - else if ( m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2 ) - nHorFlag = TEXT_DRAW_RIGHT; - Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) ); - _rDevice.DrawText( aTextRect, m_pImpl->rModel.getRowHeader( m_pImpl->nCurrentRow ), nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); + ULONG const nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, 0 ) | TEXT_DRAW_CLIP; + // TODO: is using the horizontal alignment of the 0'th column a good idea here? This is pretty ... arbitray .. + _rDevice.DrawText( aTextRect, m_pImpl->rModel.getRowHeader( m_pImpl->nCurrentRow ), nDrawTextFlags ); // TODO: active? selected? (void)_bActive; @@ -439,29 +446,9 @@ namespace svt { namespace table i_context.rDevice.SetTextColor( textColor ); } - - ULONG nVerFlag = TEXT_DRAW_TOP; - const VerticalAlignment eVertAlign = m_pImpl->rModel.getVerticalAlign(); - switch ( eVertAlign ) - { - case VerticalAlignment_MIDDLE: nVerFlag = TEXT_DRAW_VCENTER; break; - case VerticalAlignment_BOTTOM: nVerFlag = TEXT_DRAW_BOTTOM; break; - default: - break; - } - - ULONG nHorFlag = TEXT_DRAW_LEFT; - const HorizontalAlignment eHorzAlign = m_pImpl->rModel.getColumnModel( i_context.nColumn )->getHorizontalAlign(); - switch ( eHorzAlign ) - { - case HorizontalAlignment_CENTER: nHorFlag = TEXT_DRAW_CENTER; break; - case HorizontalAlignment_RIGHT: nHorFlag = TEXT_DRAW_RIGHT; break; - default: - break; - } - Rectangle const textRect( lcl_getTextRenderingArea( i_context.aContentArea ) ); - i_context.rDevice.DrawText( textRect, i_text, nHorFlag | nVerFlag | TEXT_DRAW_CLIP ); + ULONG const nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, i_context.nColumn ) | TEXT_DRAW_CLIP; + i_context.rDevice.DrawText( textRect, i_text, nDrawTextFlags ); } //------------------------------------------------------------------------------------------------------------------ -- cgit v1.2.3 From c9eead1b9965c797cca47024d30cb7b8d00c7029 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 12 Jan 2011 14:34:38 +0100 Subject: gridsort: impl_getCellRect: no need to adjust the rect as returned by the TableCellGeometry instance. If there are really situations which rely on this, there'y buggy, and need to be fixed properly. --- svtools/source/table/tablecontrol.cxx | 8 ++++---- svtools/source/table/tablecontrol_impl.cxx | 32 +++++++++++++++++------------- 2 files changed, 22 insertions(+), 18 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 4c94be7f01f4..d58243405800 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -228,17 +228,17 @@ namespace svt { namespace table void TableControl::InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved) { Rectangle _rRect; - if(_bRemoved) + if ( _bRemoved ) m_pImpl->invalidateRows(); else { - if(m_bSelectionChanged) + if ( m_bSelectionChanged ) { - m_pImpl->invalidateSelectedRegion(_nRowStart, _nRowEnd, _rRect); + m_pImpl->invalidateSelectedRegion( _nRowStart, _nRowEnd, _rRect ); m_bSelectionChanged = false; } else - m_pImpl->invalidateRow(_nRowStart, _rRect); + m_pImpl->invalidateRow( _nRowStart, _rRect ); } } diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index d528f46d8fe6..7176ba332a0b 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -1573,12 +1573,10 @@ namespace svt { namespace table { Rectangle aCellRect; impl_getCellRect( m_nCurColumn, m_nCurRow, aCellRect ); - if(!m_pModel->hasRowHeaders() && m_nCurColumn == 0) - aCellRect.Left()++; if ( _bShow ) - pRenderer->ShowCellCursor( *m_pDataWindow, aCellRect); + pRenderer->ShowCellCursor( *m_pDataWindow, aCellRect ); else - pRenderer->HideCellCursor( *m_pDataWindow, aCellRect); + pRenderer->HideCellCursor( *m_pDataWindow, aCellRect ); } } @@ -1601,7 +1599,6 @@ namespace svt { namespace table TableCellGeometry aCell( *this, aAllCells, _nColumn, _nRow ); _rCellRect = aCell.getRect(); - _rCellRect.Top()--;_rCellRect.Left()--; } //------------------------------------------------------------------------------------------------------------------ @@ -1696,7 +1693,7 @@ namespace svt { namespace table { Rectangle aCellRect; impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect ); - _rCellRect.Top() = --aCellRect.Top(); + _rCellRect.Top() = aCellRect.Top(); _rCellRect.Bottom() = aCellRect.Bottom(); } //if the region is above the current row @@ -1704,7 +1701,7 @@ namespace svt { namespace table { Rectangle aCellRect; impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect ); - _rCellRect.Top() = --aCellRect.Top(); + _rCellRect.Top() = aCellRect.Top(); impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect ); _rCellRect.Bottom() = aCellRect.Bottom(); } @@ -1713,7 +1710,7 @@ namespace svt { namespace table { Rectangle aCellRect; impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect ); - _rCellRect.Top() = --aCellRect.Top(); + _rCellRect.Top() = aCellRect.Top(); impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect ); _rCellRect.Bottom() = aCellRect.Bottom(); } @@ -1723,26 +1720,33 @@ namespace svt { namespace table //this method is to be called, when a new row is added void TableControl_Impl::invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect) { - if(m_nCurRow < 0) + if ( m_nCurRow < 0 ) + // hmm? Why this? Looks like a hack to me, working around some other problem. m_nCurRow = 0; - if(m_nCursorHidden == 2) + + if ( m_nCursorHidden == 2 ) + // WTF? what kind of hack is this? --m_nCursorHidden; + impl_getAllVisibleCellsArea( _rCellRect ); - TableRowGeometry _rRow( *this, _rCellRect, _nRowPos); impl_ni_updateScrollbars(); - m_pDataWindow->Invalidate(_rRow.getRect()); + + TableRowGeometry const aRow( *this, _rCellRect, _nRowPos); + m_pDataWindow->Invalidate( aRow.getRect() ); } //------------------------------------------------------------------------------------------------------------------ + std::vector& TableControl_Impl::getSelectedRows() { return m_aSelectedRows; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::clearSelection() { m_aSelectedRows.clear(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::removeSelectedRow(RowPos _nRowPos) { -- cgit v1.2.3 From 4c08b4b3d3b5427ffa843868704e8dd44c8b1826 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 13 Jan 2011 14:08:36 +0100 Subject: gridsort: reworked the notification system for inserted/removed rows In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though we're not there, yet). Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl. And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no preparation whatsoever for column selection, anywhere, thus it was a complete dummy.) Also, its de/selectRows methods have been removed: They have questionable use, and make implementation rather difficult, compared with multiple calls to de/selectRow. --- svtools/inc/svtools/table/tablecontrol.hxx | 15 +- svtools/inc/svtools/table/tablemodel.hxx | 23 +- svtools/source/table/tablecontrol.cxx | 45 +++- svtools/source/table/tablecontrol_impl.cxx | 256 ++++++++++++++++--- svtools/source/table/tablecontrol_impl.hxx | 36 ++- svtools/source/uno/svtxgridcontrol.cxx | 276 +++------------------ svtools/source/uno/svtxgridcontrol.hxx | 11 +- svtools/source/uno/unocontroltablemodel.cxx | 68 ++++- svtools/source/uno/unocontroltablemodel.hxx | 6 + .../source/controls/grid/defaultgriddatamodel.cxx | 49 ++-- toolkit/source/controls/grid/gridcontrol.cxx | 14 +- toolkit/source/controls/grid/gridcontrol.hxx | 5 +- .../source/controls/grid/grideventforwarder.cxx | 4 +- .../source/controls/grid/grideventforwarder.hxx | 2 +- 14 files changed, 445 insertions(+), 365 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 259b390071bb..595ff5bae847 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -87,7 +87,7 @@ namespace svt { namespace table ~TableControl(); /// sets a new table model - SVT_DLLPRIVATE void SetModel( PTableModel _pModel ); + void SetModel( PTableModel _pModel ); /// retrieves the current table model PTableModel GetModel() const; @@ -159,17 +159,13 @@ namespace svt { namespace table SVT_DLLPRIVATE virtual void Resize(); virtual void Select(); - SVT_DLLPRIVATE void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } - const Link& GetSelectHdl() const { return m_aSelectHdl; } + void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } + const Link& GetSelectHdl() const { return m_aSelectHdl; } /**invalidates the table if table has been changed e.g. new row added */ void InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved); - /**gets the vector, which contains the selected rows - */ - std::vector& GetSelectedRows(); - /**after removing a row, updates the vector which contains the selected rows if the row, which should be removed, is selected, it will be erased from the vector */ @@ -221,13 +217,16 @@ namespace svt { namespace table virtual sal_Bool HasColHeader(); virtual sal_Bool isAccessibleAlive( ) const; virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); + virtual ::std::vector< sal_Int32 >& GetSelectedRows(); virtual void RemoveSelectedRow(RowPos _nRowPos); virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; // ............................................................................................................. - void clearSelection(); void selectionChanged(bool _bChanged); + void SelectRow( RowPos const i_rowIndex, bool const i_select ); + void SelectAll( bool const i_select ); + protected: ::svt::IAccessibleFactory& getAccessibleFactory(); diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 50030de7a31d..83054b5d0a57 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -103,7 +103,8 @@ namespace svt { namespace table the table @param first - the old index of the first removed row + the old index of the first removed row. If this is -1, then all + rows have been removed from the model. @param last the old index of the last removed row. Must not be smaller than ->first @@ -119,27 +120,19 @@ namespace svt { namespace table the index of the last newly inserted row. Must not be smaller than ->first */ - virtual void columnsInserted( ColPos first, ColPos last ) = 0; + virtual void columnInserted( ColPos const i_colIndex ) = 0; /** notifies the listener that one or more columns have been removed from the table - @param first - the old index of the first removed column - @param last - the old index of the last removed column. Must not be smaller - than ->first + @param i_colIndex + the old index of the removed column */ - virtual void columnsRemoved( ColPos first, ColPos last ) = 0; - - /** notifies the listener that a column in the table has moved + virtual void columnRemoved( ColPos const i_colIndex ) = 0; - @param oldIndex - the old index of the column within the model - @param newIndex - the new index of the column within the model + /** notifies the listener that all columns have been removed form the model */ - virtual void columnMoved( ColPos oldIndex, ColPos newIndex ) = 0; + virtual void allColumnsRemoved() = 0; /** notifies the listener that a rectangular cell range in the table has been updated diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index d58243405800..757310ba224d 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -219,9 +219,48 @@ namespace svt { namespace table } // ----------------------------------------------------------------------------------------------------------------- - void TableControl::clearSelection() + void TableControl::SelectRow( RowPos const i_rowIndex, bool const i_select ) { - m_pImpl->clearSelection(); + ENSURE_OR_RETURN_VOID( ( i_rowIndex >= 0 ) && ( i_rowIndex < m_pImpl->getModel()->getRowCount() ), + "TableControl::SelectRow: no control (anymore)!" ); + + if ( i_select ) + { + if ( !m_pImpl->markRowAsSelected( i_rowIndex ) ) + // nothing to do + return; + } + else + { + m_pImpl->markRowAsDeselected( i_rowIndex ); + } + + selectionChanged( true ); + InvalidateDataWindow( i_rowIndex, i_rowIndex, false ); + Select(); + } + + // ----------------------------------------------------------------------------------------------------------------- + void TableControl::SelectAll( bool const i_select ) + { + if ( i_select ) + { + if ( !m_pImpl->markAllRowsAsSelected() ) + // nothing to do + return; + } + else + { + if ( !m_pImpl->markAllRowsAsDeselected() ) + // nothing to do + return; + } + + + selectionChanged( true ); + Invalidate(); + // TODO: can't we do better than this, and invalidate only the rows which changed? + Select(); } // ----------------------------------------------------------------------------------------------------------------- @@ -537,7 +576,7 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ sal_Int32 TableControl::GetSelectedRowCount() const { - return m_pImpl->getSelectedRows().size(); + return sal_Int32( m_pImpl->getSelectedRowCount() ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 7176ba332a0b..31078eb23ce7 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -36,6 +36,15 @@ #include "tablegeometry.hxx" #include "cellvalueconversion.hxx" +#include "accessibletableimp.hxx" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +/** === end UNO includes === **/ + #include #include #include @@ -50,6 +59,14 @@ namespace svt { namespace table { //...................................................................................................................... + /** === begin UNO using === **/ + using ::com::sun::star::accessibility::AccessibleTableModelChange; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Any; + /** === end UNO using === **/ + namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId; + namespace AccessibleTableModelChangeType = ::com::sun::star::accessibility::AccessibleTableModelChangeType; + //==================================================================== //= TempHideCursor //==================================================================== @@ -446,25 +463,125 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::rowsInserted( RowPos first, RowPos last ) + void TableControl_Impl::rowsInserted( RowPos i_first, RowPos i_last ) { - OSL_ENSURE( false, "TableControl_Impl::rowsInserted: not implemented!" ); - // there's no known implementation (yet) which calls this method - OSL_UNUSED( first ); - OSL_UNUSED( last ); + DBG_CHECK_ME(); + OSL_PRECOND( i_last >= i_first, "TableControl_Impl::rowsInserted: invalid row indexes!" ); + + TableSize const insertedRows = i_last - i_first + 1; + + // adjust selection, if necessary + bool selectionChanged = false; + for ( ::std::vector< RowPos >::iterator selPos = m_aSelectedRows.begin(); selPos != m_aSelectedRows.end(); ++selPos ) + { + if ( *selPos >= i_first ) + { + *selPos += insertedRows; + selectionChanged = true; + } + } + + // adjust our cached row count + m_nRowCount = m_pModel->getRowCount(); + + // if the rows have been inserted before the current row, adjust this + if ( i_first <= m_nCurRow ) + goTo( m_nCurColumn, m_nCurRow + insertedRows ); + + // notify A1YY events + if ( m_rAntiImpl.isAccessibleAlive() ) + { + m_rAntiImpl.commitGridControlEvent( AccessibleEventId::TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange( AccessibleTableModelChangeType::INSERT, i_first, i_last, 0, m_pModel->getColumnCount() ) ), + Any() + ); + m_rAntiImpl.commitGridControlEvent( AccessibleEventId::CHILD, + makeAny( m_rAntiImpl.m_pAccessTable->m_pAccessible->getTableHeader( TCTYPE_ROWHEADERBAR ) ), + Any() + ); + +// for ( sal_Int32 i = 0 ; i <= m_pModel->getColumnCount(); ++i ) +// { +// m_rAntiImpl.commitGridControlEvent( +// CHILD, +// makeAny( m_rAntiImpl.m_pAccessTable->m_pAccessible->getTable() ), +// Any()); +// } + // Huh? What's that? We're notifying |columnCount| CHILD events here, claiming the *table* itself + // has been inserted. Doesn't make much sense, does it? + } + + // schedule repaint + m_rAntiImpl.InvalidateDataWindow( i_first, i_last, false ); + + // call selection handlers, if necessary + if ( selectionChanged ) + m_rAntiImpl.Select(); } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::rowsRemoved( RowPos first, RowPos last ) + void TableControl_Impl::rowsRemoved( RowPos i_first, RowPos i_last ) { - OSL_ENSURE( false, "TableControl_Impl::rowsRemoved: not implemented!" ); - // there's no known implementation (yet) which calls this method - OSL_UNUSED( first ); - OSL_UNUSED( last ); + sal_Int32 firstRemovedRow = i_first; + sal_Int32 lastRemovedRow = i_last; + + // adjust selection, if necessary + bool selectionChanged = false; + if ( i_first == -1 ) + { + selectionChanged = markAllRowsAsDeselected(); + + firstRemovedRow = 0; + lastRemovedRow = m_nRowCount - 1; + } + else + { + ENSURE_OR_RETURN_VOID( i_last >= i_first, "TableControl_Impl::rowsRemoved: illegal indexes!" ); + + for ( sal_Int32 row = i_first; row < i_last; ++row ) + { + selectionChanged |= markRowAsDeselected( row ); + } + } + + // adjust cached row count + m_nRowCount = m_pModel->getRowCount(); + + // adjust the current row, if it is larger than the row count now + if ( m_nCurRow >= m_nRowCount ) + { + if ( m_nRowCount > 0 ) + goTo( m_nCurColumn, m_nRowCount - 1 ); + else + m_nCurRow = ROW_INVALID; + } + + // notify A11Y events + if ( m_rAntiImpl.isAccessibleAlive() ) + { + m_rAntiImpl.commitGridControlEvent( + AccessibleEventId::TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange( + AccessibleTableModelChangeType::DELETE, + firstRemovedRow, + lastRemovedRow, + 0, + m_pModel->getColumnCount() + ) ), + Any() + ); + } + + // schedule a repaint + m_rAntiImpl.InvalidateDataWindow( firstRemovedRow, lastRemovedRow, true ); + + // call selection handlers, if necessary + if ( selectionChanged ) + m_rAntiImpl.Select(); } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::columnsInserted( ColPos i_first, ColPos i_last ) + void TableControl_Impl::columnInserted( ColPos const i_colIndex ) { m_nColumnCount = m_pModel->getColumnCount(); impl_ni_updateColumnWidths(); @@ -472,12 +589,11 @@ namespace svt { namespace table m_rAntiImpl.Invalidate(); - OSL_UNUSED( i_first ); - OSL_UNUSED( i_last ); + OSL_UNUSED( i_colIndex ); } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::columnsRemoved( ColPos i_first, ColPos i_last ) + void TableControl_Impl::columnRemoved( ColPos const i_colIndex ) { m_nColumnCount = m_pModel->getColumnCount(); impl_ni_updateColumnWidths(); @@ -485,17 +601,17 @@ namespace svt { namespace table m_rAntiImpl.Invalidate(); - OSL_UNUSED( i_first ); - OSL_UNUSED( i_last ); + OSL_UNUSED( i_colIndex ); } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::columnMoved( ColPos oldIndex, ColPos newIndex ) + void TableControl_Impl::allColumnsRemoved() { - OSL_ENSURE( false, "TableControl_Impl::columnMoved: not implemented!" ); - // there's no known implementation (yet) which calls this method - OSL_UNUSED( oldIndex ); - OSL_UNUSED( newIndex ); + m_nColumnCount = m_pModel->getColumnCount(); + impl_ni_updateColumnWidths(); + impl_ni_updateScrollbars(); + + m_rAntiImpl.Invalidate(); } //------------------------------------------------------------------------------------------------------------------ @@ -1741,12 +1857,6 @@ namespace svt { namespace table return m_aSelectedRows; } - //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::clearSelection() - { - m_aSelectedRows.clear(); - } - //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::removeSelectedRow(RowPos _nRowPos) { @@ -1841,10 +1951,13 @@ namespace svt { namespace table // TODO: give veto listeners a chance - if ( ( _nColumn < -1 ) || ( _nColumn >= m_nColumnCount ) - || ( _nRow < -1 ) || ( _nRow >= m_nRowCount ) + if ( ( _nColumn < 0 ) || ( _nColumn >= m_nColumnCount ) + || ( _nRow < 0 ) || ( _nRow >= m_nRowCount ) ) + { + OSL_ENSURE( false, "TableControl_Impl::goTo: invalid row or column index!" ); return false; + } TempHideCursor aHideCursor( *this ); m_nCurColumn = _nColumn; @@ -2086,6 +2199,88 @@ namespace svt { namespace table return lowerBound - m_aColumnWidths.begin(); } + //-------------------------------------------------------------------- + bool TableControl_Impl::markRowAsDeselected( RowPos const i_rowIndex ) + { + DBG_CHECK_ME(); + + ::std::vector< RowPos >::iterator selPos = ::std::find( m_aSelectedRows.begin(), m_aSelectedRows.end(), i_rowIndex ); + if ( selPos == m_aSelectedRows.end() ) + return false; + + m_aSelectedRows.erase( selPos ); + return true; + } + + //-------------------------------------------------------------------- + bool TableControl_Impl::markRowAsSelected( RowPos const i_rowIndex ) + { + DBG_CHECK_ME(); + + if ( isRowSelected( i_rowIndex ) ) + return false; + + SelectionMode const eSelMode = getSelEngine()->GetSelectionMode(); + switch ( eSelMode ) + { + case SINGLE_SELECTION: + if ( !m_aSelectedRows.empty() ) + { + OSL_ENSURE( m_aSelectedRows.size() == 1, "TableControl::markRowAsSelected: SingleSelection with more than one selected element?" ); + m_aSelectedRows[0] = i_rowIndex; + break; + } + // fall through + + case MULTIPLE_SELECTION: + m_aSelectedRows.push_back( i_rowIndex ); + break; + + default: + OSL_ENSURE( false, "TableControl_Impl::markRowAsSelected: unsupported selection mode!" ); + return false; + } + + return true; + } + + //-------------------------------------------------------------------- + bool TableControl_Impl::markAllRowsAsDeselected() + { + if ( m_aSelectedRows.empty() ) + return false; + + m_aSelectedRows.clear(); + return true; + } + + //-------------------------------------------------------------------- + bool TableControl_Impl::markAllRowsAsSelected() + { + DBG_CHECK_ME(); + + SelectionMode const eSelMode = getSelEngine()->GetSelectionMode(); + ENSURE_OR_RETURN_FALSE( eSelMode == MULTIPLE_SELECTION, "TableControl_Impl::markAllRowsAsSelected: unsupported selection mode!" ); + + if ( m_aSelectedRows.size() == size_t( m_pModel->getRowCount() ) ) + { + #if OSL_DEBUG_LEVEL > 0 + for ( TableSize row = 0; row < m_pModel->getRowCount(); ++row ) + { + OSL_ENSURE( isRowSelected( row ), "TableControl_Impl::markAllRowsAsSelected: inconsistency in the selected rows!" ); + } + #endif + // already all rows marked as selected + return false; + } + + m_aSelectedRows.clear(); + for ( RowPos i=0; i < m_pModel->getRowCount(); ++i ) + m_aSelectedRows.push_back(i); + + return true; + } + //-------------------------------------------------------------------- void TableControl_Impl::resizeColumn( const Point& rPoint ) { @@ -2261,7 +2456,7 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ TableFunctionSet::TableFunctionSet(TableControl_Impl* _pTableControl) :m_pTableControl( _pTableControl) - ,m_nCurrentRow (-2) + ,m_nCurrentRow (-2) { } //------------------------------------------------------------------------------------------------------------------ @@ -2399,6 +2594,7 @@ namespace svt { namespace table } m_pTableControl->m_aSelectedRows.erase(m_pTableControl->m_aSelectedRows.begin()+pos); } + //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::DeselectAll() { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 1987dd96e6f5..c4b72889b07a 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -236,7 +236,35 @@ namespace svt { namespace table /** updates the vector, which contains the selected rows after removing the row nRowPos*/ void removeSelectedRow(RowPos _nRowPos); void invalidateRows(); - void clearSelection(); + + bool hasRowSelection() const { return !m_aSelectedRows.empty(); } + size_t getSelectedRowCount() const { return m_aSelectedRows.size(); } + + /** removes the given row index from m_aSelectedRows + + @return + if and only if the row was previously marked as selected + */ + bool markRowAsDeselected( RowPos const i_rowIndex ); + + /** marks the given row as selectged, by putting it into m_aSelectedRows + @return + if and only if the row was previously not marked as selected + */ + bool markRowAsSelected( RowPos const i_rowIndex ); + + /** marks all rows as deselected + @return + if and only if the selection actually changed by this operation + */ + bool markAllRowsAsDeselected(); + + /** marks all rows as selected + @return + if and only if all rows were selected already. + */ + bool markAllRowsAsSelected(); + // ITableControl virtual void hideCursor(); @@ -265,9 +293,9 @@ namespace svt { namespace table // ITableModelListener virtual void rowsInserted( RowPos first, RowPos last ); virtual void rowsRemoved( RowPos first, RowPos last ); - virtual void columnsInserted( ColPos first, ColPos last ); - virtual void columnsRemoved( ColPos first, ColPos last ); - virtual void columnMoved( ColPos oldIndex, ColPos newIndex ); + virtual void columnInserted( ColPos const i_colIndex ); + virtual void columnRemoved( ColPos const i_colIndex ); + virtual void allColumnsRemoved(); virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ); virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ); diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index ea0a41688355..b5d2a48026ea 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -64,12 +64,10 @@ using ::com::sun::star::accessibility::AccessibleTableModelChange; SVTXGridControl::SVTXGridControl() :m_pTableModel( new UnoControlTableModel() ) - ,m_xColumnModel( 0 ) ,m_bHasColumnHeaders( false ) ,m_bHasRowHeaders( false ) ,m_bTableModelInitCompleted( false ) ,m_nSelectedRowCount( 0 ) - ,m_nKnowRowCount( 0 ) ,m_aSelectionListeners( *this ) { } @@ -324,36 +322,29 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An { Reference< XGridDataModel > const xDataModel( aValue, UNO_QUERY ); if ( !xDataModel.is() ) - throw GridInvalidDataException( ::rtl::OUString::createFromAscii("The data model isn't set!"), *this ); + throw GridInvalidDataException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid data model." ) ), *this ); m_pTableModel->setDataModel( xDataModel ); impl_checkTableModelInit(); - - // ensure default columns exist, if they have not previously been added - sal_Int32 const nDataColumnCount = xDataModel->getColumnCount(); - if ( ( nDataColumnCount > 0 ) && ( m_xColumnModel->getColumnCount() == 0 ) ) - m_xColumnModel->setDefaultColumns( nDataColumnCount ); - // this will trigger notifications, which in turn will let us update our m_pTableModel } break; case BASEPROPERTY_GRID_COLUMNMODEL: { + // obtain new col model + Reference< XGridColumnModel > const xColumnModel( aValue, UNO_QUERY ); + if ( !xColumnModel.is() ) + throw GridInvalidModelException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid column model." ) ), *this ); + // remove all old columns m_pTableModel->removeAllColumns(); - // obtain new col model - m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY_THROW ); - // announce to the TableModel - m_pTableModel->setColumnModel( m_xColumnModel ); - - // announce the table model to the table control, if we have everything which is needed + m_pTableModel->setColumnModel( xColumnModel ); impl_checkTableModelInit(); // add new columns impl_updateColumnsFromModel_nothrow(); - break; } default: @@ -371,8 +362,17 @@ void SVTXGridControl::impl_checkTableModelInit() if ( pTable ) { pTable->SetModel( PTableModel( m_pTableModel ) ); - m_nKnowRowCount = m_pTableModel->getRowCount(); + m_bTableModelInitCompleted = true; + + // ensure default columns exist, if they have not previously been added + Reference< XGridDataModel > const xDataModel( m_pTableModel->getDataModel(), UNO_QUERY_THROW ); + Reference< XGridColumnModel > const xColumnModel( m_pTableModel->getColumnModel(), UNO_QUERY_THROW ); + + sal_Int32 const nDataColumnCount = xDataModel->getColumnCount(); + if ( ( nDataColumnCount > 0 ) && ( xColumnModel->getColumnCount() == 0 ) ) + xColumnModel->setDefaultColumns( nDataColumnCount ); + // this will trigger notifications, which in turn will let us update our m_pTableModel } } } @@ -429,7 +429,7 @@ Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru break; case BASEPROPERTY_GRID_COLUMNMODEL: - aPropertyValue <<= m_xColumnModel; + aPropertyValue <<= m_pTableModel->getColumnModel(); break; case BASEPROPERTY_HSCROLL: @@ -518,113 +518,17 @@ void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL SVTXGridControl::rowsAdded( const GridDataEvent& i_event ) throw (RuntimeException) +void SAL_CALL SVTXGridControl::rowsInserted( const GridDataEvent& i_event ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - - sal_Int32 const affectedRows = i_event.Rows.getLength(); - ENSURE_OR_RETURN_VOID( affectedRows > 0, "SVTXGridControl::rowsAdded: invalid row count!" ); - - Reference< XGridDataModel > const xDataModel( m_pTableModel->getDataModel(), UNO_QUERY_THROW ); - sal_Int32 const affectedColumns = i_event.Columns.getLength() ? i_event.Columns.getLength() : xDataModel->getColumnCount(); - ENSURE_OR_RETURN_VOID( affectedColumns > 0, "SVTXGridControl::rowsAdded: no columns at all?" ); - TableSize const columnCount = m_xColumnModel->getColumnCount(); - if ( columnCount == 0 ) - { - m_xColumnModel->setDefaultColumns( affectedColumns ); - // this will trigger notifications, which in turn will let us update our m_pTableModel - } - - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowsAdded: no control (anymore)!" ); - - pTable->InvalidateDataWindow( m_pTableModel->getRowCount() - 1, 0, false ); - if ( pTable->isAccessibleAlive() ) - { - pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange(INSERT, m_pTableModel->getRowCount()-1, m_pTableModel->getRowCount(), 0, m_pTableModel->getColumnCount())), - Any()); - pTable->commitGridControlEvent(CHILD, - makeAny( pTable->m_pAccessTable->m_pAccessible->getTableHeader(TCTYPE_ROWHEADERBAR)), - Any()); - for (sal_Int32 i = 0 ; i <= m_pTableModel->getColumnCount() ; ++i) - { - pTable->commitGridControlEvent( - CHILD, - makeAny( pTable->m_pAccessTable->m_pAccessible->getTable() ), - Any()); - } - } + m_pTableModel->notifyRowsInserted( i_event ); } //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::rowsRemoved( const GridDataEvent& i_event ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowsRemoved: no control (anymore)!" ); - - if ( i_event.Rows.getLength() == 0 ) - { - if ( !isSelectionEmpty() ) - deselectAllRows(); - - pTable->clearSelection(); - - if ( pTable->isAccessibleAlive() ) - { - pTable->commitGridControlEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( DELETE, 0, m_pTableModel->getColumnCount(), 0, m_pTableModel->getColumnCount() ) ), - Any() - ); - } - } - else - { - #if OSL_DEBUG_LEVEL > 0 - for ( sal_Int32 row = 0; row < i_event.Rows.getLength() - 1; ++row ) - { - OSL_ENSURE( i_event.Rows[row] < i_event.Rows[row], "SVTXGridControl::rowsRemoved: row indexes not sorted!" ); - } - #endif - sal_Int32 removedRowCount = 0; - for ( sal_Int32 row = 0; row < i_event.Rows.getLength(); ++row ) - { - sal_Int32 const rowIndex = i_event.Rows[row]; - ENSURE_OR_CONTINUE( ( rowIndex >= 0 ) && ( rowIndex < m_nKnowRowCount ), - "SVTXGridControl::rowsRemoved: illegal row index!" ); - - if ( isSelectedIndex( rowIndex ) ) - { - Sequence< sal_Int32 > selected(1); - selected[0] = rowIndex; - deselectRows( selected ); - } - - if ( pTable->isAccessibleAlive() ) - { - pTable->commitGridControlEvent(TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( - DELETE, rowIndex - removedRowCount, rowIndex - removedRowCount + 1, 0, m_pTableModel->getColumnCount() - // the adjustment via removedRowCount is necessary here, since with every removed row, the - // *actual* index of all subsequent rows changes, but i_event.Rows still contains the original row indexes - ) ), - Any() - ); - } - ++removedRowCount; - } - - // TODO: I don't think that the selected rows of the TableControl properly survive this - they might contain - // too large indexes now. - // Really, the ITableModel should broadcast the "rowsRemoved" event to its listeners, and the TableControl/_Impl - // should do all necessary adjustments, including for its selection, itself. - } - - m_nKnowRowCount = m_pTableModel->getRowCount(); - pTable->InvalidateDataWindow( 0, m_nKnowRowCount, true ); + m_pTableModel->notifyRowsRemoved( i_event ); } //---------------------------------------------------------------------------------------------------------------------- @@ -637,10 +541,10 @@ void SAL_CALL SVTXGridControl::dataChanged( const GridDataEvent& i_event ) throw // TODO: Our UnoControlTableModel should be a listener at the data model, and multiplex those events, // so the TableControl/_Impl can react on it. - if ( i_event.Rows.getLength() == 0 ) + if ( i_event.FirstRow == -1 ) pTable->InvalidateDataWindow( 0, m_pTableModel->getRowCount(), false ); else - pTable->InvalidateDataWindow( i_event.Rows[0], i_event.Rows[ i_event.Rows.getLength() - 1 ], false ); + pTable->InvalidateDataWindow( i_event.FirstRow, i_event.LastRow, false ); } //---------------------------------------------------------------------------------------------------------------------- @@ -730,46 +634,14 @@ void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObj } } -void SAL_CALL SVTXGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL SVTXGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::selectRows: no control (anymore)!" ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::selectRow: no control (anymore)!" ); - SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); - if(eSelMode != NO_SELECTION) - { - sal_Int32 start = rangeOfRows[0]; - int seqSize = rangeOfRows.getLength(); - sal_Int32 end = rangeOfRows[seqSize-1]; - if((start >= 0 && start < m_pTableModel->getRowCount()) && (end >= 0 && end < m_pTableModel->getRowCount())) - { - std::vector& selectedRows = pTable->GetSelectedRows(); - if(eSelMode == SINGLE_SELECTION) - { - if(!selectedRows.empty()) - selectedRows.clear(); - if(rangeOfRows.getLength() == 1) - selectedRows.push_back(start); - else - return; - } - else - { - for(int i=0;iselectionChanged(true); - pTable->InvalidateDataWindow(start, end, false); - SetSynthesizingVCLEvent( sal_True ); - pTable->Select(); - SetSynthesizingVCLEvent( sal_False ); - } - } + pTable->SelectRow( i_rowIndex, true ); } void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) @@ -779,41 +651,17 @@ void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::Run TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::selectAllRows: no control (anymore)!" ); - SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); - if(eSelMode != NO_SELECTION) - { - std::vector& selectedRows = pTable->GetSelectedRows(); - if(!selectedRows.empty()) - selectedRows.clear(); - for(int i=0;igetRowCount();i++) - selectedRows.push_back(i); - pTable->Invalidate(); - SetSynthesizingVCLEvent( sal_True ); - pTable->Select(); - SetSynthesizingVCLEvent( sal_False ); - } + pTable->SelectAll( true ); } -void SAL_CALL SVTXGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL SVTXGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::deselectRows: no control (anymore)!" ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::deselectRow: no control (anymore)!" ); - std::vector& selectedRows = pTable->GetSelectedRows(); - std::vector::iterator itStart = selectedRows.begin(); - std::vector::iterator itEnd = selectedRows.end(); - for(int i = 0; i < rangeOfRows.getLength(); i++ ) - { - std::vector::iterator iter = std::find(itStart, itEnd, rangeOfRows[i]); - selectedRows.erase(iter); - } - pTable->selectionChanged(true); - pTable->Invalidate(); - SetSynthesizingVCLEvent( sal_True ); - pTable->Select(); - SetSynthesizingVCLEvent( sal_False ); + pTable->SelectRow( i_rowIndex, false ); } void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) @@ -823,13 +671,7 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::deselectAllRows: no control (anymore)!" ); - std::vector& selectedRows = pTable->GetSelectedRows(); - if(!selectedRows.empty()) - selectedRows.clear(); - pTable->Invalidate(); - SetSynthesizingVCLEvent( sal_True ); - pTable->Select(); - SetSynthesizingVCLEvent( sal_False ); + pTable->SelectAll( false ); } ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL SVTXGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) @@ -844,11 +686,6 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R return selectedRowsToSequence; } -::sal_Bool SAL_CALL SVTXGridControl::isCellEditable() throw (::com::sun::star::uno::RuntimeException) -{ - return sal_False; -} - ::sal_Bool SAL_CALL SVTXGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -870,53 +707,9 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable, "SVTXGridControl::isSelectedIndex: no control (anymore)!", sal_False ); - std::vector& selectedRows = pTable->GetSelectedRows(); - return std::find(selectedRows.begin(),selectedRows.end(), index) != selectedRows.end(); + return pTable->IsRowSelected( index ); } -void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::isSelectedIndex: no control (anymore)!" ); - - if(index<0 || index>=m_pTableModel->getRowCount()) - return; - SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); - if(eSelMode != NO_SELECTION) - { - std::vector& selectedRows = pTable->GetSelectedRows(); - if(eSelMode == MULTIPLE_SELECTION) - { - if(!isSelectedIndex(index)) - selectedRows.push_back(index); - else - return; - } - else if(eSelMode == SINGLE_SELECTION) - { - if(!selectedRows.empty()) - { - if(!isSelectedIndex(index)) - deselectRows(getSelection()); - else - return; - } - selectedRows.push_back(index); - } - pTable->selectionChanged(true); - pTable->InvalidateDataWindow(index, index, false); - SetSynthesizingVCLEvent( sal_True ); - pTable->Select(); - SetSynthesizingVCLEvent( sal_False ); - } -} - -void SAL_CALL SVTXGridControl::selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException) -{ - (void)x; -} void SVTXGridControl::dispose() throw(::com::sun::star::uno::RuntimeException) { ::com::sun::star::lang::EventObject aObj; @@ -997,13 +790,14 @@ void SVTXGridControl::ImplCallItemListeners() void SVTXGridControl::impl_updateColumnsFromModel_nothrow() { - ENSURE_OR_RETURN_VOID( m_xColumnModel.is(), "no model!" ); + Reference< XGridColumnModel > const xColumnModel( m_pTableModel->getColumnModel() ); + ENSURE_OR_RETURN_VOID( xColumnModel.is(), "no model!" ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable != NULL, "no table!" ); try { - const Sequence< Reference< XGridColumn > > columns = m_xColumnModel->getColumns(); + const Sequence< Reference< XGridColumn > > columns = xColumnModel->getColumns(); for ( const Reference< XGridColumn >* colRef = columns.getConstArray(); colRef != columns.getConstArray() + columns.getLength(); ++colRef diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index 8ebeb09374ec..fa554664b2c0 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -56,12 +56,10 @@ class SVTXGridControl : public SVTXGridControl_Base { private: ::boost::shared_ptr< UnoControlTableModel > m_pTableModel; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > m_xColumnModel; bool m_bHasColumnHeaders; bool m_bHasRowHeaders; bool m_bTableModelInitCompleted; sal_Int32 m_nSelectedRowCount; - sal_Int32 m_nKnowRowCount; SelectionListenerMultiplexer m_aSelectionListeners; protected: @@ -73,7 +71,7 @@ public: ~SVTXGridControl(); // XGridDataListener - virtual void SAL_CALL rowsAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL rowTitleChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); @@ -89,16 +87,13 @@ public: // XGridSelection virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) 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 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 isCellEditable() 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 void SAL_CALL selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL selectColumn(::sal_Int32 x) 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); diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 66f7f518dab4..653c2e46a427 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -70,6 +70,7 @@ namespace svt { namespace table using ::com::sun::star::style::HorizontalAlignment_LEFT; using ::com::sun::star::style::HorizontalAlignment; using ::com::sun::star::uno::WeakReference; + using ::com::sun::star::awt::grid::GridDataEvent; /** === end UNO using === **/ //================================================================================================================== @@ -263,7 +264,7 @@ namespace svt { namespace table ++loop ) { - (*loop)->columnsInserted( i_position, i_position ); + (*loop)->columnInserted( i_position ); } } @@ -286,7 +287,7 @@ namespace svt { namespace table ++loop ) { - (*loop)->columnsRemoved( i_position, i_position ); + (*loop)->columnRemoved( i_position ); } // dispose the column @@ -324,7 +325,7 @@ namespace svt { namespace table ++loop ) { - (*loop)->columnsRemoved( 0, nLastIndex ); + (*loop)->allColumnsRemoved(); } } @@ -487,10 +488,16 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - bool UnoControlTableModel::hasColumnModel() const + Reference< XGridColumnModel > UnoControlTableModel::getColumnModel() const { Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel ); - return xColumnModel.is(); + return xColumnModel; + } + + //------------------------------------------------------------------------------------------------------------------ + bool UnoControlTableModel::hasColumnModel() const + { + return getColumnModel().is(); } //------------------------------------------------------------------------------------------------------------------ @@ -722,6 +729,57 @@ namespace svt { namespace table } } + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::notifyRowsInserted( GridDataEvent const & i_event ) + { + // check sanity of the event + ENSURE_OR_RETURN_VOID( i_event.FirstRow >= 0, "UnoControlTableModel::notifyRowsInserted: invalid first row!" ); + ENSURE_OR_RETURN_VOID( i_event.LastRow >= i_event.FirstRow, "UnoControlTableModel::notifyRowsInserted: invalid row indexes!" ); + + // check own sanity + Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel ); + ENSURE_OR_RETURN_VOID( xColumnModel.is(), "UnoControlTableModel::notifyRowsInserted: no column model anymore!" ); + + Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); + ENSURE_OR_RETURN_VOID( xDataModel.is(), "UnoControlTableModel::notifyRowsInserted: no data model anymore!" ); + + // implicitly add columns to the column model + // TODO: is this really a good idea? + sal_Int32 const dataColumnCount = xDataModel->getColumnCount(); + OSL_ENSURE( dataColumnCount > 0, "UnoControlTableModel::notifyRowsInserted: no columns at all?" ); + + sal_Int32 const modelColumnCount = xColumnModel->getColumnCount(); + if ( ( modelColumnCount == 0 ) && ( dataColumnCount > 0 ) ) + { + // TODO: shouldn't we clear the mutexes guard for this call? + xColumnModel->setDefaultColumns( dataColumnCount ); + } + + // multiplex the event to our own listeners + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->rowsInserted( i_event.FirstRow, i_event.LastRow ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::notifyRowsRemoved( GridDataEvent const & i_event ) + { + // multiplex the event to our own listeners + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->rowsRemoved( i_event.FirstRow, i_event.LastRow ); + } + } + // ..................................................................................................................... } } // svt::table // ..................................................................................................................... diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index c1abe2c88e3a..c38d9ed694e2 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -131,6 +131,8 @@ namespace svt { namespace table getDataModel() const; void setColumnModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > const & i_gridColumnModel ); bool hasColumnModel() const; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > + getColumnModel() const; void setRowHeaders(bool _bRowHeaders); void setColumnHeaders(bool _bColumnHeaders); @@ -144,6 +146,10 @@ namespace svt { namespace table void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); + // multiplexing of XGridDataListener events + void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent const & i_event ); + void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent const & i_event ); + /// retrieves the index of a column within the model ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const; diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 746be68d3b4e..3d9b8324de81 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -88,28 +88,6 @@ namespace toolkit { } - //------------------------------------------------------------------------------------------------------------------ - namespace - { - Sequence< sal_Int32 > lcl_buildSingleElementSequence( sal_Int32 const i_index ) - { - Sequence< sal_Int32 > aIndexes(1); - aIndexes[0] = i_index; - return aIndexes; - } - Sequence< sal_Int32 > lcl_buildIndexSequence( sal_Int32 const i_start, sal_Int32 const i_end ) - { - Sequence< sal_Int32 > aIndexes; - ENSURE_OR_RETURN( i_end >= i_start, "lcl_buildIndexSequence: illegal indexes!", aIndexes ); - - aIndexes.realloc( i_end - i_start + 1 ); - for ( sal_Int32 i = i_start; i <= i_end; ++i ) - aIndexes[ i - i_start ] = i; - - return aIndexes; - } - } - //------------------------------------------------------------------------------------------------------------------ void DefaultGridDataModel::broadcast( GridDataEvent const & i_event, void ( SAL_CALL XGridDataListener::*i_listenerMethod )( GridDataEvent const & ), ::osl::ClearableMutexGuard & i_instanceLock ) @@ -183,9 +161,10 @@ namespace toolkit if ( columnCount > m_nColumnCount ) m_nColumnCount = columnCount; + sal_Int32 const rowIndex = sal_Int32( m_aData.size() - 1 ); broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildSingleElementSequence( m_aData.size() - 1 ) ), - &XGridDataListener::rowsAdded, + GridDataEvent( *this, -1, -1, rowIndex, rowIndex ), + &XGridDataListener::rowsInserted, aGuard ); } @@ -224,9 +203,11 @@ namespace toolkit if ( maxColCount > m_nColumnCount ) m_nColumnCount = maxColCount; + sal_Int32 const firstRow = sal_Int32( m_aData.size() - rowCount ); + sal_Int32 const lastRow = sal_Int32( m_aData.size() - 1 ); broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildIndexSequence( m_aData.size() - rowCount, m_aData.size() - 1 ) ), - &XGridDataListener::rowsAdded, + GridDataEvent( *this, -1, -1, firstRow, lastRow ), + &XGridDataListener::rowsInserted, aGuard ); } @@ -243,7 +224,7 @@ namespace toolkit m_aData.erase( m_aData.begin() + i_rowIndex ); broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildSingleElementSequence( i_rowIndex ) ), + GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ), &XGridDataListener::rowsRemoved, aGuard ); @@ -258,7 +239,7 @@ namespace toolkit m_aData.clear(); broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), Sequence< sal_Int32 >() ), + GridDataEvent( *this, -1, -1, -1, -1 ), &XGridDataListener::rowsRemoved, aGuard ); @@ -280,7 +261,7 @@ namespace toolkit rRowData[ i_columnIndex ] = i_value; broadcast( - GridDataEvent( *this, lcl_buildSingleElementSequence( i_columnIndex ), lcl_buildSingleElementSequence( i_rowIndex ) ), + GridDataEvent( *this, i_columnIndex, i_columnIndex, i_rowIndex, i_rowIndex ), &XGridDataListener::dataChanged, aGuard ); @@ -317,12 +298,10 @@ namespace toolkit rDataRow[ columnIndex ] = i_values[ col ]; } - // by definition, the indexes in the notified sequences shall be sorted - Sequence< sal_Int32 > columnIndexes( i_columnIndexes ); - ::std::sort( stl_begin( columnIndexes ), stl_end( columnIndexes ) ); - + sal_Int32 const firstAffectedColumn = *::std::min_element( stl_begin( i_columnIndexes ), stl_end( i_columnIndexes ) ); + sal_Int32 const lastAffectedColumn = *::std::max_element( stl_begin( i_columnIndexes ), stl_end( i_columnIndexes ) ); broadcast( - GridDataEvent( *this, columnIndexes, lcl_buildSingleElementSequence( i_rowIndex ) ), + GridDataEvent( *this, firstAffectedColumn, lastAffectedColumn, i_rowIndex, i_rowIndex ), &XGridDataListener::dataChanged, aGuard ); @@ -339,7 +318,7 @@ namespace toolkit m_aRowHeaders[ i_rowIndex ] = i_title; broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildSingleElementSequence( i_rowIndex ) ), + GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ), &XGridDataListener::rowTitleChanged, aGuard ); diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 33d0bf048bfd..b9cab5a18cf0 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -372,9 +372,9 @@ sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_ } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UnoGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL UnoGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRows( rangeOfRows); + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRow( i_rowIndex ); } //---------------------------------------------------------------------------------------------------------------------- @@ -384,9 +384,9 @@ void SAL_CALL UnoGridControl::selectAllRows() throw (::com::sun::star::uno::Runt } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UnoGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL UnoGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRows( rangeOfRows); + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRow( i_rowIndex ); } //---------------------------------------------------------------------------------------------------------------------- @@ -413,12 +413,6 @@ void SAL_CALL UnoGridControl::deselectAllRows() throw (::com::sun::star::uno::Ru return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectedIndex( index ); } -//---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UnoGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRow( y ); -} - //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index cf832cb80705..5259711e97d6 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -105,14 +105,13 @@ public: // ::com::sun::star::awt::grid::XGridSelection virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) 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 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 void SAL_CALL selectRow(::sal_Int32 y) 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); diff --git a/toolkit/source/controls/grid/grideventforwarder.cxx b/toolkit/source/controls/grid/grideventforwarder.cxx index b3d17a897bad..68293025bd4e 100755 --- a/toolkit/source/controls/grid/grideventforwarder.cxx +++ b/toolkit/source/controls/grid/grideventforwarder.cxx @@ -81,11 +81,11 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridEventForwarder::rowsAdded( const GridDataEvent& i_event ) throw (RuntimeException) + void SAL_CALL GridEventForwarder::rowsInserted( const GridDataEvent& i_event ) throw (RuntimeException) { Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); if ( xPeer.is() ) - xPeer->rowsAdded( i_event ); + xPeer->rowsInserted( i_event ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/grideventforwarder.hxx b/toolkit/source/controls/grid/grideventforwarder.hxx index c0c09a7cc95d..0abdcc59fd85 100755 --- a/toolkit/source/controls/grid/grideventforwarder.hxx +++ b/toolkit/source/controls/grid/grideventforwarder.hxx @@ -61,7 +61,7 @@ namespace toolkit virtual void SAL_CALL release() throw(); // XGridDataListener - virtual void SAL_CALL rowsAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL rowTitleChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From 2702fbdf06551b8f8ddbd9bb2ae5f6589939139d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 13 Jan 2011 15:07:42 +0100 Subject: gridsort: moved *all* members from TableControl to TableControl_Impl - this is what the PIMPL pattern is good for, right? (Removed the AccessibleTableControl_Impl class in this course, not needed anymore) --- svtools/inc/svtools/table/tablecontrol.hxx | 29 +++---- svtools/source/inc/accessibletableimp.hxx | 62 --------------- svtools/source/table/tablecontrol.cxx | 121 +++++++++-------------------- svtools/source/table/tablecontrol_impl.cxx | 108 ++++++++++++++++++------- svtools/source/table/tablecontrol_impl.hxx | 39 ++++++++-- svtools/source/uno/svtxgridcontrol.cxx | 5 +- 6 files changed, 161 insertions(+), 203 deletions(-) delete mode 100644 svtools/source/inc/accessibletableimp.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 595ff5bae847..336e56a2b01a 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -36,6 +36,7 @@ #include #include +#include //........................................................................ @@ -45,7 +46,6 @@ namespace svt { namespace table class TableControl_Impl; class TableDataWindow; - class AccessibleTableControl_Impl; //==================================================================== //= TableControl @@ -71,18 +71,10 @@ namespace svt { namespace table class SVT_DLLPUBLIC TableControl : public Control, public IAccessibleTable { private: - DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* ); - DECL_DLLPRIVATE_LINK( ImplMouseButtonUpHdl, MouseEvent* ); - - DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); + ::boost::shared_ptr< TableControl_Impl > m_pImpl; - ::boost::shared_ptr< TableControl_Impl > m_pImpl; - Link m_aSelectHdl; - bool m_bSelectionChanged; public: - ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable; - TableControl( Window* _pParent, WinBits _nStyle ); ~TableControl(); @@ -159,8 +151,8 @@ namespace svt { namespace table SVT_DLLPRIVATE virtual void Resize(); virtual void Select(); - void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } - const Link& GetSelectHdl() const { return m_aSelectHdl; } + void SetSelectHdl( const Link& rLink ); + const Link& GetSelectHdl() const; /**invalidates the table if table has been changed e.g. new row added */ @@ -170,7 +162,7 @@ namespace svt { namespace table if the row, which should be removed, is selected, it will be erased from the vector */ SelectionEngine* getSelEngine(); - TableDataWindow* getDataWindow(); + TableDataWindow& getDataWindow(); // Window overridables virtual void GetFocus(); @@ -215,20 +207,19 @@ namespace svt { namespace table virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const; virtual sal_Bool HasRowHeader(); virtual sal_Bool HasColHeader(); - virtual sal_Bool isAccessibleAlive( ) const; - virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); virtual ::std::vector< sal_Int32 >& GetSelectedRows(); virtual void RemoveSelectedRow(RowPos _nRowPos); virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; // ............................................................................................................. - void selectionChanged(bool _bChanged); - void SelectRow( RowPos const i_rowIndex, bool const i_select ); void SelectAll( bool const i_select ); - protected: - ::svt::IAccessibleFactory& getAccessibleFactory(); + private: + DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* ); + DECL_DLLPRIVATE_LINK( ImplMouseButtonUpHdl, MouseEvent* ); + + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); private: TableControl(); // never implemented diff --git a/svtools/source/inc/accessibletableimp.hxx b/svtools/source/inc/accessibletableimp.hxx deleted file mode 100644 index 3a01c01567d3..000000000000 --- a/svtools/source/inc/accessibletableimp.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************* - * 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 - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * -************************************************************************/ - -#ifndef SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX -#define SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX - -#include "svtaccessiblefactory.hxx" - -namespace svt { namespace table -{ -//........................................................................ - - - class AccessibleTableControl_Impl - { - public: - AccessibleFactoryAccess m_aFactoryAccess; - IAccessibleTableControl* m_pAccessible; - - public: - AccessibleTableControl_Impl() : m_pAccessible(NULL) - { - } - - - /// @see AccessibleTableControl::getTableRowHeader - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - getAccessibleTableHeader( AccessibleTableControlObjType _eObjType ); - /// @see AccessibleTableControl::getTable - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - getAccessibleTable( ); - - }; - -//........................................................................ -} } // namespace svt::table -//........................................................................ - -#endif // SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 757310ba224d..f493983789ef 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -29,8 +29,6 @@ #include "tablegeometry.hxx" #include "tablecontrol_impl.hxx" -#include "accessibletableimp.hxx" - #include "svtools/table/tablecontrol.hxx" #include "svtools/table/tabledatawindow.hxx" @@ -50,24 +48,6 @@ namespace svt { namespace table { //...................................................................................................................... - //================================================================================================================== - //= AccessibleTableControl_Impl - //================================================================================================================== - // ----------------------------------------------------------------------------------------------------------------- - Reference< XAccessible > AccessibleTableControl_Impl::getAccessibleTableHeader( AccessibleTableControlObjType _eObjType ) - { - if ( m_pAccessible && m_pAccessible->isAlive() ) - return m_pAccessible->getTableHeader( _eObjType ); - return NULL; - } - // ----------------------------------------------------------------------------------------------------------------- - Reference< XAccessible > AccessibleTableControl_Impl::getAccessibleTable( ) - { - if ( m_pAccessible && m_pAccessible->isAlive() ) - return m_pAccessible->getTable( ); - return NULL; - } - //================================================================================================================== //= TableControl //================================================================================================================== @@ -75,13 +55,11 @@ namespace svt { namespace table TableControl::TableControl( Window* _pParent, WinBits _nStyle ) :Control( _pParent, _nStyle ) ,m_pImpl( new TableControl_Impl( *this ) ) - ,m_bSelectionChanged(false) { - TableDataWindow* aTableData = m_pImpl->getDataWindow(); - aTableData->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); - aTableData->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) ); - aTableData->SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) ); - m_pAccessTable.reset(new ::svt::table::AccessibleTableControl_Impl()); + TableDataWindow& rDataWindow = m_pImpl->getDataWindow(); + rDataWindow.SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); + rDataWindow.SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) ); + rDataWindow.SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) ); // by default, use the background as determined by the style settings const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() ); @@ -95,10 +73,8 @@ namespace svt { namespace table ImplCallEventListeners( VCLEVENT_OBJECT_DYING ); m_pImpl->setModel( PTableModel() ); + m_pImpl->disposeAccessible(); m_pImpl.reset(); - - if ( m_pAccessTable->m_pAccessible ) - m_pAccessTable->m_pAccessible->dispose(); } // ----------------------------------------------------------------------------------------------------------------- @@ -122,10 +98,10 @@ namespace svt { namespace table Control::KeyInput( rKEvt ); else { - if(m_bSelectionChanged) + if ( m_pImpl->didSelectionChange() ) { Select(); - m_bSelectionChanged = false; + m_pImpl->setSelectionChanged( false ); } } } @@ -141,23 +117,23 @@ namespace svt { namespace table { case STATE_CHANGE_CONTROLBACKGROUND: if ( IsControlBackground() ) - getDataWindow()->SetControlBackground( GetControlBackground() ); + getDataWindow().SetControlBackground( GetControlBackground() ); else - getDataWindow()->SetControlBackground(); + getDataWindow().SetControlBackground(); break; case STATE_CHANGE_CONTROLFOREGROUND: if ( IsControlForeground() ) - getDataWindow()->SetControlForeground( GetControlForeground() ); + getDataWindow().SetControlForeground( GetControlForeground() ); else - getDataWindow()->SetControlForeground(); + getDataWindow().SetControlForeground(); break; case STATE_CHANGE_CONTROLFONT: if ( IsControlFont() ) - getDataWindow()->SetControlFont( GetControlFont() ); + getDataWindow().SetControlFont( GetControlFont() ); else - getDataWindow()->SetControlFont(); + getDataWindow().SetControlFont(); break; } } @@ -235,7 +211,7 @@ namespace svt { namespace table m_pImpl->markRowAsDeselected( i_rowIndex ); } - selectionChanged( true ); + m_pImpl->setSelectionChanged(); InvalidateDataWindow( i_rowIndex, i_rowIndex, false ); Select(); } @@ -257,7 +233,7 @@ namespace svt { namespace table } - selectionChanged( true ); + m_pImpl->setSelectionChanged(); Invalidate(); // TODO: can't we do better than this, and invalidate only the rows which changed? Select(); @@ -271,10 +247,10 @@ namespace svt { namespace table m_pImpl->invalidateRows(); else { - if ( m_bSelectionChanged ) + if ( m_pImpl->didSelectionChange() ) { m_pImpl->invalidateSelectedRegion( _nRowStart, _nRowEnd, _rRect ); - m_bSelectionChanged = false; + m_pImpl->setSelectionChanged( false ); } else m_pImpl->invalidateRow( _nRowStart, _rRect ); @@ -306,7 +282,7 @@ namespace svt { namespace table } // ----------------------------------------------------------------------------------------------------------------- - TableDataWindow* TableControl::getDataWindow() + TableDataWindow& TableControl::getDataWindow() { return m_pImpl->getDataWindow(); } @@ -315,29 +291,20 @@ namespace svt { namespace table Reference< XAccessible > TableControl::CreateAccessible() { Window* pParent = GetAccessibleParentWindow(); - DBG_ASSERT( pParent, "TableControl::CreateAccessible - parent not found" ); + ENSURE_OR_RETURN( pParent, "TableControl::CreateAccessible - parent not found", NULL ); - if( pParent && !m_pAccessTable->m_pAccessible) - { - Reference< XAccessible > xAccParent = pParent->GetAccessible(); - if( xAccParent.is() ) - { - m_pAccessTable->m_pAccessible = getAccessibleFactory().createAccessibleTableControl( - xAccParent, *this - ); - } - } - Reference< XAccessible > xAccessible; - if ( m_pAccessTable->m_pAccessible ) - xAccessible = m_pAccessTable->m_pAccessible->getMyself(); - return xAccessible; + return m_pImpl->getAccessible( *pParent ); } + + // ----------------------------------------------------------------------------------------------------------------- Reference TableControl::CreateAccessibleControl( sal_Int32 _nIndex ) { (void)_nIndex; DBG_ASSERT( FALSE, "TableControl::CreateAccessibleControl: to be overwritten!" ); return NULL; } + + // ----------------------------------------------------------------------------------------------------------------- ::rtl::OUString TableControl::GetAccessibleObjectName( AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const { ::rtl::OUString aRetText; @@ -616,26 +583,6 @@ namespace svt { namespace table (void)_nRow; (void)_nColumnPos; return GetIndexForPoint(_rPoint); - ; - } - - //------------------------------------------------------------------------------------------------------------------ - sal_Bool TableControl::isAccessibleAlive( ) const - { - return ( NULL != m_pAccessTable->m_pAccessible ) && m_pAccessTable->m_pAccessible->isAlive(); - } - - //------------------------------------------------------------------------------------------------------------------ - ::svt::IAccessibleFactory& TableControl::getAccessibleFactory() - { - return m_pAccessTable->m_aFactoryAccess.getFactory(); - } - - //------------------------------------------------------------------------------------------------------------------ - void TableControl::commitGridControlEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) - { - if ( isAccessibleAlive() ) - m_pAccessTable->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue); } //------------------------------------------------------------------------------------------------------------------ @@ -652,12 +599,6 @@ namespace svt { namespace table return m_pImpl->calcTableRect(); } - //------------------------------------------------------------------------------------------------------------------ - void TableControl::selectionChanged(bool _bChanged) - { - m_bSelectionChanged = _bChanged; - } - //------------------------------------------------------------------------------------------------------------------ IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG ) { @@ -682,7 +623,19 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void TableControl::Select() { - ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_aSelectHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_pImpl->getSelectHandler(), this ); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl::SetSelectHdl( const Link& i_selectHandler ) + { + m_pImpl->setSelectHandler( i_selectHandler ); + } + + //------------------------------------------------------------------------------------------------------------------ + const Link& TableControl::GetSelectHdl() const + { + return m_pImpl->getSelectHandler(); } //...................................................................................................................... diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 31078eb23ce7..a147e2801696 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -36,8 +36,6 @@ #include "tablegeometry.hxx" #include "cellvalueconversion.hxx" -#include "accessibletableimp.hxx" - /** === begin UNO includes === **/ #include #include @@ -63,6 +61,8 @@ namespace svt { namespace table using ::com::sun::star::accessibility::AccessibleTableModelChange; using ::com::sun::star::uno::makeAny; using ::com::sun::star::uno::Any; + using ::com::sun::star::accessibility::XAccessible; + using ::com::sun::star::uno::Reference; /** === end UNO using === **/ namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId; namespace AccessibleTableModelChangeType = ::com::sun::star::accessibility::AccessibleTableModelChangeType; @@ -402,17 +402,19 @@ namespace svt { namespace table ,m_pSelEngine ( ) ,m_aSelectedRows ( ) ,m_pTableFunctionSet ( new TableFunctionSet( this ) ) - ,m_nAnchor (-1 ) + ,m_nAnchor ( -1 ) ,m_bResizingColumn ( false ) ,m_nResizingColumn ( 0 ) ,m_bResizingGrid ( false ) ,m_bUpdatingColWidths ( false ) + ,m_bSelectionChanged ( false ) + ,m_pAccessibleTable ( NULL ) #if DBG_UTIL ,m_nRequiredInvariants ( INV_SCROLL_POSITION ) #endif { DBG_CTOR( TableControl_Impl, TableControl_Impl_checkInvariants ); - m_pSelEngine = new SelectionEngine(m_pDataWindow, m_pTableFunctionSet); + m_pSelEngine = new SelectionEngine( m_pDataWindow.get(), m_pTableFunctionSet ); m_pSelEngine->SetSelectionMode(SINGLE_SELECTION); m_pDataWindow->SetPosPixel( Point( 0, 0 ) ); m_pDataWindow->Show(); @@ -428,7 +430,6 @@ namespace svt { namespace table DELETEZ( m_pScrollCorner ); DELETEZ( m_pTableFunctionSet ); DELETEZ( m_pSelEngine ); - DELETEZ( m_pDataWindow ); } //------------------------------------------------------------------------------------------------------------------ @@ -489,22 +490,22 @@ namespace svt { namespace table goTo( m_nCurColumn, m_nCurRow + insertedRows ); // notify A1YY events - if ( m_rAntiImpl.isAccessibleAlive() ) + if ( impl_isAccessibleAlive() ) { - m_rAntiImpl.commitGridControlEvent( AccessibleEventId::TABLE_MODEL_CHANGED, + impl_commitAccessibleEvent( AccessibleEventId::TABLE_MODEL_CHANGED, makeAny( AccessibleTableModelChange( AccessibleTableModelChangeType::INSERT, i_first, i_last, 0, m_pModel->getColumnCount() ) ), Any() ); - m_rAntiImpl.commitGridControlEvent( AccessibleEventId::CHILD, - makeAny( m_rAntiImpl.m_pAccessTable->m_pAccessible->getTableHeader( TCTYPE_ROWHEADERBAR ) ), + impl_commitAccessibleEvent( AccessibleEventId::CHILD, + makeAny( m_pAccessibleTable->getTableHeader( TCTYPE_ROWHEADERBAR ) ), Any() ); // for ( sal_Int32 i = 0 ; i <= m_pModel->getColumnCount(); ++i ) // { -// m_rAntiImpl.commitGridControlEvent( +// impl_commitAccessibleEvent( // CHILD, -// makeAny( m_rAntiImpl.m_pAccessTable->m_pAccessible->getTable() ), +// makeAny( m_pAccessibleTable->getTable() ), // Any()); // } // Huh? What's that? We're notifying |columnCount| CHILD events here, claiming the *table* itself @@ -557,9 +558,9 @@ namespace svt { namespace table } // notify A11Y events - if ( m_rAntiImpl.isAccessibleAlive() ) + if ( impl_isAccessibleAlive() ) { - m_rAntiImpl.commitGridControlEvent( + impl_commitAccessibleEvent( AccessibleEventId::TABLE_MODEL_CHANGED, makeAny( AccessibleTableModelChange( AccessibleTableModelChangeType::DELETE, @@ -1333,7 +1334,7 @@ namespace svt { namespace table m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); ensureVisible(m_nCurColumn,m_nCurRow,false); - m_rAntiImpl.selectionChanged(true); + setSelectionChanged(); bSuccess = true; } else @@ -1367,7 +1368,7 @@ namespace svt { namespace table invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } ensureVisible(m_nCurColumn,m_nCurRow,false); - m_rAntiImpl.selectionChanged(true); + setSelectionChanged(); bSuccess = true; } else @@ -1446,7 +1447,7 @@ namespace svt { namespace table else m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); - m_rAntiImpl.selectionChanged(true); + setSelectionChanged(); bSuccess = true; } break; @@ -1534,7 +1535,7 @@ namespace svt { namespace table m_pSelEngine->SetAnchor(TRUE); m_nAnchor = m_nCurRow; ensureVisible(m_nCurColumn, m_nCurRow, false); - m_rAntiImpl.selectionChanged(true); + setSelectionChanged(); bSuccess = true; } } @@ -1619,7 +1620,7 @@ namespace svt { namespace table m_pSelEngine->SetAnchor(TRUE); m_nAnchor = m_nCurRow; ensureVisible(m_nCurColumn, m_nCurRow, false); - m_rAntiImpl.selectionChanged(true); + setSelectionChanged(); bSuccess = true; } } @@ -1646,11 +1647,12 @@ namespace svt { namespace table m_nAnchor = m_nCurRow; m_pSelEngine->SetAnchor(TRUE); ensureVisible(m_nCurColumn, 0, false); - m_rAntiImpl.selectionChanged(true); + setSelectionChanged(); bSuccess = true; } } - break; + break; + case cursorSelectRowAreaBottom: { if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) @@ -1671,14 +1673,16 @@ namespace svt { namespace table m_nAnchor = m_nCurRow; m_pSelEngine->SetAnchor(TRUE); ensureVisible(m_nCurColumn, m_nRowCount-1, false); - m_rAntiImpl.selectionChanged(true); + setSelectionChanged(); bSuccess = true; } + break; + default: + DBG_ERROR( "TableControl_Impl::dispatchAction: unsupported action!" ); break; - default: - DBG_ERROR( "TableControl_Impl::dispatchAction: unsupported action!" ); - } - return bSuccess; + } + + return bSuccess; } //------------------------------------------------------------------------------------------------------------------ @@ -2140,11 +2144,7 @@ namespace svt { namespace table { return m_pSelEngine; } - //------------------------------------------------------------------------------------------------------------------ - TableDataWindow* TableControl_Impl::getDataWindow() - { - return m_pDataWindow; - } + //------------------------------------------------------------------------------------------------------------------ ScrollBar* TableControl_Impl::getHorzScrollbar() { @@ -2453,6 +2453,54 @@ namespace svt { namespace table return 0L; } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > TableControl_Impl::getAccessible( Window& i_parentWindow ) + { + DBG_TESTSOLARMUTEX(); + if ( m_pAccessibleTable == NULL ) + { + Reference< XAccessible > const xAccParent = i_parentWindow.GetAccessible(); + if ( xAccParent.is() ) + { + m_pAccessibleTable = m_aFactoryAccess.getFactory().createAccessibleTableControl( + xAccParent, m_rAntiImpl + ); + } + } + + Reference< XAccessible > xAccessible; + if ( m_pAccessibleTable ) + xAccessible = m_pAccessibleTable->getMyself(); + return xAccessible; + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::disposeAccessible() + { + if ( m_pAccessibleTable ) + m_pAccessibleTable->dispose(); + m_pAccessibleTable = NULL; + } + + //------------------------------------------------------------------------------------------------------------------ + bool TableControl_Impl::impl_isAccessibleAlive() const + { + DBG_CHECK_ME(); + return ( NULL != m_pAccessibleTable ) && m_pAccessibleTable->isAlive(); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::impl_commitAccessibleEvent( sal_Int16 const i_eventID, Any const & i_newValue, Any const & i_oldValue ) + { + DBG_CHECK_ME(); + if ( impl_isAccessibleAlive() ) + m_pAccessibleTable->commitEvent( i_eventID, i_newValue, i_oldValue ); + } + + //================================================================================================================== + //= TableFunctionSet + //================================================================================================================== //------------------------------------------------------------------------------------------------------------------ TableFunctionSet::TableFunctionSet(TableControl_Impl* _pTableControl) :m_pTableControl( _pTableControl) diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index c4b72889b07a..de045ed5674b 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -27,14 +27,18 @@ #ifndef SVTOOLS_TABLECONTROL_IMPL_HXX #define SVTOOLS_TABLECONTROL_IMPL_HXX -#include -#include -#include +#include "svtools/table/tablemodel.hxx" +#include "svtools/table/tablecontrolinterface.hxx" +#include "svtools/table/tablemodel.hxx" + +#include "svtaccessiblefactory.hxx" #include #include +#include + class ScrollBar; class ScrollBarBox; @@ -141,7 +145,8 @@ namespace svt { namespace table The window's upper left corner is at position (0,0), relative to the table control, which is the direct parent of the data window. */ - TableDataWindow* m_pDataWindow; + ::boost::scoped_ptr< TableDataWindow > + m_pDataWindow; /// the vertical scrollbar, if any ScrollBar* m_pVScroll; /// the horizontal scrollbar, if any @@ -160,6 +165,12 @@ namespace svt { namespace table bool m_bResizingGrid; bool m_bUpdatingColWidths; + Link m_aSelectHdl; + bool m_bSelectionChanged; + + AccessibleFactoryAccess m_aFactoryAccess; + IAccessibleTableControl* m_pAccessibleTable; + #if DBG_UTIL #define INV_SCROLL_POSITION 1 /** represents a bitmask of invariants to check @@ -265,6 +276,11 @@ namespace svt { namespace table */ bool markAllRowsAsSelected(); + void setSelectHandler( Link const & i_selectHandler ) { m_aSelectHdl = i_selectHandler; } + Link const& getSelectHandler() const { return m_aSelectHdl; } + + void setSelectionChanged( bool const i_changed = true ) { m_bSelectionChanged = i_changed; } + bool didSelectionChange() const { return m_bSelectionChanged; } // ITableControl virtual void hideCursor(); @@ -283,13 +299,19 @@ namespace svt { namespace table virtual bool isRowSelected( RowPos i_row ) const; - TableDataWindow* getDataWindow(); + TableDataWindow& getDataWindow() { return *m_pDataWindow; } + const TableDataWindow& getDataWindow() const { return *m_pDataWindow; } ScrollBar* getHorzScrollbar(); ScrollBar* getVertScrollbar(); Rectangle calcHeaderRect(bool bColHeader); Rectangle calcTableRect(); + // A11Y + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getAccessible( Window& i_parentWindow ); + void disposeAccessible(); + // ITableModelListener virtual void rowsInserted( RowPos first, RowPos last ); virtual void rowsRemoved( RowPos first, RowPos last ); @@ -300,6 +322,13 @@ namespace svt { namespace table virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ); private: + bool impl_isAccessibleAlive() const; + void impl_commitAccessibleEvent( + sal_Int16 const i_eventID, + ::com::sun::star::uno::Any const & i_newValue, + ::com::sun::star::uno::Any const & i_oldValue + ); + /** toggles the cursor visibility The method is not bound to the classes public invariants, as it's used in diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index b5d2a48026ea..84185ce071a8 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -28,7 +28,6 @@ #include "precompiled_svtools.hxx" #include "svtxgridcontrol.hxx" -#include "accessibletableimp.hxx" #include #include "svtools/table/tablecontrolinterface.hxx" #include "svtools/table/gridtablerenderer.hxx" @@ -219,9 +218,9 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An VCLXWindow::setProperty( PropertyName, aValue ); // and forward to the grid control's data window if ( pTable->IsBackground() ) - pTable->getDataWindow()->SetBackground( pTable->GetBackground() ); + pTable->getDataWindow().SetBackground( pTable->GetBackground() ); else - pTable->getDataWindow()->SetBackground(); + pTable->getDataWindow().SetBackground(); } break; -- cgit v1.2.3 From 3fbbc7662deb5d5758667b51e24a2ac9b1b4bb34 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 13 Jan 2011 16:28:06 +0100 Subject: gridsort: cleaned up (parts of) the selection-related code --- svtools/inc/svtools/table/tablecontrol.hxx | 5 +- svtools/source/table/tablecontrol.cxx | 28 +- svtools/source/table/tablecontrol_impl.cxx | 492 +++++++++++++++-------------- svtools/source/table/tablecontrol_impl.hxx | 13 +- svtools/source/uno/svtxgridcontrol.cxx | 4 +- 5 files changed, 276 insertions(+), 266 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 336e56a2b01a..5671c7607281 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -154,9 +154,8 @@ namespace svt { namespace table void SetSelectHdl( const Link& rLink ); const Link& GetSelectHdl() const; - /**invalidates the table if table has been changed e.g. new row added - */ - void InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved); + /// invalidates those areas of the data window which are covered by the given rows + void InvalidateDataWindow( RowPos const i_firstRow, RowPos const i_lastRow ); /**after removing a row, updates the vector which contains the selected rows if the row, which should be removed, is selected, it will be erased from the vector diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index f493983789ef..7a1b9f450e09 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -96,14 +96,6 @@ namespace svt { namespace table { if ( !m_pImpl->getInputHandler()->KeyInput( *m_pImpl, rKEvt ) ) Control::KeyInput( rKEvt ); - else - { - if ( m_pImpl->didSelectionChange() ) - { - Select(); - m_pImpl->setSelectionChanged( false ); - } - } } @@ -211,8 +203,7 @@ namespace svt { namespace table m_pImpl->markRowAsDeselected( i_rowIndex ); } - m_pImpl->setSelectionChanged(); - InvalidateDataWindow( i_rowIndex, i_rowIndex, false ); + m_pImpl->invalidateRowRange( i_rowIndex, i_rowIndex ); Select(); } @@ -233,28 +224,15 @@ namespace svt { namespace table } - m_pImpl->setSelectionChanged(); Invalidate(); // TODO: can't we do better than this, and invalidate only the rows which changed? Select(); } // ----------------------------------------------------------------------------------------------------------------- - void TableControl::InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved) + void TableControl::InvalidateDataWindow( RowPos const i_firstRow, RowPos const i_lastRow ) { - Rectangle _rRect; - if ( _bRemoved ) - m_pImpl->invalidateRows(); - else - { - if ( m_pImpl->didSelectionChange() ) - { - m_pImpl->invalidateSelectedRegion( _nRowStart, _nRowEnd, _rRect ); - m_pImpl->setSelectionChanged( false ); - } - else - m_pImpl->invalidateRow( _nRowStart, _rRect ); - } + m_pImpl->invalidateRowRange( i_firstRow, i_lastRow ); } // ----------------------------------------------------------------------------------------------------------------- diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index a147e2801696..da05d1f51fcd 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -407,7 +407,6 @@ namespace svt { namespace table ,m_nResizingColumn ( 0 ) ,m_bResizingGrid ( false ) ,m_bUpdatingColWidths ( false ) - ,m_bSelectionChanged ( false ) ,m_pAccessibleTable ( NULL ) #if DBG_UTIL ,m_nRequiredInvariants ( INV_SCROLL_POSITION ) @@ -463,6 +462,26 @@ namespace svt { namespace table if ( m_nColumnCount ) m_nCurColumn = 0; } + //------------------------------------------------------------------------------------------------------------------ + namespace + { + bool lcl_adjustSelectedRows( ::std::vector< RowPos >& io_selectionIndexes, RowPos const i_firstAffectedRowIndex, TableSize const i_offset ) + { + bool didChanges = false; + for ( ::std::vector< RowPos >::iterator selPos = io_selectionIndexes.begin(); + selPos != io_selectionIndexes.end(); + ++selPos + ) + { + if ( *selPos < i_firstAffectedRowIndex ) + continue; + *selPos += i_offset; + didChanges = true; + } + return didChanges; + } + } + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::rowsInserted( RowPos i_first, RowPos i_last ) { @@ -472,15 +491,7 @@ namespace svt { namespace table TableSize const insertedRows = i_last - i_first + 1; // adjust selection, if necessary - bool selectionChanged = false; - for ( ::std::vector< RowPos >::iterator selPos = m_aSelectedRows.begin(); selPos != m_aSelectedRows.end(); ++selPos ) - { - if ( *selPos >= i_first ) - { - *selPos += insertedRows; - selectionChanged = true; - } - } + bool const selectionChanged = lcl_adjustSelectedRows( m_aSelectedRows, i_first, insertedRows ); // adjust our cached row count m_nRowCount = m_pModel->getRowCount(); @@ -513,7 +524,7 @@ namespace svt { namespace table } // schedule repaint - m_rAntiImpl.InvalidateDataWindow( i_first, i_last, false ); + invalidateRowRange( i_first, m_pModel->getRowCount() - 1 ); // call selection handlers, if necessary if ( selectionChanged ) @@ -539,10 +550,14 @@ namespace svt { namespace table { ENSURE_OR_RETURN_VOID( i_last >= i_first, "TableControl_Impl::rowsRemoved: illegal indexes!" ); - for ( sal_Int32 row = i_first; row < i_last; ++row ) + for ( sal_Int32 row = i_first; row <= i_last; ++row ) { - selectionChanged |= markRowAsDeselected( row ); + if ( markRowAsDeselected( row ) ) + selectionChanged = true; } + + if ( lcl_adjustSelectedRows( m_aSelectedRows, i_last + 1, i_first - i_last - 1 ) ) + selectionChanged = true; } // adjust cached row count @@ -574,7 +589,7 @@ namespace svt { namespace table } // schedule a repaint - m_rAntiImpl.InvalidateDataWindow( firstRemovedRow, lastRemovedRow, true ); + invalidateRowRange( firstRemovedRow, m_pModel->getRowCount() - 1 ); // call selection handlers, if necessary if ( selectionChanged ) @@ -1134,7 +1149,8 @@ namespace svt { namespace table { if ( m_bResizingGrid ) impl_ni_updateColumnWidths(); - invalidateRows(); + impl_ni_updateScrollbars(); + checkCursorPosition(); m_bResizingGrid = true; } } @@ -1309,6 +1325,8 @@ namespace svt { namespace table DBG_CHECK_ME(); bool bSuccess = false; + bool selectionChanged = false; + Rectangle rCells; switch ( _eAction ) { @@ -1334,7 +1352,7 @@ namespace svt { namespace table m_aSelectedRows.push_back(m_nCurRow); invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); ensureVisible(m_nCurColumn,m_nCurRow,false); - setSelectionChanged(); + selectionChanged = true; bSuccess = true; } else @@ -1368,7 +1386,7 @@ namespace svt { namespace table invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); } ensureVisible(m_nCurColumn,m_nCurRow,false); - setSelectionChanged(); + selectionChanged = true; bSuccess = true; } else @@ -1430,259 +1448,266 @@ namespace svt { namespace table case cursorBottomRight: bSuccess = goTo( m_nColumnCount - 1, m_nRowCount - 1 ); break; - case cursorSelectRow: - { - if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) - return bSuccess = false; - //pos is the position of the current row in the vector of selected rows, if current row is selected - int pos = getRowSelectedNumber(m_aSelectedRows, m_nCurRow); - //if current row is selected, it should be deselected, when ALT+SPACE are pressed - if(pos>-1) - { - m_aSelectedRows.erase(m_aSelectedRows.begin()+pos); - if(m_aSelectedRows.empty() && m_nAnchor != -1) - m_nAnchor = -1; - } - //else select the row->put it in the vector - else - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); - setSelectionChanged(); - bSuccess = true; - } - break; - case cursorSelectRowUp: - { - if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) - return bSuccess = false; - else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) + + case cursorSelectRow: { - //if there are other selected rows, deselect them - return false; + if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) + return bSuccess = false; + //pos is the position of the current row in the vector of selected rows, if current row is selected + int pos = getRowSelectedNumber(m_aSelectedRows, m_nCurRow); + //if current row is selected, it should be deselected, when ALT+SPACE are pressed + if(pos>-1) + { + m_aSelectedRows.erase(m_aSelectedRows.begin()+pos); + if(m_aSelectedRows.empty() && m_nAnchor != -1) + m_nAnchor = -1; + } + //else select the row->put it in the vector + else + m_aSelectedRows.push_back(m_nCurRow); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + selectionChanged = true; + bSuccess = true; } - else + break; + case cursorSelectRowUp: { - //there are other selected rows - if(m_aSelectedRows.size()>0) + if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) + return bSuccess = false; + else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) + { + //if there are other selected rows, deselect them + return false; + } + else { - //the anchor wasn't set -> a region is not selected, that's why clear all selection - //and select the current row - if(m_nAnchor==-1) + //there are other selected rows + if(m_aSelectedRows.size()>0) { - for(std::vector::iterator it=m_aSelectedRows.begin(); - it!=m_aSelectedRows.end();++it) + //the anchor wasn't set -> a region is not selected, that's why clear all selection + //and select the current row + if(m_nAnchor==-1) { - invalidateSelectedRegion(*it, *it, rCells); - } - m_aSelectedRows.clear(); - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); - } - else - { - //a region is already selected, prevRow is last selected row and the row above - nextRow - should be selected - int prevRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow); - int nextRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow-1); - if(prevRow>-1) - { - //if m_nCurRow isn't the upper one, can move up, otherwise not - if(m_nCurRow>0) - m_nCurRow--; - else - return bSuccess = true; - //if nextRow already selected, deselect it, otherwise select it - if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow) - { - m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow); - invalidateSelectedRegion(m_nCurRow+1, m_nCurRow+1, rCells); - } - else + for(std::vector::iterator it=m_aSelectedRows.begin(); + it!=m_aSelectedRows.end();++it) { - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); - } - } + invalidateSelectedRegion(*it, *it, rCells); + } + m_aSelectedRows.clear(); + m_aSelectedRows.push_back(m_nCurRow); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + } else { - if(m_nCurRow>0) + //a region is already selected, prevRow is last selected row and the row above - nextRow - should be selected + int prevRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow); + int nextRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow-1); + if(prevRow>-1) + { + //if m_nCurRow isn't the upper one, can move up, otherwise not + if(m_nCurRow>0) + m_nCurRow--; + else + return bSuccess = true; + //if nextRow already selected, deselect it, otherwise select it + if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow) + { + m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow); + invalidateSelectedRegion(m_nCurRow+1, m_nCurRow+1, rCells); + } + else + { + m_aSelectedRows.push_back(m_nCurRow); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + } + } + else { - m_aSelectedRows.push_back(m_nCurRow); - m_nCurRow--; - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells); + if(m_nCurRow>0) + { + m_aSelectedRows.push_back(m_nCurRow); + m_nCurRow--; + m_aSelectedRows.push_back(m_nCurRow); + invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells); + } } } } - } - else - { - //if nothing is selected and the current row isn't the upper one - //select the current and one row above - //otherwise select only the upper row - if(m_nCurRow>0) - { - m_aSelectedRows.push_back(m_nCurRow); - m_nCurRow--; - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells); - } else { - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + //if nothing is selected and the current row isn't the upper one + //select the current and one row above + //otherwise select only the upper row + if(m_nCurRow>0) + { + m_aSelectedRows.push_back(m_nCurRow); + m_nCurRow--; + m_aSelectedRows.push_back(m_nCurRow); + invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells); + } + else + { + m_aSelectedRows.push_back(m_nCurRow); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + } } + m_pSelEngine->SetAnchor(TRUE); + m_nAnchor = m_nCurRow; + ensureVisible(m_nCurColumn, m_nCurRow, false); + selectionChanged = true; + bSuccess = true; } - m_pSelEngine->SetAnchor(TRUE); - m_nAnchor = m_nCurRow; - ensureVisible(m_nCurColumn, m_nCurRow, false); - setSelectionChanged(); - bSuccess = true; - } - } - break; - case cursorSelectRowDown: - { - if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) - bSuccess = false; - else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) - { - bSuccess = false; } - else + break; + case cursorSelectRowDown: { - if(m_aSelectedRows.size()>0) + if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) + bSuccess = false; + else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) { - //the anchor wasn't set -> a region is not selected, that's why clear all selection - //and select the current row - if(m_nAnchor==-1) + bSuccess = false; + } + else + { + if(m_aSelectedRows.size()>0) { - for(std::vector::iterator it=m_aSelectedRows.begin(); - it!=m_aSelectedRows.end();++it) + //the anchor wasn't set -> a region is not selected, that's why clear all selection + //and select the current row + if(m_nAnchor==-1) { - invalidateSelectedRegion(*it, *it, rCells); - } - m_aSelectedRows.clear(); - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + for(std::vector::iterator it=m_aSelectedRows.begin(); + it!=m_aSelectedRows.end();++it) + { + invalidateSelectedRegion(*it, *it, rCells); + } + m_aSelectedRows.clear(); + m_aSelectedRows.push_back(m_nCurRow); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + } + else + { + //a region is already selected, prevRow is last selected row and the row beneath - nextRow - should be selected + int prevRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow); + int nextRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow+1); + if(prevRow>-1) + { + //if m_nCurRow isn't the last one, can move down, otherwise not + if(m_nCurRow-1 && m_aSelectedRows[nextRow] == m_nCurRow) + { + m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow); + invalidateSelectedRegion(m_nCurRow-1, m_nCurRow-1, rCells); + } + else + { + m_aSelectedRows.push_back(m_nCurRow); + invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + } + } + else + { + if(m_nCurRow-1) - { - //if m_nCurRow isn't the last one, can move down, otherwise not - if(m_nCurRow-1 && m_aSelectedRows[nextRow] == m_nCurRow) - { - m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow); - invalidateSelectedRegion(m_nCurRow-1, m_nCurRow-1, rCells); - } - else - { - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); - } + //there wasn't any selection, select current and row beneath, otherwise only row beneath + if(m_nCurRowSetAnchor(TRUE); + m_nAnchor = m_nCurRow; + ensureVisible(m_nCurColumn, m_nCurRow, false); + selectionChanged = true; + bSuccess = true; } + } + break; + + case cursorSelectRowAreaTop: + { + if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) + bSuccess = false; + else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) + bSuccess = false; else { - //there wasn't any selection, select current and row beneath, otherwise only row beneath - if(m_nCurRow=0) { - m_aSelectedRows.push_back(m_nCurRow); - m_nCurRow++; - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells); - } - else - { - m_aSelectedRows.push_back(m_nCurRow); - invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells); + if ( !isRowSelected( iter ) ) + m_aSelectedRows.push_back(iter); + --iter; } + m_nCurRow = 0; + m_nAnchor = m_nCurRow; + m_pSelEngine->SetAnchor(TRUE); + ensureVisible(m_nCurColumn, 0, false); + selectionChanged = true; + bSuccess = true; } - m_pSelEngine->SetAnchor(TRUE); - m_nAnchor = m_nCurRow; - ensureVisible(m_nCurColumn, m_nCurRow, false); - setSelectionChanged(); - bSuccess = true; } - } break; - case cursorSelectRowAreaTop: - { - if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) - bSuccess = false; - else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) - bSuccess = false; - else + + case cursorSelectRowAreaBottom: { - //select the region between the current and the upper row + if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) + return bSuccess = false; + else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) + return bSuccess = false; + //select the region between the current and the last row RowPos iter = m_nCurRow; - invalidateSelectedRegion(m_nCurRow, 0, rCells); - //put the rows in vector - while(iter>=0) + invalidateSelectedRegion(m_nCurRow, m_nRowCount-1, rCells); + //put the rows in the vector + while(iter<=m_nRowCount) { if ( !isRowSelected( iter ) ) m_aSelectedRows.push_back(iter); - --iter; + ++iter; } - m_nCurRow = 0; + m_nCurRow = m_nRowCount-1; m_nAnchor = m_nCurRow; m_pSelEngine->SetAnchor(TRUE); - ensureVisible(m_nCurColumn, 0, false); - setSelectionChanged(); + ensureVisible(m_nCurColumn, m_nRowCount-1, false); + selectionChanged = true; bSuccess = true; } - } - break; + break; + default: + DBG_ERROR( "TableControl_Impl::dispatchAction: unsupported action!" ); + break; + } - case cursorSelectRowAreaBottom: - { - if(m_pSelEngine->GetSelectionMode() == NO_SELECTION) - return bSuccess = false; - else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION) - return bSuccess = false; - //select the region between the current and the last row - RowPos iter = m_nCurRow; - invalidateSelectedRegion(m_nCurRow, m_nRowCount-1, rCells); - //put the rows in the vector - while(iter<=m_nRowCount) + if ( bSuccess && selectionChanged ) { - if ( !isRowSelected( iter ) ) - m_aSelectedRows.push_back(iter); - ++iter; + m_rAntiImpl.Select(); } - m_nCurRow = m_nRowCount-1; - m_nAnchor = m_nCurRow; - m_pSelEngine->SetAnchor(TRUE); - ensureVisible(m_nCurColumn, m_nRowCount-1, false); - setSelectionChanged(); - bSuccess = true; - } - break; - default: - DBG_ERROR( "TableControl_Impl::dispatchAction: unsupported action!" ); - break; - } - return bSuccess; + return bSuccess; } //------------------------------------------------------------------------------------------------------------------ @@ -1838,21 +1863,29 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ //this method is to be called, when a new row is added - void TableControl_Impl::invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect) + void TableControl_Impl::invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow ) { - if ( m_nCurRow < 0 ) - // hmm? Why this? Looks like a hack to me, working around some other problem. - m_nCurRow = 0; - if ( m_nCursorHidden == 2 ) // WTF? what kind of hack is this? --m_nCursorHidden; - impl_getAllVisibleCellsArea( _rCellRect ); - impl_ni_updateScrollbars(); + RowPos const firstRow = i_firstRow < m_nTopRow ? m_nTopRow : i_firstRow; + RowPos const lastVisibleRow = m_nTopRow + impl_getVisibleRows( true ) - 1; + RowPos const lastRow = i_lastRow > lastVisibleRow ? lastVisibleRow : i_lastRow; - TableRowGeometry const aRow( *this, _rCellRect, _nRowPos); - m_pDataWindow->Invalidate( aRow.getRect() ); + Rectangle aInvalidateRect; + + Rectangle aVisibleCellsArea; + impl_getAllVisibleCellsArea( aVisibleCellsArea ); + + TableRowGeometry aRow( *this, aVisibleCellsArea, firstRow ); + while ( aRow.isValid() && ( aRow.getRow() <= lastRow ) ) + { + aInvalidateRect.Union( aRow.getRect() ); + aRow.moveDown(); + } + + m_pDataWindow->Invalidate( aInvalidateRect ); } //------------------------------------------------------------------------------------------------------------------ @@ -1889,9 +1922,10 @@ namespace svt { namespace table m_nCurRow = _nRowPos-1; } //------------------------------------------------------------------------------ - void TableControl_Impl::invalidateRows() + void TableControl_Impl::checkCursorPosition() { - impl_ni_updateScrollbars(); + DBG_CHECK_ME(); + TableSize nVisibleRows = impl_getVisibleRows(true); TableSize nVisibleCols = impl_getVisibleColumns(true); if ( ( m_nTopRow + nVisibleRows > m_nRowCount ) diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index de045ed5674b..63a297d612da 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -166,7 +166,6 @@ namespace svt { namespace table bool m_bUpdatingColWidths; Link m_aSelectHdl; - bool m_bSelectionChanged; AccessibleFactoryAccess m_aFactoryAccess; IAccessibleTableControl* m_pAccessibleTable; @@ -238,15 +237,18 @@ namespace svt { namespace table /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/ void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect ); - /** to be called when a new row is added to the control*/ - void invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect ); + /** invalidates the part of the data window which is covered by the given row + */ + void invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow ); /** returns the vector, which contains the selected rows*/ std::vector& getSelectedRows(); /** updates the vector, which contains the selected rows after removing the row nRowPos*/ void removeSelectedRow(RowPos _nRowPos); - void invalidateRows(); + + + void checkCursorPosition(); bool hasRowSelection() const { return !m_aSelectedRows.empty(); } size_t getSelectedRowCount() const { return m_aSelectedRows.size(); } @@ -279,9 +281,6 @@ namespace svt { namespace table void setSelectHandler( Link const & i_selectHandler ) { m_aSelectHdl = i_selectHandler; } Link const& getSelectHandler() const { return m_aSelectHdl; } - void setSelectionChanged( bool const i_changed = true ) { m_bSelectionChanged = i_changed; } - bool didSelectionChange() const { return m_bSelectionChanged; } - // ITableControl virtual void hideCursor(); virtual void showCursor(); diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 84185ce071a8..123662da0221 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -541,9 +541,9 @@ void SAL_CALL SVTXGridControl::dataChanged( const GridDataEvent& i_event ) throw // TODO: Our UnoControlTableModel should be a listener at the data model, and multiplex those events, // so the TableControl/_Impl can react on it. if ( i_event.FirstRow == -1 ) - pTable->InvalidateDataWindow( 0, m_pTableModel->getRowCount(), false ); + pTable->InvalidateDataWindow( 0, m_pTableModel->getRowCount() ); else - pTable->InvalidateDataWindow( i_event.FirstRow, i_event.LastRow, false ); + pTable->InvalidateDataWindow( i_event.FirstRow, i_event.LastRow ); } //---------------------------------------------------------------------------------------------------------------------- -- cgit v1.2.3 From efd8adea09c07035875f8bdb18f8959ea603e898 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 13 Jan 2011 16:49:07 +0100 Subject: gridsort: added runtime (non-pro) consistency checks for TableControl_Impl::m_aSelectedRows --- svtools/source/table/tablecontrol_impl.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index da05d1f51fcd..db3600390771 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -312,6 +312,20 @@ namespace svt { namespace table if ( m_pInputHandler != m_pModel->getInputHandler() ) return "input handler is not the model-provided one!"; + // m_aSelectedRows should have reasonable content + { + if ( m_aSelectedRows.size() > m_pModel->getRowCount() ) + return "there are more rows selected than actually exist"; + for ( ::std::vector< RowPos >::const_iterator selRow = m_aSelectedRows.begin(); + selRow != m_aSelectedRows.end(); + ++selRow + ) + { + if ( ( *selRow < 0 ) || ( *selRow >= m_pModel->getRowCount() ) ) + return "a non-existent row is selected"; + } + } + // m_nColHeaderHeightPixel consistent with the model's value? { TableMetrics nHeaderHeight = m_pModel->hasColumnHeaders() ? m_pModel->getColumnHeaderHeight() : 0; -- cgit v1.2.3 From 3d914bead0bbe44781c13ae2957475971b773b4d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 13 Jan 2011 16:52:06 +0100 Subject: gridsort: rowsRemoved/Inserted: update scrollbars --- svtools/source/table/tablecontrol_impl.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index db3600390771..a6e99fc5700e 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -514,6 +514,9 @@ namespace svt { namespace table if ( i_first <= m_nCurRow ) goTo( m_nCurColumn, m_nCurRow + insertedRows ); + // adjust scrollbars + impl_ni_updateScrollbars(); + // notify A1YY events if ( impl_isAccessibleAlive() ) { @@ -586,6 +589,9 @@ namespace svt { namespace table m_nCurRow = ROW_INVALID; } + // adjust scrollbars + impl_ni_updateScrollbars(); + // notify A11Y events if ( impl_isAccessibleAlive() ) { -- cgit v1.2.3 From 4394d293a5cebb453590bbed775551a3c30c2ec9 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 09:32:50 +0100 Subject: gridsort: fixed invalidateRowRange for some edge cases --- svtools/source/table/tablecontrol_impl.cxx | 11 ++++-- svtools/source/table/tablecontrol_impl.hxx | 6 ++- svtools/source/table/tablegeometry.cxx | 59 ++++++++++++++++++------------ svtools/source/table/tablegeometry.hxx | 42 +++++++++++---------- 4 files changed, 71 insertions(+), 47 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index a6e99fc5700e..3c7cb555f374 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -541,7 +541,7 @@ namespace svt { namespace table } // schedule repaint - invalidateRowRange( i_first, m_pModel->getRowCount() - 1 ); + invalidateRowRange( i_first, ROW_INVALID ); // call selection handlers, if necessary if ( selectionChanged ) @@ -609,7 +609,7 @@ namespace svt { namespace table } // schedule a repaint - invalidateRowRange( firstRemovedRow, m_pModel->getRowCount() - 1 ); + invalidateRowRange( firstRemovedRow, ROW_INVALID ); // call selection handlers, if necessary if ( selectionChanged ) @@ -1891,20 +1891,23 @@ namespace svt { namespace table RowPos const firstRow = i_firstRow < m_nTopRow ? m_nTopRow : i_firstRow; RowPos const lastVisibleRow = m_nTopRow + impl_getVisibleRows( true ) - 1; - RowPos const lastRow = i_lastRow > lastVisibleRow ? lastVisibleRow : i_lastRow; + RowPos const lastRow = ( ( i_lastRow == ROW_INVALID ) || ( i_lastRow > lastVisibleRow ) ) ? lastVisibleRow : i_lastRow; Rectangle aInvalidateRect; Rectangle aVisibleCellsArea; impl_getAllVisibleCellsArea( aVisibleCellsArea ); - TableRowGeometry aRow( *this, aVisibleCellsArea, firstRow ); + TableRowGeometry aRow( *this, aVisibleCellsArea, firstRow, true ); while ( aRow.isValid() && ( aRow.getRow() <= lastRow ) ) { aInvalidateRect.Union( aRow.getRect() ); aRow.moveDown(); } + if ( i_lastRow == ROW_INVALID ) + aInvalidateRect.Bottom() = m_pDataWindow->GetOutputSizePixel().Height(); + m_pDataWindow->Invalidate( aInvalidateRect ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 63a297d612da..9dfdaedc29f8 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -29,7 +29,6 @@ #include "svtools/table/tablemodel.hxx" #include "svtools/table/tablecontrolinterface.hxx" -#include "svtools/table/tablemodel.hxx" #include "svtaccessiblefactory.hxx" @@ -238,6 +237,11 @@ namespace svt { namespace table void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect ); /** invalidates the part of the data window which is covered by the given row + @param i_firstRow + the index of the first row to include in the invalidation + @param i_lastRow + the index of the last row to include in the invalidation, or ROW_INVALID if the invalidation + should happen down to the bottom of the data window. */ void invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow ); diff --git a/svtools/source/table/tablegeometry.cxx b/svtools/source/table/tablegeometry.cxx index 01425f3bb292..661079775daa 100644 --- a/svtools/source/table/tablegeometry.cxx +++ b/svtools/source/table/tablegeometry.cxx @@ -27,25 +27,25 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svtools.hxx" - #include "tablegeometry.hxx" #include "tablecontrol_impl.hxx" #include -//........................................................................ +//...................................................................................................................... namespace svt { namespace table { -//........................................................................ +//...................................................................................................................... - //==================================================================== + //================================================================================================================== //= TableRowGeometry - //==================================================================== - //-------------------------------------------------------------------- - TableRowGeometry::TableRowGeometry( const TableControl_Impl& _rControl, const Rectangle& _rBoundaries, - RowPos _nRow ) + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + TableRowGeometry::TableRowGeometry( TableControl_Impl const & _rControl, Rectangle const & _rBoundaries, + RowPos const _nRow, bool const i_allowVirtualRows ) :TableGeometry( _rControl, _rBoundaries ) ,m_nRowPos( _nRow ) + ,m_bAllowVirtualRows( i_allowVirtualRows ) { if ( m_nRowPos == ROW_COL_HEADERS ) { @@ -58,10 +58,10 @@ namespace svt { namespace table } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableRowGeometry::impl_initRect() { - if ( ( m_nRowPos >= m_rControl.m_nTopRow ) && ( m_nRowPos < m_rControl.m_pModel->getRowCount() ) ) + if ( ( m_nRowPos >= m_rControl.m_nTopRow ) && impl_isValidRow( m_nRowPos ) ) { m_aRect.Top() = m_rControl.m_nColHeaderHeightPixel + ( m_nRowPos - m_rControl.m_nTopRow ) * m_rControl.m_nRowHeightPixel; m_aRect.Bottom() = m_aRect.Top() + m_rControl.m_nRowHeightPixel - 1; @@ -70,7 +70,13 @@ namespace svt { namespace table m_aRect.SetEmpty(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + bool TableRowGeometry::impl_isValidRow( RowPos const i_row ) const + { + return m_bAllowVirtualRows || ( i_row < m_rControl.m_pModel->getRowCount() ); + } + + //------------------------------------------------------------------------------------------------------------------ bool TableRowGeometry::moveDown() { if ( m_nRowPos == ROW_COL_HEADERS ) @@ -80,7 +86,7 @@ namespace svt { namespace table } else { - if ( ++m_nRowPos < m_rControl.m_pModel->getRowCount() ) + if ( impl_isValidRow( ++m_nRowPos ) ) m_aRect.Move( 0, m_rControl.m_nRowHeightPixel ); else m_aRect.SetEmpty(); @@ -88,14 +94,15 @@ namespace svt { namespace table return isValid(); } - //==================================================================== + //================================================================================================================== //= TableColumnGeometry - //==================================================================== - //-------------------------------------------------------------------- - TableColumnGeometry::TableColumnGeometry( const TableControl_Impl& _rControl, const Rectangle& _rBoundaries, - ColPos _nCol ) + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + TableColumnGeometry::TableColumnGeometry( TableControl_Impl const & _rControl, Rectangle const & _rBoundaries, + ColPos const _nCol, bool const i_allowVirtualColumns ) :TableGeometry( _rControl, _rBoundaries ) ,m_nColPos( _nCol ) + ,m_bAllowVirtualColumns( i_allowVirtualColumns ) { if ( m_nColPos == COL_ROW_HEADERS ) { @@ -108,11 +115,11 @@ namespace svt { namespace table } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableColumnGeometry::impl_initRect() { ColPos nLeftColumn = m_rControl.m_nLeftColumn; - if ( ( m_nColPos >= nLeftColumn ) && ( m_nColPos < (ColPos)m_rControl.m_aColumnWidths.size() ) ) + if ( ( m_nColPos >= nLeftColumn ) && impl_isValidColumn( m_nColPos ) ) { m_aRect.Left() = m_rControl.m_nRowHeaderWidthPixel; // TODO: take into account any possibly frozen columns @@ -125,7 +132,13 @@ namespace svt { namespace table m_aRect.SetEmpty(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + bool TableColumnGeometry::impl_isValidColumn( ColPos const i_column ) const + { + return m_bAllowVirtualColumns || ( i_column < ColPos( m_rControl.m_aColumnWidths.size() ) ); + } + + //------------------------------------------------------------------------------------------------------------------ bool TableColumnGeometry::moveRight() { if ( m_nColPos == COL_ROW_HEADERS ) @@ -135,7 +148,7 @@ namespace svt { namespace table } else { - if ( ++m_nColPos < (ColPos)m_rControl.m_aColumnWidths.size() ) + if ( impl_isValidColumn( ++m_nColPos ) ) { m_aRect.Left() = m_aRect.Right() + 1; m_aRect.Right() += m_rControl.m_aColumnWidths[ m_nColPos ].getWidth(); @@ -147,6 +160,6 @@ namespace svt { namespace table return isValid(); } -//........................................................................ +//...................................................................................................................... } } // namespace svt::table -//........................................................................ +//...................................................................................................................... diff --git a/svtools/source/table/tablegeometry.hxx b/svtools/source/table/tablegeometry.hxx index 7bfc2527d5fc..fedc7cb2f24f 100644 --- a/svtools/source/table/tablegeometry.hxx +++ b/svtools/source/table/tablegeometry.hxx @@ -27,13 +27,9 @@ #ifndef SVTOOLS_TABLEGEOMETRY_HXX #define SVTOOLS_TABLEGEOMETRY_HXX -#ifndef SVTOOLS_INC_TABLE_TABLETYPES_HXX -#include -#endif +#include "svtools/table/tabletypes.hxx" -#ifndef _SV_GEN_HXX #include -#endif //........................................................................ namespace svt { namespace table @@ -79,12 +75,15 @@ namespace svt { namespace table { protected: RowPos m_nRowPos; + bool m_bAllowVirtualRows; public: TableRowGeometry( - const TableControl_Impl& _rControl, - const Rectangle& _rBoundaries, - RowPos _nRow + TableControl_Impl const & _rControl, + Rectangle const & _rBoundaries, + RowPos const _nRow, + bool const i_allowVirtualRows = false + // allow rows >= getRowCount()? ); // status @@ -93,7 +92,8 @@ namespace svt { namespace table bool moveDown(); private: - void impl_initRect(); + void impl_initRect(); + bool impl_isValidRow( RowPos const i_row ) const; }; //==================================================================== @@ -103,12 +103,14 @@ namespace svt { namespace table { protected: ColPos m_nColPos; + bool m_bAllowVirtualColumns; public: TableColumnGeometry( - const TableControl_Impl& _rControl, - const Rectangle& _rBoundaries, - ColPos _nCol + TableControl_Impl const & _rControl, + Rectangle const & _rBoundaries, + ColPos const _nCol, + bool const i_allowVirtualColumns = false ); // status @@ -117,7 +119,8 @@ namespace svt { namespace table bool moveRight(); private: - void impl_initRect(); + void impl_initRect(); + bool impl_isValidColumn( ColPos const i_column ) const; }; //==================================================================== @@ -133,13 +136,14 @@ namespace svt { namespace table public: TableCellGeometry( - const TableControl_Impl& _rControl, - const Rectangle& _rBoundaries, - ColPos _nCol, - RowPos _nRow + TableControl_Impl const & _rControl, + Rectangle const & _rBoundaries, + ColPos const _nCol, + RowPos const _nRow, + bool const i_alllowVirtualCells = false ) - :m_aRow( _rControl, _rBoundaries, _nRow ) - ,m_aCol( _rControl, _rBoundaries, _nCol ) + :m_aRow( _rControl, _rBoundaries, _nRow, i_alllowVirtualCells ) + ,m_aCol( _rControl, _rBoundaries, _nCol, i_alllowVirtualCells ) { } -- cgit v1.2.3 From d41461c3de4108c5e09c64e30a38079b01217e96 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 09:50:02 +0100 Subject: gridsort: replaced RemoveSelectedRow by ClearSelection - the first implementation was buggy, anyway, and ClearSelection is the same as SelectAll( false ) (which was the only use case) --- svtools/inc/svtools/accessiblefactory.hxx | 15 ++++++++------- svtools/inc/svtools/accessibletable.hxx | 2 +- svtools/inc/svtools/table/tablecontrol.hxx | 13 ++++++------- svtools/source/table/tablecontrol.cxx | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) mode change 100755 => 100644 svtools/inc/svtools/accessibletable.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/accessiblefactory.hxx b/svtools/inc/svtools/accessiblefactory.hxx index 9606e93a2fa0..372af4fdca25 100755 --- a/svtools/inc/svtools/accessiblefactory.hxx +++ b/svtools/inc/svtools/accessiblefactory.hxx @@ -28,16 +28,12 @@ #ifndef SVTOOLS_ACCESSIBLE_FACTORY_HXX #define SVTOOLS_ACCESSIBLE_FACTORY_HXX -#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX +#include "AccessibleBrowseBoxObjType.hxx" +#include "accessibletableprovider.hxx" + #include -#endif -#ifndef _RTL_REF_HXX #include -#endif -#include "AccessibleBrowseBoxObjType.hxx" -#include "accessibletableprovider.hxx" -#include "accessibletable.hxx" namespace com { namespace sun { namespace star { namespace accessibility { @@ -64,6 +60,11 @@ namespace svt class ToolPanelDeck; class IToolPanelDeck; class PanelTabBar; + namespace table + { + class IAccessibleTable; + class IAccessibleTableControl; + } /** a function which is able to create a factory for the standard Accessible/Context components needed for standard toolkit controls diff --git a/svtools/inc/svtools/accessibletable.hxx b/svtools/inc/svtools/accessibletable.hxx old mode 100755 new mode 100644 index 8ff17a2b71c7..e332c8a46ad5 --- a/svtools/inc/svtools/accessibletable.hxx +++ b/svtools/inc/svtools/accessibletable.hxx @@ -123,7 +123,7 @@ public: virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const = 0; virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0; virtual std::vector& GetSelectedRows() = 0; - virtual void RemoveSelectedRow(sal_Int32 _nRowPos) = 0; + virtual void ClearSelection() = 0; virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0; }; diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 5671c7607281..2ba571542de4 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -28,12 +28,13 @@ #define SVTOOLS_INC_TABLE_TABLECONTROL_HXX #include "svtools/svtdllapi.h" -#include +#include "svtools/table/tablemodel.hxx" +#include "svtools/table/tabledatawindow.hxx" +#include "svtools/accessibletable.hxx" +#include "svtools/accessiblefactory.hxx" + #include #include -#include -#include -#include #include #include @@ -65,8 +66,6 @@ namespace svt { namespace table The control supports the concept of a current (or active cell). The control supports accessibility, this is encapsulated in IAccessibleTable - - // TODO: scrolling? */ class SVT_DLLPUBLIC TableControl : public Control, public IAccessibleTable { @@ -207,7 +206,7 @@ namespace svt { namespace table virtual sal_Bool HasRowHeader(); virtual sal_Bool HasColHeader(); virtual ::std::vector< sal_Int32 >& GetSelectedRows(); - virtual void RemoveSelectedRow(RowPos _nRowPos); + virtual void ClearSelection(); virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; // ............................................................................................................. diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 7a1b9f450e09..4fb3c8efc117 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -242,9 +242,9 @@ namespace svt { namespace table } // ----------------------------------------------------------------------------------------------------------------- - void TableControl::RemoveSelectedRow(RowPos _nRowPos) + void TableControl::ClearSelection() { - m_pImpl->removeSelectedRow(_nRowPos); + SelectAll( false ); } // ----------------------------------------------------------------------------------------------------------------- -- cgit v1.2.3 From dfe2edc22c03fc4b0f536749cdf9550412ef7e89 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 11:04:24 +0100 Subject: gridsort: ouch. Removed IAccessibleTable::GetSelectedRows. It exposed an internal implementation detail, and in fact some clients (the A11Y API implementation) exploited this, e.g. by simply adding elements to the array, without the owner (the TableControl/_Impl) ever noticing it. Replaced that with a working API. In this course, removed XGridSelection::getMin/MaxSelectionIndex. Pretty useless IMO, unused, and ugly to implement. --- svtools/inc/svtools/accessibletable.hxx | 10 +++-- svtools/inc/svtools/table/tablecontrol.hxx | 13 +++--- svtools/source/table/tablecontrol.cxx | 44 +++++++++---------- svtools/source/table/tablecontrol_impl.cxx | 41 ++++-------------- svtools/source/table/tablecontrol_impl.hxx | 8 +--- svtools/source/table/tabledatawindow.cxx | 5 +-- svtools/source/uno/svtxgridcontrol.cxx | 63 ++++++---------------------- svtools/source/uno/svtxgridcontrol.hxx | 2 - toolkit/source/controls/grid/gridcontrol.cxx | 12 ------ toolkit/source/controls/grid/gridcontrol.hxx | 2 - 10 files changed, 53 insertions(+), 147 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/accessibletable.hxx b/svtools/inc/svtools/accessibletable.hxx index e332c8a46ad5..dfa5a603fc5d 100644 --- a/svtools/inc/svtools/accessibletable.hxx +++ b/svtools/inc/svtools/accessibletable.hxx @@ -109,8 +109,6 @@ public: virtual long GetRowCount() const= 0; virtual long GetColumnCount() const= 0; virtual sal_Bool HasRowHeader() const= 0; - virtual sal_Int32 GetSelectedRowCount() const= 0; - virtual bool IsRowSelected( long _nRow ) const= 0; virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint )= 0; virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, BOOL _bOnScreen = TRUE ) = 0; virtual Rectangle calcTableRect( BOOL _bOnScreen = TRUE ) = 0; @@ -122,9 +120,13 @@ public: virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const = 0; virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const = 0; virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0; - virtual std::vector& GetSelectedRows() = 0; - virtual void ClearSelection() = 0; virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0; + + virtual sal_Int32 GetSelectedRowCount() const = 0; + virtual sal_Int32 GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const = 0; + virtual bool IsRowSelected( sal_Int32 const i_rowIndex ) const = 0; + virtual void SelectRow( sal_Int32 const i_rowIndex, bool const i_select ) = 0; + virtual void SelectAllRows( bool const i_select ) = 0; }; // ---------------------------------------------------------------------------- diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 2ba571542de4..4077f9fc053a 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -190,8 +190,6 @@ namespace svt { namespace table virtual long GetRowCount() const; virtual long GetColumnCount() const; virtual sal_Bool HasRowHeader() const; - virtual sal_Int32 GetSelectedRowCount() const; - virtual bool IsRowSelected( long _nRow ) const; virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ); virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, BOOL _bOnScreen = TRUE ); virtual Rectangle calcTableRect( BOOL _bOnScreen = TRUE ); @@ -205,13 +203,14 @@ namespace svt { namespace table virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const; virtual sal_Bool HasRowHeader(); virtual sal_Bool HasColHeader(); - virtual ::std::vector< sal_Int32 >& GetSelectedRows(); - virtual void ClearSelection(); virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; - // ............................................................................................................. - void SelectRow( RowPos const i_rowIndex, bool const i_select ); - void SelectAll( bool const i_select ); + virtual sal_Int32 GetSelectedRowCount() const; + virtual sal_Int32 GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const; + virtual bool IsRowSelected( sal_Int32 const i_rowIndex ) const; + virtual void SelectRow( sal_Int32 const i_rowIndex, bool const i_select ); + virtual void SelectAllRows( bool const i_select ); + // ............................................................................................................. private: DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* ); diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 4fb3c8efc117..46f3735e054c 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -186,6 +186,24 @@ namespace svt { namespace table return m_pImpl->goTo( _nColPos, _nRowPos ); } + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 TableControl::GetSelectedRowCount() const + { + return sal_Int32( m_pImpl->getSelectedRowCount() ); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 TableControl::GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const + { + return sal_Int32( m_pImpl->getSelectedRowIndex( i_selectionIndex ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + bool TableControl::IsRowSelected( sal_Int32 const i_rowIndex ) const + { + return m_pImpl->isRowSelected( i_rowIndex ); + } + // ----------------------------------------------------------------------------------------------------------------- void TableControl::SelectRow( RowPos const i_rowIndex, bool const i_select ) { @@ -208,7 +226,7 @@ namespace svt { namespace table } // ----------------------------------------------------------------------------------------------------------------- - void TableControl::SelectAll( bool const i_select ) + void TableControl::SelectAllRows( bool const i_select ) { if ( i_select ) { @@ -235,18 +253,6 @@ namespace svt { namespace table m_pImpl->invalidateRowRange( i_firstRow, i_lastRow ); } - // ----------------------------------------------------------------------------------------------------------------- - std::vector& TableControl::GetSelectedRows() - { - return m_pImpl->getSelectedRows(); - } - - // ----------------------------------------------------------------------------------------------------------------- - void TableControl::ClearSelection() - { - SelectAll( false ); - } - // ----------------------------------------------------------------------------------------------------------------- ITableControl& TableControl::getTableControlInterface() { @@ -518,18 +524,6 @@ namespace svt { namespace table return GetModel()->hasRowHeaders(); } - //------------------------------------------------------------------------------------------------------------------ - sal_Int32 TableControl::GetSelectedRowCount() const - { - return sal_Int32( m_pImpl->getSelectedRowCount() ); - } - - //------------------------------------------------------------------------------------------------------------------ - bool TableControl::IsRowSelected( long _nRow ) const - { - return m_pImpl->isRowSelected( _nRow ); - } - //------------------------------------------------------------------------------------------------------------------ sal_Bool TableControl::ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ) { diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 3c7cb555f374..932dde9a23e7 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -1910,40 +1910,7 @@ namespace svt { namespace table m_pDataWindow->Invalidate( aInvalidateRect ); } - //------------------------------------------------------------------------------------------------------------------ - - std::vector& TableControl_Impl::getSelectedRows() - { - return m_aSelectedRows; - } - //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::removeSelectedRow(RowPos _nRowPos) - { - int i =0; - //if the row is selected, remove it from the selection vector - if ( isRowSelected( _nRowPos ) ) - { - if(m_aSelectedRows.size()>1) - m_aSelectedRows.erase(m_aSelectedRows.begin()+_nRowPos); - else - m_aSelectedRows.clear(); - } - //after removing a row, row positions must be updated, so selected rows could stay selected - if(m_aSelectedRows.size()>1) - { - for(std::vector::iterator it=m_aSelectedRows.begin();it!=m_aSelectedRows.end();++it) - { - if(*it > _nRowPos) - m_aSelectedRows[i]=*it-1; - ++i; - } - } - if(_nRowPos == 0) - m_nCurRow = 0; - else - m_nCurRow = _nRowPos-1; - } //------------------------------------------------------------------------------ void TableControl_Impl::checkCursorPosition() { @@ -2220,6 +2187,14 @@ namespace svt { namespace table return ::std::find( m_aSelectedRows.begin(), m_aSelectedRows.end(), i_row ) != m_aSelectedRows.end(); } + //------------------------------------------------------------------------------------------------------------------ + RowPos TableControl_Impl::getSelectedRowIndex( size_t const i_selectionIndex ) const + { + if ( i_selectionIndex < m_aSelectedRows.size() ) + return m_aSelectedRows[ i_selectionIndex ]; + return ROW_INVALID; + } + //------------------------------------------------------------------------------------------------------------------ int TableControl_Impl::getRowSelectedNumber(const ::std::vector& selectedRows, RowPos current) { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 9dfdaedc29f8..bebe6e2e18ef 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -245,17 +245,11 @@ namespace svt { namespace table */ void invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow ); - /** returns the vector, which contains the selected rows*/ - std::vector& getSelectedRows(); - - /** updates the vector, which contains the selected rows after removing the row nRowPos*/ - void removeSelectedRow(RowPos _nRowPos); - - void checkCursorPosition(); bool hasRowSelection() const { return !m_aSelectedRows.empty(); } size_t getSelectedRowCount() const { return m_aSelectedRows.size(); } + RowPos getSelectedRowIndex( size_t const i_selectionIndex ) const; /** removes the given row index from m_aSelectedRows diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index ed7b3f8478b3..920fb3fcaada 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -168,16 +168,13 @@ namespace svt { namespace table { const Point aPoint = rMEvt.GetPosPixel(); const RowPos nCurRow = m_rTableControl.getRowAtPoint( aPoint ); - std::vector selectedRows(m_rTableControl.getSelectedRows()); if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) ) Window::MouseButtonDown( rMEvt ); else { if(nCurRow >= 0 && m_rTableControl.getSelEngine()->GetSelectionMode() != NO_SELECTION) { - bool found = std::find(selectedRows.begin(),selectedRows.end(), nCurRow) != selectedRows.end(); - - if( !found ) + if( !m_rTableControl.isRowSelected( nCurRow ) ) { m_aSelectHdl.Call( NULL ); } diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 123662da0221..e95becad8876 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -597,42 +597,6 @@ void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObj } //---------------------------------------------------------------------------------------------------------------------- -::sal_Int32 SAL_CALL SVTXGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN( pTable, "SVTXGridControl::getMinSelectionIndex: no control (anymore)!", -1 ); - - std::vector& selectedRows = pTable->GetSelectedRows(); - if(selectedRows.empty()) - return -1; - else - { - std::vector::iterator itStart = selectedRows.begin(); - std::vector::iterator itEnd = selectedRows.end(); - return *(std::min_element(itStart, itEnd)); - } -} - -::sal_Int32 SAL_CALL SVTXGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN( pTable, "SVTXGridControl::getMaxSelectionIndex: no control (anymore)!", -1 ); - - std::vector& selectedRows = pTable->GetSelectedRows(); - if(selectedRows.empty()) - return -1; - else - { - std::vector::iterator itStart = selectedRows.begin(); - std::vector::iterator itEnd = selectedRows.end(); - return *(std::max_element(itStart, itEnd)); - } -} - void SAL_CALL SVTXGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -650,7 +614,7 @@ void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::Run TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::selectAllRows: no control (anymore)!" ); - pTable->SelectAll( true ); + pTable->SelectAllRows( true ); } void SAL_CALL SVTXGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) @@ -670,7 +634,7 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::deselectAllRows: no control (anymore)!" ); - pTable->SelectAll( false ); + pTable->SelectAllRows( false ); } ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL SVTXGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) @@ -680,9 +644,11 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable, "SVTXGridControl::getSelection: no control (anymore)!", Sequence< sal_Int32 >() ); - std::vector& selectedRows = pTable->GetSelectedRows(); - Sequence selectedRowsToSequence(comphelper::containerToSequence(selectedRows)); - return selectedRowsToSequence; + sal_Int32 selectionCount = pTable->GetSelectedRowCount(); + Sequence< sal_Int32 > selectedRows( selectionCount ); + for ( sal_Int32 i=0; iGetSelectedRowIndex(i); + return selectedRows; } ::sal_Bool SAL_CALL SVTXGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) @@ -692,11 +658,7 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable, "SVTXGridControl::getSelection: no control (anymore)!", sal_True ); - std::vector& selectedRows = pTable->GetSelectedRows(); - if(selectedRows.empty()) - return sal_True; - else - return sal_False; + return pTable->GetSelectedRowCount() > 0; } ::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex( ::sal_Int32 index ) throw (::com::sun::star::uno::RuntimeException) @@ -746,23 +708,22 @@ void SVTXGridControl::ImplCallItemListeners() if ( m_aSelectionListeners.getLength() ) { - ::std::vector selRows = pTable->GetSelectedRows(); + sal_Int32 const actSelRowCount = pTable->GetSelectedRowCount(); ::com::sun::star::awt::grid::GridSelectionEvent aEvent; aEvent.Source = (::cppu::OWeakObject*)this; aEvent.Column = 0; - sal_Int32 actSelRowCount = selRows.size(); sal_Int32 diff = actSelRowCount - m_nSelectedRowCount; //row added to selection if(diff >= 1) { aEvent.Action = com::sun::star::awt::grid::SelectionEventType(0); - aEvent.Row = selRows[actSelRowCount-1]; + aEvent.Row = pTable->GetSelectedRowIndex( actSelRowCount - 1 ); aEvent.Range = diff; } //selected row changed else if(diff == 0 && actSelRowCount != 0) { - aEvent.Row = selRows[actSelRowCount-1]; + aEvent.Row = pTable->GetSelectedRowIndex( actSelRowCount - 1 ); aEvent.Action = com::sun::star::awt::grid::SelectionEventType(2); aEvent.Range = 0; } @@ -771,7 +732,7 @@ void SVTXGridControl::ImplCallItemListeners() //selection changed: multiple row deselected, only 1 row is selected if(actSelRowCount == 1) { - aEvent.Row = selRows[actSelRowCount-1]; + aEvent.Row = pTable->GetSelectedRowIndex( actSelRowCount - 1 ); aEvent.Action = com::sun::star::awt::grid::SelectionEventType(2); } //row is deselected diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index fa554664b2c0..7ac53ecd4cba 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -85,8 +85,6 @@ public: virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); // XGridSelection - virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); 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); diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index b9cab5a18cf0..14faa851400a 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -359,18 +359,6 @@ sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_ return xGrid->getCurrentRow(); } -//---------------------------------------------------------------------------------------------------------------------- -::sal_Int32 SAL_CALL UnoGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) -{ - return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMinSelectionIndex(); -} - -//---------------------------------------------------------------------------------------------------------------------- -::sal_Int32 SAL_CALL UnoGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException) -{ - return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMaxSelectionIndex(); -} - //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index 5259711e97d6..61d9f8fc0232 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -103,8 +103,6 @@ public: virtual ::sal_Int32 SAL_CALL getCurrentRow( ) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridSelection - virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); 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); -- cgit v1.2.3 From b7f4e6a2d6725a6a0b9c415996d035da7e37cb7b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 11:07:02 +0100 Subject: gridsort: respect runtime-changes of the table metrics (in the UNO control model) --- svtools/inc/svtools/table/tablemodel.hxx | 7 +++++ svtools/source/table/tablecontrol_impl.cxx | 28 ++++++++++++----- svtools/source/table/tablecontrol_impl.hxx | 5 +++ svtools/source/uno/unocontroltablemodel.cxx | 49 +++++++++++++++++++---------- svtools/source/uno/unocontroltablemodel.hxx | 26 +++++---------- 5 files changed, 72 insertions(+), 43 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 83054b5d0a57..026b792c39e8 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -153,6 +153,13 @@ namespace svt { namespace table */ virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ) = 0; + /** notifies the listener that the metrics of the table changed. + + Metrics here include the column header height, the row header width, the row height, and the presence + of both the row and column header. + */ + virtual void tableMetricsChanged() = 0; + /// deletes the listener instance virtual ~ITableModelListener(){}; }; diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 932dde9a23e7..af3f1c768273 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -661,6 +661,14 @@ namespace svt { namespace table OSL_UNUSED( lastRow ); } + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::tableMetricsChanged() + { + impl_ni_updateCachedTableMetrics(); + impl_ni_updateScrollbars(); + m_rAntiImpl.Invalidate(); + } + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_invalidateColumn( ColPos const i_column ) { @@ -744,20 +752,26 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::impl_ni_updateCachedModelValues() + void TableControl_Impl::impl_ni_updateCachedTableMetrics() { - m_nRowHeightPixel = 15; - m_nColHeaderHeightPixel = 0; - m_nRowHeaderWidthPixel = 0; - m_pInputHandler.reset(); - m_nColumnCount = m_nRowCount = 0; - m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_APPFONT ).Height(); + + m_nColHeaderHeightPixel = 0; if ( m_pModel->hasColumnHeaders() ) m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_APPFONT ).Height(); + + m_nRowHeaderWidthPixel = 0; if ( m_pModel->hasRowHeaders() ) m_nRowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT).Width(); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::impl_ni_updateCachedModelValues() + { + m_pInputHandler.reset(); + m_nColumnCount = m_nRowCount = 0; + impl_ni_updateCachedTableMetrics(); impl_ni_updateColumnWidths(); m_pInputHandler = m_pModel->getInputHandler(); diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index bebe6e2e18ef..721847caaf7b 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -317,6 +317,7 @@ namespace svt { namespace table virtual void allColumnsRemoved(); virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ); virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ); + virtual void tableMetricsChanged(); private: bool impl_isAccessibleAlive() const; @@ -366,6 +367,10 @@ namespace svt { namespace table */ void impl_ni_updateCachedModelValues(); + /** updates the cached table metrics (row height etc.) + */ + void impl_ni_updateCachedTableMetrics(); + /** updates ->m_aColumnWidthsPixel with the current pixel widths of all model columns The method takes into account the current zoom factor and map mode of the table diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 653c2e46a427..75e58bcdf03c 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -212,14 +212,22 @@ namespace svt { namespace table void UnoControlTableModel::setRowHeaders(bool _bRowHeaders) { DBG_CHECK_ME(); + if ( m_pImpl->bHasRowHeaders == _bRowHeaders ) + return; + m_pImpl->bHasRowHeaders = _bRowHeaders; + impl_notifyTableMetricsChanged(); } //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setColumnHeaders(bool _bColumnHeaders) { DBG_CHECK_ME(); + if ( m_pImpl->bHasColumnHeaders == _bColumnHeaders ) + return; + m_pImpl->bHasColumnHeaders = _bColumnHeaders; + impl_notifyTableMetricsChanged(); } //------------------------------------------------------------------------------------------------------------------ @@ -329,6 +337,19 @@ namespace svt { namespace table } } + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::impl_notifyTableMetricsChanged() const + { + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->tableMetricsChanged(); + } + } + //------------------------------------------------------------------------------------------------------------------ PTableRenderer UnoControlTableModel::getRenderer() const { @@ -354,7 +375,11 @@ namespace svt { namespace table void UnoControlTableModel::setRowHeight(TableMetrics _nRowHeight) { DBG_CHECK_ME(); + if ( m_pImpl->nRowHeight == _nRowHeight ) + return; + m_pImpl->nRowHeight = _nRowHeight; + impl_notifyTableMetricsChanged(); } //------------------------------------------------------------------------------------------------------------------ @@ -376,32 +401,22 @@ namespace svt { namespace table void UnoControlTableModel::setColumnHeaderHeight(TableMetrics _nHeight) { DBG_CHECK_ME(); + if ( m_pImpl->nColumnHeaderHeight == _nHeight ) + return; + m_pImpl->nColumnHeaderHeight = _nHeight; + impl_notifyTableMetricsChanged(); } //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::setRowHeaderWidth(TableMetrics _nWidth) { DBG_CHECK_ME(); - m_pImpl->nRowHeaderWidth = _nWidth; - } - - //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::SetTitleHeight( TableMetrics _nHeight ) - { - DBG_CHECK_ME(); - DBG_ASSERT( _nHeight > 0, "DefaultTableModel::SetTitleHeight: invalid height value!" ); - m_pImpl->nColumnHeaderHeight = _nHeight; - // TODO: notification - } + if ( m_pImpl->nRowHeaderWidth == _nWidth ) + return; - //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::SetHandleWidth( TableMetrics _nWidth ) - { - DBG_CHECK_ME(); - DBG_ASSERT( _nWidth > 0, "DefaultTableModel::SetHandleWidth: invalid width value!" ); m_pImpl->nRowHeaderWidth = _nWidth; - // TODO: notification + impl_notifyTableMetricsChanged(); } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index c38d9ed694e2..f89419ac071f 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -66,25 +66,6 @@ namespace svt { namespace table UnoControlTableModel(); ~UnoControlTableModel(); - /// returns the current row height, in 1/100 millimeters - inline TableMetrics GetRowHeight() const { return getRowHeight(); } - /// sets a new row height. - void setRowHeight( TableMetrics _nHeight ); - /// sets a new row header width. - void setRowHeaderWidth( TableMetrics _nWidth ); - /// sets a new column header height. - void setColumnHeaderHeight( TableMetrics _nHeight ); - - /// returns the height of the title row (containing the column headers) - inline TableMetrics GetTitleHeight() const { return getColumnHeaderHeight(); } - /// sets a new height for the title row (containing the column headers) - void SetTitleHeight( TableMetrics _nHeight ); - - /// returns the width of the handle column (containing the row headers) - inline TableMetrics GetHandleWidth() const { return getRowHeaderWidth(); } - /// sets a new width for the handle column (containing the row headers) - void SetHandleWidth( TableMetrics _nWidth ); - public: // ITableModel overridables virtual TableSize getColumnCount() const; @@ -137,6 +118,10 @@ namespace svt { namespace table void setRowHeaders(bool _bRowHeaders); void setColumnHeaders(bool _bColumnHeaders); + void setRowHeight( TableMetrics _nHeight ); + void setRowHeaderWidth( TableMetrics _nWidth ); + void setColumnHeaderHeight( TableMetrics _nHeight ); + void setLineColor( ::com::sun::star::uno::Any const & i_color ); void setHeaderBackgroundColor( ::com::sun::star::uno::Any const & i_color ); void setHeaderTextColor( ::com::sun::star::uno::Any const & i_color ); @@ -159,6 +144,9 @@ namespace svt { namespace table #ifdef DBG_UTIL const char* checkInvariants() const; #endif + + private: + void impl_notifyTableMetricsChanged() const; }; // ..................................................................................................................... -- cgit v1.2.3 From b6d8855706f5048082ab60467d1460ee3658ce19 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 11:28:11 +0100 Subject: gridsort: added runtime-checks (non-pro only) for consistency of m_aColumnWidths --- svtools/source/table/tablecontrol_impl.cxx | 35 ++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index af3f1c768273..484a3e3ca248 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -351,10 +351,27 @@ namespace svt { namespace table return "row header widths are inconsistent!"; } - // TODO: check m_aColumnWidths - // - for each element, getStart <= getEnd() - // - for each i: col[ i ].getEnd() == col[ i+1 ].getStart() - // - col[ m_nLeftColumn ].getStart == m_nRowHeaderWidthPixel + // m_aColumnWidths consistency + if ( size_t( m_nColumnCount ) != m_aColumnWidths.size() ) + return "wrong number of cached column widths"; + + for ( ColumnPositions::const_iterator col = m_aColumnWidths.begin(); + col != m_aColumnWidths.end(); + ) + { + if ( col->getEnd() < col->getStart() ) + return "column widths: 'end' is expected to not be smaller than start"; + + ColumnPositions::const_iterator nextCol = col + 1; + if ( nextCol != m_aColumnWidths.end() ) + if ( col->getEnd() != nextCol->getStart() ) + return "column widths: one column's end should be the next column's start"; + col = nextCol; + } + + if ( m_nLeftColumn < m_nColumnCount ) + if ( m_aColumnWidths[ m_nLeftColumn ].getStart() != m_nRowHeaderWidthPixel ) + return "the left-most column should start immediately after the row header"; if ( m_nCursorHidden < 0 ) return "invalid hidden count for the cursor!"; @@ -1128,14 +1145,14 @@ namespace svt { namespace table // position it if ( m_pHScroll ) { - TableSize nVisibleUnits = lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false ); - int nRange = m_nColumnCount; - if( m_nLeftColumn + nVisibleUnits == nRange-1) + TableSize const nVisibleUnits = lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false ); + TableMetrics const nRange = m_nColumnCount; + if( m_nLeftColumn + nVisibleUnits == nRange - 1 ) { - if ( m_aColumnWidths[ nRange-2 ].getEnd() - m_aColumnWidths[ m_nLeftColumn ].getEnd() + m_aColumnWidths[ nRange-1 ].getWidth() > aDataCellPlayground.GetWidth() ) + if ( m_aColumnWidths[ nRange - 1 ].getStart() - m_aColumnWidths[ m_nLeftColumn ].getEnd() + m_aColumnWidths[ nRange-1 ].getWidth() > aDataCellPlayground.GetWidth() ) { m_pHScroll->SetVisibleSize( nVisibleUnits -1 ); - m_pHScroll->SetPageSize(nVisibleUnits -1); + m_pHScroll->SetPageSize( nVisibleUnits - 1 ); } } Rectangle aScrollbarArea( -- cgit v1.2.3 From 13cbe08da83e43ab876418f9eb6061b67416002c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 11:31:43 +0100 Subject: gridsort: fix calculation of auto-alternating-color: Do not adjust towards WHITE, but towards the color of the other rows --- svtools/source/table/gridtablerenderer.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 35220576e5c0..8fc95c203b7a 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -256,17 +256,17 @@ namespace svt { namespace table if ( !aRowColors ) { // use alternating default colors - if ( ( m_pImpl->nCurrentRow % 2 ) == 0 ) + Color const fieldColor = _rStyle.GetFieldColor(); + if ( _rStyle.GetHighContrastMode() || ( ( m_pImpl->nCurrentRow % 2 ) == 0 ) ) { - backgroundColor = _rStyle.GetFieldColor(); + backgroundColor = fieldColor; } else { Color hilightColor = _rStyle.GetHighlightColor(); - USHORT const luminance = hilightColor.GetLuminance(); - hilightColor.SetRed( 9 * ( 255 - hilightColor.GetRed() ) / 10 + hilightColor.GetRed() ); - hilightColor.SetGreen( 9 * ( 255 - hilightColor.GetGreen() ) / 10 + hilightColor.GetGreen() ); - hilightColor.SetBlue( 9 * ( 255 - hilightColor.GetBlue() ) / 10 + hilightColor.GetBlue() ); + hilightColor.SetRed( 9 * ( fieldColor.GetRed() - hilightColor.GetRed() ) / 10 + hilightColor.GetRed() ); + hilightColor.SetGreen( 9 * ( fieldColor.GetGreen() - hilightColor.GetGreen() ) / 10 + hilightColor.GetGreen() ); + hilightColor.SetBlue( 9 * ( fieldColor.GetBlue() - hilightColor.GetBlue() ) / 10 + hilightColor.GetBlue() ); backgroundColor = hilightColor; } } -- cgit v1.2.3 From acaf4f1d75540acd79b7380c7f0ade4e04b75bd8 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 11:44:35 +0100 Subject: gridsort: moved tabledatawindow from svtools/inc/svtools to svtools/source/table - this is not a public file, after all --- svtools/inc/svtools/table/tablecontrol.hxx | 6 +- svtools/inc/svtools/table/tabledatawindow.hxx | 87 --------------------------- svtools/source/table/defaultinputhandler.cxx | 3 +- svtools/source/table/tablecontrol.cxx | 7 ++- svtools/source/table/tablecontrol_impl.cxx | 2 +- svtools/source/table/tabledatawindow.cxx | 2 +- svtools/source/table/tabledatawindow.hxx | 87 +++++++++++++++++++++++++++ 7 files changed, 97 insertions(+), 97 deletions(-) delete mode 100644 svtools/inc/svtools/table/tabledatawindow.hxx create mode 100644 svtools/source/table/tabledatawindow.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 4077f9fc053a..a5360145bc46 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -29,7 +29,6 @@ #include "svtools/svtdllapi.h" #include "svtools/table/tablemodel.hxx" -#include "svtools/table/tabledatawindow.hxx" #include "svtools/accessibletable.hxx" #include "svtools/accessiblefactory.hxx" @@ -46,7 +45,6 @@ namespace svt { namespace table //........................................................................ class TableControl_Impl; - class TableDataWindow; //==================================================================== //= TableControl @@ -159,8 +157,8 @@ namespace svt { namespace table /**after removing a row, updates the vector which contains the selected rows if the row, which should be removed, is selected, it will be erased from the vector */ - SelectionEngine* getSelEngine(); - TableDataWindow& getDataWindow(); + SelectionEngine* getSelEngine(); + Window& getDataWindow(); // Window overridables virtual void GetFocus(); diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/inc/svtools/table/tabledatawindow.hxx deleted file mode 100644 index 1cc030be512b..000000000000 --- a/svtools/inc/svtools/table/tabledatawindow.hxx +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************* - * 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 - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * -************************************************************************/ - -#ifndef SVTOOLS_SOURCE_TABLE_TABLEDATAWINDOW_HXX -#define SVTOOLS_SOURCE_TABLE_TABLEDATAWINDOW_HXX - -#ifndef _SV_WINDOW_HXX -#include -#endif -#include - -//........................................................................ -namespace svt { namespace table -{ -//........................................................................ - - class TableControl_Impl; - class TableFunctionSet; - - - //==================================================================== - //= TableDataWindow - //==================================================================== - /** the window containing the content area (including headers) of - a table control - */ - class TableDataWindow : public Window - { - friend class TableFunctionSet; - private: - TableControl_Impl& m_rTableControl; - Link m_aMouseButtonDownHdl; - Link m_aMouseButtonUpHdl; - Link m_aSelectHdl; - public: - TableDataWindow( TableControl_Impl& _rTableControl ); - inline void SetMouseButtonDownHdl( const Link& rLink ) { m_aMouseButtonDownHdl = rLink; } - inline const Link& GetMouseButtonDownHdl() const { return m_aMouseButtonDownHdl; } - inline void SetMouseButtonUpHdl( const Link& rLink ) { m_aMouseButtonUpHdl = rLink; } - inline const Link& GetMouseButtonUpHdl() const { return m_aMouseButtonUpHdl; } - inline void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } - inline const Link& GetSelectHdl() const { return m_aSelectHdl; } - - // Window overridables - virtual void Paint( const Rectangle& rRect ); - virtual void MouseMove( const MouseEvent& rMEvt); - virtual void MouseButtonDown( const MouseEvent& rMEvt); - virtual void MouseButtonUp( const MouseEvent& rMEvt); - virtual void SetPointer( const Pointer& rPointer ); - virtual void CaptureMouse(); - virtual void ReleaseMouse(); - virtual long Notify(NotifyEvent& rNEvt); - virtual void SetControlBackground(const Color& rColor); - virtual void SetControlBackground(); - virtual void RequestHelp( const HelpEvent& rHEvt ); - - void SetBackground(const Wallpaper& rColor); - void SetBackground(); - }; -//........................................................................ -} } // namespace svt::table -//........................................................................ - -#endif // SVTOOLS_SOURCE_TABLE_TABLEDATAWINDOW_HXX diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index e8e4c3e178d0..9b28860ca0ae 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -30,10 +30,11 @@ #include "svtools/table/defaultinputhandler.hxx" #include "svtools/table/tablecontrolinterface.hxx" +#include "tabledatawindow.hxx" + #include #include #include -#include "svtools/table/tabledatawindow.hxx" //........................................................................ namespace svt { namespace table diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 46f3735e054c..500b2ca423e9 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -27,10 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svtools.hxx" +#include "svtools/table/tablecontrol.hxx" + #include "tablegeometry.hxx" #include "tablecontrol_impl.hxx" -#include "svtools/table/tablecontrol.hxx" -#include "svtools/table/tabledatawindow.hxx" +#include "tabledatawindow.hxx" #include #include @@ -266,7 +267,7 @@ namespace svt { namespace table } // ----------------------------------------------------------------------------------------------------------------- - TableDataWindow& TableControl::getDataWindow() + Window& TableControl::getDataWindow() { return m_pImpl->getDataWindow(); } diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 484a3e3ca248..e7d781018f34 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -30,8 +30,8 @@ #include "svtools/table/tablecontrol.hxx" #include "svtools/table/defaultinputhandler.hxx" #include "svtools/table/tablemodel.hxx" -#include "svtools/table/tabledatawindow.hxx" +#include "tabledatawindow.hxx" #include "tablecontrol_impl.hxx" #include "tablegeometry.hxx" #include "cellvalueconversion.hxx" diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 920fb3fcaada..1b2106f6d7e0 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -28,8 +28,8 @@ #include "precompiled_svtools.hxx" #include "svtools/table/tablecontrol.hxx" -#include "svtools/table/tabledatawindow.hxx" +#include "tabledatawindow.hxx" #include "tablecontrol_impl.hxx" #include "tablegeometry.hxx" #include "cellvalueconversion.hxx" diff --git a/svtools/source/table/tabledatawindow.hxx b/svtools/source/table/tabledatawindow.hxx new file mode 100644 index 000000000000..1cc030be512b --- /dev/null +++ b/svtools/source/table/tabledatawindow.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_SOURCE_TABLE_TABLEDATAWINDOW_HXX +#define SVTOOLS_SOURCE_TABLE_TABLEDATAWINDOW_HXX + +#ifndef _SV_WINDOW_HXX +#include +#endif +#include + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + class TableControl_Impl; + class TableFunctionSet; + + + //==================================================================== + //= TableDataWindow + //==================================================================== + /** the window containing the content area (including headers) of + a table control + */ + class TableDataWindow : public Window + { + friend class TableFunctionSet; + private: + TableControl_Impl& m_rTableControl; + Link m_aMouseButtonDownHdl; + Link m_aMouseButtonUpHdl; + Link m_aSelectHdl; + public: + TableDataWindow( TableControl_Impl& _rTableControl ); + inline void SetMouseButtonDownHdl( const Link& rLink ) { m_aMouseButtonDownHdl = rLink; } + inline const Link& GetMouseButtonDownHdl() const { return m_aMouseButtonDownHdl; } + inline void SetMouseButtonUpHdl( const Link& rLink ) { m_aMouseButtonUpHdl = rLink; } + inline const Link& GetMouseButtonUpHdl() const { return m_aMouseButtonUpHdl; } + inline void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } + inline const Link& GetSelectHdl() const { return m_aSelectHdl; } + + // Window overridables + virtual void Paint( const Rectangle& rRect ); + virtual void MouseMove( const MouseEvent& rMEvt); + virtual void MouseButtonDown( const MouseEvent& rMEvt); + virtual void MouseButtonUp( const MouseEvent& rMEvt); + virtual void SetPointer( const Pointer& rPointer ); + virtual void CaptureMouse(); + virtual void ReleaseMouse(); + virtual long Notify(NotifyEvent& rNEvt); + virtual void SetControlBackground(const Color& rColor); + virtual void SetControlBackground(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + + void SetBackground(const Wallpaper& rColor); + void SetBackground(); + }; +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_SOURCE_TABLE_TABLEDATAWINDOW_HXX -- cgit v1.2.3 From d0cdc38a6771473b81f002da6769b7b723d657ff Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 12:23:42 +0100 Subject: gridsort: TableDataWindow: use Help::ShowTip instead of Help::ShowQuickHelp. This means it doesn't interfere with the "normal" quick help (which is a singleton really dedicated to, well, quickly displaying help). Also, it means we do not need the QUICKHELP_NO_DELAY flag. To prevent flickering when repeatedly showing such a tip, introduced Help::UpdateTip, which updates an existing tip, instead of destroying the old tip window, and creating a new one. Used this new UpdateTip also in the BrowseBox, means means some less flickering there, too. --- svtools/source/brwbox/datwin.cxx | 9 ++-- svtools/source/table/tabledatawindow.cxx | 73 +++++++++++++++++++++----------- svtools/source/table/tabledatawindow.hxx | 7 +++ vcl/inc/vcl/help.hxx | 4 ++ vcl/inc/vcl/helpwin.hxx | 1 + vcl/source/app/help.cxx | 23 +++++++--- 6 files changed, 84 insertions(+), 33 deletions(-) (limited to 'svtools') diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx index cb43e4989355..2c771f778d92 100644 --- a/svtools/source/brwbox/datwin.cxx +++ b/svtools/source/brwbox/datwin.cxx @@ -752,17 +752,18 @@ void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt ) ULONG nPos = GetThumbPos(); if ( nPos != _nLastPos ) { - if ( _nTip ) - Help::HideTip( _nTip ); - String aTip( String::CreateFromInt32(nPos) ); aTip += '/'; if ( _pDataWin->GetRealRowCount().Len() ) aTip += _pDataWin->GetRealRowCount(); else aTip += String::CreateFromInt32(GetRangeMax()); + Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) ); - _nTip = Help::ShowTip( this, aRect, aTip ); + if ( _nTip ) + Help::UpdateTip( _nTip, this, aRect, aTip ); + else + _nTip = Help::ShowTip( this, aRect, aTip ); _nLastPos = nPos; } diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 1b2106f6d7e0..56be34897fe2 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -36,22 +36,23 @@ #include -//........................................................................ +//...................................................................................................................... namespace svt { namespace table { -//........................................................................ +//...................................................................................................................... /** === begin UNO using === **/ using ::com::sun::star::uno::Any; /** === end UNO using === **/ - //==================================================================== + //================================================================================================================== //= TableDataWindow - //==================================================================== - //-------------------------------------------------------------------- + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl ) :Window( &_rTableControl.getAntiImpl() ) ,m_rTableControl( _rTableControl ) + ,m_nTipWindowHandle( 0 ) { // by default, use the background as determined by the style settings const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() ); @@ -59,33 +60,39 @@ namespace svt { namespace table SetFillColor( aWindowColor ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + TableDataWindow::~TableDataWindow() + { + impl_hideTipWindow(); + } + + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::Paint( const Rectangle& rUpdateRect ) { m_rTableControl.doPaintContent( rUpdateRect ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::SetBackground( const Wallpaper& rColor ) { Window::SetBackground( rColor ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::SetControlBackground( const Color& rColor ) { Window::SetControlBackground( rColor ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::SetBackground() { Window::SetBackground(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::SetControlBackground() { Window::SetControlBackground(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::RequestHelp( const HelpEvent& rHEvt ) { USHORT const nHelpMode = rHEvt.GetMode(); @@ -99,10 +106,10 @@ namespace svt { namespace table RowPos const hitRow = rTableControl.getRowAtPoint( aMousePos ); ColPos const hitCol = rTableControl.getColAtPoint( aMousePos ); + ::rtl::OUString sHelpText; + if ( ( hitCol >= 0 ) && ( hitCol < pTableModel->getColumnCount() ) ) { - ::rtl::OUString sHelpText; - if ( hitRow == ROW_COL_HEADERS ) { sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText(); @@ -131,14 +138,19 @@ namespace svt { namespace table sHelpText = CellValueConversion::convertToString( aCellToolTip ); } + } + if ( sHelpText.getLength() ) + { Rectangle const aControlScreenRect( OutputToScreenPixel( Point( 0, 0 ) ), GetOutputSizePixel() ); - Help::ShowQuickHelp( this, aControlScreenRect, sHelpText, String(), QUICKHELP_FORCE_REPOSITION | QUICKHELP_NO_DELAY ); - // also do this when the help text is empty - in this case, a previously active tip help window - // (possible displaying the tooltip for another cell) will be hidden, which is intended here. + + if ( m_nTipWindowHandle ) + Help::UpdateTip( m_nTipWindowHandle, this, aControlScreenRect, sHelpText ); + else + m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText ); } } else @@ -147,9 +159,22 @@ namespace svt { namespace table } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void TableDataWindow::impl_hideTipWindow() + { + if ( m_nTipWindowHandle != 0 ) + { + Help::HideTip( m_nTipWindowHandle ); + m_nTipWindowHandle = 0; + } + } + + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::MouseMove( const MouseEvent& rMEvt ) { + if ( rMEvt.IsLeaveWindow() ) + impl_hideTipWindow(); + Point aPoint = rMEvt.GetPosPixel(); if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) ) { @@ -163,7 +188,7 @@ namespace svt { namespace table } } } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt ) { const Point aPoint = rMEvt.GetPosPixel(); @@ -182,7 +207,7 @@ namespace svt { namespace table } m_aMouseButtonDownHdl.Call((MouseEvent*) &rMEvt); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::MouseButtonUp( const MouseEvent& rMEvt ) { if ( !m_rTableControl.getInputHandler()->MouseButtonUp( m_rTableControl, rMEvt ) ) @@ -190,17 +215,17 @@ namespace svt { namespace table m_aMouseButtonUpHdl.Call((MouseEvent*) &rMEvt); m_rTableControl.getAntiImpl().GrabFocus(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::SetPointer( const Pointer& rPointer ) { Window::SetPointer(rPointer); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::CaptureMouse() { Window::CaptureMouse(); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::ReleaseMouse( ) { Window::ReleaseMouse(); @@ -223,6 +248,6 @@ namespace svt { namespace table } return nDone ? nDone : Window::Notify( rNEvt ); } -//........................................................................ +//...................................................................................................................... } } // namespace svt::table -//........................................................................ +//...................................................................................................................... diff --git a/svtools/source/table/tabledatawindow.hxx b/svtools/source/table/tabledatawindow.hxx index 1cc030be512b..45ffec92c286 100644 --- a/svtools/source/table/tabledatawindow.hxx +++ b/svtools/source/table/tabledatawindow.hxx @@ -55,8 +55,12 @@ namespace svt { namespace table Link m_aMouseButtonDownHdl; Link m_aMouseButtonUpHdl; Link m_aSelectHdl; + ULONG m_nTipWindowHandle; + public: TableDataWindow( TableControl_Impl& _rTableControl ); + ~TableDataWindow(); + inline void SetMouseButtonDownHdl( const Link& rLink ) { m_aMouseButtonDownHdl = rLink; } inline const Link& GetMouseButtonDownHdl() const { return m_aMouseButtonDownHdl; } inline void SetMouseButtonUpHdl( const Link& rLink ) { m_aMouseButtonUpHdl = rLink; } @@ -79,6 +83,9 @@ namespace svt { namespace table void SetBackground(const Wallpaper& rColor); void SetBackground(); + + private: + void impl_hideTipWindow(); }; //........................................................................ } } // namespace svt::table diff --git a/vcl/inc/vcl/help.hxx b/vcl/inc/vcl/help.hxx index 4fb039b25bec..a43b0fe84862 100644 --- a/vcl/inc/vcl/help.hxx +++ b/vcl/inc/vcl/help.hxx @@ -118,6 +118,10 @@ public: static ULONG ShowTip( Window* pParent, const Rectangle& rScreenRect, const XubString& rText, USHORT nStyle = 0 ); + static void UpdateTip( ULONG nId, + Window* pParent, + const Rectangle& rScreenRect, + const XubString& rText ); static void HideTip( ULONG nId ); }; diff --git a/vcl/inc/vcl/helpwin.hxx b/vcl/inc/vcl/helpwin.hxx index 244ae1b7d846..799685251e02 100644 --- a/vcl/inc/vcl/helpwin.hxx +++ b/vcl/inc/vcl/helpwin.hxx @@ -66,6 +66,7 @@ public: const String& GetHelpText() const { return maHelpText; } void SetHelpText( const String& rHelpText ); USHORT GetWinStyle() const { return mnHelpWinStyle; } + USHORT GetStyle() const { return mnStyle; } // Nur merken: void SetStatusText( const String& rStatusText ) { maStatusText = rStatusText; } diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index 46f5e2132e5c..09650cee9231 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -36,6 +36,7 @@ #include "vcl/help.hxx" #include "vcl/helpwin.hxx" #include "tools/debug.hxx" +#include "tools/diagnose_ex.h" #include "tools/time.hxx" // ======================================================================= @@ -274,18 +275,30 @@ BOOL Help::ShowQuickHelp( Window* pParent, // ----------------------------------------------------------------------- -ULONG Help::ShowTip( Window* pParent, const Rectangle& rRect, +ULONG Help::ShowTip( Window* pParent, const Rectangle& rScreenRect, const XubString& rText, USHORT nStyle ) { USHORT nHelpWinStyle = HELPWINSTYLE_QUICK; HelpTextWindow* pHelpWin = new HelpTextWindow( pParent, rText, nHelpWinStyle, nStyle ); + ULONG nId = reinterpret_cast< ULONG >( pHelpWin ); + UpdateTip( nId, pParent, rScreenRect, rText ); + + pHelpWin->ShowHelp( HELPDELAY_NONE ); + return nId; +} + +// ----------------------------------------------------------------------- + +void Help::UpdateTip( ULONG nId, Window* pParent, const Rectangle& rScreenRect, const XubString& rText ) +{ + HelpTextWindow* pHelpWin = reinterpret_cast< HelpTextWindow* >( nId ); + ENSURE_OR_RETURN_VOID( pHelpWin != NULL, "Help::UpdateTip: invalid ID!" ); + Size aSz = pHelpWin->CalcOutSize(); pHelpWin->SetOutputSizePixel( aSz ); - ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, - pParent->OutputToScreenPixel( pParent->GetPointerPosPixel() ), &rRect ); - pHelpWin->ShowHelp( HELPDELAY_NONE ); - return (ULONG)pHelpWin; + ImplSetHelpWindowPos( pHelpWin, pHelpWin->GetWinStyle(), pHelpWin->GetStyle(), + pParent->OutputToScreenPixel( pParent->GetPointerPosPixel() ), &rScreenRect ); } // ----------------------------------------------------------------------- -- cgit v1.2.3 From f30518cc978f4f74a7e61d03872b913124e82f76 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 13:19:09 +0100 Subject: gridsort: re-add tooltip support to X(Mutable)GridDataModel, this time more explicit, and less magical --- svtools/source/uno/unocontroltablemodel.cxx | 14 +++- .../source/controls/grid/defaultgriddatamodel.cxx | 86 +++++++++++++++------- .../source/controls/grid/defaultgriddatamodel.hxx | 19 ++++- 3 files changed, 87 insertions(+), 32 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 75e58bcdf03c..17aac65c0dfb 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -554,9 +554,17 @@ namespace svt { namespace table void UnoControlTableModel::getCellToolTip( ColPos const i_col, RowPos const i_row, Any& o_cellToolTip ) { DBG_CHECK_ME(); - OSL_UNUSED( i_col ); - OSL_UNUSED( i_row ); - OSL_UNUSED( o_cellToolTip ); + try + { + Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); + ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" ); + + o_cellToolTip = xDataModel->getCellToolTip( i_col, i_row ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 3d9b8324de81..693f86e187d9 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -115,20 +115,47 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - Any SAL_CALL DefaultGridDataModel::getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) + DefaultGridDataModel::CellData const & DefaultGridDataModel::impl_getCellData_throw( sal_Int32 const i_column, sal_Int32 const i_row ) const { - ::osl::MutexGuard aGuard( GetMutex() ); - if ( ( i_row < 0 ) || ( size_t( i_row ) > m_aData.size() ) || ( i_column < 0 ) || ( i_column > m_nColumnCount ) ) - throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + throw IndexOutOfBoundsException( ::rtl::OUString(), *const_cast< DefaultGridDataModel* >( this ) ); - ::std::vector< Any > const & rRow( m_aData[ i_row ] ); + RowData const & rRow( m_aData[ i_row ] ); if ( size_t( i_column ) < rRow.size() ) return rRow[ i_column ]; - return Any(); + static CellData s_aEmpty; + return s_aEmpty; + } + + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::CellData& DefaultGridDataModel::impl_getCellDataAccess_throw( sal_Int32 const i_column, sal_Int32 const i_row ) + { + if ( ( i_row < 0 ) || ( size_t( i_row ) >= m_aData.size() ) + || ( i_column < 0 ) || ( i_column >= m_nColumnCount ) + ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + RowData& rRowData( m_aData[ i_row ] ); + if ( size_t( i_column ) >= rRowData.size() ) + rRowData.resize( i_column + 1 ); + return rRowData[ i_column ]; + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL DefaultGridDataModel::getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + return impl_getCellData_throw( i_column, i_row ).first; + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL DefaultGridDataModel::getCellToolTip( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + return impl_getCellData_throw( i_column, i_row ).second; } //------------------------------------------------------------------------------------------------------------------ @@ -153,9 +180,7 @@ namespace toolkit m_aRowHeaders.push_back( i_title ); // store row m_aData - ::std::vector< Any > newRow( columnCount ); - ::std::copy( i_data.getConstArray(), i_data.getConstArray() + columnCount, newRow.begin() ); - m_aData.push_back( newRow ); + impl_addRow( i_data ); // update column count if ( columnCount > m_nColumnCount ) @@ -169,6 +194,20 @@ namespace toolkit ); } + //------------------------------------------------------------------------------------------------------------------ + void DefaultGridDataModel::impl_addRow( Sequence< Any > const & i_rowData, sal_Int32 const i_assumedColCount ) + { + OSL_PRECOND( ( i_assumedColCount <= 0 ) || ( i_assumedColCount >= i_rowData.getLength() ), + "DefaultGridDataModel::impl_addRow: invalid column count!" ); + + RowData newRow( i_assumedColCount > 0 ? i_assumedColCount : i_rowData.getLength() ); + RowData::iterator cellData = newRow.begin(); + for ( const Any* pData = stl_begin( i_rowData ); pData != stl_end( i_rowData ); ++pData, ++cellData ) + cellData->first = *pData; + + m_aData.push_back( newRow ); + } + //------------------------------------------------------------------------------------------------------------------ void SAL_CALL DefaultGridDataModel::addRows( const Sequence< ::rtl::OUString >& i_titles, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException) { @@ -193,11 +232,7 @@ namespace toolkit for ( sal_Int32 row=0; row newRow( maxColCount ); - Sequence< Any > const & rRowData = i_data[row]; - ::std::copy( rRowData.getConstArray(), rRowData.getConstArray() + rRowData.getLength(), newRow.begin() ); - m_aData.push_back( newRow ); + impl_addRow( i_data[row], maxColCount ); } if ( maxColCount > m_nColumnCount ) @@ -250,15 +285,7 @@ namespace toolkit { ::osl::ClearableMutexGuard aGuard( GetMutex() ); - if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) - || ( i_columnIndex < 0 ) || ( i_columnIndex >= m_nColumnCount ) - ) - throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - - ::std::vector< Any >& rRowData( m_aData[ i_rowIndex ] ); - if ( size_t( i_columnIndex ) >= rRowData.size() ) - rRowData.resize( i_columnIndex + 1 ); - rRowData[ i_columnIndex ] = i_value; + impl_getCellDataAccess_throw( i_columnIndex, i_rowIndex ).first = i_value; broadcast( GridDataEvent( *this, i_columnIndex, i_columnIndex, i_rowIndex, i_rowIndex ), @@ -288,14 +315,14 @@ namespace toolkit throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); } - ::std::vector< Any >& rDataRow = m_aData[ i_rowIndex ]; + RowData& rDataRow = m_aData[ i_rowIndex ]; for ( sal_Int32 col = 0; col < columnCount; ++col ) { sal_Int32 const columnIndex = i_columnIndexes[ col ]; if ( size_t( columnIndex ) >= rDataRow.size() ) rDataRow.resize( columnIndex + 1 ); - rDataRow[ columnIndex ] = i_values[ col ]; + rDataRow[ columnIndex ].first = i_values[ col ]; } sal_Int32 const firstAffectedColumn = *::std::min_element( stl_begin( i_columnIndexes ), stl_end( i_columnIndexes ) ); @@ -312,7 +339,7 @@ namespace toolkit { ::osl::ClearableMutexGuard aGuard( GetMutex() ); - if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) ) + if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aRowHeaders.size() ) ) throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); m_aRowHeaders[ i_rowIndex ] = i_title; @@ -324,6 +351,13 @@ namespace toolkit ); } + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::setCellToolTip( ::sal_Int32 i_rowIndex, ::sal_Int32 i_columnIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + impl_getCellDataAccess_throw( i_columnIndex, i_rowIndex ).second = i_value; + } + //------------------------------------------------------------------------------------------------------------------ void SAL_CALL DefaultGridDataModel::addGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException) { diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 842e714c904c..acfb777ef5b0 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -69,6 +69,7 @@ public: virtual void SAL_CALL updateCell( ::sal_Int32 RowIndex, ::sal_Int32 ColumnIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateRow( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setRowTitle( ::sal_Int32 RowIndex, const ::rtl::OUString& Title ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCellToolTip( ::sal_Int32 RowIndex, ::sal_Int32 ColumnIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); @@ -76,6 +77,7 @@ public: virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellToolTip( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getRowTitle( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); // XComponent @@ -92,15 +94,26 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); private: + typedef ::std::pair< Any, Any > CellData; + typedef ::std::vector< CellData > RowData; + typedef ::std::vector< RowData > GridData; + void broadcast( GridDataEvent const & i_event, void ( SAL_CALL ::com::sun::star::awt::grid::XGridDataListener::*i_listenerMethod )( ::com::sun::star::awt::grid::GridDataEvent const & ), ::osl::ClearableMutexGuard & i_instanceLock ); - ::std::vector< ::std::vector < Any > > m_aData; - ::std::vector< ::rtl::OUString > m_aRowHeaders; - sal_Int32 m_nColumnCount; + void impl_addRow( Sequence< Any > const & i_rowData, sal_Int32 const i_assumedColCount = -1 ); + + CellData const & + impl_getCellData_throw( sal_Int32 const i_column, sal_Int32 const i_row ) const; + CellData& + impl_getCellDataAccess_throw( sal_Int32 const i_column, sal_Int32 const i_row ); + + GridData m_aData; + ::std::vector< ::rtl::OUString > m_aRowHeaders; + sal_Int32 m_nColumnCount; }; } -- cgit v1.2.3 From db9388daa6f997ea54b7637c761bf0664b68ff6f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 14 Jan 2011 13:59:11 +0100 Subject: gridsort: if the tooltip text contains line breaks, force the tip style to be 'balloon' - the 'normal' style doesn't support line breaks --- svtools/source/table/tabledatawindow.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'svtools') diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 56be34897fe2..36966d92aea5 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -107,6 +107,7 @@ namespace svt { namespace table ColPos const hitCol = rTableControl.getColAtPoint( aMousePos ); ::rtl::OUString sHelpText; + USHORT nHelpStyle = 0; if ( ( hitCol >= 0 ) && ( hitCol < pTableModel->getColumnCount() ) ) { @@ -137,6 +138,9 @@ namespace svt { namespace table } sHelpText = CellValueConversion::convertToString( aCellToolTip ); + + if ( sHelpText.indexOf( '\n' ) >= 0 ) + nHelpStyle = QUICKHELP_TIP_STYLE_BALLOON; } } @@ -150,7 +154,7 @@ namespace svt { namespace table if ( m_nTipWindowHandle ) Help::UpdateTip( m_nTipWindowHandle, this, aControlScreenRect, sHelpText ); else - m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText ); + m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText, nHelpStyle ); } } else -- cgit v1.2.3 From 0f3d6394017700f441a7be18acce08dba5e08db0 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Sun, 16 Jan 2011 00:25:19 +0100 Subject: locales34: #i113937# added Yiddish_USA [yi-US] locale data; contributed by --- i18npool/inc/i18npool/lang.h | 1 + i18npool/source/isolang/isolang.cxx | 1 + i18npool/source/isolang/mslangid.cxx | 1 + .../source/localedata/data/localedata_others.map | 17 +++ i18npool/source/localedata/data/makefile.mk | 1 + i18npool/source/localedata/data/yi_US.xml | 163 +++++++++++++++++++++ i18npool/source/localedata/localedata.cxx | 1 + svtools/source/misc/langtab.src | 3 +- 8 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 i18npool/source/localedata/data/yi_US.xml (limited to 'svtools') diff --git a/i18npool/inc/i18npool/lang.h b/i18npool/inc/i18npool/lang.h index 52e4e51d7a41..717facd02502 100644 --- a/i18npool/inc/i18npool/lang.h +++ b/i18npool/inc/i18npool/lang.h @@ -515,6 +515,7 @@ typedef unsigned short LanguageType; #define LANGUAGE_USER_GIKUYU 0x0655 #define LANGUAGE_USER_RUSYN_UKRAINE 0x0656 #define LANGUAGE_USER_RUSYN_SLOVAKIA 0x8256 /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_USER_RUSYN_UKRAINE)) */ +#define LANGUAGE_USER_YIDDISH_US 0x083D /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_YIDDISH)) */ #endif /* INCLUDED_I18NPOOL_LANG_H */ diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx index 357be80a69ea..35d2ba63f549 100644 --- a/i18npool/source/isolang/isolang.cxx +++ b/i18npool/source/isolang/isolang.cxx @@ -353,6 +353,7 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = { LANGUAGE_PAPIAMENTU, "pap", "AN" }, { LANGUAGE_USER_PAPIAMENTU_ARUBA, "pap", "AW" }, { LANGUAGE_ENGLISH_SINGAPORE, "en", "SG" }, + { LANGUAGE_USER_YIDDISH_US, "yi", "US" }, { LANGUAGE_YIDDISH, "yi", "IL" }, // new: old was "ji" { LANGUAGE_YIDDISH, "ji", "IL" }, // old: new is "yi" { LANGUAGE_SYRIAC, "syr", "TR" }, // "TR" according to http://www.ethnologue.com/show_language.asp?code=SYC diff --git a/i18npool/source/isolang/mslangid.cxx b/i18npool/source/isolang/mslangid.cxx index a03d24e6fcdb..36cdddbdd27f 100644 --- a/i18npool/source/isolang/mslangid.cxx +++ b/i18npool/source/isolang/mslangid.cxx @@ -339,6 +339,7 @@ sal_Int16 MsLangId::getScriptType( LanguageType nLang ) case LANGUAGE_FARSI: case LANGUAGE_HEBREW: case LANGUAGE_YIDDISH: + case LANGUAGE_USER_YIDDISH_US: case LANGUAGE_MARATHI: case LANGUAGE_PUNJABI: case LANGUAGE_GUJARATI: diff --git a/i18npool/source/localedata/data/localedata_others.map b/i18npool/source/localedata/data/localedata_others.map index e5de10cb68e5..d278095e4bc9 100644 --- a/i18npool/source/localedata/data/localedata_others.map +++ b/i18npool/source/localedata/data/localedata_others.map @@ -72,6 +72,7 @@ getAllCalendars_uz_UZ; getAllCalendars_ve_ZA; getAllCalendars_vi_VN; getAllCalendars_xh_ZA; +getAllCalendars_yi_US; getAllCalendars_zh_CN; getAllCalendars_zh_HK; getAllCalendars_zh_MO; @@ -150,6 +151,7 @@ getAllCurrencies_uz_UZ; getAllCurrencies_ve_ZA; getAllCurrencies_vi_VN; getAllCurrencies_xh_ZA; +getAllCurrencies_yi_US; getAllCurrencies_zh_CN; getAllCurrencies_zh_HK; getAllCurrencies_zh_MO; @@ -228,6 +230,7 @@ getAllFormats0_uz_UZ; getAllFormats0_ve_ZA; getAllFormats0_vi_VN; getAllFormats0_xh_ZA; +getAllFormats0_yi_US; getAllFormats0_zh_CN; getAllFormats0_zh_HK; getAllFormats0_zh_MO; @@ -306,6 +309,7 @@ getBreakIteratorRules_uz_UZ; getBreakIteratorRules_ve_ZA; getBreakIteratorRules_vi_VN; getBreakIteratorRules_xh_ZA; +getBreakIteratorRules_yi_US; getBreakIteratorRules_zh_CN; getBreakIteratorRules_zh_HK; getBreakIteratorRules_zh_MO; @@ -384,6 +388,7 @@ getCollationOptions_uz_UZ; getCollationOptions_ve_ZA; getCollationOptions_vi_VN; getCollationOptions_xh_ZA; +getCollationOptions_yi_US; getCollationOptions_zh_CN; getCollationOptions_zh_HK; getCollationOptions_zh_MO; @@ -462,6 +467,7 @@ getCollatorImplementation_uz_UZ; getCollatorImplementation_ve_ZA; getCollatorImplementation_vi_VN; getCollatorImplementation_xh_ZA; +getCollatorImplementation_yi_US; getCollatorImplementation_zh_CN; getCollatorImplementation_zh_HK; getCollatorImplementation_zh_MO; @@ -540,6 +546,7 @@ getContinuousNumberingLevels_uz_UZ; getContinuousNumberingLevels_ve_ZA; getContinuousNumberingLevels_vi_VN; getContinuousNumberingLevels_xh_ZA; +getContinuousNumberingLevels_yi_US; getContinuousNumberingLevels_zh_CN; getContinuousNumberingLevels_zh_HK; getContinuousNumberingLevels_zh_MO; @@ -618,6 +625,7 @@ getFollowPageWords_uz_UZ; getFollowPageWords_ve_ZA; getFollowPageWords_vi_VN; getFollowPageWords_xh_ZA; +getFollowPageWords_yi_US; getFollowPageWords_zh_CN; getFollowPageWords_zh_HK; getFollowPageWords_zh_MO; @@ -696,6 +704,7 @@ getForbiddenCharacters_uz_UZ; getForbiddenCharacters_ve_ZA; getForbiddenCharacters_vi_VN; getForbiddenCharacters_xh_ZA; +getForbiddenCharacters_yi_US; getForbiddenCharacters_zh_CN; getForbiddenCharacters_zh_HK; getForbiddenCharacters_zh_MO; @@ -774,6 +783,7 @@ getIndexAlgorithm_uz_UZ; getIndexAlgorithm_ve_ZA; getIndexAlgorithm_vi_VN; getIndexAlgorithm_xh_ZA; +getIndexAlgorithm_yi_US; getIndexAlgorithm_zh_CN; getIndexAlgorithm_zh_HK; getIndexAlgorithm_zh_MO; @@ -852,6 +862,7 @@ getLCInfo_uz_UZ; getLCInfo_ve_ZA; getLCInfo_vi_VN; getLCInfo_xh_ZA; +getLCInfo_yi_US; getLCInfo_zh_CN; getLCInfo_zh_HK; getLCInfo_zh_MO; @@ -930,6 +941,7 @@ getLocaleItem_uz_UZ; getLocaleItem_ve_ZA; getLocaleItem_vi_VN; getLocaleItem_xh_ZA; +getLocaleItem_yi_US; getLocaleItem_zh_CN; getLocaleItem_zh_HK; getLocaleItem_zh_MO; @@ -1008,6 +1020,7 @@ getOutlineNumberingLevels_uz_UZ; getOutlineNumberingLevels_ve_ZA; getOutlineNumberingLevels_vi_VN; getOutlineNumberingLevels_xh_ZA; +getOutlineNumberingLevels_yi_US; getOutlineNumberingLevels_zh_CN; getOutlineNumberingLevels_zh_HK; getOutlineNumberingLevels_zh_MO; @@ -1086,6 +1099,7 @@ getReservedWords_uz_UZ; getReservedWords_ve_ZA; getReservedWords_vi_VN; getReservedWords_xh_ZA; +getReservedWords_yi_US; getReservedWords_zh_CN; getReservedWords_zh_HK; getReservedWords_zh_MO; @@ -1164,6 +1178,7 @@ getSearchOptions_uz_UZ; getSearchOptions_ve_ZA; getSearchOptions_vi_VN; getSearchOptions_xh_ZA; +getSearchOptions_yi_US; getSearchOptions_zh_CN; getSearchOptions_zh_HK; getSearchOptions_zh_MO; @@ -1242,6 +1257,7 @@ getTransliterations_uz_UZ; getTransliterations_ve_ZA; getTransliterations_vi_VN; getTransliterations_xh_ZA; +getTransliterations_yi_US; getTransliterations_zh_CN; getTransliterations_zh_HK; getTransliterations_zh_MO; @@ -1320,6 +1336,7 @@ getUnicodeScripts_uz_UZ; getUnicodeScripts_ve_ZA; getUnicodeScripts_vi_VN; getUnicodeScripts_xh_ZA; +getUnicodeScripts_yi_US; getUnicodeScripts_zh_CN; getUnicodeScripts_zh_HK; getUnicodeScripts_zh_MO; diff --git a/i18npool/source/localedata/data/makefile.mk b/i18npool/source/localedata/data/makefile.mk index 23dc4d44a9fd..13979b343226 100644 --- a/i18npool/source/localedata/data/makefile.mk +++ b/i18npool/source/localedata/data/makefile.mk @@ -313,6 +313,7 @@ SHL4OBJS= \ $(SLO)$/localedata_ve_ZA.obj \ $(SLO)$/localedata_vi_VN.obj \ $(SLO)$/localedata_xh_ZA.obj \ + $(SLO)$/localedata_yi_US.obj \ $(SLO)$/localedata_zh_CN.obj \ $(SLO)$/localedata_zh_HK.obj \ $(SLO)$/localedata_zh_MO.obj \ diff --git a/i18npool/source/localedata/data/yi_US.xml b/i18npool/source/localedata/data/yi_US.xml new file mode 100644 index 000000000000..cf52c1ae1fdf --- /dev/null +++ b/i18npool/source/localedata/data/yi_US.xml @@ -0,0 +1,163 @@ + + + + + + yi + Yiddish + + + US + United States + + + + + + + + א-י כ ל מ נ ס ע פ צ-ת + 10 + ז“ + ז“ + + + + + + sun + זונ' + זונטיק + + + mon + מאָנ' + מאָנטיק + + + tue + דינ' + דינסטיק + + + wed + מיט' + מיטװאָך + + + thu + דאָנ' + דאָנערשטיק + + + fri + פֿרײַ' + פֿרײַטיק + + + sat + שבת + שבת + + + + + jan + יאַנ + יאַנואַר + + + feb + פֿעב + פֿעברואַר + + + mar + מאַר + מאַרץ + + + apr + אַפּר + אַפּריל + + + may + מײַ + מײַ + + + jun + יונ + יוני + + + jul + יול + יולי + + + aug + אױג + אױגוסט + + + sep + סעפּ + סעפּטעמבער + + + oct + אָקט + אָקטאָבער + + + nov + נאָװ + נאָװעמבער + + + dec + דעצ + דעצעמבער + + + + + bc + פֿ"ק + פֿ"ק + + + ad + אצ“ר + אצ“ר + + + + sun + + 1 + + + + + + + אמת + פֿאַלש + ערשט יאָרפֿערטל + צװײט יאָרפֿערטל + דריט יאָרפֿערטל + פֿערט יאָרפֿערטל + אױבן + אונטן + י“פֿ1 + י“פֿ2 + י“פֿ3 + י“פֿ4 + + + + + diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index b668cfb8d751..6ef2c495d5ce 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -252,6 +252,7 @@ static const struct { { "om_ET", lcl_DATA_OTHERS }, { "plt_MG", lcl_DATA_OTHERS }, { "mai_IN", lcl_DATA_OTHERS }, + { "yi_US", lcl_DATA_OTHERS } }; static const sal_Unicode under = sal_Unicode('_'); diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src index 067eb601a5af..493502b5da1b 100644 --- a/svtools/source/misc/langtab.src +++ b/svtools/source/misc/langtab.src @@ -301,7 +301,7 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE < "Shuswap" ; LANGUAGE_USER_SHUSWAP ; > ; < "Oromo" ; LANGUAGE_OROMO ; > ; < "Greek, Ancient" ; LANGUAGE_USER_ANCIENT_GREEK ; > ; - < "Yiddish" ; LANGUAGE_YIDDISH ; > ; + < "Yiddish (Israel)" ; LANGUAGE_YIDDISH ; > ; < "Quechua (Ecuador)" ; LANGUAGE_QUECHUA_ECUADOR ; > ; < "Uyghur" ; LANGUAGE_UIGHUR_CHINA ; > ; < "Asturian" ; LANGUAGE_USER_ASTURIAN ; > ; @@ -323,6 +323,7 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE < "Yoruba" ; LANGUAGE_YORUBA ; > ; < "Rusyn (Ukraine)" ; LANGUAGE_USER_RUSYN_UKRAINE ; > ; < "Rusyn (Slovakia)" ; LANGUAGE_USER_RUSYN_SLOVAKIA ; > ; + < "Yiddish (USA)" ; LANGUAGE_USER_YIDDISH_US ; > ; }; }; -- cgit v1.2.3 From 4fe4d999103c9d0c8dafd785d4a77ff6aa95d555 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Sun, 16 Jan 2011 19:21:42 +0100 Subject: locales34: #i116240# added Hawaiian [haw-US] locale data; contributed by via it46 localegen --- i18npool/source/localedata/data/haw_US.xml | 358 +++++++++++++++++++++ .../source/localedata/data/localedata_others.map | 19 +- i18npool/source/localedata/data/makefile.mk | 1 + i18npool/source/localedata/localedata.cxx | 3 +- svtools/source/misc/langtab.src | 1 + 5 files changed, 380 insertions(+), 2 deletions(-) create mode 100644 i18npool/source/localedata/data/haw_US.xml (limited to 'svtools') diff --git a/i18npool/source/localedata/data/haw_US.xml b/i18npool/source/localedata/data/haw_US.xml new file mode 100644 index 000000000000..b9fd553e24ef --- /dev/null +++ b/i18npool/source/localedata/data/haw_US.xml @@ -0,0 +1,358 @@ + + + + + + haw + Hawaiian + + + US + United States + + + + + / + , + . + : + . + ; + , + + + + + + + + + + + AM + PM + metric + + + + General + + + 0 + + + 0.00 + + + #,##0 + + + #,##0.00 + + + #,###.00 + + + 0.00E+00 + + + 0.00E+000 + + + 0% + + + 0.00% + + + [CURRENCY]#,##0;([CURRENCY]#,##0) + + + [CURRENCY]#,##0.00;([CURRENCY]#,##0.00) + + + [CURRENCY]#,##0;[RED]([CURRENCY]#,##0) + + + [CURRENCY]#,##0.00;[RED]([CURRENCY]#,##0.00) + + + CCC#,##0.00 + + + [CURRENCY]#,##0.--;[RED]([CURRENCY]#,##0.--) + + + YY/MM/DD + + + NNNNDD MMMM YYYY + + + YY/MM/DD + + + YYYY/MM/DD + + + D MMM YY + + + D MMM YYYY + + + D MMM YYYY + + + D MMMM YYYY + + + D MMMM YYYY + + + NN, DD/MMM/YY + + + NN, D MMM YY + + + NN, D MMMM YYYY + + + NNNND MMMM YYYY + + + MM/DD + + + YY-MM-DD + ISO 8601 + + + YYYY-MM-DD + ISO 8601 + + + YY/MM + + + MMM/DD + + + MMMM + + + QQ YY + + + WW + + + HH:MM + + + HH:MM:SS + + + HH:MM AM/PM + + + HH:MM:SS AM/PM + + + [HH]:MM:SS + + + MM:SS.00 + + + [HH]:MM:SS.00 + + + YY/MM/DD HH:MM + + + YYYY/MM/DD HH:MM:SS AM/PM + + + + + + IGNORE_CASE + + + + + IGNORE_CASE + + + + A E I O U H K L M N P W + 0 + 1 + p. + pp. + + + + + + sun + LP + Lāpule + + + mon + P1 + Poʻakahi + + + tue + P2 + Poʻalua + + + wed + P3 + Poʻakolu + + + thu + P4 + Poʻahā + + + fri + P5 + Poʻalima + + + sat + P6 + Poʻaono + + + + + jan + Ian. + Ianuali + + + feb + Pep. + Pepeluali + + + mar + Mal. + Malaki + + + apr + ʻAp. + ʻApelila + + + may + Mei + Mei + + + jun + Iun. + Iune + + + jul + Iul. + Iulai + + + aug + ʻAuk. + ʻAukake + + + sep + Kep. + Kepakemapa + + + oct + ʻOk. + ʻOkakopa + + + nov + Now. + Nowemapa + + + dec + Kek. + Kekemapa + + + + + bc + BC + BC + + + ad + CE + CE + + + + mon + + 1 + + + + + USD + $ + USD + Kālā ʻAmelika + 2 + + + + + + + + + + ʻOiaʻiʻo + Hewa + Kau Hapahā 1 + Kau Hapaha 2 + Kau Hapahā 3 + Kau Hapahā 4 + Luna + Lalo + KH1 + KH2 + KH3 + KH4 + + + + + + + + + + + + + + + diff --git a/i18npool/source/localedata/data/localedata_others.map b/i18npool/source/localedata/data/localedata_others.map index d278095e4bc9..e194b38cbf07 100644 --- a/i18npool/source/localedata/data/localedata_others.map +++ b/i18npool/source/localedata/data/localedata_others.map @@ -1,5 +1,6 @@ UDK_3_0_0 { global: +GetVersionInfo; getAllCalendars_af_NA; getAllCalendars_af_ZA; getAllCalendars_ak_GH; @@ -21,6 +22,7 @@ getAllCalendars_fa_IR; getAllCalendars_gug_PY; getAllCalendars_gu_IN; getAllCalendars_ha_GH; +getAllCalendars_haw_US; getAllCalendars_he_IL; getAllCalendars_hi_IN; getAllCalendars_hil_PH; @@ -100,6 +102,7 @@ getAllCurrencies_fa_IR; getAllCurrencies_gug_PY; getAllCurrencies_gu_IN; getAllCurrencies_ha_GH; +getAllCurrencies_haw_US; getAllCurrencies_he_IL; getAllCurrencies_hi_IN; getAllCurrencies_hil_PH; @@ -179,6 +182,7 @@ getAllFormats0_fa_IR; getAllFormats0_gug_PY; getAllFormats0_gu_IN; getAllFormats0_ha_GH; +getAllFormats0_haw_US; getAllFormats0_he_IL; getAllFormats0_hi_IN; getAllFormats0_hil_PH; @@ -258,6 +262,7 @@ getBreakIteratorRules_fa_IR; getBreakIteratorRules_gug_PY; getBreakIteratorRules_gu_IN; getBreakIteratorRules_ha_GH; +getBreakIteratorRules_haw_US; getBreakIteratorRules_he_IL; getBreakIteratorRules_hi_IN; getBreakIteratorRules_hil_PH; @@ -337,6 +342,7 @@ getCollationOptions_fa_IR; getCollationOptions_gug_PY; getCollationOptions_gu_IN; getCollationOptions_ha_GH; +getCollationOptions_haw_US; getCollationOptions_he_IL; getCollationOptions_hi_IN; getCollationOptions_hil_PH; @@ -416,6 +422,7 @@ getCollatorImplementation_fa_IR; getCollatorImplementation_gug_PY; getCollatorImplementation_gu_IN; getCollatorImplementation_ha_GH; +getCollatorImplementation_haw_US; getCollatorImplementation_he_IL; getCollatorImplementation_hi_IN; getCollatorImplementation_hil_PH; @@ -495,6 +502,7 @@ getContinuousNumberingLevels_fa_IR; getContinuousNumberingLevels_gug_PY; getContinuousNumberingLevels_gu_IN; getContinuousNumberingLevels_ha_GH; +getContinuousNumberingLevels_haw_US; getContinuousNumberingLevels_he_IL; getContinuousNumberingLevels_hi_IN; getContinuousNumberingLevels_hil_PH; @@ -574,6 +582,7 @@ getFollowPageWords_fa_IR; getFollowPageWords_gug_PY; getFollowPageWords_gu_IN; getFollowPageWords_ha_GH; +getFollowPageWords_haw_US; getFollowPageWords_he_IL; getFollowPageWords_hi_IN; getFollowPageWords_hil_PH; @@ -653,6 +662,7 @@ getForbiddenCharacters_fa_IR; getForbiddenCharacters_gug_PY; getForbiddenCharacters_gu_IN; getForbiddenCharacters_ha_GH; +getForbiddenCharacters_haw_US; getForbiddenCharacters_he_IL; getForbiddenCharacters_hi_IN; getForbiddenCharacters_hil_PH; @@ -732,6 +742,7 @@ getIndexAlgorithm_fa_IR; getIndexAlgorithm_gug_PY; getIndexAlgorithm_gu_IN; getIndexAlgorithm_ha_GH; +getIndexAlgorithm_haw_US; getIndexAlgorithm_he_IL; getIndexAlgorithm_hi_IN; getIndexAlgorithm_hil_PH; @@ -811,6 +822,7 @@ getLCInfo_fa_IR; getLCInfo_gug_PY; getLCInfo_gu_IN; getLCInfo_ha_GH; +getLCInfo_haw_US; getLCInfo_he_IL; getLCInfo_hi_IN; getLCInfo_hil_PH; @@ -890,6 +902,7 @@ getLocaleItem_fa_IR; getLocaleItem_gug_PY; getLocaleItem_gu_IN; getLocaleItem_ha_GH; +getLocaleItem_haw_US; getLocaleItem_he_IL; getLocaleItem_hi_IN; getLocaleItem_hil_PH; @@ -969,6 +982,7 @@ getOutlineNumberingLevels_fa_IR; getOutlineNumberingLevels_gug_PY; getOutlineNumberingLevels_gu_IN; getOutlineNumberingLevels_ha_GH; +getOutlineNumberingLevels_haw_US; getOutlineNumberingLevels_he_IL; getOutlineNumberingLevels_hi_IN; getOutlineNumberingLevels_hil_PH; @@ -1048,6 +1062,7 @@ getReservedWords_fa_IR; getReservedWords_gug_PY; getReservedWords_gu_IN; getReservedWords_ha_GH; +getReservedWords_haw_US; getReservedWords_he_IL; getReservedWords_hi_IN; getReservedWords_hil_PH; @@ -1127,6 +1142,7 @@ getSearchOptions_fa_IR; getSearchOptions_gug_PY; getSearchOptions_gu_IN; getSearchOptions_ha_GH; +getSearchOptions_haw_US; getSearchOptions_he_IL; getSearchOptions_hi_IN; getSearchOptions_hil_PH; @@ -1206,6 +1222,7 @@ getTransliterations_fa_IR; getTransliterations_gug_PY; getTransliterations_gu_IN; getTransliterations_ha_GH; +getTransliterations_haw_US; getTransliterations_he_IL; getTransliterations_hi_IN; getTransliterations_hil_PH; @@ -1285,6 +1302,7 @@ getUnicodeScripts_fa_IR; getUnicodeScripts_gug_PY; getUnicodeScripts_gu_IN; getUnicodeScripts_ha_GH; +getUnicodeScripts_haw_US; getUnicodeScripts_he_IL; getUnicodeScripts_hi_IN; getUnicodeScripts_hil_PH; @@ -1343,7 +1361,6 @@ getUnicodeScripts_zh_MO; getUnicodeScripts_zh_SG; getUnicodeScripts_zh_TW; getUnicodeScripts_zu_ZA; -GetVersionInfo; local: *; diff --git a/i18npool/source/localedata/data/makefile.mk b/i18npool/source/localedata/data/makefile.mk index 13979b343226..d1f68b269dd0 100644 --- a/i18npool/source/localedata/data/makefile.mk +++ b/i18npool/source/localedata/data/makefile.mk @@ -261,6 +261,7 @@ SHL4OBJS= \ $(SLO)$/localedata_fa_IR.obj \ $(SLO)$/localedata_gu_IN.obj \ $(SLO)$/localedata_gug_PY.obj \ + $(SLO)$/localedata_haw_US.obj \ $(SLO)$/localedata_ha_GH.obj \ $(SLO)$/localedata_he_IL.obj \ $(SLO)$/localedata_hi_IN.obj \ diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 6ef2c495d5ce..30b56c0d9f7f 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -252,7 +252,8 @@ static const struct { { "om_ET", lcl_DATA_OTHERS }, { "plt_MG", lcl_DATA_OTHERS }, { "mai_IN", lcl_DATA_OTHERS }, - { "yi_US", lcl_DATA_OTHERS } + { "yi_US", lcl_DATA_OTHERS }, + { "haw_US", lcl_DATA_OTHERS } }; static const sal_Unicode under = sal_Unicode('_'); diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src index 493502b5da1b..b40dc16ddc30 100644 --- a/svtools/source/misc/langtab.src +++ b/svtools/source/misc/langtab.src @@ -324,6 +324,7 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE < "Rusyn (Ukraine)" ; LANGUAGE_USER_RUSYN_UKRAINE ; > ; < "Rusyn (Slovakia)" ; LANGUAGE_USER_RUSYN_SLOVAKIA ; > ; < "Yiddish (USA)" ; LANGUAGE_USER_YIDDISH_US ; > ; + < "Hawaiian" ; LANGUAGE_HAWAIIAN_UNITED_STATES ; > ; }; }; -- cgit v1.2.3 From 2a40932afc49617f08f7e52c017710ddefb889ce Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Sun, 16 Jan 2011 20:19:23 +0100 Subject: locales34: #i116241# added Limbu (Nepal) [lif-NP] locale data; contributed by via it46 localegen --- i18npool/inc/i18npool/lang.h | 1 + i18npool/source/isolang/isolang.cxx | 1 + i18npool/source/isolang/mslangid.cxx | 1 + i18npool/source/localedata/data/lif_NP.xml | 357 +++++++++++++++++++++ .../source/localedata/data/localedata_others.map | 17 + i18npool/source/localedata/data/makefile.mk | 1 + i18npool/source/localedata/localedata.cxx | 3 +- svtools/source/misc/langtab.src | 1 + 8 files changed, 381 insertions(+), 1 deletion(-) create mode 100644 i18npool/source/localedata/data/lif_NP.xml (limited to 'svtools') diff --git a/i18npool/inc/i18npool/lang.h b/i18npool/inc/i18npool/lang.h index 717facd02502..0fd4f38f0f6d 100644 --- a/i18npool/inc/i18npool/lang.h +++ b/i18npool/inc/i18npool/lang.h @@ -516,6 +516,7 @@ typedef unsigned short LanguageType; #define LANGUAGE_USER_RUSYN_UKRAINE 0x0656 #define LANGUAGE_USER_RUSYN_SLOVAKIA 0x8256 /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_USER_RUSYN_UKRAINE)) */ #define LANGUAGE_USER_YIDDISH_US 0x083D /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_YIDDISH)) */ +#define LANGUAGE_USER_LIMBU 0x0657 #endif /* INCLUDED_I18NPOOL_LANG_H */ diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx index 35d2ba63f549..dffc38873282 100644 --- a/i18npool/source/isolang/isolang.cxx +++ b/i18npool/source/isolang/isolang.cxx @@ -462,6 +462,7 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = { LANGUAGE_USER_GIKUYU, "ki", "KE" }, { LANGUAGE_USER_RUSYN_UKRAINE, "rue", "UA" }, { LANGUAGE_USER_RUSYN_SLOVAKIA, "rue", "SK" }, + { LANGUAGE_USER_LIMBU, "lif", "NP" }, { LANGUAGE_NONE, "zxx", "" }, // added to ISO 639-2 on 2006-01-11: Used to declare the absence of linguistic information { LANGUAGE_DONTKNOW, "", "" } // marks end of table }; diff --git a/i18npool/source/isolang/mslangid.cxx b/i18npool/source/isolang/mslangid.cxx index 36cdddbdd27f..599299951164 100644 --- a/i18npool/source/isolang/mslangid.cxx +++ b/i18npool/source/isolang/mslangid.cxx @@ -375,6 +375,7 @@ sal_Int16 MsLangId::getScriptType( LanguageType nLang ) case LANGUAGE_USER_DOGRI_INDIA: case LANGUAGE_USER_MAITHILI_INDIA: case LANGUAGE_UIGHUR_CHINA: + case LANGUAGE_USER_LIMBU: nScript = ::com::sun::star::i18n::ScriptType::COMPLEX; break; diff --git a/i18npool/source/localedata/data/lif_NP.xml b/i18npool/source/localedata/data/lif_NP.xml new file mode 100644 index 000000000000..fadbfad11ff3 --- /dev/null +++ b/i18npool/source/localedata/data/lif_NP.xml @@ -0,0 +1,357 @@ + + + + + + lif + Limbu + + + NP + Nepal + + + + + / + , + . + : + . + ; + , + , + + + + + + + + + + पूर्वान्ह + अपरान्ह + metric + + + + General + + + 0 + + + 0.00 + + + #,##0 + + + #,##0.00 + + + #,###.00 + + + 0.00E+00 + + + 0.00E+000 + + + 0% + + + 0.00% + + + [CURRENCY] #,##0;-[CURRENCY] #,##0 + + + [CURRENCY] #,##0.00;-[CURRENCY] #,##0.00 + + + [CURRENCY] #,##0;[RED]-[CURRENCY] #,##0 + + + [CURRENCY] #,##0.00;[RED]-[CURRENCY] #,##0.00 + + + CCC#,##0.00 + + + [CURRENCY] #,##0.--;[RED]-[CURRENCY] #,##0.-- + + + YY/MM/DD + + + NNNNDD, MMMM YYYY + + + YY/MM/DD + + + YYYY/MM/DD + + + D, MMM YY + + + D, MMM YYYY + + + D, MMM YYYY + + + D, MMMM YYYY + + + D, MMMM YYYY + + + NN, DD/MMM/YY + + + NN, D, MMM YY + + + NN, D, MMMM YYYY + + + NNNND, MMMM YYYY + + + MM/DD + + + YY-MM-DD + ISO 8601 + + + YYYY-MM-DD + ISO 8601 + + + YY/MM + + + MMM/DD + + + MMMM + + + QQ YY + + + WW + + + HH:MM + + + HH:MM:SS + + + HH:MM AM/PM + + + HH:MM:SS AM/PM + + + [HH]:MM:SS + + + MM:SS.00 + + + [HH]:MM:SS.00 + + + YY/MM/DD HH:MM + + + YYYY/MM/DD HH:MM:SS AM/PM + + + + + + IGNORE_CASE + + + + + IGNORE_CASE + + + + ᤁ-ᤜ + 85 + p. + pp. + + + + + + sun + ᤋᤧᤏᤧᤒᤠ + ᤋᤧᤏᤧᤒᤠ + + + mon + ᤑᤥᤖᤠᤒᤠ + ᤑᤥᤖᤠᤒᤠ + + + tue + ᤔᤡᤰᤜᤠᤱᤒᤠ + ᤔᤡᤰᤜᤠᤱᤒᤠ + + + wed + ᤂᤧᤰᤛᤢᤒᤠ + ᤂᤧᤰᤛᤢᤒᤠ + + + thu + ᤁᤢᤖᤢ᤺ᤵᤐᤠ + ᤁᤢᤖᤢ᤺ᤵᤐᤠ + + + fri + ᤑᤛᤢ᤺ᤵᤐᤠ + ᤑᤛᤢ᤺ᤵᤐᤠ + + + sat + ᤛᤧᤴᤇᤪᤧᤱᤒᤠ + ᤛᤧᤴᤇᤪᤧᤱᤒᤠ + + + + + jan + जन + जनवरी + + + feb + फेब + फेब्रुअरी + + + mar + मार्च + मार्च + + + apr + अप्रि + अप्रिल + + + may + मे + मे + + + jun + जुन + जुन + + + jul + जुला + जुलाई + + + aug + अग + अगस्त + + + sep + सेप्ट + सेप्टेम्बर + + + oct + अक्टो + अक्टोबर + + + nov + नोभे + नोभेम्बर + + + dec + डिसे + डिसेम्बर + + + + + bc + ईसापूर्व + ईसापूर्व + + + ad + सन् + सन् + + + + sun + + 1 + + + + + NPR + रू + NPR + Nepalese Rupee + 2 + + + + + + + + + + ठीक + बेठीक + पहिलो सत्र + दोस्रो सत्र + तेस्रो सत्र + चौथो सत्र + माथि + तल + Q1 + Q2 + Q3 + Q4 + + + + + + + + + + + + + + + diff --git a/i18npool/source/localedata/data/localedata_others.map b/i18npool/source/localedata/data/localedata_others.map index e194b38cbf07..003c7ed30a77 100644 --- a/i18npool/source/localedata/data/localedata_others.map +++ b/i18npool/source/localedata/data/localedata_others.map @@ -38,6 +38,7 @@ getAllCalendars_ko_KR; getAllCalendars_ku_TR; getAllCalendars_ky_KG; getAllCalendars_lg_UG; +getAllCalendars_lif_NP; getAllCalendars_ln_CD; getAllCalendars_lo_LA; getAllCalendars_mai_IN; @@ -118,6 +119,7 @@ getAllCurrencies_ko_KR; getAllCurrencies_ku_TR; getAllCurrencies_ky_KG; getAllCurrencies_lg_UG; +getAllCurrencies_lif_NP; getAllCurrencies_ln_CD; getAllCurrencies_lo_LA; getAllCurrencies_mai_IN; @@ -198,6 +200,7 @@ getAllFormats0_ko_KR; getAllFormats0_ku_TR; getAllFormats0_ky_KG; getAllFormats0_lg_UG; +getAllFormats0_lif_NP; getAllFormats0_ln_CD; getAllFormats0_lo_LA; getAllFormats0_mai_IN; @@ -278,6 +281,7 @@ getBreakIteratorRules_ko_KR; getBreakIteratorRules_ku_TR; getBreakIteratorRules_ky_KG; getBreakIteratorRules_lg_UG; +getBreakIteratorRules_lif_NP; getBreakIteratorRules_ln_CD; getBreakIteratorRules_lo_LA; getBreakIteratorRules_mai_IN; @@ -358,6 +362,7 @@ getCollationOptions_ko_KR; getCollationOptions_ku_TR; getCollationOptions_ky_KG; getCollationOptions_lg_UG; +getCollationOptions_lif_NP; getCollationOptions_ln_CD; getCollationOptions_lo_LA; getCollationOptions_mai_IN; @@ -438,6 +443,7 @@ getCollatorImplementation_ko_KR; getCollatorImplementation_ku_TR; getCollatorImplementation_ky_KG; getCollatorImplementation_lg_UG; +getCollatorImplementation_lif_NP; getCollatorImplementation_ln_CD; getCollatorImplementation_lo_LA; getCollatorImplementation_mai_IN; @@ -518,6 +524,7 @@ getContinuousNumberingLevels_ko_KR; getContinuousNumberingLevels_ku_TR; getContinuousNumberingLevels_ky_KG; getContinuousNumberingLevels_lg_UG; +getContinuousNumberingLevels_lif_NP; getContinuousNumberingLevels_ln_CD; getContinuousNumberingLevels_lo_LA; getContinuousNumberingLevels_mai_IN; @@ -598,6 +605,7 @@ getFollowPageWords_ko_KR; getFollowPageWords_ku_TR; getFollowPageWords_ky_KG; getFollowPageWords_lg_UG; +getFollowPageWords_lif_NP; getFollowPageWords_ln_CD; getFollowPageWords_lo_LA; getFollowPageWords_mai_IN; @@ -678,6 +686,7 @@ getForbiddenCharacters_ko_KR; getForbiddenCharacters_ku_TR; getForbiddenCharacters_ky_KG; getForbiddenCharacters_lg_UG; +getForbiddenCharacters_lif_NP; getForbiddenCharacters_ln_CD; getForbiddenCharacters_lo_LA; getForbiddenCharacters_mai_IN; @@ -758,6 +767,7 @@ getIndexAlgorithm_ko_KR; getIndexAlgorithm_ku_TR; getIndexAlgorithm_ky_KG; getIndexAlgorithm_lg_UG; +getIndexAlgorithm_lif_NP; getIndexAlgorithm_ln_CD; getIndexAlgorithm_lo_LA; getIndexAlgorithm_mai_IN; @@ -838,6 +848,7 @@ getLCInfo_ko_KR; getLCInfo_ku_TR; getLCInfo_ky_KG; getLCInfo_lg_UG; +getLCInfo_lif_NP; getLCInfo_ln_CD; getLCInfo_lo_LA; getLCInfo_mai_IN; @@ -918,6 +929,7 @@ getLocaleItem_ko_KR; getLocaleItem_ku_TR; getLocaleItem_ky_KG; getLocaleItem_lg_UG; +getLocaleItem_lif_NP; getLocaleItem_ln_CD; getLocaleItem_lo_LA; getLocaleItem_mai_IN; @@ -998,6 +1010,7 @@ getOutlineNumberingLevels_ko_KR; getOutlineNumberingLevels_ku_TR; getOutlineNumberingLevels_ky_KG; getOutlineNumberingLevels_lg_UG; +getOutlineNumberingLevels_lif_NP; getOutlineNumberingLevels_ln_CD; getOutlineNumberingLevels_lo_LA; getOutlineNumberingLevels_mai_IN; @@ -1078,6 +1091,7 @@ getReservedWords_ko_KR; getReservedWords_ku_TR; getReservedWords_ky_KG; getReservedWords_lg_UG; +getReservedWords_lif_NP; getReservedWords_ln_CD; getReservedWords_lo_LA; getReservedWords_mai_IN; @@ -1158,6 +1172,7 @@ getSearchOptions_ko_KR; getSearchOptions_ku_TR; getSearchOptions_ky_KG; getSearchOptions_lg_UG; +getSearchOptions_lif_NP; getSearchOptions_ln_CD; getSearchOptions_lo_LA; getSearchOptions_mai_IN; @@ -1238,6 +1253,7 @@ getTransliterations_ko_KR; getTransliterations_ku_TR; getTransliterations_ky_KG; getTransliterations_lg_UG; +getTransliterations_lif_NP; getTransliterations_ln_CD; getTransliterations_lo_LA; getTransliterations_mai_IN; @@ -1318,6 +1334,7 @@ getUnicodeScripts_ko_KR; getUnicodeScripts_ku_TR; getUnicodeScripts_ky_KG; getUnicodeScripts_lg_UG; +getUnicodeScripts_lif_NP; getUnicodeScripts_ln_CD; getUnicodeScripts_lo_LA; getUnicodeScripts_mai_IN; diff --git a/i18npool/source/localedata/data/makefile.mk b/i18npool/source/localedata/data/makefile.mk index d1f68b269dd0..87ee3a2dc997 100644 --- a/i18npool/source/localedata/data/makefile.mk +++ b/i18npool/source/localedata/data/makefile.mk @@ -278,6 +278,7 @@ SHL4OBJS= \ $(SLO)$/localedata_ku_TR.obj \ $(SLO)$/localedata_ky_KG.obj \ $(SLO)$/localedata_lg_UG.obj \ + $(SLO)$/localedata_lif_NP.obj \ $(SLO)$/localedata_ln_CD.obj \ $(SLO)$/localedata_lo_LA.obj \ $(SLO)$/localedata_mai_IN.obj \ diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 30b56c0d9f7f..8e3ce2544db0 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -253,7 +253,8 @@ static const struct { { "plt_MG", lcl_DATA_OTHERS }, { "mai_IN", lcl_DATA_OTHERS }, { "yi_US", lcl_DATA_OTHERS }, - { "haw_US", lcl_DATA_OTHERS } + { "haw_US", lcl_DATA_OTHERS }, + { "lif_NP", lcl_DATA_OTHERS } }; static const sal_Unicode under = sal_Unicode('_'); diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src index b40dc16ddc30..f0d63077d69b 100644 --- a/svtools/source/misc/langtab.src +++ b/svtools/source/misc/langtab.src @@ -325,6 +325,7 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE < "Rusyn (Slovakia)" ; LANGUAGE_USER_RUSYN_SLOVAKIA ; > ; < "Yiddish (USA)" ; LANGUAGE_USER_YIDDISH_US ; > ; < "Hawaiian" ; LANGUAGE_HAWAIIAN_UNITED_STATES ; > ; + < "Limbu" ; LANGUAGE_USER_LIMBU ; > ; }; }; -- cgit v1.2.3 From 00abb7e08b1a2de2200878ec58c968bc8717565a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Sun, 16 Jan 2011 21:18:35 +0100 Subject: gridsort: GCC WaE --- svtools/inc/svtools/table/tablemodel.hxx | 2 +- svtools/source/table/gridtablerenderer.cxx | 2 ++ svtools/source/uno/svtxgridcontrol.cxx | 4 +++- svtools/source/uno/unocontroltablemodel.cxx | 2 -- 4 files changed, 6 insertions(+), 4 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 026b792c39e8..be2d21fff42c 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -77,7 +77,7 @@ namespace svt { namespace table /// denotes column attributes related to the appearance of the column, i.e. those relevant for rendering #define COL_ATTRS_APPEARANCE (0x00000002) /// denotes the entirety of column attributes - #define COL_ATTRS_ALL (0xFFFFFFFF) + #define COL_ATTRS_ALL (0x7FFFFFFF) //==================================================================== //= ITableModelListener diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 8fc95c203b7a..201c128855e6 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -492,6 +492,8 @@ namespace svt { namespace table OSL_UNUSED( i_active ); OSL_UNUSED( i_selected ); + OSL_UNUSED( i_rowPos ); + OSL_UNUSED( i_colPos ); return true; } diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index e95becad8876..fe6c8fee5119 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -547,9 +547,10 @@ void SAL_CALL SVTXGridControl::dataChanged( const GridDataEvent& i_event ) throw } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL SVTXGridControl::rowTitleChanged( const GridDataEvent& Event ) throw (RuntimeException) +void SAL_CALL SVTXGridControl::rowTitleChanged( const GridDataEvent& i_event ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); + OSL_UNUSED( i_event ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowTitleChanged: no control (anymore)!" ); @@ -586,6 +587,7 @@ void SAL_CALL SVTXGridControl::elementReplaced( const ContainerEvent& i_event ) { OSL_ENSURE( false, "SVTXGridControl::elementReplaced: not implemented!" ); // at the moment, the XGridColumnModel API does not allow replacing columns + OSL_UNUSED( i_event ); // TODO: replace the respective column in our table model } diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 17aac65c0dfb..e2881eb22fc6 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -312,8 +312,6 @@ namespace svt { namespace table if ( m_pImpl->aColumns.empty() ) return; - const ColPos nLastIndex = m_pImpl->aColumns.size() - 1; - // dispose the column instances for ( ColumnModels::const_iterator col = m_pImpl->aColumns.begin(); col != m_pImpl->aColumns.end(); -- cgit v1.2.3 From 7d8bdf3acc166a2816e501b6a8c0b8ec126703de Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Sun, 16 Jan 2011 21:50:59 +0100 Subject: locales34: #i115482# added Lojban [jbo] to language list --- i18npool/inc/i18npool/lang.h | 1 + i18npool/source/isolang/isolang.cxx | 3 +++ svtools/source/misc/langtab.src | 1 + 3 files changed, 5 insertions(+) (limited to 'svtools') diff --git a/i18npool/inc/i18npool/lang.h b/i18npool/inc/i18npool/lang.h index 0fd4f38f0f6d..cc236cef103d 100644 --- a/i18npool/inc/i18npool/lang.h +++ b/i18npool/inc/i18npool/lang.h @@ -517,6 +517,7 @@ typedef unsigned short LanguageType; #define LANGUAGE_USER_RUSYN_SLOVAKIA 0x8256 /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_USER_RUSYN_UKRAINE)) */ #define LANGUAGE_USER_YIDDISH_US 0x083D /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_YIDDISH)) */ #define LANGUAGE_USER_LIMBU 0x0657 +#define LANGUAGE_USER_LOJBAN 0x0658 /* no locale */ #endif /* INCLUDED_I18NPOOL_LANG_H */ diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx index dffc38873282..02b2d266e106 100644 --- a/i18npool/source/isolang/isolang.cxx +++ b/i18npool/source/isolang/isolang.cxx @@ -463,6 +463,7 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = { LANGUAGE_USER_RUSYN_UKRAINE, "rue", "UA" }, { LANGUAGE_USER_RUSYN_SLOVAKIA, "rue", "SK" }, { LANGUAGE_USER_LIMBU, "lif", "NP" }, + { LANGUAGE_USER_LOJBAN, "jbo", "" }, { LANGUAGE_NONE, "zxx", "" }, // added to ISO 639-2 on 2006-01-11: Used to declare the absence of linguistic information { LANGUAGE_DONTKNOW, "", "" } // marks end of table }; @@ -687,6 +688,7 @@ static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry( LanguageType nLan case LANGUAGE_BASQUE: case LANGUAGE_USER_ESPERANTO: case LANGUAGE_USER_INTERLINGUA: + case LANGUAGE_USER_LOJBAN: return *pEntry; default: ; // nothing @@ -767,6 +769,7 @@ static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry( case LANGUAGE_BASQUE: case LANGUAGE_USER_ESPERANTO: case LANGUAGE_USER_INTERLINGUA: + case LANGUAGE_USER_LOJBAN: return *pEntry; default: ; // nothing diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src index f0d63077d69b..5e7295bb7a5d 100644 --- a/svtools/source/misc/langtab.src +++ b/svtools/source/misc/langtab.src @@ -326,6 +326,7 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE < "Yiddish (USA)" ; LANGUAGE_USER_YIDDISH_US ; > ; < "Hawaiian" ; LANGUAGE_HAWAIIAN_UNITED_STATES ; > ; < "Limbu" ; LANGUAGE_USER_LIMBU ; > ; + < "Lojban" ; LANGUAGE_USER_LOJBAN ; > ; }; }; -- cgit v1.2.3 From 4f92c0948774b3e85642699b38ee1d560515e271 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Sun, 16 Jan 2011 22:18:56 +0100 Subject: locales34: #i115633# added Kabyle [kab-DZ] to language list --- i18npool/inc/i18npool/lang.h | 1 + i18npool/source/isolang/isolang.cxx | 1 + svtools/source/misc/langtab.src | 1 + 3 files changed, 3 insertions(+) (limited to 'svtools') diff --git a/i18npool/inc/i18npool/lang.h b/i18npool/inc/i18npool/lang.h index cc236cef103d..91da0e3ec78f 100644 --- a/i18npool/inc/i18npool/lang.h +++ b/i18npool/inc/i18npool/lang.h @@ -518,6 +518,7 @@ typedef unsigned short LanguageType; #define LANGUAGE_USER_YIDDISH_US 0x083D /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_YIDDISH)) */ #define LANGUAGE_USER_LIMBU 0x0657 #define LANGUAGE_USER_LOJBAN 0x0658 /* no locale */ +#define LANGUAGE_USER_KABYLE 0x0659 #endif /* INCLUDED_I18NPOOL_LANG_H */ diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx index 02b2d266e106..f174ad431a57 100644 --- a/i18npool/source/isolang/isolang.cxx +++ b/i18npool/source/isolang/isolang.cxx @@ -464,6 +464,7 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = { LANGUAGE_USER_RUSYN_SLOVAKIA, "rue", "SK" }, { LANGUAGE_USER_LIMBU, "lif", "NP" }, { LANGUAGE_USER_LOJBAN, "jbo", "" }, + { LANGUAGE_USER_KABYLE, "kab", "DZ" }, { LANGUAGE_NONE, "zxx", "" }, // added to ISO 639-2 on 2006-01-11: Used to declare the absence of linguistic information { LANGUAGE_DONTKNOW, "", "" } // marks end of table }; diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src index 5e7295bb7a5d..effe6506cb1f 100644 --- a/svtools/source/misc/langtab.src +++ b/svtools/source/misc/langtab.src @@ -327,6 +327,7 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE < "Hawaiian" ; LANGUAGE_HAWAIIAN_UNITED_STATES ; > ; < "Limbu" ; LANGUAGE_USER_LIMBU ; > ; < "Lojban" ; LANGUAGE_USER_LOJBAN ; > ; + < "Kabyle" ; LANGUAGE_USER_KABYLE ; > ; }; }; -- cgit v1.2.3 From 70315564786969decd1ee9eeb2549ce6545be1f3 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Sun, 16 Jan 2011 22:18:58 +0100 Subject: gridsort: made the row title a row heading, being an Any instead of a string --- svtools/inc/svtools/table/tablemodel.hxx | 2 +- svtools/source/table/gridtablerenderer.cxx | 17 +++++++++++------ svtools/source/table/tablecontrol.cxx | 4 +++- svtools/source/table/tablecontrol_impl.cxx | 4 ++-- svtools/source/uno/svtxgridcontrol.cxx | 4 ++-- svtools/source/uno/svtxgridcontrol.hxx | 2 +- svtools/source/uno/unocontroltablemodel.cxx | 10 +++++----- svtools/source/uno/unocontroltablemodel.hxx | 2 +- .../source/controls/grid/defaultgriddatamodel.cxx | 22 +++++++++++----------- .../source/controls/grid/defaultgriddatamodel.hxx | 14 +++++++------- .../source/controls/grid/grideventforwarder.cxx | 4 ++-- .../source/controls/grid/grideventforwarder.hxx | 2 +- 12 files changed, 47 insertions(+), 40 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index be2d21fff42c..c5855414db97 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -460,7 +460,7 @@ namespace svt { namespace table /** retrieves title of a given row */ - virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const = 0; + virtual ::com::sun::star::uno::Any getRowHeading( RowPos const i_rowPos ) const = 0; /** returns the color to be used for rendering the grid lines. diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 201c128855e6..ef3ef711267c 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -306,13 +306,18 @@ namespace svt { namespace table _rDevice.SetLineColor( lineColor ); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); - ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderTextColor(), _rStyle, &StyleSettings::GetFieldTextColor ); - _rDevice.SetTextColor( textColor ); + Any const rowHeading( m_pImpl->rModel.getRowHeading( m_pImpl->nCurrentRow ) ); + ::rtl::OUString const rowTitle( CellValueConversion::convertToString( rowHeading ) ); + if ( rowTitle.getLength() ) + { + ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderTextColor(), _rStyle, &StyleSettings::GetFieldTextColor ); + _rDevice.SetTextColor( textColor ); - Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) ); - ULONG const nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, 0 ) | TEXT_DRAW_CLIP; - // TODO: is using the horizontal alignment of the 0'th column a good idea here? This is pretty ... arbitray .. - _rDevice.DrawText( aTextRect, m_pImpl->rModel.getRowHeader( m_pImpl->nCurrentRow ), nDrawTextFlags ); + Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) ); + ULONG const nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, 0 ) | TEXT_DRAW_CLIP; + // TODO: is using the horizontal alignment of the 0'th column a good idea here? This is pretty ... arbitray .. + _rDevice.DrawText( aTextRect, rowTitle, nDrawTextFlags ); + } // TODO: active? selected? (void)_bActive; diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 500b2ca423e9..c448af323b8b 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -364,7 +364,9 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString TableControl::GetRowName( sal_Int32 _nIndex) const { - return GetModel()->getRowHeader( _nIndex ); + ::rtl::OUString sRowName; + GetModel()->getRowHeading( _nIndex ) >>= sRowName; + return sRowName; } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index e7d781018f34..26a11fd7049d 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -209,10 +209,10 @@ namespace svt { namespace table virtual void getCellToolTip( ColPos const, RowPos const, ::com::sun::star::uno::Any& ) { } - virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const + virtual Any getRowHeading( RowPos const i_rowPos ) const { (void)i_rowPos; - return ::rtl::OUString(); + return Any(); } }; diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index fe6c8fee5119..57c0040935cc 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -547,13 +547,13 @@ void SAL_CALL SVTXGridControl::dataChanged( const GridDataEvent& i_event ) throw } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL SVTXGridControl::rowTitleChanged( const GridDataEvent& i_event ) throw (RuntimeException) +void SAL_CALL SVTXGridControl::rowHeadingChanged( const GridDataEvent& i_event ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); OSL_UNUSED( i_event ); TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowTitleChanged: no control (anymore)!" ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowHeadingChanged: no control (anymore)!" ); // TODO: we could do better than this - invalidate the header area only pTable->Invalidate(); diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx index 7ac53ecd4cba..525327b3c760 100644 --- a/svtools/source/uno/svtxgridcontrol.hxx +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -74,7 +74,7 @@ public: virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rowTitleChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowHeadingChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); // XContainerListener virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index e2881eb22fc6..a47b798c7d59 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -566,24 +566,24 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - ::rtl::OUString UnoControlTableModel::getRowHeader( RowPos const i_rowPos ) const + Any UnoControlTableModel::getRowHeading( RowPos const i_rowPos ) const { DBG_CHECK_ME(); - ::rtl::OUString sRowHeader; + Any aRowHeading; Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); - ENSURE_OR_RETURN( xDataModel.is(), "UnoControlTableModel::getRowHeader: no data model anymore!", sRowHeader ); + ENSURE_OR_RETURN( xDataModel.is(), "UnoControlTableModel::getRowHeading: no data model anymore!", aRowHeading ); try { - sRowHeader = xDataModel->getRowTitle( i_rowPos ); + aRowHeading = xDataModel->getRowHeading( i_rowPos ); } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - return sRowHeader; + return aRowHeading; } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index f89419ac071f..85a4b9480370 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -85,7 +85,7 @@ namespace svt { namespace table virtual void removeTableModelListener( const PTableModelListener& i_listener ); virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ); virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ); - virtual ::rtl::OUString getRowHeader( RowPos const i_rowPos ) const; + virtual ::com::sun::star::uno::Any getRowHeading( RowPos const i_rowPos ) const; virtual ::boost::optional< ::Color > getLineColor() const; virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const; virtual ::boost::optional< ::Color > getHeaderTextColor() const; diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index ab0ba1734e53..d113415ccf79 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -163,7 +163,7 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - ::rtl::OUString SAL_CALL DefaultGridDataModel::getRowTitle( ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) + Any SAL_CALL DefaultGridDataModel::getRowHeading( ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) { ::comphelper::ComponentGuard aGuard( *this, rBHelper ); @@ -174,14 +174,14 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::addRow( const ::rtl::OUString& i_title, const Sequence< Any >& i_data ) throw (RuntimeException) + void SAL_CALL DefaultGridDataModel::addRow( const Any& i_heading, const Sequence< Any >& i_data ) throw (RuntimeException) { ::comphelper::ComponentGuard aGuard( *this, rBHelper ); sal_Int32 const columnCount = i_data.getLength(); // store header name - m_aRowHeaders.push_back( i_title ); + m_aRowHeaders.push_back( i_heading ); // store row m_aData impl_addRow( i_data ); @@ -213,14 +213,14 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::addRows( const Sequence< ::rtl::OUString >& i_titles, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException) + void SAL_CALL DefaultGridDataModel::addRows( const Sequence< Any >& i_headings, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException) { - if ( i_titles.getLength() != i_data.getLength() ) + if ( i_headings.getLength() != i_data.getLength() ) throw IllegalArgumentException( ::rtl::OUString(), *this, -1 ); ::comphelper::ComponentGuard aGuard( *this, rBHelper ); - sal_Int32 const rowCount = i_titles.getLength(); + sal_Int32 const rowCount = i_headings.getLength(); if ( rowCount == 0 ) return; @@ -235,7 +235,7 @@ namespace toolkit for ( sal_Int32 row=0; row= m_aRowHeaders.size() ) ) throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); - m_aRowHeaders[ i_rowIndex ] = i_title; + m_aRowHeaders[ i_rowIndex ] = i_heading; broadcast( GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ), - &XGridDataListener::rowTitleChanged, + &XGridDataListener::rowHeadingChanged, aGuard ); } @@ -395,7 +395,7 @@ namespace toolkit GridData aEmptyData; m_aData.swap( aEmptyData ); - ::std::vector< ::rtl::OUString > aEmptyRowHeaders; + ::std::vector< Any > aEmptyRowHeaders; m_aRowHeaders.swap( aEmptyRowHeaders ); m_nColumnCount = 0; diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 7f87aa16cfa7..13a31277e533 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -63,13 +63,13 @@ public: virtual ~DefaultGridDataModel(); // XMutableGridDataModel - virtual void SAL_CALL addRow( const ::rtl::OUString& Title, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Data ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addRows( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& Titles, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& Data ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRow( const Any& i_heading, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Data ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& Headings, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& Data ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeRow( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeAllRows( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateCellData( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateRowData( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRowTitle( ::sal_Int32 RowIndex, const ::rtl::OUString& Title ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRowHeading( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Heading ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateCellToolTip( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateRowToolTip( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); @@ -80,7 +80,7 @@ public: virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getCellToolTip( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getRowTitle( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getRowHeading( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); // OComponentHelper virtual void SAL_CALL disposing(); @@ -110,9 +110,9 @@ private: CellData& impl_getCellDataAccess_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex ); RowData& impl_getRowDataAccess_throw( sal_Int32 const i_rowIndex, size_t const i_requiredColumnCount ); - GridData m_aData; - ::std::vector< ::rtl::OUString > m_aRowHeaders; - sal_Int32 m_nColumnCount; + GridData m_aData; + ::std::vector< ::com::sun::star::uno::Any > m_aRowHeaders; + sal_Int32 m_nColumnCount; }; } diff --git a/toolkit/source/controls/grid/grideventforwarder.cxx b/toolkit/source/controls/grid/grideventforwarder.cxx index 68293025bd4e..c3760b8315a3 100755 --- a/toolkit/source/controls/grid/grideventforwarder.cxx +++ b/toolkit/source/controls/grid/grideventforwarder.cxx @@ -105,11 +105,11 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridEventForwarder::rowTitleChanged( const GridDataEvent& i_event ) throw (RuntimeException) + void SAL_CALL GridEventForwarder::rowHeadingChanged( const GridDataEvent& i_event ) throw (RuntimeException) { Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); if ( xPeer.is() ) - xPeer->rowTitleChanged( i_event ); + xPeer->rowHeadingChanged( i_event ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/grideventforwarder.hxx b/toolkit/source/controls/grid/grideventforwarder.hxx index 0abdcc59fd85..5a8b03f57037 100755 --- a/toolkit/source/controls/grid/grideventforwarder.hxx +++ b/toolkit/source/controls/grid/grideventforwarder.hxx @@ -64,7 +64,7 @@ namespace toolkit virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rowTitleChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowHeadingChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); // XContainerListener virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From dbff9efb818fa543dac91591930d75bfee429a11 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 17 Jan 2011 12:19:05 +0100 Subject: gridsort: delegated the column resize functionality to the DefaultInputHandler implementation --- svtools/inc/svtools/table/defaultinputhandler.hxx | 5 +- .../inc/svtools/table/tablecontrolinterface.hxx | 103 +++++++-- svtools/source/table/defaultinputhandler.cxx | 131 +++++++++--- svtools/source/table/gridtablerenderer.cxx | 4 +- svtools/source/table/tablecontrol_impl.cxx | 233 ++++++++------------- svtools/source/table/tablecontrol_impl.hxx | 44 ++-- svtools/source/table/tabledatawindow.cxx | 129 +++++------- svtools/source/table/tabledatawindow.hxx | 3 - 8 files changed, 360 insertions(+), 292 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/defaultinputhandler.hxx b/svtools/inc/svtools/table/defaultinputhandler.hxx index 31b5db319290..5be517d2c623 100644 --- a/svtools/inc/svtools/table/defaultinputhandler.hxx +++ b/svtools/inc/svtools/table/defaultinputhandler.hxx @@ -27,7 +27,8 @@ #ifndef SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX #define SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX -#include +#include "svtools/table/tableinputhandler.hxx" +#include "svtools/table/tabletypes.hxx" //........................................................................ namespace svt { namespace table @@ -44,7 +45,7 @@ namespace svt { namespace table friend class TableDataWindow; private: DefaultInputHandler_Impl* m_pImpl; - bool m_bResize; + ColPos m_nResizingColumn; public: DefaultInputHandler(); diff --git a/svtools/inc/svtools/table/tablecontrolinterface.hxx b/svtools/inc/svtools/table/tablecontrolinterface.hxx index 359fd65815ef..038a701173be 100644 --- a/svtools/inc/svtools/table/tablecontrolinterface.hxx +++ b/svtools/inc/svtools/table/tablecontrolinterface.hxx @@ -34,11 +34,16 @@ #include "svtools/table/tabletypes.hxx" #include "svtools/table/tablemodel.hxx" -//........................................................................ +class Pointer; + +//...................................................................................................................... namespace svt { namespace table { -//........................................................................ +//...................................................................................................................... + //================================================================================================================== + //= TableControlAction + //================================================================================================================== enum TableControlAction { /// moves the cursor in the table control one row up, if possible, by keeping the current column @@ -80,9 +85,70 @@ namespace svt { namespace table invalidTableControlAction }; - //==================================================================== + //================================================================================================================== + //= TableCellArea + //================================================================================================================== + enum TableCellArea + { + CellContent, + ColumnDivider + }; + + //================================================================================================================== + //= TableCell + //================================================================================================================== + struct TableCell + { + ColPos nColumn; + RowPos nRow; + TableCellArea eArea; + + TableCell() + :nColumn( COL_INVALID ) + ,nRow( ROW_INVALID ) + ,eArea( CellContent ) + { + } + + TableCell( ColPos const i_column, RowPos const i_row ) + :nColumn( i_column ) + ,nRow( i_row ) + ,eArea( CellContent ) + { + } + }; + + //================================================================================================================== + //= ColumnMetrics + //================================================================================================================== + struct ColumnMetrics + { + /** the start of the column, in pixels. Might be negative, in case the column is scrolled out of the visible + area. + */ + long nStartPixel; + + /** the end of the column, in pixels, plus 1. Effectively, this is the accumulated width of a all columns + up to the current one. + */ + long nEndPixel; + + ColumnMetrics() + :nStartPixel(0) + ,nEndPixel(0) + { + } + + ColumnMetrics( long const i_start, long const i_end ) + :nStartPixel( i_start ) + ,nEndPixel( i_end ) + { + } + }; + + //================================================================================================================== //= ITableControl - //==================================================================== + //================================================================================================================== /** defines a callback interface to be implemented by a concrete table control */ class SAL_NO_VTABLE ITableControl @@ -126,24 +192,35 @@ namespace svt { namespace table virtual PTableModel getModel() const = 0; /// returns the index of the currently active column - virtual ColPos getCurrentColumn() const = 0; + virtual ColPos getCurrentColumn() const = 0; /// returns the index of the currently active row - virtual RowPos getCurrentRow() const = 0; + virtual RowPos getCurrentRow() const = 0; + + virtual ::Size getTableSizePixel() const = 0; + virtual void setPointer( Pointer const & i_pointer ) = 0; + virtual void captureMouse() = 0; + virtual void releaseMouse() = 0; + virtual void invalidate() = 0; + virtual long pixelWidthToAppFont( long const i_pixels ) const = 0; + + virtual void hideTracking() = 0; + virtual void showTracking( Rectangle const & i_location, sal_uInt16 const i_flags ) = 0; virtual void activateCellAt( const Point& rPoint ) = 0; - virtual RowPos getRowAtPoint( const Point& rPoint ) const = 0; - virtual ColPos getColAtPoint( const Point& rPoint ) const = 0; - virtual void resizeColumn(const Point& rPoint ) = 0; - virtual bool checkResizeColumn(const Point& rPoint) = 0; - virtual bool endResizeColumn(const Point& rPoint) = 0; + + virtual RowPos getRowAtPoint( const Point& rPoint ) const = 0; + virtual ColPos getColAtPoint( const Point& rPoint ) const = 0; + virtual TableCell hitTest( const Point& rPoint ) const = 0; + virtual ColumnMetrics getColumnMetrics( ColPos const i_column ) const = 0; + virtual bool isRowSelected( RowPos _nRow ) const = 0; virtual ~ITableControl() {}; }; -//........................................................................ +//...................................................................................................................... } } // namespace svt::table -//........................................................................ +//...................................................................................................................... #endif // SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index 9b28860ca0ae..add92e850c4f 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -51,7 +51,7 @@ namespace svt { namespace table //-------------------------------------------------------------------- DefaultInputHandler::DefaultInputHandler() :m_pImpl( new DefaultInputHandler_Impl ) - ,m_bResize(false) + ,m_nResizingColumn( COL_INVALID ) { } @@ -62,40 +62,84 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - bool DefaultInputHandler::MouseMove( ITableControl& _rControl, const MouseEvent& _rMEvt ) + bool DefaultInputHandler::MouseMove( ITableControl& i_control, const MouseEvent& _rMEvt ) { - Point aPoint = _rMEvt.GetPosPixel(); - if ( m_bResize ) + Point const aPoint = _rMEvt.GetPosPixel(); + + // resize test + if ( m_nResizingColumn != COL_INVALID ) { - _rControl.resizeColumn( aPoint ); + ::Size const tableSize = i_control.getTableSizePixel(); + + // set proper pointer + Pointer aNewPointer( POINTER_ARROW ); + ColumnMetrics const & columnMetrics( i_control.getColumnMetrics( m_nResizingColumn ) ); + if ( ( aPoint.X() > tableSize.Width() ) + || ( aPoint.X() < columnMetrics.nStartPixel ) + ) + { + aNewPointer = Pointer( POINTER_NOTALLOWED ); + } + else + { + aNewPointer = Pointer( POINTER_HSPLIT ); + } + i_control.setPointer( aNewPointer ); + + // show tracking line + i_control.hideTracking(); + i_control.showTracking( + Rectangle( + Point( aPoint.X(), 0 ), + Size( 1, tableSize.Height() ) + ), + SHOWTRACK_SPLIT | SHOWTRACK_WINDOW + ); return true; } - return false; + + // test for column divider, adjust the mouse pointer, if necessary + Pointer aNewPointer( POINTER_ARROW ); + + TableCell const tableCell = i_control.hitTest( aPoint ); + if ( ( tableCell.nRow == ROW_COL_HEADERS ) && ( tableCell.eArea == ColumnDivider ) ) + { + aNewPointer = Pointer( POINTER_HSPLIT ); + } + + i_control.setPointer( aNewPointer ); + return true; } //-------------------------------------------------------------------- - bool DefaultInputHandler::MouseButtonDown( ITableControl& _rControl, const MouseEvent& _rMEvt ) + bool DefaultInputHandler::MouseButtonDown( ITableControl& i_tableControl, const MouseEvent& _rMEvt ) { bool bHandled = false; - Point aPoint = _rMEvt.GetPosPixel(); - RowPos nRow = _rControl.getRowAtPoint( aPoint ); - if ( nRow == ROW_COL_HEADERS ) + Point const aPoint = _rMEvt.GetPosPixel(); + TableCell const tableCell( i_tableControl.hitTest( aPoint ) ); + if ( tableCell.nRow == ROW_COL_HEADERS ) { - m_bResize = _rControl.checkResizeColumn(aPoint); + if ( ( tableCell.nColumn != COL_INVALID ) + && ( tableCell.eArea == ColumnDivider ) + ) + { + m_nResizingColumn = tableCell.nColumn; + i_tableControl.captureMouse(); + } bHandled = true; } - else if(nRow >= 0) + else if ( tableCell.nRow >= 0 ) { bool bSetCursor = false; - if ( _rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) + if ( i_tableControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) { bSetCursor = true; } else { - if ( !_rControl.isRowSelected( nRow ) ) + if ( !i_tableControl.isRowSelected( tableCell.nRow ) ) { - bHandled = _rControl.getSelEngine()->SelMouseButtonDown( _rMEvt ); + bHandled = i_tableControl.getSelEngine()->SelMouseButtonDown( _rMEvt ); } else { @@ -105,32 +149,71 @@ namespace svt { namespace table if ( bSetCursor ) { - _rControl.activateCellAt( aPoint ); + i_tableControl.activateCellAt( aPoint ); bHandled = true; } } return bHandled; } //-------------------------------------------------------------------- - bool DefaultInputHandler::MouseButtonUp( ITableControl& _rControl, const MouseEvent& _rMEvt ) + bool DefaultInputHandler::MouseButtonUp( ITableControl& i_tableControl, const MouseEvent& _rMEvt ) { bool bHandled = false; - const Point aPoint = _rMEvt.GetPosPixel(); - - if ( m_bResize ) + Point const aPoint = _rMEvt.GetPosPixel(); + if ( m_nResizingColumn != COL_INVALID ) { - m_bResize = _rControl.endResizeColumn( aPoint ); + i_tableControl.hideTracking(); + PColumnModel const pColumn = i_tableControl.getModel()->getColumnModel( m_nResizingColumn ); + long const maxWidthLogical = pColumn->getMaxWidth(); + long const minWidthLogical = pColumn->getMinWidth(); + + // new position of mouse + long const requestedEnd = aPoint.X(); + + // old position of right border + long const oldEnd = i_tableControl.getColumnMetrics( m_nResizingColumn ).nEndPixel; + + // position of left border if cursor in the to-be-resized column + long const columnStart = i_tableControl.getColumnMetrics( m_nResizingColumn ).nStartPixel; + long const requestedWidth = requestedEnd - columnStart; + // TODO: this is not correct, strictly: It assumes that the mouse was pressed exactly on the "end" pos, + // but for a while now, we have relaxed this, and allow clicking a few pixels aside, too + + if ( requestedEnd >= columnStart ) + { + long requestedWidthLogical = i_tableControl.pixelWidthToAppFont( requestedWidth ); + // respect column width limits + if ( oldEnd > requestedEnd ) + { + // column has become smaller, check against minimum width + if ( ( minWidthLogical != 0 ) && ( requestedWidthLogical < minWidthLogical ) ) + requestedWidthLogical = minWidthLogical; + } + else if ( oldEnd < requestedEnd ) + { + // column has become larger, check against max width + if ( ( maxWidthLogical != 0 ) && ( requestedWidthLogical >= maxWidthLogical ) ) + requestedWidthLogical = maxWidthLogical; + } + pColumn->setWidth( requestedWidthLogical ); + i_tableControl.invalidate(); + } + + i_tableControl.setPointer( Pointer() ); + i_tableControl.releaseMouse(); + + m_nResizingColumn = COL_INVALID; bHandled = true; } - else if ( _rControl.getRowAtPoint( aPoint ) >= 0 ) + else if ( i_tableControl.getRowAtPoint( aPoint ) >= 0 ) { - if ( _rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) + if ( i_tableControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) { bHandled = true; } else { - bHandled = _rControl.getSelEngine()->SelMouseButtonUp( _rMEvt ); + bHandled = i_tableControl.getSelEngine()->SelMouseButtonUp( _rMEvt ); } } return bHandled; diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index ef3ef711267c..5fa7e0ab6f8d 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -202,7 +202,7 @@ namespace svt { namespace table _rDevice.Push( PUSH_LINECOLOR); String sHeaderText; - PColumnModel pColumn = m_pImpl->rModel.getColumnModel( _nCol ); + PColumnModel const pColumn = m_pImpl->rModel.getColumnModel( _nCol ); DBG_ASSERT( !!pColumn, "GridTableRenderer::PaintColumnHeader: invalid column model object!" ); if ( !!pColumn ) sHeaderText = pColumn->getName(); @@ -214,7 +214,7 @@ namespace svt { namespace table ULONG const nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, _nCol ) | TEXT_DRAW_CLIP; _rDevice.DrawText( aTextRect, sHeaderText, nDrawTextFlags ); - ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() ); + ::boost::optional< ::Color > const aLineColor( m_pImpl->rModel.getLineColor() ); ::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor; _rDevice.SetLineColor( lineColor ); _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight()); diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 26a11fd7049d..cdae26548a43 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -434,8 +434,6 @@ namespace svt { namespace table ,m_aSelectedRows ( ) ,m_pTableFunctionSet ( new TableFunctionSet( this ) ) ,m_nAnchor ( -1 ) - ,m_bResizingColumn ( false ) - ,m_nResizingColumn ( 0 ) ,m_bResizingGrid ( false ) ,m_bUpdatingColWidths ( false ) ,m_pAccessibleTable ( NULL ) @@ -712,7 +710,10 @@ namespace svt { namespace table if ( nGroup & COL_ATTRS_WIDTH ) { if ( !m_bUpdatingColWidths ) + { impl_ni_updateColumnWidths(); + impl_ni_updateScrollbars(); + } nGroup &= ~COL_ATTRS_WIDTH; } @@ -901,7 +902,7 @@ namespace svt { namespace table const long columnStart = accumulatedPixelWidth; const long columnEnd = columnStart + aPrePixelWidths[i]; - m_aColumnWidths.push_back( ColumnWidthInfo( columnStart, columnEnd ) ); + m_aColumnWidths.push_back( MutableColumnMetrics( columnStart, columnEnd ) ); accumulatedPixelWidth = columnEnd; } @@ -925,7 +926,7 @@ namespace svt { namespace table ) { // make the last resizable column wider - ColumnWidthInfo& rResizeColInfo( m_aColumnWidths[ lastResizableCol ] ); + MutableColumnMetrics& rResizeColInfo( m_aColumnWidths[ lastResizableCol ] ); rResizeColInfo.setEnd( rResizeColInfo.getEnd() + freeSpaceRight ); // update the column model @@ -1198,8 +1199,7 @@ namespace svt { namespace table { if ( m_nColumnCount != 0 ) { - if ( m_bResizingGrid ) - impl_ni_updateColumnWidths(); + impl_ni_updateColumnWidths(); impl_ni_updateScrollbars(); checkCursorPosition(); m_bResizingGrid = true; @@ -1207,16 +1207,15 @@ namespace svt { namespace table } else { - //In the case that column headers are defined but data hasn't yet been set, - //only column headers will be shown + // In the case that column headers are defined but data hasn't yet been set, + // only column headers will be shown if ( m_pModel->hasColumnHeaders() ) { if ( m_nColHeaderHeightPixel > 1 ) { m_pDataWindow->SetSizePixel( m_rAntiImpl.GetOutputSizePixel() ); - if ( m_bResizingGrid ) - //update column widths to fit in grid - impl_ni_updateColumnWidths(); + // update column widths to fit in grid + impl_ni_updateColumnWidths(); m_bResizingGrid = true; } } @@ -1826,18 +1825,36 @@ namespace svt { namespace table if ( ( rPoint.X() >= 0 ) && ( rPoint.X() < m_nRowHeaderWidthPixel ) ) return COL_ROW_HEADERS; - Rectangle aAllCellsArea; - impl_getAllVisibleCellsArea( aAllCellsArea ); + return impl_getColumnForOrdinate( rPoint.X() ); + } - TableColumnGeometry aHitTest( *this, aAllCellsArea, COL_ROW_HEADERS ); - while ( aHitTest.isValid() ) + //------------------------------------------------------------------------------------------------------------------ + TableCell TableControl_Impl::hitTest( Point const & i_point ) const + { + TableCell aCell( getColAtPoint( i_point ), getRowAtPoint( i_point ) ); + if ( aCell.nColumn > COL_ROW_HEADERS ) { - if ( aHitTest.getRect().IsInside( rPoint ) ) - return aHitTest.getCol(); - aHitTest.moveRight(); + PColumnModel const pColumn = m_pModel->getColumnModel( aCell.nColumn ); + MutableColumnMetrics const & rColInfo( m_aColumnWidths[ aCell.nColumn ] ); + if ( ( rColInfo.getEnd() - 3 <= i_point.X() ) + && ( rColInfo.getEnd() >= i_point.X() ) + && pColumn->isResizable() + ) + { + aCell.eArea = ColumnDivider; + } } + return aCell; + } + + //------------------------------------------------------------------------------------------------------------------ + ColumnMetrics TableControl_Impl::getColumnMetrics( ColPos const i_column ) const + { + DBG_CHECK_ME(); - return COL_INVALID; + ENSURE_OR_RETURN( ( i_column >= 0 ) && ( i_column < m_pModel->getColumnCount() ), + "TableControl_Impl::getColumnMetrics: illegal column index!", ColumnMetrics() ); + return (ColumnMetrics const &)m_aColumnWidths[ i_column ]; } //------------------------------------------------------------------------------------------------------------------ @@ -1858,6 +1875,55 @@ namespace svt { namespace table return m_nCurRow; } + //------------------------------------------------------------------------------------------------------------------ + ::Size TableControl_Impl::getTableSizePixel() const + { + return m_pDataWindow->GetOutputSizePixel(); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::setPointer( Pointer const & i_pointer ) + { + DBG_CHECK_ME(); + m_pDataWindow->SetPointer( i_pointer ); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::captureMouse() + { + m_pDataWindow->CaptureMouse(); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::releaseMouse() + { + m_pDataWindow->ReleaseMouse(); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::invalidate() + { + m_pDataWindow->Invalidate(); + } + + //------------------------------------------------------------------------------------------------------------------ + long TableControl_Impl::pixelWidthToAppFont( long const i_pixels ) const + { + return m_pDataWindow->PixelToLogic( Size( i_pixels, 0 ), MAP_APPFONT ).Width(); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::hideTracking() + { + m_pDataWindow->HideTracking(); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl_Impl::showTracking( Rectangle const & i_location, sal_uInt16 const i_flags ) + { + m_pDataWindow->ShowTracking( i_location, i_flags ); + } + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::activateCellAt(const Point& rPoint) { @@ -2344,135 +2410,6 @@ namespace svt { namespace table return true; } - //-------------------------------------------------------------------- - void TableControl_Impl::resizeColumn( const Point& rPoint ) - { - Pointer aNewPointer( POINTER_ARROW ); - const ColPos hitColumn = impl_getColumnForOrdinate( rPoint.X() ); - if ( m_bResizingColumn ) - { - const ColumnWidthInfo& rColInfo( m_aColumnWidths[ m_nResizingColumn ] ); - if ( ( rPoint.X() > m_pDataWindow->GetOutputSizePixel().Width() ) - || ( rPoint.X() < rColInfo.getStart() ) - ) - { - aNewPointer = Pointer( POINTER_NOTALLOWED ); - } - else - { - aNewPointer = Pointer( POINTER_HSPLIT ); - } - m_pDataWindow->HideTracking(); - - int lineHeight = m_nColHeaderHeightPixel; - lineHeight += m_nRowHeightPixel * m_nRowCount; - const int gridHeight = m_pDataWindow->GetOutputSizePixel().Height(); - if ( lineHeight >= gridHeight ) - lineHeight = gridHeight; - - m_pDataWindow->ShowTracking( - Rectangle( - Point( rPoint.X(), 0 ), - Size( 1, lineHeight ) - ), - SHOWTRACK_SPLIT | SHOWTRACK_WINDOW - ); - } - else if ( hitColumn != COL_INVALID ) - { - // hit test for the column separator - const PColumnModel pColumn = m_pModel->getColumnModel( hitColumn ); - const ColumnWidthInfo& rColInfo( m_aColumnWidths[ hitColumn ] ); - if ( ( rColInfo.getEnd() - 2 <= rPoint.X() ) - && ( rColInfo.getEnd() + 2 > rPoint.X() ) - && pColumn->isResizable() - ) - aNewPointer = Pointer( POINTER_HSPLIT ); - } - - m_pDataWindow->SetPointer( aNewPointer ); - } - - //-------------------------------------------------------------------- - bool TableControl_Impl::checkResizeColumn( const Point& rPoint ) - { - m_bResizingGrid = false; - - if ( m_bResizingColumn ) - return true; - - const ColPos hitColumn = impl_getColumnForOrdinate( rPoint.X() ); - if ( hitColumn == COL_INVALID ) - return false; - - const PColumnModel pColumn = m_pModel->getColumnModel( hitColumn ); - const ColumnWidthInfo& rColInfo( m_aColumnWidths[ hitColumn ] ); - - // hit test for the column separator - if ( ( rColInfo.getEnd() - 2 <= rPoint.X() ) - && ( rColInfo.getEnd() + 2 > rPoint.X() ) - && pColumn->isResizable() - ) - { - m_nResizingColumn = hitColumn; - m_pDataWindow->CaptureMouse(); - m_bResizingColumn = true; - } - return m_bResizingColumn; - } - //-------------------------------------------------------------------- - bool TableControl_Impl::endResizeColumn( const Point& rPoint ) - { - DBG_CHECK_ME(); - ENSURE_OR_RETURN_FALSE( m_bResizingColumn, "TableControl_Impl::endResizeColumn: not resizing currently!" ); - - m_pDataWindow->HideTracking(); - const PColumnModel pColumn = m_pModel->getColumnModel( m_nResizingColumn ); - const long maxWidthLogical = pColumn->getMaxWidth(); - const long minWidthLogical = pColumn->getMinWidth(); - - // new position of mouse - const long requestedEnd = rPoint.X(); - - // old position of right border - const long oldEnd = m_aColumnWidths[ m_nResizingColumn ].getEnd(); - - // position of left border if cursor in the to-be-resized column - const long columnStart = m_aColumnWidths[ m_nResizingColumn ].getStart(); - const long requestedWidth = requestedEnd - columnStart; - // TODO: this is not correct, strictly: It assumes that the mouse was pressed exactly on the "end" pos, - // but for a while now, we have relaxed this, and allow clicking a few pixels aside, too - - if ( requestedEnd >= columnStart ) - { - long requestedWidthLogical = m_rAntiImpl.PixelToLogic( Size( requestedWidth, 0 ), MAP_APPFONT ).Width(); - // respect column width limits - if ( oldEnd > requestedEnd ) - { - // column has become smaller, check against minimum width - if ( ( minWidthLogical != 0 ) && ( requestedWidthLogical < minWidthLogical ) ) - requestedWidthLogical = minWidthLogical; - } - else if ( oldEnd < requestedEnd ) - { - // column has become larger, check against max width - if ( ( maxWidthLogical != 0 ) && ( requestedWidthLogical >= maxWidthLogical ) ) - requestedWidthLogical = maxWidthLogical; - } - pColumn->setPreferredWidth( requestedWidthLogical ); - } - - impl_ni_updateColumnWidths(); - impl_ni_updateScrollbars(); - m_pDataWindow->Invalidate( INVALIDATE_UPDATE ); - m_pDataWindow->SetPointer( Pointer() ); - m_bResizingColumn = false; - m_bResizingGrid = true; - - m_pDataWindow->ReleaseMouse(); - return m_bResizingColumn; - } - //-------------------------------------------------------------------- Rectangle TableControl_Impl::calcHeaderRect(bool bColHeader) { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 721847caaf7b..5b84cd9ca4cd 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -46,17 +46,15 @@ namespace svt { namespace table { //........................................................................ - struct ColumnWidthInfo + struct MutableColumnMetrics : protected ColumnMetrics { - ColumnWidthInfo() - :nStartPixel( 0 ) - ,nEndPixel( 0 ) + MutableColumnMetrics() + :ColumnMetrics() { } - ColumnWidthInfo( long const i_startPixel, long const i_endPixel ) - :nStartPixel( i_startPixel ) - ,nEndPixel( i_endPixel ) + MutableColumnMetrics( long const i_startPixel, long const i_endPixel ) + :ColumnMetrics( i_startPixel, i_endPixel ) { } @@ -68,31 +66,22 @@ namespace svt { namespace table long getWidth() const { return nEndPixel - nStartPixel; } - private: - /** the start of the column, in pixels. Might be negative, in case the column is scrolled out of the visible - area. - */ - long nStartPixel; - - /** the end of the column, in pixels, plus 1. Effectively, this is the accumulated width of a all columns - up to the current one. - */ - long nEndPixel; + ColumnMetrics const & operator()() { return *this; } }; struct ColumnInfoPositionLess { - bool operator()( ColumnWidthInfo const& i_colInfo, long const i_position ) + bool operator()( MutableColumnMetrics const& i_colInfo, long const i_position ) { return i_colInfo.getEnd() < i_position; } - bool operator()( long const i_position, ColumnWidthInfo const& i_colInfo ) + bool operator()( long const i_position, MutableColumnMetrics const& i_colInfo ) { return i_position < i_colInfo.getStart(); } }; - typedef ::std::vector< ColumnWidthInfo > ColumnPositions; + typedef ::std::vector< MutableColumnMetrics > ColumnPositions; class TableControl; class TableDataWindow; @@ -159,8 +148,6 @@ namespace svt { namespace table TableFunctionSet* m_pTableFunctionSet; //part of selection engine RowPos m_nAnchor; - bool m_bResizingColumn; - ColPos m_nResizingColumn; bool m_bResizingGrid; bool m_bUpdatingColWidths; @@ -287,12 +274,19 @@ namespace svt { namespace table virtual PTableModel getModel() const; virtual ColPos getCurrentColumn() const; virtual RowPos getCurrentRow() const; + virtual ::Size getTableSizePixel() const; + virtual void setPointer( Pointer const & i_pointer ); + virtual void captureMouse(); + virtual void releaseMouse(); + virtual void invalidate(); + virtual long pixelWidthToAppFont( long const i_pixels ) const; + virtual void hideTracking(); + virtual void showTracking( Rectangle const & i_location, sal_uInt16 const i_flags ); virtual void activateCellAt( const Point& rPoint ); virtual RowPos getRowAtPoint( const Point& rPoint ) const; virtual ColPos getColAtPoint( const Point& rPoint ) const; - virtual void resizeColumn(const Point& rPoint); - virtual bool checkResizeColumn(const Point& rPoint); - virtual bool endResizeColumn(const Point& rPoint); + virtual TableCell hitTest( const Point& rPoint ) const; + virtual ColumnMetrics getColumnMetrics( ColPos const i_column ) const; virtual bool isRowSelected( RowPos i_row ) const; diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 36966d92aea5..cdf909d9fa65 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -96,71 +96,71 @@ namespace svt { namespace table void TableDataWindow::RequestHelp( const HelpEvent& rHEvt ) { USHORT const nHelpMode = rHEvt.GetMode(); - if ( ( nHelpMode & HELPMODE_QUICK ) != 0 ) + if ( ( IsMouseCaptured() ) + || ( ( nHelpMode & HELPMODE_QUICK ) == 0 ) + ) { - ITableControl& rTableControl = m_rTableControl; - PTableModel const pTableModel( rTableControl.getModel() ); - - Point const aMousePos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ); + Window::RequestHelp( rHEvt ); + return; + } - RowPos const hitRow = rTableControl.getRowAtPoint( aMousePos ); - ColPos const hitCol = rTableControl.getColAtPoint( aMousePos ); + ::rtl::OUString sHelpText; + USHORT nHelpStyle = 0; - ::rtl::OUString sHelpText; - USHORT nHelpStyle = 0; + Point const aMousePos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ); + RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos ); + ColPos const hitCol = m_rTableControl.getColAtPoint( aMousePos ); - if ( ( hitCol >= 0 ) && ( hitCol < pTableModel->getColumnCount() ) ) + PTableModel const pTableModel( m_rTableControl.getModel() ); + if ( ( hitCol >= 0 ) && ( hitCol < pTableModel->getColumnCount() ) ) + { + if ( hitRow == ROW_COL_HEADERS ) { - if ( hitRow == ROW_COL_HEADERS ) - { - sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText(); - } - else if ( ( hitRow >= 0 ) && ( hitRow < pTableModel->getRowCount() ) ) + sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText(); + } + else if ( ( hitRow >= 0 ) && ( hitRow < pTableModel->getRowCount() ) ) + { + Any aCellToolTip; + pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip ); + if ( !aCellToolTip.hasValue() ) { - Any aCellToolTip; - pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip ); - if ( !aCellToolTip.hasValue() ) - { - // use the cell content - pTableModel->getCellContent( hitCol, hitRow, aCellToolTip ); - - // use the cell content as tool tip only if it doesn't fit into the cell. - bool const activeCell = ( hitRow == rTableControl.getCurrentRow() ) && ( hitCol == rTableControl.getCurrentColumn() ); - bool const selectedCell = rTableControl.isRowSelected( hitRow ); + // use the cell content + pTableModel->getCellContent( hitCol, hitRow, aCellToolTip ); - Rectangle const aWindowRect( Point( 0, 0 ), GetOutputSizePixel() ); - TableCellGeometry const aCell( m_rTableControl, aWindowRect, hitCol, hitRow ); - Rectangle const aCellRect( aCell.getRect() ); + // use the cell content as tool tip only if it doesn't fit into the cell. + bool const activeCell = ( hitRow == m_rTableControl.getCurrentRow() ) && ( hitCol == m_rTableControl.getCurrentColumn() ); + bool const selectedCell = m_rTableControl.isRowSelected( hitRow ); - PTableRenderer const pRenderer = pTableModel->getRenderer(); - if ( pRenderer->FitsIntoCell( aCellToolTip, hitCol, hitRow, activeCell, selectedCell, *this, aCellRect ) ) - aCellToolTip.clear(); - } + Rectangle const aWindowRect( Point( 0, 0 ), GetOutputSizePixel() ); + TableCellGeometry const aCell( m_rTableControl, aWindowRect, hitCol, hitRow ); + Rectangle const aCellRect( aCell.getRect() ); - sHelpText = CellValueConversion::convertToString( aCellToolTip ); - - if ( sHelpText.indexOf( '\n' ) >= 0 ) - nHelpStyle = QUICKHELP_TIP_STYLE_BALLOON; + PTableRenderer const pRenderer = pTableModel->getRenderer(); + if ( pRenderer->FitsIntoCell( aCellToolTip, hitCol, hitRow, activeCell, selectedCell, *this, aCellRect ) ) + aCellToolTip.clear(); } - } - if ( sHelpText.getLength() ) - { - Rectangle const aControlScreenRect( - OutputToScreenPixel( Point( 0, 0 ) ), - GetOutputSizePixel() - ); + sHelpText = CellValueConversion::convertToString( aCellToolTip ); - if ( m_nTipWindowHandle ) - Help::UpdateTip( m_nTipWindowHandle, this, aControlScreenRect, sHelpText ); - else - m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText, nHelpStyle ); + if ( sHelpText.indexOf( '\n' ) >= 0 ) + nHelpStyle = QUICKHELP_TIP_STYLE_BALLOON; } } - else + + if ( sHelpText.getLength() ) { - Window::RequestHelp( rHEvt ); + Rectangle const aControlScreenRect( + OutputToScreenPixel( Point( 0, 0 ) ), + GetOutputSizePixel() + ); + + if ( m_nTipWindowHandle ) + Help::UpdateTip( m_nTipWindowHandle, this, aControlScreenRect, sHelpText ); + else + m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText, nHelpStyle ); } + else + impl_hideTipWindow(); } //------------------------------------------------------------------------------------------------------------------ @@ -179,24 +179,18 @@ namespace svt { namespace table if ( rMEvt.IsLeaveWindow() ) impl_hideTipWindow(); - Point aPoint = rMEvt.GetPosPixel(); if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) ) { - if ( m_rTableControl.getRowAtPoint( aPoint ) == ROW_COL_HEADERS ) - { - m_rTableControl.resizeColumn( aPoint ); - } - else - { - Window::MouseMove( rMEvt ); - } + Window::MouseMove( rMEvt ); } } //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt ) { - const Point aPoint = rMEvt.GetPosPixel(); - const RowPos nCurRow = m_rTableControl.getRowAtPoint( aPoint ); + impl_hideTipWindow(); + + Point const aPoint = rMEvt.GetPosPixel(); + RowPos const nCurRow = m_rTableControl.getRowAtPoint( aPoint ); if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) ) Window::MouseButtonDown( rMEvt ); else @@ -219,21 +213,6 @@ namespace svt { namespace table m_aMouseButtonUpHdl.Call((MouseEvent*) &rMEvt); m_rTableControl.getAntiImpl().GrabFocus(); } - //------------------------------------------------------------------------------------------------------------------ - void TableDataWindow::SetPointer( const Pointer& rPointer ) - { - Window::SetPointer(rPointer); - } - //------------------------------------------------------------------------------------------------------------------ - void TableDataWindow::CaptureMouse() - { - Window::CaptureMouse(); - } - //------------------------------------------------------------------------------------------------------------------ - void TableDataWindow::ReleaseMouse( ) - { - Window::ReleaseMouse(); - } // ----------------------------------------------------------------------- long TableDataWindow::Notify(NotifyEvent& rNEvt ) { diff --git a/svtools/source/table/tabledatawindow.hxx b/svtools/source/table/tabledatawindow.hxx index 45ffec92c286..68532fb71793 100644 --- a/svtools/source/table/tabledatawindow.hxx +++ b/svtools/source/table/tabledatawindow.hxx @@ -73,9 +73,6 @@ namespace svt { namespace table virtual void MouseMove( const MouseEvent& rMEvt); virtual void MouseButtonDown( const MouseEvent& rMEvt); virtual void MouseButtonUp( const MouseEvent& rMEvt); - virtual void SetPointer( const Pointer& rPointer ); - virtual void CaptureMouse(); - virtual void ReleaseMouse(); virtual long Notify(NotifyEvent& rNEvt); virtual void SetControlBackground(const Color& rColor); virtual void SetControlBackground(); -- cgit v1.2.3 From 1a31d1f55bf8d28069dd4b9d353f42e12bcb3e04 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 17 Jan 2011 13:14:28 +0100 Subject: gridsort: outsourced the column-resizing functionality into a dedicated class. Less cluttering in the InputHandler implementation this way. Same outsourcing is still to happen to the row selection functionality. The upcoming feature of column sorting will be a IMouseFunction implementation, too. --- svtools/inc/svtools/table/defaultinputhandler.hxx | 18 +- svtools/source/table/defaultinputhandler.cxx | 219 ++++++++++------------ svtools/source/table/makefile.mk | 1 + svtools/source/table/mousefunction.cxx | 194 +++++++++++++++++++ svtools/source/table/mousefunction.hxx | 119 ++++++++++++ 5 files changed, 420 insertions(+), 131 deletions(-) create mode 100755 svtools/source/table/mousefunction.cxx create mode 100755 svtools/source/table/mousefunction.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/defaultinputhandler.hxx b/svtools/inc/svtools/table/defaultinputhandler.hxx index 5be517d2c623..6990f903cdb2 100644 --- a/svtools/inc/svtools/table/defaultinputhandler.hxx +++ b/svtools/inc/svtools/table/defaultinputhandler.hxx @@ -30,22 +30,22 @@ #include "svtools/table/tableinputhandler.hxx" #include "svtools/table/tabletypes.hxx" -//........................................................................ +#include + +//...................................................................................................................... namespace svt { namespace table { -//........................................................................ +//...................................................................................................................... struct DefaultInputHandler_Impl; - //==================================================================== + //================================================================================================================== //= DefaultInputHandler - //==================================================================== + //================================================================================================================== class DefaultInputHandler : public ITableInputHandler { - friend class TableDataWindow; private: - DefaultInputHandler_Impl* m_pImpl; - ColPos m_nResizingColumn; + ::boost::scoped_ptr< DefaultInputHandler_Impl > m_pImpl; public: DefaultInputHandler(); @@ -63,8 +63,8 @@ namespace svt { namespace table virtual bool Notify ( ITableControl& _rControl, NotifyEvent& rNEvt ); }; -//........................................................................ +//...................................................................................................................... } } // namespace svt::table -//........................................................................ +//...................................................................................................................... #endif // SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index add92e850c4f..4c9dc2f415d9 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -31,104 +31,116 @@ #include "svtools/table/tablecontrolinterface.hxx" #include "tabledatawindow.hxx" +#include "mousefunction.hxx" #include #include #include -//........................................................................ +//...................................................................................................................... namespace svt { namespace table { -//....................................................................... +//...................................................................................................................... + typedef ::rtl::Reference< IMouseFunction > PMouseFunction; + typedef ::std::vector< PMouseFunction > MouseFunctions; struct DefaultInputHandler_Impl { + PMouseFunction pActiveFunction; + MouseFunctions aMouseFunctions; }; - //==================================================================== + //================================================================================================================== //= DefaultInputHandler - //==================================================================== - //-------------------------------------------------------------------- + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ DefaultInputHandler::DefaultInputHandler() :m_pImpl( new DefaultInputHandler_Impl ) - ,m_nResizingColumn( COL_INVALID ) { + m_pImpl->aMouseFunctions.push_back( new ColumnResize ); } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ DefaultInputHandler::~DefaultInputHandler() { - DELETEZ( m_pImpl ); } - //-------------------------------------------------------------------- - bool DefaultInputHandler::MouseMove( ITableControl& i_control, const MouseEvent& _rMEvt ) + //------------------------------------------------------------------------------------------------------------------ + namespace { - Point const aPoint = _rMEvt.GetPosPixel(); - - // resize test - if ( m_nResizingColumn != COL_INVALID ) + bool lcl_delegateMouseEvent( DefaultInputHandler_Impl& i_impl, ITableControl& i_control, const MouseEvent& i_event, + FunctionResult ( IMouseFunction::*i_handlerMethod )( ITableControl&, const MouseEvent& ) ) { - ::Size const tableSize = i_control.getTableSizePixel(); - - // set proper pointer - Pointer aNewPointer( POINTER_ARROW ); - ColumnMetrics const & columnMetrics( i_control.getColumnMetrics( m_nResizingColumn ) ); - if ( ( aPoint.X() > tableSize.Width() ) - || ( aPoint.X() < columnMetrics.nStartPixel ) - ) - { - aNewPointer = Pointer( POINTER_NOTALLOWED ); - } - else + if ( i_impl.pActiveFunction.is() ) { - aNewPointer = Pointer( POINTER_HSPLIT ); + bool furtherHandler = false; + switch ( (i_impl.pActiveFunction.get()->*i_handlerMethod)( i_control, i_event ) ) + { + case ActivateFunction: + OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected - function already *is* active!" ); + break; + case ContinueFunction: + break; + case DeactivateFunction: + i_impl.pActiveFunction.clear(); + break; + case SkipFunction: + furtherHandler = true; + break; + } + if ( !furtherHandler ) + // handled the event + return true; } - i_control.setPointer( aNewPointer ); - - // show tracking line - i_control.hideTracking(); - i_control.showTracking( - Rectangle( - Point( aPoint.X(), 0 ), - Size( 1, tableSize.Height() ) - ), - SHOWTRACK_SPLIT | SHOWTRACK_WINDOW - ); - return true; - } - // test for column divider, adjust the mouse pointer, if necessary - Pointer aNewPointer( POINTER_ARROW ); + // ask all other handlers + bool handled = false; + for ( MouseFunctions::iterator handler = i_impl.aMouseFunctions.begin(); + ( handler != i_impl.aMouseFunctions.end() ) && !handled; + ++handler + ) + { + if ( *handler == i_impl.pActiveFunction ) + // we already invoked this function + continue; - TableCell const tableCell = i_control.hitTest( aPoint ); - if ( ( tableCell.nRow == ROW_COL_HEADERS ) && ( tableCell.eArea == ColumnDivider ) ) - { - aNewPointer = Pointer( POINTER_HSPLIT ); + switch ( (handler->get()->*i_handlerMethod)( i_control, i_event ) ) + { + case ActivateFunction: + i_impl.pActiveFunction = *handler; + handled = true; + break; + case ContinueFunction: + case DeactivateFunction: + OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected: inactivate handler cannot be continued or deactivated!" ); + break; + case SkipFunction: + handled = false; + break; + } + } + return handled; } + } - i_control.setPointer( aNewPointer ); - return true; + //------------------------------------------------------------------------------------------------------------------ + bool DefaultInputHandler::MouseMove( ITableControl& i_tableControl, const MouseEvent& i_event ) + { + return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseMove ); } - //-------------------------------------------------------------------- - bool DefaultInputHandler::MouseButtonDown( ITableControl& i_tableControl, const MouseEvent& _rMEvt ) + //------------------------------------------------------------------------------------------------------------------ + bool DefaultInputHandler::MouseButtonDown( ITableControl& i_tableControl, const MouseEvent& i_event ) { + if ( lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseDown ) ) + return true; + bool bHandled = false; - Point const aPoint = _rMEvt.GetPosPixel(); + + // TODO: move the below to a IMouseFunction implementation, too + Point const aPoint = i_event.GetPosPixel(); TableCell const tableCell( i_tableControl.hitTest( aPoint ) ); - if ( tableCell.nRow == ROW_COL_HEADERS ) - { - if ( ( tableCell.nColumn != COL_INVALID ) - && ( tableCell.eArea == ColumnDivider ) - ) - { - m_nResizingColumn = tableCell.nColumn; - i_tableControl.captureMouse(); - } - bHandled = true; - } - else if ( tableCell.nRow >= 0 ) + if ( tableCell.nRow >= 0 ) { bool bSetCursor = false; if ( i_tableControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) @@ -139,7 +151,7 @@ namespace svt { namespace table { if ( !i_tableControl.isRowSelected( tableCell.nRow ) ) { - bHandled = i_tableControl.getSelEngine()->SelMouseButtonDown( _rMEvt ); + bHandled = i_tableControl.getSelEngine()->SelMouseButtonDown( i_event ); } else { @@ -153,59 +165,21 @@ namespace svt { namespace table bHandled = true; } } + return bHandled; } - //-------------------------------------------------------------------- - bool DefaultInputHandler::MouseButtonUp( ITableControl& i_tableControl, const MouseEvent& _rMEvt ) - { - bool bHandled = false; - Point const aPoint = _rMEvt.GetPosPixel(); - if ( m_nResizingColumn != COL_INVALID ) - { - i_tableControl.hideTracking(); - PColumnModel const pColumn = i_tableControl.getModel()->getColumnModel( m_nResizingColumn ); - long const maxWidthLogical = pColumn->getMaxWidth(); - long const minWidthLogical = pColumn->getMinWidth(); - - // new position of mouse - long const requestedEnd = aPoint.X(); - - // old position of right border - long const oldEnd = i_tableControl.getColumnMetrics( m_nResizingColumn ).nEndPixel; - - // position of left border if cursor in the to-be-resized column - long const columnStart = i_tableControl.getColumnMetrics( m_nResizingColumn ).nStartPixel; - long const requestedWidth = requestedEnd - columnStart; - // TODO: this is not correct, strictly: It assumes that the mouse was pressed exactly on the "end" pos, - // but for a while now, we have relaxed this, and allow clicking a few pixels aside, too - if ( requestedEnd >= columnStart ) - { - long requestedWidthLogical = i_tableControl.pixelWidthToAppFont( requestedWidth ); - // respect column width limits - if ( oldEnd > requestedEnd ) - { - // column has become smaller, check against minimum width - if ( ( minWidthLogical != 0 ) && ( requestedWidthLogical < minWidthLogical ) ) - requestedWidthLogical = minWidthLogical; - } - else if ( oldEnd < requestedEnd ) - { - // column has become larger, check against max width - if ( ( maxWidthLogical != 0 ) && ( requestedWidthLogical >= maxWidthLogical ) ) - requestedWidthLogical = maxWidthLogical; - } - pColumn->setWidth( requestedWidthLogical ); - i_tableControl.invalidate(); - } + //------------------------------------------------------------------------------------------------------------------ + bool DefaultInputHandler::MouseButtonUp( ITableControl& i_tableControl, const MouseEvent& i_event ) + { + if ( lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseUp ) ) + return true; - i_tableControl.setPointer( Pointer() ); - i_tableControl.releaseMouse(); + bool bHandled = false; - m_nResizingColumn = COL_INVALID; - bHandled = true; - } - else if ( i_tableControl.getRowAtPoint( aPoint ) >= 0 ) + // TODO: move the below to a IMouseFunction implementation, too + Point const aPoint = i_event.GetPosPixel(); + if ( i_tableControl.getRowAtPoint( aPoint ) >= 0 ) { if ( i_tableControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) { @@ -213,12 +187,13 @@ namespace svt { namespace table } else { - bHandled = i_tableControl.getSelEngine()->SelMouseButtonUp( _rMEvt ); + bHandled = i_tableControl.getSelEngine()->SelMouseButtonUp( i_event ); } } return bHandled; } - //-------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ bool DefaultInputHandler::KeyInput( ITableControl& _rControl, const KeyEvent& rKEvt ) { bool bHandled = false; @@ -267,21 +242,21 @@ namespace svt { namespace table return bHandled; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool DefaultInputHandler::GetFocus( ITableControl& _rControl ) { _rControl.showCursor(); return false; // continue processing } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool DefaultInputHandler::LoseFocus( ITableControl& _rControl ) { _rControl.hideCursor(); return false; // continue processing } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool DefaultInputHandler::RequestHelp( ITableControl& _rControl, const HelpEvent& _rHEvt ) { (void)_rControl; @@ -290,7 +265,7 @@ namespace svt { namespace table return false; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool DefaultInputHandler::Command( ITableControl& _rControl, const CommandEvent& _rCEvt ) { (void)_rControl; @@ -299,7 +274,7 @@ namespace svt { namespace table return false; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool DefaultInputHandler::PreNotify( ITableControl& _rControl, NotifyEvent& _rNEvt ) { (void)_rControl; @@ -308,7 +283,7 @@ namespace svt { namespace table return false; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ bool DefaultInputHandler::Notify( ITableControl& _rControl, NotifyEvent& _rNEvt ) { (void)_rControl; @@ -316,6 +291,6 @@ namespace svt { namespace table // TODO return false; } -//........................................................................ +//...................................................................................................................... } } // namespace svt::table -//........................................................................ +//...................................................................................................................... diff --git a/svtools/source/table/makefile.mk b/svtools/source/table/makefile.mk index 7fa1b00d1740..39fa03454372 100644 --- a/svtools/source/table/makefile.mk +++ b/svtools/source/table/makefile.mk @@ -46,6 +46,7 @@ SLOFILES=\ $(SLO)$/tablegeometry.obj \ $(SLO)$/defaultinputhandler.obj \ $(SLO)$/tabledatawindow.obj \ + $(SLO)$/mousefunction.obj \ $(SLO)$/cellvalueconversion.obj #LIB1TARGET= $(SLB)$/$(TARGET).lib diff --git a/svtools/source/table/mousefunction.cxx b/svtools/source/table/mousefunction.cxx new file mode 100755 index 000000000000..fa075284e225 --- /dev/null +++ b/svtools/source/table/mousefunction.cxx @@ -0,0 +1,194 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_svtools.hxx" + +#include "mousefunction.hxx" +#include "svtools/table/tablecontrolinterface.hxx" + +#include +#include + +//...................................................................................................................... +namespace svt { namespace table +{ +//...................................................................................................................... + + //================================================================================================================== + //= MouseFunction + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + oslInterlockedCount MouseFunction::acquire() + { + return osl_incrementInterlockedCount( &m_refCount ); + } + + //------------------------------------------------------------------------------------------------------------------ + oslInterlockedCount MouseFunction::release() + { + oslInterlockedCount newCount = osl_decrementInterlockedCount( &m_refCount ); + if ( newCount == 0 ) + { + delete this; + return 0; + } + return newCount; + } + + //================================================================================================================== + //= ColumnResize + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + FunctionResult ColumnResize::handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) + { + Point const aPoint = i_event.GetPosPixel(); + + if ( m_nResizingColumn == COL_INVALID ) + { + // if we hit a column divider, change the mosue pointer accordingly + Pointer aNewPointer( POINTER_ARROW ); + TableCell const tableCell = i_tableControl.hitTest( aPoint ); + if ( ( tableCell.nRow == ROW_COL_HEADERS ) && ( tableCell.eArea == ColumnDivider ) ) + { + aNewPointer = Pointer( POINTER_HSPLIT ); + } + i_tableControl.setPointer( aNewPointer ); + + return SkipFunction; // TODO: is this correct? + } + + ::Size const tableSize = i_tableControl.getTableSizePixel(); + + // set proper pointer + Pointer aNewPointer( POINTER_ARROW ); + ColumnMetrics const & columnMetrics( i_tableControl.getColumnMetrics( m_nResizingColumn ) ); + if ( ( aPoint.X() > tableSize.Width() ) + || ( aPoint.X() < columnMetrics.nStartPixel ) + ) + { + aNewPointer = Pointer( POINTER_NOTALLOWED ); + } + else + { + aNewPointer = Pointer( POINTER_HSPLIT ); + } + i_tableControl.setPointer( aNewPointer ); + + // show tracking line + i_tableControl.hideTracking(); + i_tableControl.showTracking( + Rectangle( + Point( aPoint.X(), 0 ), + Size( 1, tableSize.Height() ) + ), + SHOWTRACK_SPLIT | SHOWTRACK_WINDOW + ); + + (void)i_event; + return ContinueFunction; + } + + //------------------------------------------------------------------------------------------------------------------ + FunctionResult ColumnResize::handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) + { + if ( m_nResizingColumn != COL_INVALID ) + { + OSL_ENSURE( false, "ColumnResize::handleMouseDown: suspicious: MouseButtonDown while still tracking?" ); + return ContinueFunction; + } + + Point const aPoint = i_event.GetPosPixel(); + TableCell const tableCell( i_tableControl.hitTest( aPoint ) ); + if ( tableCell.nRow == ROW_COL_HEADERS ) + { + if ( ( tableCell.nColumn != COL_INVALID ) + && ( tableCell.eArea == ColumnDivider ) + ) + { + m_nResizingColumn = tableCell.nColumn; + i_tableControl.captureMouse(); + return ActivateFunction; + } + } + + return SkipFunction; + } + + //------------------------------------------------------------------------------------------------------------------ + FunctionResult ColumnResize::handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) + { + if ( m_nResizingColumn == COL_INVALID ) + return SkipFunction; + + Point const aPoint = i_event.GetPosPixel(); + + i_tableControl.hideTracking(); + PColumnModel const pColumn = i_tableControl.getModel()->getColumnModel( m_nResizingColumn ); + long const maxWidthLogical = pColumn->getMaxWidth(); + long const minWidthLogical = pColumn->getMinWidth(); + + // new position of mouse + long const requestedEnd = aPoint.X(); + + // old position of right border + long const oldEnd = i_tableControl.getColumnMetrics( m_nResizingColumn ).nEndPixel; + + // position of left border if cursor in the to-be-resized column + long const columnStart = i_tableControl.getColumnMetrics( m_nResizingColumn ).nStartPixel; + long const requestedWidth = requestedEnd - columnStart; + // TODO: this is not correct, strictly: It assumes that the mouse was pressed exactly on the "end" pos, + // but for a while now, we have relaxed this, and allow clicking a few pixels aside, too + + if ( requestedEnd >= columnStart ) + { + long requestedWidthLogical = i_tableControl.pixelWidthToAppFont( requestedWidth ); + // respect column width limits + if ( oldEnd > requestedEnd ) + { + // column has become smaller, check against minimum width + if ( ( minWidthLogical != 0 ) && ( requestedWidthLogical < minWidthLogical ) ) + requestedWidthLogical = minWidthLogical; + } + else if ( oldEnd < requestedEnd ) + { + // column has become larger, check against max width + if ( ( maxWidthLogical != 0 ) && ( requestedWidthLogical >= maxWidthLogical ) ) + requestedWidthLogical = maxWidthLogical; + } + pColumn->setWidth( requestedWidthLogical ); + i_tableControl.invalidate(); + } + + i_tableControl.setPointer( Pointer() ); + i_tableControl.releaseMouse(); + + m_nResizingColumn = COL_INVALID; + return DeactivateFunction; + } + +//...................................................................................................................... +} } // namespace svt::table +//...................................................................................................................... diff --git a/svtools/source/table/mousefunction.hxx b/svtools/source/table/mousefunction.hxx new file mode 100755 index 000000000000..64c3a9533bcd --- /dev/null +++ b/svtools/source/table/mousefunction.hxx @@ -0,0 +1,119 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SVTOOLS_MOUSEFUNCTION_HXX +#define SVTOOLS_MOUSEFUNCTION_HXX + +#include "svtools/table/tabletypes.hxx" + +#include + +#include + +class MouseEvent; + +//...................................................................................................................... +namespace svt { namespace table +{ +//...................................................................................................................... + + class ITableControl; + + //================================================================================================================== + //= FunctionResult + //================================================================================================================== + enum FunctionResult + { + ActivateFunction, + ContinueFunction, + DeactivateFunction, + + SkipFunction + }; + + //================================================================================================================== + //= IMouseFunction + //================================================================================================================== + class IMouseFunction : public ::rtl::IReference, public ::boost::noncopyable + { + public: + virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0; + virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0; + virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0; + + protected: + virtual ~IMouseFunction() { } + }; + + //================================================================================================================== + //= MouseFunction + //================================================================================================================== + class MouseFunction : public IMouseFunction + { + public: + MouseFunction() + :m_refCount( 0 ) + { + } + protected: + ~MouseFunction() + { + } + + public: + virtual oslInterlockedCount SAL_CALL acquire(); + virtual oslInterlockedCount SAL_CALL release(); + + private: + oslInterlockedCount m_refCount; + }; + + //================================================================================================================== + //= ColumnResize + //================================================================================================================== + class ColumnResize : public MouseFunction + { + public: + ColumnResize() + :m_nResizingColumn( COL_INVALID ) + { + } + + public: + // IMouseFunction + virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ); + virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ); + virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ); + + private: + ColPos m_nResizingColumn; + }; + +//...................................................................................................................... +} } // namespace svt::table +//...................................................................................................................... + +#endif // SVTOOLS_MOUSEFUNCTION_HXX -- cgit v1.2.3 From 79610ce242aad3b0020f5f6d11d54bca2dcac7bc Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 17 Jan 2011 13:49:08 +0100 Subject: gridsort: moved the row selection functionality into a IMouseFunction implementation, too --- svtools/source/table/defaultinputhandler.cxx | 57 ++---------------------- svtools/source/table/mousefunction.cxx | 66 ++++++++++++++++++++++++++++ svtools/source/table/mousefunction.hxx | 21 +++++++++ svtools/source/table/tabledatawindow.cxx | 24 +++++----- 4 files changed, 104 insertions(+), 64 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index 4c9dc2f415d9..0870fac86087 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -58,6 +58,7 @@ namespace svt { namespace table :m_pImpl( new DefaultInputHandler_Impl ) { m_pImpl->aMouseFunctions.push_back( new ColumnResize ); + m_pImpl->aMouseFunctions.push_back( new RowSelection ); } //------------------------------------------------------------------------------------------------------------------ @@ -132,65 +133,13 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ bool DefaultInputHandler::MouseButtonDown( ITableControl& i_tableControl, const MouseEvent& i_event ) { - if ( lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseDown ) ) - return true; - - bool bHandled = false; - - // TODO: move the below to a IMouseFunction implementation, too - Point const aPoint = i_event.GetPosPixel(); - TableCell const tableCell( i_tableControl.hitTest( aPoint ) ); - if ( tableCell.nRow >= 0 ) - { - bool bSetCursor = false; - if ( i_tableControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) - { - bSetCursor = true; - } - else - { - if ( !i_tableControl.isRowSelected( tableCell.nRow ) ) - { - bHandled = i_tableControl.getSelEngine()->SelMouseButtonDown( i_event ); - } - else - { - bSetCursor = true; - } - } - - if ( bSetCursor ) - { - i_tableControl.activateCellAt( aPoint ); - bHandled = true; - } - } - - return bHandled; + return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseDown ); } //------------------------------------------------------------------------------------------------------------------ bool DefaultInputHandler::MouseButtonUp( ITableControl& i_tableControl, const MouseEvent& i_event ) { - if ( lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseUp ) ) - return true; - - bool bHandled = false; - - // TODO: move the below to a IMouseFunction implementation, too - Point const aPoint = i_event.GetPosPixel(); - if ( i_tableControl.getRowAtPoint( aPoint ) >= 0 ) - { - if ( i_tableControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) - { - bHandled = true; - } - else - { - bHandled = i_tableControl.getSelEngine()->SelMouseButtonUp( i_event ); - } - } - return bHandled; + return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseUp ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/table/mousefunction.cxx b/svtools/source/table/mousefunction.cxx index fa075284e225..d0fda5e6e7d1 100755 --- a/svtools/source/table/mousefunction.cxx +++ b/svtools/source/table/mousefunction.cxx @@ -189,6 +189,72 @@ namespace svt { namespace table return DeactivateFunction; } + //================================================================================================================== + //= RowSelection + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + FunctionResult RowSelection::handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) + { + return SkipFunction; + } + + //------------------------------------------------------------------------------------------------------------------ + FunctionResult RowSelection::handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) + { + bool handled = false; + + Point const aPoint = i_event.GetPosPixel(); + TableCell const tableCell( i_tableControl.hitTest( aPoint ) ); + if ( tableCell.nRow >= 0 ) + { + bool bSetCursor = false; + if ( i_tableControl.getSelEngine()->GetSelectionMode() == NO_SELECTION ) + { + bSetCursor = true; + } + else + { + if ( !i_tableControl.isRowSelected( tableCell.nRow ) ) + { + handled = i_tableControl.getSelEngine()->SelMouseButtonDown( i_event ); + } + else + { + bSetCursor = true; + } + } + + if ( bSetCursor ) + { + i_tableControl.activateCellAt( aPoint ); + handled = true; + } + } + + if ( handled ) + m_bActive = true; + return handled ? ActivateFunction : SkipFunction; + } + + //------------------------------------------------------------------------------------------------------------------ + FunctionResult RowSelection::handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) + { + Point const aPoint = i_event.GetPosPixel(); + if ( i_tableControl.getRowAtPoint( aPoint ) >= 0 ) + { + if ( i_tableControl.getSelEngine()->GetSelectionMode() != NO_SELECTION ) + { + i_tableControl.getSelEngine()->SelMouseButtonUp( i_event ); + } + } + if ( m_bActive ) + { + m_bActive = false; + return DeactivateFunction; + } + return SkipFunction; + } + //...................................................................................................................... } } // namespace svt::table //...................................................................................................................... diff --git a/svtools/source/table/mousefunction.hxx b/svtools/source/table/mousefunction.hxx index 64c3a9533bcd..dccd013e5680 100755 --- a/svtools/source/table/mousefunction.hxx +++ b/svtools/source/table/mousefunction.hxx @@ -112,6 +112,27 @@ namespace svt { namespace table ColPos m_nResizingColumn; }; + //================================================================================================================== + //= RowSelection + //================================================================================================================== + class RowSelection : public MouseFunction + { + public: + RowSelection() + :m_bActive( false ) + { + } + + public: + // IMouseFunction + virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ); + virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ); + virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ); + + private: + bool m_bActive; + }; + //...................................................................................................................... } } // namespace svt::table //...................................................................................................................... diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index cdf909d9fa65..7f1515be8b73 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -190,30 +190,34 @@ namespace svt { namespace table impl_hideTipWindow(); Point const aPoint = rMEvt.GetPosPixel(); - RowPos const nCurRow = m_rTableControl.getRowAtPoint( aPoint ); + RowPos const hitRow = m_rTableControl.getRowAtPoint( aPoint ); + bool const wasRowSelected = m_rTableControl.isRowSelected( hitRow ); + if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) ) + { Window::MouseButtonDown( rMEvt ); - else + return; + } + + bool const isRowSelected = m_rTableControl.isRowSelected( hitRow ); + if ( isRowSelected != wasRowSelected ) { - if(nCurRow >= 0 && m_rTableControl.getSelEngine()->GetSelectionMode() != NO_SELECTION) - { - if( !m_rTableControl.isRowSelected( nCurRow ) ) - { - m_aSelectHdl.Call( NULL ); - } - } + m_aSelectHdl.Call( NULL ); } m_aMouseButtonDownHdl.Call((MouseEvent*) &rMEvt); } + //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::MouseButtonUp( const MouseEvent& rMEvt ) { if ( !m_rTableControl.getInputHandler()->MouseButtonUp( m_rTableControl, rMEvt ) ) Window::MouseButtonUp( rMEvt ); + m_aMouseButtonUpHdl.Call((MouseEvent*) &rMEvt); m_rTableControl.getAntiImpl().GrabFocus(); } - // ----------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------------ long TableDataWindow::Notify(NotifyEvent& rNEvt ) { long nDone = 0; -- cgit v1.2.3 From 0621b2ecec8cd1d5f3249efb09f2c1b1c4462a24 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 17 Jan 2011 13:54:53 +0100 Subject: gridsort: fix impl_getColumnForOrdinate to take row headers into account --- svtools/source/table/tablecontrol_impl.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index cdae26548a43..87d249c63b10 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -2308,19 +2308,24 @@ namespace svt { namespace table { DBG_CHECK_ME(); - if ( m_aColumnWidths.empty() ) + if ( ( m_aColumnWidths.empty() ) || ( i_ordinate < 0 ) ) return COL_INVALID; + if ( i_ordinate < m_nRowHeaderWidthPixel ) + return COL_ROW_HEADERS; + + long const ordinate = i_ordinate - m_nRowHeaderWidthPixel; + ColumnPositions::const_iterator lowerBound = ::std::lower_bound( m_aColumnWidths.begin(), m_aColumnWidths.end(), - i_ordinate + 1, + ordinate + 1, ColumnInfoPositionLess() ); if ( lowerBound == m_aColumnWidths.end() ) { // point is *behind* the start of the last column ... - if ( i_ordinate < m_aColumnWidths.rbegin()->getEnd() ) + if ( ordinate < m_aColumnWidths.rbegin()->getEnd() ) // ... but still before its end return m_nColumnCount - 1; return COL_INVALID; -- cgit v1.2.3 From bdf5a65cb535289f5bcf15b01cee2ad1352c882e Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 17 Jan 2011 14:18:20 +0100 Subject: gridsort: do not activate header cells --- svtools/source/table/tablecontrol_impl.cxx | 120 +++++++++++++---------------- svtools/source/table/tablecontrol_impl.hxx | 17 ++-- 2 files changed, 64 insertions(+), 73 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 87d249c63b10..56a5908ebe4f 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -1929,16 +1929,12 @@ namespace svt { namespace table { DBG_CHECK_ME(); - TempHideCursor aHideCursor( *this ); - - const RowPos newRowPos = getRowAtPoint( rPoint ); - const ColPos newColPos = getColAtPoint( rPoint ); + RowPos const newRowPos = getRowAtPoint( rPoint ); + ColPos const newColPos = getColAtPoint( rPoint ); - if ( ( newRowPos != ROW_INVALID ) && ( newColPos != COL_INVALID ) ) - { - m_nCurColumn = newColPos; - m_nCurRow = newRowPos; - ensureVisible( m_nCurColumn, m_nCurRow, true ); + if ( ( newRowPos >= 0 ) && ( newColPos >= 0 ) ) + { // don't activate invalid or header cells + goTo( newColPos, newRowPos ); } } //------------------------------------------------------------------------------------------------------------------ @@ -2509,7 +2505,7 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ TableFunctionSet::TableFunctionSet(TableControl_Impl* _pTableControl) :m_pTableControl( _pTableControl) - ,m_nCurrentRow (-2) + ,m_nCurrentRow( ROW_INVALID ) { } //------------------------------------------------------------------------------------------------------------------ @@ -2523,106 +2519,105 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::CreateAnchor() { - m_pTableControl->m_nAnchor = m_pTableControl->m_nCurRow; + m_pTableControl->setAnchor( m_pTableControl->getCurRow() ); } + //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::DestroyAnchor() { - m_pTableControl->m_nAnchor = -1; + m_pTableControl->setAnchor( ROW_INVALID ); } + //------------------------------------------------------------------------------------------------------------------ BOOL TableFunctionSet::SetCursorAtPoint(const Point& rPoint, BOOL bDontSelectAtCursor) { BOOL bHandled = FALSE; - // newRow is the row which includes the point, m_nCurRow is the last selected row, before the mouse click - const RowPos newRow = m_pTableControl->getRowAtPoint( rPoint ); - const ColPos newCol = m_pTableControl->getColAtPoint( rPoint ); + // newRow is the row which includes the point, getCurRow() is the last selected row, before the mouse click + RowPos newRow = m_pTableControl->getRowAtPoint( rPoint ); + if ( newRow == ROW_COL_HEADERS ) + newRow = m_pTableControl->getTopRow(); + + ColPos newCol = m_pTableControl->getColAtPoint( rPoint ); + if ( newCol == COL_ROW_HEADERS ) + newCol = m_pTableControl->getLeftColumn(); + if ( ( newRow == ROW_INVALID ) || ( newCol == COL_INVALID ) ) return FALSE; if ( bDontSelectAtCursor ) { - if ( m_pTableControl->m_aSelectedRows.size()>1 ) - m_pTableControl->m_pSelEngine->AddAlways(TRUE); + if ( m_pTableControl->getSelectedRowCount() > 1 ) + m_pTableControl->getSelEngine()->AddAlways(TRUE); bHandled = TRUE; } - else if ( m_pTableControl->m_nAnchor == m_pTableControl->m_nCurRow ) + else if ( m_pTableControl->getAnchor() == m_pTableControl->getCurRow() ) { //selecting region, - int diff = m_pTableControl->m_nCurRow - newRow; + int diff = m_pTableControl->getCurRow() - newRow; //selected region lies above the last selection if( diff >= 0) { //put selected rows in vector - while ( m_pTableControl->m_nAnchor >= newRow ) + while ( m_pTableControl->getAnchor() >= newRow ) { - bool isAlreadySelected = m_pTableControl->isRowSelected( m_pTableControl->m_nAnchor ); - //if row isn't selected, put it in vector, otherwise don't put it there, because it will be twice there - if(!isAlreadySelected) - m_pTableControl->m_aSelectedRows.push_back(m_pTableControl->m_nAnchor); - m_pTableControl->m_nAnchor--; + m_pTableControl->markRowAsSelected( m_pTableControl->getAnchor() ); + m_pTableControl->setAnchor( m_pTableControl->getAnchor() - 1 ); diff--; } - m_pTableControl->m_nAnchor++; + m_pTableControl->setAnchor( m_pTableControl->getAnchor() + 1 ); } //selected region lies beneath the last selected row else { - while ( m_pTableControl->m_nAnchor <= newRow ) + while ( m_pTableControl->getAnchor() <= newRow ) { - bool isAlreadySelected = m_pTableControl->isRowSelected( m_pTableControl->m_nAnchor ); - if(!isAlreadySelected) - m_pTableControl->m_aSelectedRows.push_back(m_pTableControl->m_nAnchor); - m_pTableControl->m_nAnchor++; + m_pTableControl->markRowAsSelected( m_pTableControl->getAnchor() ); + m_pTableControl->setAnchor( m_pTableControl->getAnchor() + 1 ); diff++; } - m_pTableControl->m_nAnchor--; + m_pTableControl->setAnchor( m_pTableControl->getAnchor() - 1 ); } Rectangle aCellRect; - m_pTableControl->invalidateSelectedRegion( m_pTableControl->m_nCurRow, newRow, aCellRect ); + m_pTableControl->invalidateSelectedRegion( m_pTableControl->getCurRow(), newRow, aCellRect ); bHandled = TRUE; } //no region selected else { - if(m_pTableControl->m_aSelectedRows.empty()) - m_pTableControl->m_aSelectedRows.push_back( newRow ); + if ( !m_pTableControl->hasRowSelection() ) + m_pTableControl->markRowAsSelected( newRow ); else { - if(m_pTableControl->m_pSelEngine->GetSelectionMode()==SINGLE_SELECTION) + if ( m_pTableControl->getSelEngine()->GetSelectionMode() == SINGLE_SELECTION ) { DeselectAll(); - m_pTableControl->m_aSelectedRows.push_back( newRow ); + m_pTableControl->markRowAsSelected( newRow ); } else { - bool isAlreadySelected = m_pTableControl->isRowSelected( newRow ); - if ( !isAlreadySelected ) - m_pTableControl->m_aSelectedRows.push_back( newRow ); + m_pTableControl->markRowAsSelected( newRow ); } } - if(m_pTableControl->m_aSelectedRows.size()>1 && m_pTableControl->m_pSelEngine->GetSelectionMode()!=SINGLE_SELECTION) - m_pTableControl->m_pSelEngine->AddAlways(TRUE); + if ( m_pTableControl->getSelectedRowCount() > 1 && m_pTableControl->getSelEngine()->GetSelectionMode() != SINGLE_SELECTION ) + m_pTableControl->getSelEngine()->AddAlways(TRUE); Rectangle aCellRect; m_pTableControl->invalidateSelectedRegion( newRow, newRow, aCellRect ); bHandled = TRUE; } - m_pTableControl->m_nCurRow = newRow; - m_pTableControl->m_nCurColumn = newCol; - m_pTableControl->ensureVisible( newCol, newRow, true ); + m_pTableControl->goTo( newCol, newRow ); return bHandled; } //------------------------------------------------------------------------------------------------------------------ BOOL TableFunctionSet::IsSelectionAtPoint( const Point& rPoint ) { - m_pTableControl->m_pSelEngine->AddAlways(FALSE); - if(m_pTableControl->m_aSelectedRows.empty()) + m_pTableControl->getSelEngine()->AddAlways(FALSE); + if ( !m_pTableControl->hasRowSelection() ) return FALSE; else { RowPos curRow = m_pTableControl->getRowAtPoint( rPoint ); - m_pTableControl->m_nAnchor = -1; + m_pTableControl->setAnchor( ROW_INVALID ); bool selected = m_pTableControl->isRowSelected( curRow ); m_nCurrentRow = curRow; return selected; @@ -2634,32 +2629,25 @@ namespace svt { namespace table (void)rPoint; long pos = 0; long i = 0; - Rectangle rCells; - for(std::vector::iterator it=m_pTableControl->m_aSelectedRows.begin(); - it!=m_pTableControl->m_aSelectedRows.end();++it) - { - if(*it == m_nCurrentRow) - { - pos = i; - m_pTableControl->invalidateSelectedRegion(*it, *it, rCells); - } - ++i; - } - m_pTableControl->m_aSelectedRows.erase(m_pTableControl->m_aSelectedRows.begin()+pos); + + Rectangle aCellRange; + m_pTableControl->invalidateSelectedRegion( m_nCurrentRow, m_nCurrentRow, aCellRange ); + m_pTableControl->markRowAsDeselected( m_nCurrentRow ); } //------------------------------------------------------------------------------------------------------------------ void TableFunctionSet::DeselectAll() { - if(!m_pTableControl->m_aSelectedRows.empty()) + if ( m_pTableControl->hasRowSelection() ) { - Rectangle rCells; - for(std::vector::iterator it=m_pTableControl->m_aSelectedRows.begin(); - it!=m_pTableControl->m_aSelectedRows.end();++it) + Rectangle aCellRange; + for ( size_t i=0; igetSelectedRowCount(); ++i ) { - m_pTableControl->invalidateSelectedRegion(*it, *it, rCells); + RowPos const rowIndex = m_pTableControl->getSelectedRowIndex(i); + m_pTableControl->invalidateSelectedRegion( rowIndex, rowIndex, aCellRange ); } - m_pTableControl->m_aSelectedRows.clear(); + + m_pTableControl->markAllRowsAsDeselected(); } } diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 5b84cd9ca4cd..78b87916083f 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -97,7 +97,6 @@ namespace svt { namespace table friend class TableRowGeometry; friend class TableColumnGeometry; friend class SuspendInvariants; - friend class TableFunctionSet; private: /// the control whose impl-instance we implemnt @@ -167,14 +166,18 @@ namespace svt { namespace table #endif public: - - void setModel( PTableModel _pModel ); inline const PTableInputHandler& getInputHandler() const { return m_pInputHandler; } - inline void setCurRow(RowPos curRow){ m_nCurRow = curRow; } + inline RowPos getCurRow() const { return m_nCurRow; } + inline void setCurRow( RowPos i_curRow ){ m_nCurRow = i_curRow; } + + RowPos getAnchor() const { return m_nAnchor; } + void setAnchor( RowPos const i_anchor ) { m_nAnchor = i_anchor; } + inline RowPos getTopRow() const { return m_nTopRow; } + inline ColPos getLeftColumn() const { return m_nLeftColumn; } inline const TableControl& getAntiImpl() const { return m_rAntiImpl; } inline TableControl& getAntiImpl() { return m_rAntiImpl; } @@ -449,10 +452,10 @@ namespace svt { namespace table //see seleng.hxx, seleng.cxx, FunctionSet overridables, part of selection engine class TableFunctionSet : public FunctionSet { - friend class TableDataWindow; private: - TableControl_Impl* m_pTableControl; - RowPos m_nCurrentRow; + TableControl_Impl* m_pTableControl; + RowPos m_nCurrentRow; + public: TableFunctionSet(TableControl_Impl* _pTableControl); virtual ~TableFunctionSet(); -- cgit v1.2.3 From 405a0f6cf14f30bed6cf676d7c3224c1c2cb1312 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 17 Jan 2011 14:25:56 +0100 Subject: gridsort: fix getRowAtPoint --- svtools/source/table/tablecontrol_impl.cxx | 36 ++++++++++++++---------------- svtools/source/table/tablecontrol_impl.hxx | 4 ++++ 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'svtools') 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 ); -- cgit v1.2.3 From dc971d000d15cbf5d19119cf54c44aafaff88c50 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 18 Jan 2011 11:15:23 +0100 Subject: gridsort: GCC WaE --- svtools/source/table/mousefunction.cxx | 2 ++ svtools/source/table/tablecontrol_impl.cxx | 5 +---- toolkit/source/controls/grid/defaultgriddatamodel.cxx | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/mousefunction.cxx b/svtools/source/table/mousefunction.cxx index d0fda5e6e7d1..f5e6080f9ddd 100755 --- a/svtools/source/table/mousefunction.cxx +++ b/svtools/source/table/mousefunction.cxx @@ -195,6 +195,8 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ FunctionResult RowSelection::handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) { + OSL_UNUSED( i_tableControl ); + OSL_UNUSED( i_event ); return SkipFunction; } diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 12370ca305ce..dcd169381aef 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -314,7 +314,7 @@ namespace svt { namespace table // m_aSelectedRows should have reasonable content { - if ( m_aSelectedRows.size() > m_pModel->getRowCount() ) + if ( m_aSelectedRows.size() > size_t( m_pModel->getRowCount() ) ) return "there are more rows selected than actually exist"; for ( ::std::vector< RowPos >::const_iterator selRow = m_aSelectedRows.begin(); selRow != m_aSelectedRows.end(); @@ -2625,9 +2625,6 @@ namespace svt { namespace table void TableFunctionSet::DeselectAtPoint( const Point& rPoint ) { (void)rPoint; - long pos = 0; - long i = 0; - Rectangle aCellRange; m_pTableControl->invalidateSelectedRegion( m_nCurrentRow, m_nCurrentRow, aCellRange ); m_pTableControl->markRowAsDeselected( m_nCurrentRow ); diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index d113415ccf79..9ddb70c01760 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -71,7 +71,8 @@ namespace toolkit //------------------------------------------------------------------------------------------------------------------ DefaultGridDataModel::DefaultGridDataModel( DefaultGridDataModel const & i_copySource ) - :DefaultGridDataModel_Base( m_aMutex ) + :cppu::BaseMutex() + ,DefaultGridDataModel_Base( m_aMutex ) ,m_aData( i_copySource.m_aData ) ,m_aRowHeaders( i_copySource.m_aRowHeaders ) ,m_nColumnCount( i_copySource.m_nColumnCount ) -- cgit v1.2.3 From 4a593d1851b4673f7b9a68c7f336f182fc6b43bb Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 18 Jan 2011 11:49:19 +0100 Subject: gridsort: initial support for sorting the table data (unfinished) What's there is a IMouseFunction implementation which cares for sorting the ITableModel's data, by the column whose header was clicked. This is dependent on the model declaring support for sorting, by exposing a ITableSort interface. Missing pieces: - no UNO equivalent, yet (neither as design nor as implementation) - visualization of the current sort order/column --- .../inc/svtools/table/tablecontrolinterface.hxx | 25 +++++- svtools/inc/svtools/table/tablemodel.hxx | 10 +++ svtools/inc/svtools/table/tablesort.hxx | 91 ++++++++++++++++++++++ svtools/source/table/defaultinputhandler.cxx | 1 + svtools/source/table/mousefunction.cxx | 74 ++++++++++++++++-- svtools/source/table/mousefunction.hxx | 21 +++++ svtools/source/table/tablecontrol_impl.cxx | 16 ++-- svtools/source/table/tablecontrol_impl.hxx | 2 +- svtools/source/uno/svtxgridcontrol.cxx | 8 +- svtools/source/uno/unocontroltablemodel.cxx | 36 +++++++-- svtools/source/uno/unocontroltablemodel.hxx | 7 +- 11 files changed, 259 insertions(+), 32 deletions(-) create mode 100755 svtools/inc/svtools/table/tablesort.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablecontrolinterface.hxx b/svtools/inc/svtools/table/tablecontrolinterface.hxx index 038a701173be..6ff2b07e84ed 100644 --- a/svtools/inc/svtools/table/tablecontrolinterface.hxx +++ b/svtools/inc/svtools/table/tablecontrolinterface.hxx @@ -197,23 +197,40 @@ namespace svt { namespace table /// returns the index of the currently active row virtual RowPos getCurrentRow() const = 0; + /// activates the given cell + virtual bool activateCell( ColPos const i_col, RowPos const i_row ) = 0; + + /// retrieves the size of the table window, in pixels virtual ::Size getTableSizePixel() const = 0; + + /// sets a new mouse pointer for the table window virtual void setPointer( Pointer const & i_pointer ) = 0; + + /// captures the mouse to the table window virtual void captureMouse() = 0; + + /// releases the mouse, after it had previously been captured virtual void releaseMouse() = 0; + + /// invalidates the table window virtual void invalidate() = 0; + + /// calculates a width, given in pixels, into a AppFont-based width virtual long pixelWidthToAppFont( long const i_pixels ) const = 0; - virtual void hideTracking() = 0; + /// shows a trackign rectangle virtual void showTracking( Rectangle const & i_location, sal_uInt16 const i_flags ) = 0; - virtual void activateCellAt( const Point& rPoint ) = 0; + /// hides a prviously shown tracking rectangle + virtual void hideTracking() = 0; - virtual RowPos getRowAtPoint( const Point& rPoint ) const = 0; - virtual ColPos getColAtPoint( const Point& rPoint ) const = 0; + /// does a hit test for the given pixel coordinates virtual TableCell hitTest( const Point& rPoint ) const = 0; + + /// retrieves the metrics for a given column virtual ColumnMetrics getColumnMetrics( ColPos const i_column ) const = 0; + /// determines whether a given row is selected virtual bool isRowSelected( RowPos _nRow ) const = 0; virtual ~ITableControl() {}; diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index c5855414db97..80ce012b05d0 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -31,6 +31,7 @@ #include "svtools/table/tabletypes.hxx" #include "svtools/table/tablerenderer.hxx" #include "svtools/table/tableinputhandler.hxx" +#include "svtools/table/tablesort.hxx" #include #include @@ -313,6 +314,7 @@ namespace svt { namespace table @see getWidth */ virtual TableMetrics getPreferredWidth() const = 0; + /** sets the preferred width of the column, to be used when user resizes column @see getMaxWidth @@ -506,8 +508,16 @@ namespace svt { namespace table virtual ::boost::optional< ::std::vector< ::Color > > getRowBackgroundColors() const = 0; + /** determines the vertical alignment of content within a cell + */ virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() const = 0; + /** returns an adapter to the sorting functionality of the model + + It is legitimate to return here, in this case, the table model does not support sorting. + */ + virtual ITableDataSort* getSortAdapter() = 0; + /// destroys the table model instance virtual ~ITableModel() { } }; diff --git a/svtools/inc/svtools/table/tablesort.hxx b/svtools/inc/svtools/table/tablesort.hxx new file mode 100755 index 000000000000..a8f86a3953e1 --- /dev/null +++ b/svtools/inc/svtools/table/tablesort.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SVTOOLS_TABLESORT_HXX +#define SVTOOLS_TABLESORT_HXX + +#include "svtools/table/tabletypes.hxx" + +//...................................................................................................................... +namespace svt { namespace table +{ +//...................................................................................................................... + + //================================================================================================================== + //= ColumnSortDirection + //================================================================================================================== + enum ColumnSortDirection + { + ColumnSortAscending, + ColumnSortDescending + }; + + //================================================================================================================== + //= ColumnSort + //================================================================================================================== + struct ColumnSort + { + ColPos nColumnPos; + ColumnSortDirection eSortDirection; + + ColumnSort() + :nColumnPos( COL_INVALID ) + ,eSortDirection( ColumnSortAscending ) + { + } + + ColumnSort( ColPos const i_columnPos, ColumnSortDirection i_sortDirection ) + :nColumnPos( i_columnPos ) + ,eSortDirection( i_sortDirection ) + { + } + }; + + //================================================================================================================== + //= ITableDataSort + //================================================================================================================== + /** provides sorting functionality for the datta underlying an ITableModel + */ + class SAL_NO_VTABLE ITableDataSort + { + public: + /** sorts the rows in the model by the given column's data, in the given direction. + */ + virtual void sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ) = 0; + + /** retrieves the current sort order of the data + + If the nColumnIndex member of the returned srtructure is COL_INVALID, then + the data is currently not sorted. + */ + virtual ColumnSort getCurrentSortOrder() const = 0; + }; + +//...................................................................................................................... +} } // namespace svt::table +//...................................................................................................................... + +#endif // SVTOOLS_TABLESORT_HXX diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx index 0870fac86087..e2706a37a715 100644 --- a/svtools/source/table/defaultinputhandler.cxx +++ b/svtools/source/table/defaultinputhandler.cxx @@ -59,6 +59,7 @@ namespace svt { namespace table { m_pImpl->aMouseFunctions.push_back( new ColumnResize ); m_pImpl->aMouseFunctions.push_back( new RowSelection ); + m_pImpl->aMouseFunctions.push_back( new ColumnSortHandler ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/table/mousefunction.cxx b/svtools/source/table/mousefunction.cxx index f5e6080f9ddd..e3a47057423f 100755 --- a/svtools/source/table/mousefunction.cxx +++ b/svtools/source/table/mousefunction.cxx @@ -120,8 +120,7 @@ namespace svt { namespace table return ContinueFunction; } - Point const aPoint = i_event.GetPosPixel(); - TableCell const tableCell( i_tableControl.hitTest( aPoint ) ); + TableCell const tableCell( i_tableControl.hitTest( i_event.GetPosPixel() ) ); if ( tableCell.nRow == ROW_COL_HEADERS ) { if ( ( tableCell.nColumn != COL_INVALID ) @@ -205,8 +204,7 @@ namespace svt { namespace table { bool handled = false; - Point const aPoint = i_event.GetPosPixel(); - TableCell const tableCell( i_tableControl.hitTest( aPoint ) ); + TableCell const tableCell( i_tableControl.hitTest( i_event.GetPosPixel() ) ); if ( tableCell.nRow >= 0 ) { bool bSetCursor = false; @@ -228,7 +226,7 @@ namespace svt { namespace table if ( bSetCursor ) { - i_tableControl.activateCellAt( aPoint ); + i_tableControl.activateCell( tableCell.nColumn, tableCell.nRow ); handled = true; } } @@ -241,8 +239,8 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ FunctionResult RowSelection::handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) { - Point const aPoint = i_event.GetPosPixel(); - if ( i_tableControl.getRowAtPoint( aPoint ) >= 0 ) + TableCell const tableCell = i_tableControl.hitTest( i_event.GetPosPixel() ); + if ( tableCell.nRow >= 0 ) { if ( i_tableControl.getSelEngine()->GetSelectionMode() != NO_SELECTION ) { @@ -257,6 +255,68 @@ namespace svt { namespace table return SkipFunction; } + //================================================================================================================== + //= ColumnSortHandler + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + FunctionResult ColumnSortHandler::handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) + { + OSL_UNUSED( i_tableControl ); + OSL_UNUSED( i_event ); + return SkipFunction; + } + + //------------------------------------------------------------------------------------------------------------------ + FunctionResult ColumnSortHandler::handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) + { + if ( m_nActiveColumn != COL_INVALID ) + { + OSL_ENSURE( false, "ColumnSortHandler::handleMouseDown: called while already active - suspicious!" ); + return ContinueFunction; + } + + if ( i_tableControl.getModel()->getSortAdapter() == NULL ) + // no sorting support at the model + return SkipFunction; + + TableCell const tableCell( i_tableControl.hitTest( i_event.GetPosPixel() ) ); + if ( ( tableCell.nRow != ROW_COL_HEADERS ) || ( tableCell.nColumn < 0 ) ) + return SkipFunction; + + // TODO: ensure the column header is rendered in some special way, indicating its current state + + m_nActiveColumn = tableCell.nColumn; + return ActivateFunction; + } + + //------------------------------------------------------------------------------------------------------------------ + FunctionResult ColumnSortHandler::handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) + { + if ( m_nActiveColumn == COL_INVALID ) + return SkipFunction; + + TableCell const tableCell( i_tableControl.hitTest( i_event.GetPosPixel() ) ); + if ( ( tableCell.nRow != ROW_COL_HEADERS ) || ( tableCell.nColumn != m_nActiveColumn ) ) + // mouse was pressed on a column header, but released outside of it. + // => just deactivate, without sorting + return DeactivateFunction; + + ITableDataSort* pSort = i_tableControl.getModel()->getSortAdapter(); + ENSURE_OR_RETURN( pSort != NULL, "ColumnSortHandler::handleMouseUp: somebody is mocking with us!", DeactivateFunction ); + // in handleMousButtonDown, the model claimed to have sort support ... + + ColumnSortDirection eSortDirection = ColumnSortAscending; + ColumnSort const aCurrentSort = pSort->getCurrentSortOrder(); + if ( aCurrentSort.nColumnPos == m_nActiveColumn ) + // invert existing sort order + eSortDirection = ( aCurrentSort.eSortDirection == ColumnSortAscending ) ? ColumnSortDescending : ColumnSortAscending; + + pSort->sortByColumn( m_nActiveColumn, eSortDirection ); + + m_nActiveColumn = COL_INVALID; + return DeactivateFunction; + } + //...................................................................................................................... } } // namespace svt::table //...................................................................................................................... diff --git a/svtools/source/table/mousefunction.hxx b/svtools/source/table/mousefunction.hxx index dccd013e5680..2149026a0923 100755 --- a/svtools/source/table/mousefunction.hxx +++ b/svtools/source/table/mousefunction.hxx @@ -133,6 +133,27 @@ namespace svt { namespace table bool m_bActive; }; + //================================================================================================================== + //= ColumnSortHandler + //================================================================================================================== + class ColumnSortHandler : public MouseFunction + { + public: + ColumnSortHandler() + :m_nActiveColumn( COL_INVALID ) + { + } + + public: + // IMouseFunction + virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ); + virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ); + virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ); + + private: + ColPos m_nActiveColumn; + }; + //...................................................................................................................... } } // namespace svt::table //...................................................................................................................... diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index dcd169381aef..8e995babb36f 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -200,6 +200,10 @@ namespace svt { namespace table { return com::sun::star::style::VerticalAlignment(0); } + virtual ITableDataSort* getSortAdapter() + { + return NULL; + } virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ) { (void)i_row; @@ -1907,18 +1911,12 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::activateCellAt(const Point& rPoint) + bool TableControl_Impl::activateCell( ColPos const i_col, RowPos const i_row ) { DBG_CHECK_ME(); - - RowPos const newRowPos = getRowAtPoint( rPoint ); - ColPos const newColPos = getColAtPoint( rPoint ); - - if ( ( newRowPos >= 0 ) && ( newColPos >= 0 ) ) - { // don't activate invalid or header cells - goTo( newColPos, newRowPos ); - } + return goTo( i_col, i_row ); } + //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect) { diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index a6aebbaa6cc4..0975368a88a2 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -277,6 +277,7 @@ namespace svt { namespace table virtual PTableModel getModel() const; virtual ColPos getCurrentColumn() const; virtual RowPos getCurrentRow() const; + virtual bool activateCell( ColPos const i_col, RowPos const i_row ); virtual ::Size getTableSizePixel() const; virtual void setPointer( Pointer const & i_pointer ); virtual void captureMouse(); @@ -285,7 +286,6 @@ namespace svt { namespace table virtual long pixelWidthToAppFont( long const i_pixels ) const; virtual void hideTracking(); virtual void showTracking( Rectangle const & i_location, sal_uInt16 const i_flags ); - virtual void activateCellAt( const Point& rPoint ); virtual RowPos getRowAtPoint( const Point& rPoint ) const; virtual ColPos getColAtPoint( const Point& rPoint ) const; virtual TableCell hitTest( const Point& rPoint ) const; diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 57c0040935cc..ef9b10030230 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -91,8 +91,8 @@ sal_Int32 SAL_CALL SVTXGridControl::getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getRowAtPoint: no control (anymore)!", -1 ); - sal_Int32 const nRow = pTable->getTableControlInterface().getRowAtPoint( Point( x, y ) ); - return ( nRow >= 0 ) ? nRow : -1; + TableCell const tableCell = pTable->getTableControlInterface().hitTest( Point( x, y ) ); + return ( tableCell.nRow >= 0 ) ? tableCell.nRow : -1; } // --------------------------------------------------------------------------------------------------------------------- @@ -103,8 +103,8 @@ sal_Int32 SAL_CALL SVTXGridControl::getColumnAtPoint(::sal_Int32 x, ::sal_Int32 TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getColumnAtPoint: no control (anymore)!", -1 ); - sal_Int32 const nColumn = pTable->getTableControlInterface().getColAtPoint( Point( x, y ) ); - return ( nColumn >= 0 ) ? nColumn : -1; + TableCell const tableCell = pTable->getTableControlInterface().hitTest( Point( x, y ) ); + return ( tableCell.nColumn >= 0 ) ? tableCell.nColumn : -1; } // --------------------------------------------------------------------------------------------------------------------- diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index a47b798c7d59..1e6a690f48e7 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -69,6 +69,8 @@ namespace svt { namespace table using ::com::sun::star::uno::Any; using ::com::sun::star::style::HorizontalAlignment_LEFT; using ::com::sun::star::style::HorizontalAlignment; + using ::com::sun::star::style::VerticalAlignment_TOP; + using ::com::sun::star::style::VerticalAlignment; using ::com::sun::star::uno::WeakReference; using ::com::sun::star::awt::grid::GridDataEvent; /** === end UNO using === **/ @@ -96,7 +98,7 @@ namespace svt { namespace table ::boost::optional< ::Color > m_aTextColor; ::boost::optional< ::Color > m_aTextLineColor; ::boost::optional< ::std::vector< ::Color > > m_aRowColors; - ::com::sun::star::style::VerticalAlignment m_eVerticalAlign; + VerticalAlignment m_eVerticalAlign; ModellListeners m_aListeners; WeakReference< XGridDataModel > m_aDataModel; WeakReference< XGridColumnModel > m_aColumnModel; @@ -118,7 +120,7 @@ namespace svt { namespace table ,m_aTextColor ( ) ,m_aTextLineColor ( ) ,m_aRowColors ( ) - ,m_eVerticalAlign ( com::sun::star::style::VerticalAlignment_TOP ) + ,m_eVerticalAlign ( VerticalAlignment_TOP ) { } }; @@ -704,20 +706,20 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - ::com::sun::star::style::VerticalAlignment UnoControlTableModel::getVerticalAlign() const + VerticalAlignment UnoControlTableModel::getVerticalAlign() const { DBG_CHECK_ME(); return m_pImpl->m_eVerticalAlign; } - //-------------------------------------------------------------------- - void UnoControlTableModel::setVerticalAlign( com::sun::star::style::VerticalAlignment _xAlign ) + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::setVerticalAlign( VerticalAlignment _xAlign ) { DBG_CHECK_ME(); m_pImpl->m_eVerticalAlign = _xAlign; } - //-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ ColPos UnoControlTableModel::getColumnPos( UnoGridColumnFacade const & i_column ) const { DBG_CHECK_ME(); @@ -733,6 +735,28 @@ namespace svt { namespace table return COL_INVALID; } + //------------------------------------------------------------------------------------------------------------------ + ITableDataSort* UnoControlTableModel::getSortAdapter() + { + // TODO: make this depend on whether or not our XGridDataModel has sorting support + return this; + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ) + { + // TODO + OSL_UNUSED( i_column ); + OSL_UNUSED( i_sortDirection ); + } + + //------------------------------------------------------------------------------------------------------------------ + ColumnSort UnoControlTableModel::getCurrentSortOrder() const + { + // TODO + return ColumnSort(); + } + //-------------------------------------------------------------------- void UnoControlTableModel::notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const { diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 85a4b9480370..32930a64326d 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -57,7 +57,7 @@ namespace svt { namespace table //================================================================================================================== class UnoGridColumnFacade; struct UnoControlTableModel_Impl; - class UnoControlTableModel : public ITableModel + class UnoControlTableModel : public ITableModel, public ITableDataSort { private: UnoControlTableModel_Impl* m_pImpl; @@ -95,6 +95,11 @@ namespace svt { namespace table getRowBackgroundColors() const; virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() const; + virtual ITableDataSort* getSortAdapter(); + + // ITableDataSort overridables + virtual void sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ); + virtual ColumnSort getCurrentSortOrder() const; // column write access void appendColumn( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); -- cgit v1.2.3 From 961e924dbc7ebd1cea9927134524a443a7666240 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 18 Jan 2011 11:49:20 +0100 Subject: gridsort: #163172# added UNO API support for sorting grid data. Implementation still unfinished. Things missing in the SortableGridData implementation - add as listener to the delegator, so we're notified of changes - translate and multiplex those changes - do own notifications (XGridDataListener.dataChanged) when the sort order changed - (possibly) update the sort order when the data in the current sort-column changed --- svtools/inc/svtools/table/tablesort.hxx | 2 +- svtools/source/uno/unocontroltablemodel.cxx | 42 +- toolkit/inc/toolkit/helper/servicenames.hxx | 1 + toolkit/source/controls/grid/gridcontrol.cxx | 32 +- toolkit/source/controls/grid/initguard.hxx | 64 +++ toolkit/source/controls/grid/makefile.mk | 5 +- .../source/controls/grid/sortablegriddatamodel.cxx | 450 +++++++++++++++++++++ .../source/controls/grid/sortablegriddatamodel.hxx | 138 +++++++ toolkit/source/helper/registerservices.cxx | 3 +- toolkit/source/helper/servicenames.cxx | 2 + toolkit/util/tk.component | 3 + 11 files changed, 724 insertions(+), 18 deletions(-) create mode 100755 toolkit/source/controls/grid/initguard.hxx create mode 100755 toolkit/source/controls/grid/sortablegriddatamodel.cxx create mode 100755 toolkit/source/controls/grid/sortablegriddatamodel.hxx (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablesort.hxx b/svtools/inc/svtools/table/tablesort.hxx index a8f86a3953e1..1690b4d51344 100755 --- a/svtools/inc/svtools/table/tablesort.hxx +++ b/svtools/inc/svtools/table/tablesort.hxx @@ -57,7 +57,7 @@ namespace svt { namespace table { } - ColumnSort( ColPos const i_columnPos, ColumnSortDirection i_sortDirection ) + ColumnSort( ColPos const i_columnPos, ColumnSortDirection const i_sortDirection ) :nColumnPos( i_columnPos ) ,eSortDirection( i_sortDirection ) { diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 1e6a690f48e7..505cccf22702 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -38,6 +38,7 @@ #include #include #include +#include /** === end UNO includes === **/ #include @@ -73,6 +74,8 @@ namespace svt { namespace table using ::com::sun::star::style::VerticalAlignment; using ::com::sun::star::uno::WeakReference; using ::com::sun::star::awt::grid::GridDataEvent; + using ::com::sun::star::awt::grid::XSortableGridData; + using ::com::sun::star::beans::Pair; /** === end UNO using === **/ //================================================================================================================== @@ -738,23 +741,48 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ ITableDataSort* UnoControlTableModel::getSortAdapter() { - // TODO: make this depend on whether or not our XGridDataModel has sorting support - return this; + DBG_CHECK_ME(); + + Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY ); + if ( xSortAccess.is() ) + return this; + return NULL; } //------------------------------------------------------------------------------------------------------------------ void UnoControlTableModel::sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ) { - // TODO - OSL_UNUSED( i_column ); - OSL_UNUSED( i_sortDirection ); + DBG_CHECK_ME(); + + try + { + Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); + xSortAccess->sortByColumn( i_column, i_sortDirection == ColumnSortAscending ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //------------------------------------------------------------------------------------------------------------------ ColumnSort UnoControlTableModel::getCurrentSortOrder() const { - // TODO - return ColumnSort(); + DBG_CHECK_ME(); + + ColumnSort currentSort; + try + { + Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); + Pair< ::sal_Int32, ::sal_Bool > const aCurrentSortOrder( xSortAccess->getCurrentSortOrder() ); + currentSort.nColumnPos = aCurrentSortOrder.First; + currentSort.eSortDirection = aCurrentSortOrder.Second ? ColumnSortAscending : ColumnSortDescending; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return currentSort; } //-------------------------------------------------------------------- diff --git a/toolkit/inc/toolkit/helper/servicenames.hxx b/toolkit/inc/toolkit/helper/servicenames.hxx index 2d1df79b733b..a149f9e8f25f 100644 --- a/toolkit/inc/toolkit/helper/servicenames.hxx +++ b/toolkit/inc/toolkit/helper/servicenames.hxx @@ -97,6 +97,7 @@ extern const sal_Char __FAR_DATA szServiceName_GridControlModel[]; extern const sal_Char __FAR_DATA szServiceName_DefaultGridDataModel[]; extern const sal_Char __FAR_DATA szServiceName_DefaultGridColumnModel[]; extern const sal_Char __FAR_DATA szServiceName_GridColumn[]; +extern const sal_Char __FAR_DATA szServiceName_SortableGridDataModel[]; extern const sal_Char __FAR_DATA szServiceName_UnoSimpleAnimationControl[], szServiceName2_UnoSimpleAnimationControl[]; extern const sal_Char __FAR_DATA szServiceName_UnoSimpleAnimationControlModel[], szServiceName2_UnoSimpleAnimationControlModel[]; diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 14faa851400a..f054ca1ea05d 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include #include @@ -55,9 +57,25 @@ using namespace ::com::sun::star::view; namespace toolkit { -// ---------------------------------------------------- -// class UnoGridModel -// ---------------------------------------------------- +//====================================================================================================================== +//= UnoGridModel +//====================================================================================================================== +namespace +{ + Reference< XGridDataModel > lcl_getDefaultDataModel_throw( ::comphelper::ComponentContext const & i_context ) + { + Reference< XMutableGridDataModel > const xDelegatorModel( DefaultGridDataModel::create( i_context.getUNOContext() ), UNO_QUERY_THROW ); + Reference< XGridDataModel > const xDataModel( SortableGridDataModel::create( i_context.getUNOContext(), xDelegatorModel ), UNO_QUERY_THROW ); + return xDataModel; + } + + Reference< XGridColumnModel > lcl_getDefaultColumnModel_throw( ::comphelper::ComponentContext const & i_context ) + { + Reference< XGridColumnModel > const xColumnModel( i_context.createComponent( "com.sun.star.awt.grid.DefaultGridColumnModel" ), UNO_QUERY_THROW ); + return xColumnModel; + } +} + //---------------------------------------------------------------------------------------------------------------------- UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) :UnoControlModel( i_factory ) @@ -80,8 +98,8 @@ UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun:: ImplRegisterProperty( BASEPROPERTY_GRID_SHOWCOLUMNHEADER ); ImplRegisterProperty( BASEPROPERTY_COLUMN_HEADER_HEIGHT ); ImplRegisterProperty( BASEPROPERTY_ROW_HEIGHT ); - ImplRegisterProperty( BASEPROPERTY_GRID_DATAMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridDataModel" ) ) ); - ImplRegisterProperty( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridColumnModel" ) ) ); + ImplRegisterProperty( BASEPROPERTY_GRID_DATAMODEL, makeAny( lcl_getDefaultDataModel_throw( maContext ) ) ); + ImplRegisterProperty( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( lcl_getDefaultColumnModel_throw( maContext ) ) ); ImplRegisterProperty( BASEPROPERTY_GRID_SELECTIONMODE ); ImplRegisterProperty( BASEPROPERTY_FONTRELIEF ); ImplRegisterProperty( BASEPROPERTY_FONTEMPHASISMARK ); @@ -114,7 +132,7 @@ UnoGridModel::UnoGridModel( const UnoGridModel& rModel ) DBG_UNHANDLED_EXCEPTION(); } if ( !success ) - setFastPropertyValue( BASEPROPERTY_GRID_DATAMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridDataModel" ) ) ); + setFastPropertyValue( BASEPROPERTY_GRID_DATAMODEL, makeAny( lcl_getDefaultDataModel_throw( maContext ) ) ); // clone the column model success = false; @@ -129,7 +147,7 @@ UnoGridModel::UnoGridModel( const UnoGridModel& rModel ) DBG_UNHANDLED_EXCEPTION(); } if ( !success ) - setFastPropertyValue( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( maContext.createComponent( "com.sun.star.awt.grid.DefaultGridColumnModel" ) ) ); + setFastPropertyValue( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( lcl_getDefaultColumnModel_throw( maContext ) ) ); } //---------------------------------------------------------------------------------------------------------------------- diff --git a/toolkit/source/controls/grid/initguard.hxx b/toolkit/source/controls/grid/initguard.hxx new file mode 100755 index 000000000000..b2dddd2e5987 --- /dev/null +++ b/toolkit/source/controls/grid/initguard.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SVTOOLS_INITGUARD_HXX +#define SVTOOLS_INITGUARD_HXX + +/** === begin UNO includes === **/ +#include +/** === end UNO includes === **/ + +#include + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + //================================================================================================================== + //= InitGuard + //================================================================================================================== + template < class IMPL > + class InitGuard : public ::comphelper::ComponentGuard + { + public: + InitGuard( IMPL& i_component, ::cppu::OBroadcastHelper & i_broadcastHelper ) + :comphelper::ComponentGuard( i_component, i_broadcastHelper ) + { + if ( !i_component.isInitialized() ) + throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), *&i_component ); + } + + ~InitGuard() + { + } + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // SVTOOLS_INITGUARD_HXX diff --git a/toolkit/source/controls/grid/makefile.mk b/toolkit/source/controls/grid/makefile.mk index c7bc6f038b10..5b4e87bf77ee 100644 --- a/toolkit/source/controls/grid/makefile.mk +++ b/toolkit/source/controls/grid/makefile.mk @@ -44,8 +44,9 @@ SLOFILES= \ $(SLO)$/defaultgriddatamodel.obj\ $(SLO)$/defaultgridcolumnmodel.obj\ $(SLO)$/gridcolumn.obj\ - $(SLO)$/grideventforwarder.obj - + $(SLO)$/grideventforwarder.obj\ + $(SLO)$/sortablegriddatamodel.obj + # --- Targets ------------------------------------------------------ .INCLUDE : target.mk diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx new file mode 100755 index 000000000000..4b525dbc925a --- /dev/null +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -0,0 +1,450 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_toolkit.hxx" + +#include "sortablegriddatamodel.hxx" +#include "initguard.hxx" +#include "toolkit/helper/servicenames.hxx" + +/** === begin UNO includes === **/ +#include +#include +/** === end UNO includes === **/ + +#include +#include +#include + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::TypeClass; + using ::com::sun::star::uno::TypeClass_VOID; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::awt::grid::XGridDataListener; + using ::com::sun::star::beans::Pair; + using ::com::sun::star::util::XCloneable; + using ::com::sun::star::i18n::XCollator; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::lang::XMultiServiceFactory; + /** === end UNO using === **/ + + typedef InitGuard< SortableGridDataModel > MethodGuard; + + //================================================================================================================== + //= SortableGridDataModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + SortableGridDataModel::SortableGridDataModel( Reference< XMultiServiceFactory > const & i_factory ) + :SortableGridDataModel_Base( m_aMutex ) + ,m_context( i_factory ) + ,m_isInitialized( false ) + ,m_delegator() + ,m_collator() + ,m_currentSortColumn( -1 ) + ,m_sortAscending( true ) + ,m_rowIndexTranslation() + { + } + + //------------------------------------------------------------------------------------------------------------------ + SortableGridDataModel::SortableGridDataModel( SortableGridDataModel const & i_copySource ) + :cppu::BaseMutex() + ,SortableGridDataModel_Base( m_aMutex ) + ,m_context( i_copySource.m_context ) + ,m_collator( i_copySource.m_collator ) + ,m_isInitialized( true ) + ,m_delegator() + ,m_currentSortColumn( i_copySource.m_currentSortColumn ) + ,m_sortAscending( i_copySource.m_sortAscending ) + ,m_rowIndexTranslation( i_copySource.m_rowIndexTranslation ) + { + ENSURE_OR_THROW( i_copySource.m_delegator.is(), + "not expected to be called for a disposed copy source!" ); + m_delegator.set( i_copySource.m_delegator->createClone(), UNO_QUERY_THROW ); + } + + //------------------------------------------------------------------------------------------------------------------ + SortableGridDataModel::~SortableGridDataModel() + { + if ( !rBHelper.bDisposed ) + { + acquire(); + dispose(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + Reference< XCollator > lcl_loadDefaultCollator_throw( ::comphelper::ComponentContext const & i_context ) + { + Reference< XCollator > const xCollator( i_context.createComponent( "com.sun.star.i18n.Collator" ), UNO_QUERY_THROW ); + xCollator->loadDefaultCollator( Application::GetSettings().GetLocale(), 0 ); + return xCollator; + } + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::initialize( const Sequence< Any >& i_arguments ) throw (Exception, RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + + Reference< XMutableGridDataModel > xDelegator; + Reference< XCollator > xCollator; + switch ( i_arguments.getLength() ) + { + case 1: // SortableGridDataModel.create( XMutableGridDataModel ) + xDelegator.set( i_arguments[0], UNO_QUERY ); + xCollator = lcl_loadDefaultCollator_throw( m_context ); + break; + + case 2: // SortableGridDataModel.createWithCollator( XMutableGridDataModel, XCollator ) + xDelegator.set( i_arguments[0], UNO_QUERY ); + xCollator.set( i_arguments[1], UNO_QUERY ); + if ( !xCollator.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 2 ); + break; + } + if ( !xDelegator.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + + // TODO: add as listener to the delegator model, so we're able to multiplex the events it will notify + + m_delegator = xDelegator; + m_isInitialized = true; + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + class CellDataLessComparison : public ::std::binary_function< sal_Int32, sal_Int32, bool > + { + public: + CellDataLessComparison( + ::std::vector< Any > const & i_data, + ::comphelper::IKeyPredicateLess& i_predicate, + sal_Bool const i_sortAscending + ) + :m_data( i_data ) + ,m_predicate( i_predicate ) + ,m_sortAscending( i_sortAscending ) + { + } + + bool operator()( sal_Int32 const i_lhs, sal_Int32 const i_rhs ) const + { + Any const & lhs = m_data[ i_lhs ]; + Any const & rhs = m_data[ i_rhs ]; + // is less than everything else + if ( !lhs.hasValue() ) + return m_sortAscending; + if ( !rhs.hasValue() ) + return !m_sortAscending; + + // actually compare + if ( m_sortAscending ) + return m_predicate.isLess( lhs, rhs ); + else + return m_predicate.isLess( rhs, lhs ); + } + + private: + ::std::vector< Any > const & m_data; + ::comphelper::IKeyPredicateLess const & m_predicate; + sal_Bool const m_sortAscending; + }; + } + + //------------------------------------------------------------------------------------------------------------------ + void SortableGridDataModel::impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending ) + { + ::sal_Int32 const rowCount( getRowCount() ); + ::std::vector< ::sal_Int32 > aIndexTranslation( rowCount ); + + try + { + // build an unsorted translation table, and retrieve the unsorted data + ::std::vector< Any > aColumnData( rowCount ); + Type dataType; + for ( ::sal_Int32 rowIndex = 0; rowIndex < rowCount; ++rowIndex ) + { + aColumnData[ rowIndex ] = m_delegator->getCellData( i_columnIndex, rowIndex ); + aIndexTranslation[ rowIndex ] = rowIndex; + + // determine the data types we assume for the complete column + if ( ( dataType.getTypeClass() == TypeClass_VOID ) && aColumnData[ rowIndex ].hasValue() ) + dataType = aColumnData[ rowIndex ].getValueType(); + } + + // get predicate object + ::std::auto_ptr< ::comphelper::IKeyPredicateLess > const pPredicate( ::comphelper::getStandardLessPredicate( dataType ) ); + ENSURE_OR_RETURN_VOID( pPredicate.get(), "SortableGridDataModel::impl_reIndex_nothrow: no sortable data found!" ); + + // then sort + CellDataLessComparison const aComparator( aColumnData, *pPredicate, i_sortAscending ); + ::std::sort( aIndexTranslation.begin(), aIndexTranslation.end(), aComparator ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + return; + } + + m_rowIndexTranslation.swap( aIndexTranslation ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::sortByColumn( ::sal_Int32 i_columnIndex, ::sal_Bool i_sortAscending ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + + if ( ( i_columnIndex < 0 ) || ( i_columnIndex >= getColumnCount() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + impl_reIndex_nothrow( i_columnIndex, i_sortAscending ); + + m_currentSortColumn = i_columnIndex; + m_sortAscending = i_sortAscending; + } + + //------------------------------------------------------------------------------------------------------------------ + Pair< ::sal_Int32, ::sal_Bool > SAL_CALL SortableGridDataModel::getCurrentSortOrder( ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + return Pair< ::sal_Int32, ::sal_Bool >( m_currentSortColumn, m_sortAscending ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::addRow( const Any& i_heading, const Sequence< Any >& i_data ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + m_delegator->addRow( i_heading, i_data ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::addRows( const Sequence< Any >& i_headings, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + m_delegator->addRows( i_headings, i_data ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::removeRow( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + m_delegator->removeRow( rowIndex ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::removeAllRows( ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + m_delegator->removeAllRows(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::updateCellData( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + m_delegator->updateCellData( i_columnIndex, rowIndex, i_value ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::updateRowData( const Sequence< ::sal_Int32 >& i_columnIndexes, ::sal_Int32 i_rowIndex, const Sequence< Any >& i_values ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + m_delegator->updateRowData( i_columnIndexes, rowIndex, i_values ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::setRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + m_delegator->setRowHeading( rowIndex, i_heading ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::updateCellToolTip( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + m_delegator->updateCellToolTip( i_columnIndex, rowIndex, i_value ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::updateRowToolTip( ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + m_delegator->updateRowToolTip( rowIndex, i_value ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::addGridDataListener( const Reference< XGridDataListener >& i_listener ) throw (RuntimeException) + { + rBHelper.addListener( XGridDataListener::static_type(), i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::removeGridDataListener( const Reference< XGridDataListener >& i_listener ) throw (RuntimeException) + { + rBHelper.removeListener( XGridDataListener::static_type(), i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL SortableGridDataModel::getRowCount() throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + return m_delegator->getRowCount(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL SortableGridDataModel::getColumnCount() throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + return m_delegator->getColumnCount(); + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL SortableGridDataModel::getCellData( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + return m_delegator->getCellData( i_columnIndex, rowIndex ); + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL SortableGridDataModel::getCellToolTip( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + return m_delegator->getCellToolTip( i_columnIndex, rowIndex ); + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL SortableGridDataModel::getRowHeading( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + return m_delegator->getRowHeading( rowIndex ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::disposing() + { + m_currentSortColumn = -1; + + Reference< XComponent > const delegatorComponent( m_delegator.get() ); + m_delegator.clear(); + delegatorComponent->dispose(); + + Reference< XComponent > const collatorComponent( m_collator, UNO_QUERY ); + m_collator.clear(); + if ( collatorComponent.is() ) + collatorComponent->dispose(); + + ::std::vector< ::sal_Int32 > aEmpty; + m_rowIndexTranslation.swap( aEmpty ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XCloneable > SAL_CALL SortableGridDataModel::createClone( ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + return new SortableGridDataModel( *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL SortableGridDataModel::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.SortableGridDataModel" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL SortableGridDataModel::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > const aServiceNames( getSupportedServiceNames() ); + for ( sal_Int32 i=0; i SAL_CALL SortableGridDataModel::getSupportedServiceNames( ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aServiceNames(1); + aServiceNames[0] = ::rtl::OUString::createFromAscii( szServiceName_SortableGridDataModel ); + return aServiceNames; + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SortableGridDataModel::impl_translateRowIndex_throw( ::sal_Int32 const i_publicRowIndex ) const + { + if ( ( i_publicRowIndex < 0 ) || ( i_publicRowIndex >= m_delegator->getRowCount() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *const_cast< SortableGridDataModel* >( this ) ); + + if ( !impl_isSorted_nothrow() ) + // no need to translate anything + return i_publicRowIndex; + + ENSURE_OR_RETURN( size_t( i_publicRowIndex ) < m_rowIndexTranslation.size(), + "SortableGridDataModel::impl_translateRowIndex_throw: inconsistency!", i_publicRowIndex ); + // obviously the translation table contains too few elements - it should have exactly |getRowCount()| + // elements + + return m_rowIndexTranslation[ i_publicRowIndex ]; + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SortableGridDataModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) +{ + return *( new ::toolkit::SortableGridDataModel( i_factory ) ); +} diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.hxx b/toolkit/source/controls/grid/sortablegriddatamodel.hxx new file mode 100755 index 000000000000..64dad34af2bf --- /dev/null +++ b/toolkit/source/controls/grid/sortablegriddatamodel.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * 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 + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef TOOLKIT_SORTABLEGRIDDATAMODEL_HXX +#define TOOLKIT_SORTABLEGRIDDATAMODEL_HXX + +/** === begin UNO includes === **/ +#include +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include +#include + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + //================================================================================================================== + //= SortableGridDataModel + //================================================================================================================== + typedef ::cppu::WeakComponentImplHelper3 < ::com::sun::star::awt::grid::XSortableMutableGridDataModel + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XInitialization + > SortableGridDataModel_Base; + class SortableGridDataModel :public ::cppu::BaseMutex + ,public SortableGridDataModel_Base + { + public: + SortableGridDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & i_factory ); + SortableGridDataModel( SortableGridDataModel const & i_copySource ); + + public: + bool isInitialized() const { return m_isInitialized; } + + protected: + ~SortableGridDataModel(); + + public: + // XSortableGridData + virtual void SAL_CALL sortByColumn( ::sal_Int32 ColumnIndex, ::sal_Bool SortAscending ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::beans::Pair< ::sal_Int32, ::sal_Bool > SAL_CALL getCurrentSortOrder( ) throw (::com::sun::star::uno::RuntimeException); + + // XMutableGridDataModel + virtual void SAL_CALL addRow( const ::com::sun::star::uno::Any& Heading, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Data ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Headings, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& Data ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRow( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeAllRows( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCellData( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowData( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRowHeading( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Heading ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCellToolTip( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowToolTip( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + + // XGridDataModel + virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellToolTip( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getRowHeading( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + + // XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + private: + /** translates the given public index into one to be passed to our delegator + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the given index does not denote a valid row + */ + ::sal_Int32 impl_translateRowIndex_throw( ::sal_Int32 const i_publicRowIndex ) const; + + inline bool impl_isSorted_nothrow() const + { + return m_currentSortColumn >= 0; + } + + /** rebuilds the index translation structure. + + Neither m_currentSortColumn nor m_sortAscending are touched by this method. + Also, the given column index is not checked, this is the responsibility of the caller. + */ + void impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending ); + + private: + ::comphelper::ComponentContext m_context; + bool m_isInitialized; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XMutableGridDataModel > m_delegator; + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator > m_collator; + ::sal_Int32 m_currentSortColumn; + ::sal_Bool m_sortAscending; + ::std::vector< ::sal_Int32 > m_rowIndexTranslation; + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_SORTABLEGRIDDATAMODEL_HXX diff --git a/toolkit/source/helper/registerservices.cxx b/toolkit/source/helper/registerservices.cxx index ef6dca4f4916..61e734d39208 100644 --- a/toolkit/source/helper/registerservices.cxx +++ b/toolkit/source/helper/registerservices.cxx @@ -207,6 +207,7 @@ extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL DefaultGridDataModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GridColumn_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); +extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SortableGridDataModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); extern void * SAL_CALL comp_AsyncCallback_component_getFactory( const char * implName, void * serviceManager, void * registryKey ); @@ -298,7 +299,7 @@ TOOLKIT_DLLPUBLIC void* SAL_CALL component_getFactory( const sal_Char* sImplemen GET_FACTORY( DefaultGridDataModel, szServiceName_DefaultGridDataModel, NULL ); GET_FACTORY( DefaultGridColumnModel, szServiceName_DefaultGridColumnModel, NULL ); GET_FACTORY_WITH_IMPL_PREFIX( GridColumn, "org.openoffice.comp.toolkit", szServiceName_GridColumn, NULL ); - + GET_FACTORY_WITH_IMPL_PREFIX( SortableGridDataModel, "org.openoffice.comp.toolkit", szServiceName_SortableGridDataModel, NULL ); if ( rtl_str_compare( sImplementationName, "com.sun.star.awt.comp.AsyncCallback" ) == 0 ) return comp_AsyncCallback_component_getFactory( sImplementationName, _pServiceManager, _pRegistryKey ); diff --git a/toolkit/source/helper/servicenames.cxx b/toolkit/source/helper/servicenames.cxx index f57f52f13e57..0a2131a92eb3 100644 --- a/toolkit/source/helper/servicenames.cxx +++ b/toolkit/source/helper/servicenames.cxx @@ -102,3 +102,5 @@ const sal_Char __FAR_DATA szServiceName_GridControlModel[] = "com.sun.star.awt.g const sal_Char __FAR_DATA szServiceName_DefaultGridDataModel[] = "com.sun.star.awt.grid.DefaultGridDataModel"; const sal_Char __FAR_DATA szServiceName_DefaultGridColumnModel[] = "com.sun.star.awt.grid.DefaultGridColumnModel"; const sal_Char __FAR_DATA szServiceName_GridColumn[] = "com.sun.star.awt.grid.GridColumn"; +const sal_Char __FAR_DATA szServiceName_SortableGridDataModel[] = "com.sun.star.awt.grid.SortableGridDataModel"; + diff --git a/toolkit/util/tk.component b/toolkit/util/tk.component index e919e8451dbb..ef6e8abfc268 100644 --- a/toolkit/util/tk.component +++ b/toolkit/util/tk.component @@ -44,6 +44,9 @@ + + + -- cgit v1.2.3 From de9dba9275aff2863978f7f665685d54ef82b0ad Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 18 Jan 2011 17:30:17 +0100 Subject: gridsort: introduce XSortableGridDataModel::removeColumnSort --- svtools/source/uno/unocontroltablemodel.cxx | 10 +- .../source/controls/grid/sortablegriddatamodel.cxx | 440 +++++++++++++++++++-- .../source/controls/grid/sortablegriddatamodel.hxx | 68 +++- 3 files changed, 484 insertions(+), 34 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index 505cccf22702..ae4de7c36809 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -38,7 +38,7 @@ #include #include #include -#include +#include /** === end UNO includes === **/ #include @@ -74,7 +74,7 @@ namespace svt { namespace table using ::com::sun::star::style::VerticalAlignment; using ::com::sun::star::uno::WeakReference; using ::com::sun::star::awt::grid::GridDataEvent; - using ::com::sun::star::awt::grid::XSortableGridData; + using ::com::sun::star::awt::grid::XSortableGridDataModel; using ::com::sun::star::beans::Pair; /** === end UNO using === **/ @@ -743,7 +743,7 @@ namespace svt { namespace table { DBG_CHECK_ME(); - Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY ); + Reference< XSortableGridDataModel > const xSortAccess( getDataModel(), UNO_QUERY ); if ( xSortAccess.is() ) return this; return NULL; @@ -756,7 +756,7 @@ namespace svt { namespace table try { - Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); + Reference< XSortableGridDataModel > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); xSortAccess->sortByColumn( i_column, i_sortDirection == ColumnSortAscending ); } catch( const Exception& ) @@ -773,7 +773,7 @@ namespace svt { namespace table ColumnSort currentSort; try { - Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); + Reference< XSortableGridDataModel > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); Pair< ::sal_Int32, ::sal_Bool > const aCurrentSortOrder( xSortAccess->getCurrentSortOrder() ); currentSort.nColumnPos = aCurrentSortOrder.First; currentSort.eSortDirection = aCurrentSortOrder.Second ? ColumnSortAscending : ColumnSortDescending; diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx index 4b525dbc925a..d69f3d6187a5 100755 --- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -27,18 +27,22 @@ #include "precompiled_toolkit.hxx" #include "sortablegriddatamodel.hxx" -#include "initguard.hxx" #include "toolkit/helper/servicenames.hxx" /** === begin UNO includes === **/ #include #include +#include /** === end UNO includes === **/ #include +#include #include +#include #include +#include + //...................................................................................................................... namespace toolkit { @@ -66,38 +70,104 @@ namespace toolkit using ::com::sun::star::i18n::XCollator; using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::awt::grid::GridDataEvent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::ucb::AlreadyInitializedException; /** === end UNO using === **/ - typedef InitGuard< SortableGridDataModel > MethodGuard; +#ifdef DBG_UTIL + const char* SortableGridDataModel_checkInvariants( const void* _pInstance ) + { + return static_cast< const SortableGridDataModel* >( _pInstance )->checkInvariants(); + } + + //------------------------------------------------------------------------------------------------------------------ + const char* SortableGridDataModel::checkInvariants() const + { + if ( m_publicToPrivateRowIndex.size() != m_privateToPublicRowIndex.size() ) + return "inconsistent index maps"; + + if ( m_delegator.is() ) + { + if ( m_publicToPrivateRowIndex.size() != size_t( m_delegator->getRowCount() ) ) + return "wrong cached row count"; + } + else + { + if ( !m_publicToPrivateRowIndex.empty() ) + return "disposed or not initialized, but having a non-empty map"; + } + + for ( size_t publicIndex=0; publicIndex= m_privateToPublicRowIndex.size() ) ) + return "invalid cached private index"; + + if ( m_privateToPublicRowIndex[ privateIndex ] != sal_Int32( publicIndex ) ) + return "index map traversal not commutavive"; + } + + if ( impl_isSorted_nothrow() && m_publicToPrivateRowIndex.empty() ) + return "sorted, but no row index translation tables"; + + if ( !impl_isSorted_nothrow() && !m_publicToPrivateRowIndex.empty() ) + return "unsorted, but have index translation tables"; + + return NULL; + } +#endif + +#define DBG_CHECK_ME() \ + DBG_CHKTHIS( SortableGridDataModel, SortableGridDataModel_checkInvariants ) + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + template< class STLCONTAINER > + static void lcl_clear( STLCONTAINER& i_container ) + { + STLCONTAINER empty; + empty.swap( i_container ); + } + } //================================================================================================================== //= SortableGridDataModel //================================================================================================================== + DBG_NAME( SortableGridDataModel ) //------------------------------------------------------------------------------------------------------------------ SortableGridDataModel::SortableGridDataModel( Reference< XMultiServiceFactory > const & i_factory ) :SortableGridDataModel_Base( m_aMutex ) + ,SortableGridDataModel_PrivateBase() ,m_context( i_factory ) ,m_isInitialized( false ) ,m_delegator() ,m_collator() ,m_currentSortColumn( -1 ) ,m_sortAscending( true ) - ,m_rowIndexTranslation() + ,m_publicToPrivateRowIndex() + ,m_privateToPublicRowIndex() { + DBG_CTOR( SortableGridDataModel, SortableGridDataModel_checkInvariants ); } //------------------------------------------------------------------------------------------------------------------ SortableGridDataModel::SortableGridDataModel( SortableGridDataModel const & i_copySource ) :cppu::BaseMutex() ,SortableGridDataModel_Base( m_aMutex ) + ,SortableGridDataModel_PrivateBase() ,m_context( i_copySource.m_context ) ,m_collator( i_copySource.m_collator ) ,m_isInitialized( true ) ,m_delegator() ,m_currentSortColumn( i_copySource.m_currentSortColumn ) ,m_sortAscending( i_copySource.m_sortAscending ) - ,m_rowIndexTranslation( i_copySource.m_rowIndexTranslation ) + ,m_publicToPrivateRowIndex( i_copySource.m_publicToPrivateRowIndex ) + ,m_privateToPublicRowIndex( i_copySource.m_privateToPublicRowIndex ) { + DBG_CTOR( SortableGridDataModel, SortableGridDataModel_checkInvariants ); + ENSURE_OR_THROW( i_copySource.m_delegator.is(), "not expected to be called for a disposed copy source!" ); m_delegator.set( i_copySource.m_delegator->createClone(), UNO_QUERY_THROW ); @@ -111,6 +181,43 @@ namespace toolkit acquire(); dispose(); } + + DBG_DTOR( SortableGridDataModel, SortableGridDataModel_checkInvariants ); + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL SortableGridDataModel::queryInterface( const Type& aType ) throw (RuntimeException) + { + Any aReturn( SortableGridDataModel_Base::queryInterface( aType ) ); + if ( !aReturn.hasValue() ) + aReturn = SortableGridDataModel_PrivateBase::queryInterface( aType ); + return aReturn; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::acquire( ) throw () + { + SortableGridDataModel_Base::acquire(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::release( ) throw () + { + SortableGridDataModel_Base::release(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< Type > SAL_CALL SortableGridDataModel::getTypes( ) throw (RuntimeException) + { + return SortableGridDataModel_Base::getTypes(); + // don't expose the types got via SortableGridDataModel_PrivateBase - they're private, after all + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::sal_Int8 > SAL_CALL SortableGridDataModel::getImplementationId( ) throw (RuntimeException) + { + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); } //------------------------------------------------------------------------------------------------------------------ @@ -128,6 +235,10 @@ namespace toolkit void SAL_CALL SortableGridDataModel::initialize( const Sequence< Any >& i_arguments ) throw (Exception, RuntimeException) { ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + if ( m_delegator.is() ) + throw AlreadyInitializedException( ::rtl::OUString(), *this ); Reference< XMutableGridDataModel > xDelegator; Reference< XCollator > xCollator; @@ -148,12 +259,210 @@ namespace toolkit if ( !xDelegator.is() ) throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); - // TODO: add as listener to the delegator model, so we're able to multiplex the events it will notify - m_delegator = xDelegator; + m_collator = xCollator; + + m_delegator->addGridDataListener( this ); + m_isInitialized = true; } + //------------------------------------------------------------------------------------------------------------------ + GridDataEvent SortableGridDataModel::impl_createPublicEvent( GridDataEvent const & i_originalEvent ) const + { + GridDataEvent aEvent( i_originalEvent ); + aEvent.Source = *const_cast< SortableGridDataModel* >( this ); + aEvent.FirstRow = impl_getPublicRowIndex_nothrow( aEvent.FirstRow ); + aEvent.LastRow = impl_getPublicRowIndex_nothrow( aEvent.LastRow ); + return aEvent; + } + + //------------------------------------------------------------------------------------------------------------------ + void SortableGridDataModel::impl_broadcast( void ( SAL_CALL XGridDataListener::*i_listenerMethod )( const GridDataEvent & ), + GridDataEvent const & i_publicEvent, MethodGuard& i_instanceLock ) + { + ::cppu::OInterfaceContainerHelper* pListeners = rBHelper.getContainer( XGridDataListener::static_type() ); + if ( pListeners == NULL ) + return; + + i_instanceLock.clear(); + pListeners->notifyEach( i_listenerMethod, i_publicEvent ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::rowsInserted( const GridDataEvent& i_event ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + // if the data is not sorted, broadcast the event unchanged + if ( !impl_isSorted_nothrow() ) + { + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard ); + return; + } + + bool needReIndex = false; + if ( i_event.FirstRow > i_event.LastRow ) + { + OSL_ENSURE( false, "SortableGridDataModel::rowsInserted: invalid event - invalid row indexes!" ); + needReIndex = true; + } + else if ( size_t( i_event.FirstRow ) > m_privateToPublicRowIndex.size() ) + { + OSL_ENSURE( false, "SortableGridDataModel::rowsInserted: invalid event - too large row index!" ); + needReIndex = true; + } + + if ( needReIndex ) + { + impl_rebuildIndexesAndNotify( aGuard ); + return; + } + + // we do not insert the new rows into the sort order - if somebody adds rows while we're sorted, s/he has + // to resort. Instead, we simply append the rows, no matter where they were inserted in the delegator data + // model. + sal_Int32 const nPublicFirstRow = sal_Int32( m_privateToPublicRowIndex.size() ); + sal_Int32 nPublicLastRow = nPublicFirstRow; + for ( sal_Int32 newRow = i_event.FirstRow; newRow <= i_event.LastRow; ++newRow, ++nPublicLastRow ) + { + m_privateToPublicRowIndex.push_back( nPublicLastRow ); + m_publicToPrivateRowIndex.push_back( nPublicLastRow ); + } + + // broadcast the event + GridDataEvent const aEvent( *this, -1, -1, nPublicFirstRow, nPublicLastRow ); + impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + void lcl_decrementValuesGreaterThan( ::std::vector< ::sal_Int32 > & io_indexMap, sal_Int32 const i_threshold ) + { + for ( ::std::vector< ::sal_Int32 >::iterator loop = io_indexMap.begin(); + loop != io_indexMap.end(); + ++loop + ) + { + if ( *loop >= i_threshold ) + --*loop; + } + } + } + + //------------------------------------------------------------------------------------------------------------------ + void SortableGridDataModel::impl_rebuildIndexesAndNotify( MethodGuard& i_instanceLock ) + { + OSL_PRECOND( impl_isSorted_nothrow(), "SortableGridDataModel::impl_rebuildIndexesAndNotify: illegal call!" ); + + // clear the indexes + lcl_clear( m_publicToPrivateRowIndex ); + lcl_clear( m_privateToPublicRowIndex ); + + // broadcast an artificial event, saying that all rows have been removed + GridDataEvent const aRemovalEvent( *this, -1, -1, -1, -1 ); + impl_broadcast( &XGridDataListener::rowsRemoved, aRemovalEvent, i_instanceLock ); + i_instanceLock.reset(); + + // rebuild the index + impl_reIndex_nothrow( m_currentSortColumn, m_sortAscending ); + + // broadcast an artificial event, saying that n rows have been added + GridDataEvent const aAdditionEvent( *this, -1, -1, 0, m_delegator->getRowCount() - 1 ); + impl_broadcast( &XGridDataListener::rowsInserted, aAdditionEvent, i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::rowsRemoved( const GridDataEvent& i_event ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + // if the data is not sorted, broadcast the event unchanged + if ( !impl_isSorted_nothrow() ) + { + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + impl_broadcast( &XGridDataListener::rowsRemoved, aEvent, aGuard ); + return; + } + + // if all rows have been removed, also simply multiplex to own listeners + if ( i_event.FirstRow < 0 ) + { + lcl_clear( m_publicToPrivateRowIndex ); + lcl_clear( m_privateToPublicRowIndex ); + GridDataEvent aEvent( i_event ); + aEvent.Source = *this; + impl_broadcast( &XGridDataListener::rowsRemoved, aEvent, aGuard ); + return; + } + + bool needReIndex = false; + if ( i_event.FirstRow != i_event.LastRow ) + { + OSL_ENSURE( false, "SortableGridDataModel::rowsRemoved: missing implementation - removal of multiple rows!" ); + needReIndex = true; + } + else if ( size_t( i_event.FirstRow ) >= m_privateToPublicRowIndex.size() ) + { + OSL_ENSURE( false, "SortableGridDataModel::rowsRemoved: inconsistent/wrong data!" ); + needReIndex = true; + } + + if ( needReIndex ) + { + impl_rebuildIndexesAndNotify( aGuard ); + return; + } + + // build public event version + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + + // remove the entries from the index maps + sal_Int32 const privateIndex = i_event.FirstRow; + sal_Int32 const publicIndex = aEvent.FirstRow; + + m_publicToPrivateRowIndex.erase( m_publicToPrivateRowIndex.begin() + publicIndex ); + m_privateToPublicRowIndex.erase( m_privateToPublicRowIndex.begin() + privateIndex ); + + // adjust remaining entries in the index maps + lcl_decrementValuesGreaterThan( m_publicToPrivateRowIndex, privateIndex ); + lcl_decrementValuesGreaterThan( m_privateToPublicRowIndex, publicIndex ); + + // broadcast the event + impl_broadcast( &XGridDataListener::rowsRemoved, aEvent, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::dataChanged( const GridDataEvent& i_event ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + impl_broadcast( &XGridDataListener::dataChanged, aEvent, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::rowHeadingChanged( const GridDataEvent& i_event ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + impl_broadcast( &XGridDataListener::rowHeadingChanged, aEvent, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::disposing( const EventObject& i_event ) throw (RuntimeException) + { + // not interested in + OSL_UNUSED( i_event ); + } + //------------------------------------------------------------------------------------------------------------------ namespace { @@ -199,7 +508,7 @@ namespace toolkit void SortableGridDataModel::impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending ) { ::sal_Int32 const rowCount( getRowCount() ); - ::std::vector< ::sal_Int32 > aIndexTranslation( rowCount ); + ::std::vector< ::sal_Int32 > aPublicToPrivate( rowCount ); try { @@ -209,7 +518,7 @@ namespace toolkit for ( ::sal_Int32 rowIndex = 0; rowIndex < rowCount; ++rowIndex ) { aColumnData[ rowIndex ] = m_delegator->getCellData( i_columnIndex, rowIndex ); - aIndexTranslation[ rowIndex ] = rowIndex; + aPublicToPrivate[ rowIndex ] = rowIndex; // determine the data types we assume for the complete column if ( ( dataType.getTypeClass() == TypeClass_VOID ) && aColumnData[ rowIndex ].hasValue() ) @@ -222,7 +531,7 @@ namespace toolkit // then sort CellDataLessComparison const aComparator( aColumnData, *pPredicate, i_sortAscending ); - ::std::sort( aIndexTranslation.begin(), aIndexTranslation.end(), aComparator ); + ::std::sort( aPublicToPrivate.begin(), aPublicToPrivate.end(), aComparator ); } catch( const Exception& ) { @@ -230,13 +539,20 @@ namespace toolkit return; } - m_rowIndexTranslation.swap( aIndexTranslation ); + // also build the "private to public" mapping + ::std::vector< sal_Int32 > aPrivateToPublic( aPublicToPrivate.size() ); + for ( size_t i=0; i= getColumnCount() ) ) throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); @@ -245,12 +561,39 @@ namespace toolkit m_currentSortColumn = i_columnIndex; m_sortAscending = i_sortAscending; + + impl_broadcast( + &XGridDataListener::dataChanged, + GridDataEvent( *this, -1, -1, -1, -1 ), + aGuard + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::removeColumnSort( ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + lcl_clear( m_publicToPrivateRowIndex ); + lcl_clear( m_privateToPublicRowIndex ); + + m_currentSortColumn = -1; + m_sortAscending = sal_True; + + impl_broadcast( + &XGridDataListener::dataChanged, + GridDataEvent( *this, -1, -1, -1, -1 ), + aGuard + ); } //------------------------------------------------------------------------------------------------------------------ Pair< ::sal_Int32, ::sal_Bool > SAL_CALL SortableGridDataModel::getCurrentSortOrder( ) throw (RuntimeException) { MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + return Pair< ::sal_Int32, ::sal_Bool >( m_currentSortColumn, m_sortAscending ); } @@ -258,6 +601,8 @@ namespace toolkit void SAL_CALL SortableGridDataModel::addRow( const Any& i_heading, const Sequence< Any >& i_data ) throw (RuntimeException) { MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + m_delegator->addRow( i_heading, i_data ); } @@ -265,6 +610,8 @@ namespace toolkit void SAL_CALL SortableGridDataModel::addRows( const Sequence< Any >& i_headings, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + m_delegator->addRows( i_headings, i_data ); } @@ -272,7 +619,9 @@ namespace toolkit void SAL_CALL SortableGridDataModel::removeRow( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); - ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); m_delegator->removeRow( rowIndex ); } @@ -280,6 +629,8 @@ namespace toolkit void SAL_CALL SortableGridDataModel::removeAllRows( ) throw (RuntimeException) { MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + m_delegator->removeAllRows(); } @@ -287,7 +638,9 @@ namespace toolkit void SAL_CALL SortableGridDataModel::updateCellData( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); - ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); m_delegator->updateCellData( i_columnIndex, rowIndex, i_value ); } @@ -295,7 +648,9 @@ namespace toolkit void SAL_CALL SortableGridDataModel::updateRowData( const Sequence< ::sal_Int32 >& i_columnIndexes, ::sal_Int32 i_rowIndex, const Sequence< Any >& i_values ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); - ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); m_delegator->updateRowData( i_columnIndexes, rowIndex, i_values ); } @@ -303,7 +658,9 @@ namespace toolkit void SAL_CALL SortableGridDataModel::setRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); - ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); m_delegator->setRowHeading( rowIndex, i_heading ); } @@ -311,7 +668,9 @@ namespace toolkit void SAL_CALL SortableGridDataModel::updateCellToolTip( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); - ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); m_delegator->updateCellToolTip( i_columnIndex, rowIndex, i_value ); } @@ -319,7 +678,9 @@ namespace toolkit void SAL_CALL SortableGridDataModel::updateRowToolTip( ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); - ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); m_delegator->updateRowToolTip( rowIndex, i_value ); } @@ -339,6 +700,8 @@ namespace toolkit ::sal_Int32 SAL_CALL SortableGridDataModel::getRowCount() throw (RuntimeException) { MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + return m_delegator->getRowCount(); } @@ -346,6 +709,8 @@ namespace toolkit ::sal_Int32 SAL_CALL SortableGridDataModel::getColumnCount() throw (RuntimeException) { MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + return m_delegator->getColumnCount(); } @@ -353,7 +718,9 @@ namespace toolkit Any SAL_CALL SortableGridDataModel::getCellData( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); - ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); return m_delegator->getCellData( i_columnIndex, rowIndex ); } @@ -361,7 +728,9 @@ namespace toolkit Any SAL_CALL SortableGridDataModel::getCellToolTip( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); - ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); return m_delegator->getCellToolTip( i_columnIndex, rowIndex ); } @@ -369,7 +738,9 @@ namespace toolkit Any SAL_CALL SortableGridDataModel::getRowHeading( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); - ::sal_Int32 const rowIndex = impl_translateRowIndex_throw( i_rowIndex ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); return m_delegator->getRowHeading( rowIndex ); } @@ -379,6 +750,7 @@ namespace toolkit m_currentSortColumn = -1; Reference< XComponent > const delegatorComponent( m_delegator.get() ); + m_delegator->removeGridDataListener( this ); m_delegator.clear(); delegatorComponent->dispose(); @@ -387,14 +759,16 @@ namespace toolkit if ( collatorComponent.is() ) collatorComponent->dispose(); - ::std::vector< ::sal_Int32 > aEmpty; - m_rowIndexTranslation.swap( aEmpty ); + lcl_clear( m_publicToPrivateRowIndex ); + lcl_clear( m_privateToPublicRowIndex ); } //------------------------------------------------------------------------------------------------------------------ Reference< XCloneable > SAL_CALL SortableGridDataModel::createClone( ) throw (RuntimeException) { MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + return new SortableGridDataModel( *this ); } @@ -423,7 +797,7 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - ::sal_Int32 SortableGridDataModel::impl_translateRowIndex_throw( ::sal_Int32 const i_publicRowIndex ) const + ::sal_Int32 SortableGridDataModel::impl_getPrivateRowIndex_throw( ::sal_Int32 const i_publicRowIndex ) const { if ( ( i_publicRowIndex < 0 ) || ( i_publicRowIndex >= m_delegator->getRowCount() ) ) throw IndexOutOfBoundsException( ::rtl::OUString(), *const_cast< SortableGridDataModel* >( this ) ); @@ -432,12 +806,28 @@ namespace toolkit // no need to translate anything return i_publicRowIndex; - ENSURE_OR_RETURN( size_t( i_publicRowIndex ) < m_rowIndexTranslation.size(), - "SortableGridDataModel::impl_translateRowIndex_throw: inconsistency!", i_publicRowIndex ); + ENSURE_OR_RETURN( size_t( i_publicRowIndex ) < m_publicToPrivateRowIndex.size(), + "SortableGridDataModel::impl_getPrivateRowIndex_throw: inconsistency!", i_publicRowIndex ); // obviously the translation table contains too few elements - it should have exactly |getRowCount()| // elements - return m_rowIndexTranslation[ i_publicRowIndex ]; + return m_publicToPrivateRowIndex[ i_publicRowIndex ]; + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SortableGridDataModel::impl_getPublicRowIndex_nothrow( ::sal_Int32 const i_privateRowIndex ) const + { + if ( !impl_isSorted_nothrow() ) + // no need to translate anything + return i_privateRowIndex; + + if ( i_privateRowIndex < 0 ) + return i_privateRowIndex; + + ENSURE_OR_RETURN( size_t( i_privateRowIndex ) < m_privateToPublicRowIndex.size(), + "SortableGridDataModel::impl_getPublicRowIndex_nothrow: invalid index!", i_privateRowIndex ); + + return m_privateToPublicRowIndex[ i_privateRowIndex ]; } //...................................................................................................................... diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.hxx b/toolkit/source/controls/grid/sortablegriddatamodel.hxx index 64dad34af2bf..26f0e63f9762 100755 --- a/toolkit/source/controls/grid/sortablegriddatamodel.hxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.hxx @@ -27,22 +27,29 @@ #ifndef TOOLKIT_SORTABLEGRIDDATAMODEL_HXX #define TOOLKIT_SORTABLEGRIDDATAMODEL_HXX +#include "initguard.hxx" + /** === begin UNO includes === **/ #include #include #include #include +#include /** === end UNO includes === **/ #include #include #include +#include //...................................................................................................................... namespace toolkit { //...................................................................................................................... + class SortableGridDataModel; + typedef InitGuard< SortableGridDataModel > MethodGuard; + //================================================================================================================== //= SortableGridDataModel //================================================================================================================== @@ -50,22 +57,29 @@ namespace toolkit , ::com::sun::star::lang::XServiceInfo , ::com::sun::star::lang::XInitialization > SortableGridDataModel_Base; + typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::grid::XGridDataListener + > SortableGridDataModel_PrivateBase; class SortableGridDataModel :public ::cppu::BaseMutex ,public SortableGridDataModel_Base + ,public SortableGridDataModel_PrivateBase { public: SortableGridDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & i_factory ); SortableGridDataModel( SortableGridDataModel const & i_copySource ); - public: bool isInitialized() const { return m_isInitialized; } +#ifdef DBG_UTIL + const char* checkInvariants() const; +#endif + protected: ~SortableGridDataModel(); public: - // XSortableGridData + // XSortableGridDataModel virtual void SAL_CALL sortByColumn( ::sal_Int32 ColumnIndex, ::sal_Bool SortAscending ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeColumnSort( ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::beans::Pair< ::sal_Int32, ::sal_Bool > SAL_CALL getCurrentSortOrder( ) throw (::com::sun::star::uno::RuntimeException); // XMutableGridDataModel @@ -102,12 +116,34 @@ namespace toolkit // XInitialization virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + // XGridDataListener + virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowHeadingChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire( ) throw (); + virtual void SAL_CALL release( ) throw (); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException); + private: /** translates the given public index into one to be passed to our delegator @throws ::com::sun::star::lang::IndexOutOfBoundsException if the given index does not denote a valid row */ - ::sal_Int32 impl_translateRowIndex_throw( ::sal_Int32 const i_publicRowIndex ) const; + ::sal_Int32 impl_getPrivateRowIndex_throw( ::sal_Int32 const i_publicRowIndex ) const; + + /** translates the given private row index to a public one + */ + ::sal_Int32 impl_getPublicRowIndex_nothrow( ::sal_Int32 const i_privateRowIndex ) const; inline bool impl_isSorted_nothrow() const { @@ -121,6 +157,29 @@ namespace toolkit */ void impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending ); + /** translates the given event, obtained from our delegator, to a version which can be broadcasted to our own + clients. + */ + ::com::sun::star::awt::grid::GridDataEvent + impl_createPublicEvent( ::com::sun::star::awt::grid::GridDataEvent const & i_originalEvent ) const; + + /** broadcasts the given event to our registered XGridDataListeners + */ + void impl_broadcast( + void ( SAL_CALL ::com::sun::star::awt::grid::XGridDataListener::*i_listenerMethod )( const ::com::sun::star::awt::grid::GridDataEvent & ), + ::com::sun::star::awt::grid::GridDataEvent const & i_publicEvent, + MethodGuard& i_instanceLock + ); + + /** rebuilds our indexes, notifying row removal and row addition events + + First, a rowsRemoved event is notified to our registered listeners. Then, the index translation tables are + rebuilt, and a rowsInserted event is notified. + + Only to be called when we're sorted. + */ + void impl_rebuildIndexesAndNotify( MethodGuard& i_instanceLock ); + private: ::comphelper::ComponentContext m_context; bool m_isInitialized; @@ -128,7 +187,8 @@ namespace toolkit ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator > m_collator; ::sal_Int32 m_currentSortColumn; ::sal_Bool m_sortAscending; - ::std::vector< ::sal_Int32 > m_rowIndexTranslation; + ::std::vector< ::sal_Int32 > m_publicToPrivateRowIndex; + ::std::vector< ::sal_Int32 > m_privateToPublicRowIndex; }; //...................................................................................................................... -- cgit v1.2.3 From 37b53c32ec5320838721ee209d259f41427f8335 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 18 Jan 2011 22:31:36 +0100 Subject: gridsort: fix calculation of nActualRows when rendering the row header area - there were edge cases where this area was too large --- svtools/source/table/tablecontrol_impl.cxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 8e995babb36f..e085fc45a990 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -1242,10 +1242,6 @@ namespace svt { namespace table // our current style settings, to be passed to the renderer const StyleSettings& rStyle = m_rAntiImpl.GetSettings().GetStyleSettings(); m_nRowCount = m_pModel->getRowCount(); - TableSize nVisibleRows = impl_getVisibleRows(true); - TableSize nActualRows = m_nRowCount; - if(m_nRowCount>nVisibleRows) - nActualRows = nVisibleRows; // the area occupied by all (at least partially) visible cells, including // headers Rectangle aAllCellsWithHeaders; @@ -1285,10 +1281,13 @@ namespace svt { namespace table { aRowHeaderArea = aAllCellsWithHeaders; aRowHeaderArea.Right() = m_nRowHeaderWidthPixel - 1; + + TableSize const nVisibleRows = impl_getVisibleRows( true ); + TableSize nActualRows = nVisibleRows; if ( m_nTopRow + nActualRows > m_nRowCount ) - aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows - 1 ) + m_nColHeaderHeightPixel - 1; - else - aRowHeaderArea.Bottom() = m_nRowHeightPixel * nActualRows + m_nColHeaderHeightPixel - 1; + nActualRows = m_nRowCount - m_nTopRow; + aRowHeaderArea.Bottom() = m_nColHeaderHeightPixel + m_nRowHeightPixel * nActualRows - 1; + pRenderer->PaintHeaderArea( *m_pDataWindow, aRowHeaderArea, false, true, rStyle ); // Note that strictly, aRowHeaderArea also contains the intersection between column // and row header area. However, below we go to paint this intersection, again, -- cgit v1.2.3 From e8f649b5ad64a2a3f07dfab1a52033d126da211b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 19 Jan 2011 11:11:29 +0100 Subject: gridsort: render indicator for current column sort --- .../inc/svtools/table/tablecontrolinterface.hxx | 13 ++- svtools/source/table/gridtablerenderer.cxx | 98 +++++++++++++++++++++- svtools/source/table/mousefunction.cxx | 2 +- svtools/source/table/tablecontrol.cxx | 2 +- svtools/source/table/tablecontrol_impl.cxx | 87 ++++++++++--------- svtools/source/table/tablecontrol_impl.hxx | 6 +- svtools/source/uno/svtxgridcontrol.cxx | 19 ++++- 7 files changed, 175 insertions(+), 52 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablecontrolinterface.hxx b/svtools/inc/svtools/table/tablecontrolinterface.hxx index 6ff2b07e84ed..74e9688d01db 100644 --- a/svtools/inc/svtools/table/tablecontrolinterface.hxx +++ b/svtools/inc/svtools/table/tablecontrolinterface.hxx @@ -146,6 +146,17 @@ namespace svt { namespace table } }; + //================================================================================================================== + //= TableArea + //================================================================================================================== + enum TableArea + { + TableAreaColumnHeaders, + TableAreaRowHeaders, + TableAreaDataArea, + TableAreaAll + }; + //================================================================================================================== //= ITableControl //================================================================================================================== @@ -213,7 +224,7 @@ namespace svt { namespace table virtual void releaseMouse() = 0; /// invalidates the table window - virtual void invalidate() = 0; + virtual void invalidate( TableArea const i_what ) = 0; /// calculates a width, given in pixels, into a AppFont-based width virtual long pixelWidthToAppFont( long const i_pixels ) const = 0; diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 5fa7e0ab6f8d..91f78ff7fbc5 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -39,6 +39,8 @@ #include #include #include +#include +#include //...................................................................................................................... namespace svt { namespace table @@ -60,11 +62,65 @@ namespace svt { namespace table using ::com::sun::star::style::VerticalAlignment_BOTTOM; /** === end UNO using === **/ + //================================================================================================================== + //= CachedSortIndicator + //================================================================================================================== + class CachedSortIndicator + { + public: + CachedSortIndicator() + :m_lastHeaderHeight( 0 ) + ,m_lastArrowColor( COL_TRANSPARENT ) + { + } + + BitmapEx const & getBitmapFor( OutputDevice const & i_device, long const i_headerHeight, StyleSettings const & i_style, bool const i_sortAscending ); + + private: + long m_lastHeaderHeight; + Color m_lastArrowColor; + BitmapEx m_sortAscending; + BitmapEx m_sortDescending; + }; + + //------------------------------------------------------------------------------------------------------------------ + BitmapEx const & CachedSortIndicator::getBitmapFor( OutputDevice const & i_device, long const i_headerHeight, + StyleSettings const & i_style, bool const i_sortAscending ) + { + BitmapEx & rBitmap( i_sortAscending ? m_sortAscending : m_sortDescending ); + if ( !rBitmap || ( i_headerHeight != m_lastHeaderHeight ) || ( i_style.GetActiveColor() != m_lastArrowColor ) ) + { + long const nSortIndicatorWidth = 2 * i_headerHeight / 3; + long const nSortIndicatorHeight = 2 * nSortIndicatorWidth / 3; + + Point const aBitmapPos( 0, 0 ); + Size const aBitmapSize( nSortIndicatorWidth, nSortIndicatorHeight ); + VirtualDevice aDevice( i_device, 0, 0 ); + aDevice.SetOutputSizePixel( aBitmapSize ); + + DecorationView aDecoView( &aDevice ); + aDecoView.DrawSymbol( + Rectangle( aBitmapPos, aBitmapSize ), + i_sortAscending ? SYMBOL_SPIN_DOWN : SYMBOL_SPIN_UP, + i_style.GetActiveColor() + ); + + rBitmap = aDevice.GetBitmapEx( aBitmapPos, aBitmapSize ); + m_lastHeaderHeight = i_headerHeight; + m_lastArrowColor = i_style.GetActiveColor(); + } + return rBitmap; + } + + //================================================================================================================== + //= GridTableRenderer_Impl + //================================================================================================================== struct GridTableRenderer_Impl { - ITableModel& rModel; - RowPos nCurrentRow; - bool bUseGridLines; + ITableModel& rModel; + RowPos nCurrentRow; + bool bUseGridLines; + CachedSortIndicator aSortIndicator; GridTableRenderer_Impl( ITableModel& _rModel ) :rModel( _rModel ) @@ -73,6 +129,10 @@ namespace svt { namespace table { } }; + + //================================================================================================================== + //= helper + //================================================================================================================== namespace { static Rectangle lcl_getContentArea( GridTableRenderer_Impl const & i_impl, Rectangle const & i_cellArea ) @@ -220,6 +280,38 @@ namespace svt { namespace table _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight()); _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() ); + // draw sort indicator if the model data is sorted by the given column + ITableDataSort const * pSortAdapter = m_pImpl->rModel.getSortAdapter(); + ColumnSort aCurrentSortOrder; + if ( pSortAdapter != NULL ) + aCurrentSortOrder = pSortAdapter->getCurrentSortOrder(); + if ( aCurrentSortOrder.nColumnPos == _nCol ) + { + long const nHeaderHeight( _rArea.GetHeight() ); + BitmapEx const aIndicatorBitmap = m_pImpl->aSortIndicator.getBitmapFor( _rDevice, nHeaderHeight, _rStyle, + aCurrentSortOrder.eSortDirection == ColumnSortAscending ); + Size const aBitmapSize( aIndicatorBitmap.GetSizePixel() ); + long const nSortIndicatorPaddingX = 2; + long const nSortIndicatorPaddingY = ( nHeaderHeight - aBitmapSize.Height() ) / 2; + + if ( ( nDrawTextFlags & TEXT_DRAW_RIGHT ) != 0 ) + { + // text is right aligned => draw the sort indicator at the left hand side + _rDevice.DrawBitmapEx( + Point( nSortIndicatorPaddingX, nSortIndicatorPaddingY ), + aIndicatorBitmap + ); + } + else + { + // text is left-aligned or centered => draw the sort indicator at the right hand side + _rDevice.DrawBitmapEx( + Point( _rArea.Right() - nSortIndicatorPaddingX - aBitmapSize.Width(), nSortIndicatorPaddingY ), + aIndicatorBitmap + ); + } + } + _rDevice.Pop(); (void)_bActive; diff --git a/svtools/source/table/mousefunction.cxx b/svtools/source/table/mousefunction.cxx index e3a47057423f..6d37e35b7a4c 100755 --- a/svtools/source/table/mousefunction.cxx +++ b/svtools/source/table/mousefunction.cxx @@ -178,7 +178,7 @@ namespace svt { namespace table requestedWidthLogical = maxWidthLogical; } pColumn->setWidth( requestedWidthLogical ); - i_tableControl.invalidate(); + i_tableControl.invalidate( TableAreaAll ); } i_tableControl.setPointer( Pointer() ); diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index c448af323b8b..448da7c9395b 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -564,7 +564,7 @@ namespace svt { namespace table Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,BOOL _bOnScreen) { (void)_bOnScreen; - return m_pImpl->calcHeaderRect(_bIsColumnBar); + return m_pImpl->calcHeaderRect( _bIsColumnBar ? false : true ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index e085fc45a990..53ff00756d98 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -693,8 +693,7 @@ namespace svt { namespace table { DBG_CHECK_ME(); - Rectangle aAllCellsArea; - impl_getAllVisibleCellsArea( aAllCellsArea ); + Rectangle const aAllCellsArea( impl_getAllVisibleCellsArea() ); const TableColumnGeometry aColumn( *this, aAllCellsArea, i_column ); if ( aColumn.isValid() ) @@ -727,16 +726,15 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const + Rectangle TableControl_Impl::impl_getAllVisibleCellsArea() const { DBG_CHECK_ME(); - _rCellArea.Left() = 0; - _rCellArea.Top() = 0; + Rectangle aArea( Point( 0, 0 ), Size( 0, 0 ) ); // determine the right-most border of the last column which is // at least partially visible - _rCellArea.Right() = m_nRowHeaderWidthPixel; + aArea.Right() = m_nRowHeaderWidthPixel; if ( !m_aColumnWidths.empty() ) { // the number of pixels which are scrolled out of the left hand @@ -746,31 +744,34 @@ namespace svt { namespace table ColumnPositions::const_reverse_iterator loop = m_aColumnWidths.rbegin(); do { - _rCellArea.Right() = loop->getEnd() - nScrolledOutLeft + m_nRowHeaderWidthPixel; + aArea.Right() = loop->getEnd() - nScrolledOutLeft + m_nRowHeaderWidthPixel; ++loop; } while ( ( loop != m_aColumnWidths.rend() ) - && ( loop->getEnd() - nScrolledOutLeft >= _rCellArea.Right() ) + && ( loop->getEnd() - nScrolledOutLeft >= aArea.Right() ) ); } - // so far, _rCellArea.Right() denotes the first pixel *after* the cell area - --_rCellArea.Right(); + // so far, aArea.Right() denotes the first pixel *after* the cell area + --aArea.Right(); // determine the last row which is at least partially visible - _rCellArea.Bottom() = + aArea.Bottom() = m_nColHeaderHeightPixel + impl_getVisibleRows( true ) * m_nRowHeightPixel - 1; + + return aArea; } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const + Rectangle TableControl_Impl::impl_getAllVisibleDataCellArea() const { DBG_CHECK_ME(); - impl_getAllVisibleCellsArea( _rCellArea ); - _rCellArea.Left() = m_nRowHeaderWidthPixel; - _rCellArea.Top() = m_nColHeaderHeightPixel; + Rectangle aArea( impl_getAllVisibleCellsArea() ); + aArea.Left() = m_nRowHeaderWidthPixel; + aArea.Top() = m_nColHeaderHeightPixel; + return aArea; } //------------------------------------------------------------------------------------------------------------------ @@ -1244,8 +1245,7 @@ namespace svt { namespace table m_nRowCount = m_pModel->getRowCount(); // the area occupied by all (at least partially) visible cells, including // headers - Rectangle aAllCellsWithHeaders; - impl_getAllVisibleCellsArea( aAllCellsWithHeaders ); + Rectangle const aAllCellsWithHeaders( impl_getAllVisibleCellsArea() ); // ............................ // draw the header column area @@ -1310,8 +1310,7 @@ namespace svt { namespace table TableSize colCount = getModel()->getColumnCount(); // paint all rows - Rectangle aAllDataCellsArea; - impl_getAllVisibleDataCellArea( aAllDataCellsArea ); + Rectangle const aAllDataCellsArea( impl_getAllVisibleDataCellArea() ); for ( TableRowGeometry aRowIterator( *this, aAllCellsWithHeaders, getTopRow() ); aRowIterator.isValid(); aRowIterator.moveDown() ) @@ -1792,10 +1791,7 @@ namespace svt { namespace table return; } - Rectangle aAllCells; - impl_getAllVisibleCellsArea( aAllCells ); - - TableCellGeometry aCell( *this, aAllCells, _nColumn, _nRow ); + TableCellGeometry aCell( *this, impl_getAllVisibleCellsArea(), _nColumn, _nRow ); _rCellRect = aCell.getRect(); } @@ -1886,9 +1882,26 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::invalidate() + void TableControl_Impl::invalidate( TableArea const i_what ) { - m_pDataWindow->Invalidate(); + switch ( i_what ) + { + case TableAreaColumnHeaders: + m_pDataWindow->Invalidate( calcHeaderRect( true ) ); + break; + + case TableAreaRowHeaders: + m_pDataWindow->Invalidate( calcHeaderRect( false ) ); + break; + + case TableAreaDataArea: + m_pDataWindow->Invalidate( impl_getAllVisibleDataCellArea() ); + break; + + case TableAreaAll: + m_pDataWindow->Invalidate(); + break; + } } //------------------------------------------------------------------------------------------------------------------ @@ -1920,9 +1933,8 @@ namespace svt { namespace table void TableControl_Impl::invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect) { DBG_CHECK_ME(); - Rectangle aAllCells; //get the visible area of the table control and set the Left and right border of the region to be repainted - impl_getAllVisibleCellsArea( aAllCells ); + Rectangle const aAllCells( impl_getAllVisibleCellsArea() ); _rCellRect.Left() = aAllCells.Left(); _rCellRect.Right() = aAllCells.Right(); //if only one row is selected @@ -1967,9 +1979,7 @@ namespace svt { namespace table Rectangle aInvalidateRect; - Rectangle aVisibleCellsArea; - impl_getAllVisibleCellsArea( aVisibleCellsArea ); - + Rectangle const aVisibleCellsArea( impl_getAllVisibleCellsArea() ); TableRowGeometry aRow( *this, aVisibleCellsArea, firstRow, true ); while ( aRow.isValid() && ( aRow.getRow() <= lastRow ) ) { @@ -2409,23 +2419,18 @@ namespace svt { namespace table //-------------------------------------------------------------------- Rectangle TableControl_Impl::calcHeaderRect(bool bColHeader) { - Rectangle aRectTable, aRectTableWithHeaders; - impl_getAllVisibleDataCellArea(aRectTable); - impl_getAllVisibleCellsArea(aRectTableWithHeaders); - Size aSizeTable(aRectTable.GetSize()); - Size aSizeTableWithHeaders(aRectTableWithHeaders.GetSize()); - if(bColHeader) - return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width()-aSizeTable.Width(), aSizeTableWithHeaders.Height())); + Rectangle const aRectTableWithHeaders( impl_getAllVisibleCellsArea() ); + Size const aSizeTableWithHeaders( aRectTableWithHeaders.GetSize() ); + if ( bColHeader ) + return Rectangle( aRectTableWithHeaders.TopLeft(), Size( aSizeTableWithHeaders.Width(), m_nColHeaderHeightPixel ) ); else - return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height())); + return Rectangle( aRectTableWithHeaders.TopLeft(), Size( m_nRowHeaderWidthPixel, aSizeTableWithHeaders.Height() ) ); } //-------------------------------------------------------------------- Rectangle TableControl_Impl::calcTableRect() { - Rectangle aRect; - impl_getAllVisibleDataCellArea(aRect); - return aRect; + return impl_getAllVisibleDataCellArea(); } //-------------------------------------------------------------------- diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 0975368a88a2..747ffc8a36fa 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -282,7 +282,7 @@ namespace svt { namespace table virtual void setPointer( Pointer const & i_pointer ); virtual void captureMouse(); virtual void releaseMouse(); - virtual void invalidate(); + virtual void invalidate( TableArea const i_what ); virtual long pixelWidthToAppFont( long const i_pixels ) const; virtual void hideTracking(); virtual void showTracking( Rectangle const & i_location, sal_uInt16 const i_flags ); @@ -429,14 +429,14 @@ namespace svt { namespace table As a result of respecting the partial visibility of rows and columns, the returned area might be larger than the data window's output size. */ - void impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const; + Rectangle impl_getAllVisibleCellsArea() const; /** retrieves the area occupied by all (at least partially) visible data cells. Effectively, the returned area is the same as returned by ->impl_getAllVisibleCellsArea, minus the row and column header areas. */ - void impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const; + Rectangle impl_getAllVisibleDataCellArea() const; /** retrieves the column which covers the given ordinate */ diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index ef9b10030230..14ac857179b1 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -524,7 +524,8 @@ void SAL_CALL SVTXGridControl::rowsInserted( const GridDataEvent& i_event ) thro } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL SVTXGridControl::rowsRemoved( const GridDataEvent& i_event ) throw (RuntimeException) +void SAL_CALL//---------------------------------------------------------------------------------------------------------------------- + SVTXGridControl::rowsRemoved( const GridDataEvent& i_event ) throw (RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); m_pTableModel->notifyRowsRemoved( i_event ); @@ -544,6 +545,10 @@ void SAL_CALL SVTXGridControl::dataChanged( const GridDataEvent& i_event ) throw pTable->InvalidateDataWindow( 0, m_pTableModel->getRowCount() ); else pTable->InvalidateDataWindow( i_event.FirstRow, i_event.LastRow ); + + // if the data model is sortable, a dataChanged event is also fired in case the sort order changed. + // So, invalidate the column header area, too. + pTable->getTableControlInterface().invalidate( TableAreaColumnHeaders ); } //---------------------------------------------------------------------------------------------------------------------- @@ -556,7 +561,7 @@ void SAL_CALL SVTXGridControl::rowHeadingChanged( const GridDataEvent& i_event ) ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowHeadingChanged: no control (anymore)!" ); // TODO: we could do better than this - invalidate the header area only - pTable->Invalidate(); + pTable->getTableControlInterface().invalidate( TableAreaRowHeaders ); } @@ -609,6 +614,7 @@ void SAL_CALL SVTXGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (::com: pTable->SelectRow( i_rowIndex, true ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -619,6 +625,7 @@ void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::Run pTable->SelectAllRows( true ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -629,6 +636,7 @@ void SAL_CALL SVTXGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (::co pTable->SelectRow( i_rowIndex, false ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -639,6 +647,7 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R pTable->SelectAllRows( false ); } +//---------------------------------------------------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL SVTXGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -653,6 +662,7 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R return selectedRows; } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Bool SAL_CALL SVTXGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -663,6 +673,7 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R return pTable->GetSelectedRowCount() > 0; } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex( ::sal_Int32 index ) throw (::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -673,6 +684,7 @@ void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::R return pTable->IsRowSelected( index ); } +//---------------------------------------------------------------------------------------------------------------------- void SVTXGridControl::dispose() throw(::com::sun::star::uno::RuntimeException) { ::com::sun::star::lang::EventObject aObj; @@ -681,6 +693,7 @@ void SVTXGridControl::dispose() throw(::com::sun::star::uno::RuntimeException) VCLXWindow::dispose(); } +//---------------------------------------------------------------------------------------------------------------------- void SVTXGridControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { ::vos::OGuard aGuard( GetMutex() ); @@ -703,6 +716,7 @@ void SVTXGridControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent } } +//---------------------------------------------------------------------------------------------------------------------- void SVTXGridControl::ImplCallItemListeners() { TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); @@ -750,6 +764,7 @@ void SVTXGridControl::ImplCallItemListeners() } } +//---------------------------------------------------------------------------------------------------------------------- void SVTXGridControl::impl_updateColumnsFromModel_nothrow() { Reference< XGridColumnModel > const xColumnModel( m_pTableModel->getColumnModel() ); -- cgit v1.2.3 From 903ddf534a9a71cb54867d7c40eedf456acb018a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 19 Jan 2011 12:39:41 +0100 Subject: gridsort: introduce XGridColumn::DataModelIndex. this allows for column removal/insertion at the GridColumnModel, without the need to touch the GridDataModel --- svtools/inc/svtools/table/tablecontrol.hxx | 3 -- svtools/inc/svtools/table/tablemodel.hxx | 2 +- svtools/source/table/tablecontrol.cxx | 6 --- svtools/source/table/tablecontrol_impl.cxx | 13 +++--- svtools/source/table/tablecontrol_impl.hxx | 2 +- svtools/source/uno/svtxgridcontrol.cxx | 15 ++----- svtools/source/uno/unocontroltablemodel.cxx | 49 ++++++++++++++++++---- svtools/source/uno/unocontroltablemodel.hxx | 10 ++++- svtools/source/uno/unogridcolumnfacade.cxx | 34 +++++++++++++++ svtools/source/uno/unogridcolumnfacade.hxx | 12 +++++- .../controls/grid/defaultgridcolumnmodel.cxx | 1 + toolkit/source/controls/grid/gridcolumn.cxx | 15 +++++++ toolkit/source/controls/grid/gridcolumn.hxx | 3 ++ 13 files changed, 124 insertions(+), 41 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index a5360145bc46..a8324e0bc13d 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -151,9 +151,6 @@ namespace svt { namespace table void SetSelectHdl( const Link& rLink ); const Link& GetSelectHdl() const; - /// invalidates those areas of the data window which are covered by the given rows - void InvalidateDataWindow( RowPos const i_firstRow, RowPos const i_lastRow ); - /**after removing a row, updates the vector which contains the selected rows if the row, which should be removed, is selected, it will be erased from the vector */ diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 80ce012b05d0..b6c0c466edd0 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -142,7 +142,7 @@ namespace svt { namespace table they have about the cells in question, in particular any possibly cached cell values. */ - virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ) = 0; + virtual void cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow ) = 0; /** notifies the listener that attributes of a given column changed diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 448da7c9395b..4cccc3843adf 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -248,12 +248,6 @@ namespace svt { namespace table Select(); } - // ----------------------------------------------------------------------------------------------------------------- - void TableControl::InvalidateDataWindow( RowPos const i_firstRow, RowPos const i_lastRow ) - { - m_pImpl->invalidateRowRange( i_firstRow, i_lastRow ); - } - // ----------------------------------------------------------------------------------------------------------------- ITableControl& TableControl::getTableControlInterface() { diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 53ff00756d98..e47419f2ea52 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -670,14 +670,12 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ) + void TableControl_Impl::cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow ) { - OSL_ENSURE( false, "TableControl_Impl::cellsUpdated: not implemented!" ); - // there's no known implementation (yet) which calls this method - OSL_UNUSED( firstCol ); - OSL_UNUSED( lastCol ); - OSL_UNUSED( firstRow ); - OSL_UNUSED( lastRow ); + invalidateRowRange( i_firstRow, i_lastRow ); + + OSL_UNUSED( i_firstCol ); + OSL_UNUSED( i_lastCol ); } //------------------------------------------------------------------------------------------------------------------ @@ -1966,7 +1964,6 @@ namespace svt { namespace table m_pDataWindow->Invalidate(_rCellRect); } //------------------------------------------------------------------------------------------------------------------ - //this method is to be called, when a new row is added void TableControl_Impl::invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow ) { if ( m_nCursorHidden == 2 ) diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 747ffc8a36fa..dfc8141fa0e9 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -312,7 +312,7 @@ namespace svt { namespace table virtual void columnInserted( ColPos const i_colIndex ); virtual void columnRemoved( ColPos const i_colIndex ); virtual void allColumnsRemoved(); - virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ); + virtual void cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow ); virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ); virtual void tableMetricsChanged(); diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 14ac857179b1..d61a983b309b 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -536,18 +536,12 @@ void SAL_CALL SVTXGridControl::dataChanged( const GridDataEvent& i_event ) throw { ::vos::OGuard aGuard( GetMutex() ); - TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); - ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" ); - - // TODO: Our UnoControlTableModel should be a listener at the data model, and multiplex those events, - // so the TableControl/_Impl can react on it. - if ( i_event.FirstRow == -1 ) - pTable->InvalidateDataWindow( 0, m_pTableModel->getRowCount() ); - else - pTable->InvalidateDataWindow( i_event.FirstRow, i_event.LastRow ); + m_pTableModel->notifyDataChanged( i_event ); // if the data model is sortable, a dataChanged event is also fired in case the sort order changed. - // So, invalidate the column header area, too. + // So, just in case, invalidate the column header area, too. + TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" ); pTable->getTableControlInterface().invalidate( TableAreaColumnHeaders ); } @@ -564,7 +558,6 @@ void SAL_CALL SVTXGridControl::rowHeadingChanged( const GridDataEvent& i_event ) pTable->getTableControlInterface().invalidate( TableAreaRowHeaders ); } - //---------------------------------------------------------------------------------------------------------------------- void SAL_CALL SVTXGridControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) { diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index ae4de7c36809..b6d4d0f1e451 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -523,12 +523,18 @@ namespace svt { namespace table { DBG_CHECK_ME(); + o_cellContent.clear(); try { Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel ); - ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" ); + ENSURE_OR_RETURN_VOID( xDataModel.is(), "UnoControlTableModel::getCellContent: no data model anymore!" ); + + PColumnModel const pColumn = getColumnModel( i_col ); + UnoGridColumnFacade* pColumnImpl = dynamic_cast< UnoGridColumnFacade* >( pColumn.get() ); + ENSURE_OR_RETURN_VOID( pColumnImpl != NULL, "UnoControlTableModel::getCellContent: no (valid) column at this position!" ); + sal_Int32 const nDataColumnIndex = pColumnImpl->getDataColumnIndex() >= 0 ? pColumnImpl->getDataColumnIndex() : i_col; - if ( i_col >= xDataModel->getColumnCount() ) + if ( nDataColumnIndex >= xDataModel->getColumnCount() ) { // this is allowed, in case the column model has been dynamically extended, but the data model does // not (yet?) know about it. @@ -540,11 +546,10 @@ namespace svt { namespace table "UnoControlTableModel::getCellContent: request a column's value which the ColumnModel doesn't know about!" ); } #endif - o_cellContent.clear(); } else { - o_cellContent = xDataModel->getCellData( i_col, i_row ); + o_cellContent = xDataModel->getCellData( nDataColumnIndex, i_row ); } } catch( const Exception& ) @@ -803,7 +808,7 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::notifyRowsInserted( GridDataEvent const & i_event ) + void UnoControlTableModel::notifyRowsInserted( GridDataEvent const & i_event ) const { // check sanity of the event ENSURE_OR_RETURN_VOID( i_event.FirstRow >= 0, "UnoControlTableModel::notifyRowsInserted: invalid first row!" ); @@ -840,9 +845,8 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void UnoControlTableModel::notifyRowsRemoved( GridDataEvent const & i_event ) + void UnoControlTableModel::notifyRowsRemoved( GridDataEvent const & i_event ) const { - // multiplex the event to our own listeners ModellListeners aListeners( m_pImpl->m_aListeners ); for ( ModellListeners::const_iterator loop = aListeners.begin(); loop != aListeners.end(); @@ -853,6 +857,37 @@ namespace svt { namespace table } } + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const + { + ColPos const firstCol = i_event.FirstColumn == -1 ? 0 : i_event.FirstColumn; + ColPos const lastCol = i_event.FirstColumn == -1 ? getColumnCount() - 1 : i_event.LastColumn; + RowPos const firstRow = i_event.FirstRow == -1 ? 0 : i_event.FirstRow; + RowPos const lastRow = i_event.FirstRow == -1 ? getRowCount() - 1 : i_event.LastRow; + + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->cellsUpdated( firstCol, lastCol, firstRow, lastRow ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoControlTableModel::notifyAllDataChanged() const + { + ModellListeners aListeners( m_pImpl->m_aListeners ); + for ( ModellListeners::const_iterator loop = aListeners.begin(); + loop != aListeners.end(); + ++loop + ) + { + (*loop)->cellsUpdated( 0, getColumnCount() - 1, 0, getRowCount() - 1 ); + } + } + // ..................................................................................................................... } } // svt::table // ..................................................................................................................... diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 32930a64326d..537c3d9a5249 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -137,8 +137,9 @@ namespace svt { namespace table void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); // multiplexing of XGridDataListener events - void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent const & i_event ); - void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent const & i_event ); + void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; + void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; + void notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; /// retrieves the index of a column within the model ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const; @@ -146,6 +147,11 @@ namespace svt { namespace table /// notifies a change in a column belonging to the model void notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const; + /** notifies a change in all data represented by the model. To be used if you cannot specified the changed data + in more detail. + */ + void notifyAllDataChanged() const; + #ifdef DBG_UTIL const char* checkInvariants() const; #endif diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index 00fa72199815..98078b1fb2d4 100755 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -148,6 +148,14 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void SAL_CALL ColumnChangeMultiplexer::columnChanged( const GridColumnEvent& i_event ) throw (RuntimeException) { + if ( i_event.AttributeName.equalsAscii( "DataColumnIndex" ) ) + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + if ( m_pColumnImplementation != NULL ) + m_pColumnImplementation->dataColumnIndexChanged(); + return; + } + ColumnAttributeGroup nChangedAttributes( COL_ATTRS_NONE ); if ( i_event.AttributeName.equalsAscii( "HorizontalAlign" ) ) @@ -182,9 +190,11 @@ namespace svt { namespace table UnoGridColumnFacade::UnoGridColumnFacade( UnoControlTableModel const & i_owner, Reference< XGridColumn > const & i_gridColumn ) :m_pOwner( &i_owner ) ,m_xGridColumn( i_gridColumn, UNO_QUERY_THROW ) + ,m_nDataColumnIndex( -1 ) ,m_pChangeMultiplexer( new ColumnChangeMultiplexer( *this ) ) { m_xGridColumn->addGridColumnListener( m_pChangeMultiplexer.get() ); + impl_updateDataColumnIndex_nothrow(); } //------------------------------------------------------------------------------------------------------------------ @@ -205,6 +215,30 @@ namespace svt { namespace table m_pOwner = NULL; } + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::impl_updateDataColumnIndex_nothrow() + { + m_nDataColumnIndex = -1; + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + try + { + m_nDataColumnIndex = m_xGridColumn->getDataColumnIndex(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::dataColumnIndexChanged() + { + DBG_TESTSOLARMUTEX(); + impl_updateDataColumnIndex_nothrow(); + if ( m_pOwner != NULL ) + m_pOwner->notifyAllDataChanged(); + } + //------------------------------------------------------------------------------------------------------------------ void UnoGridColumnFacade::columnChanged( ColumnAttributeGroup const i_attributeGroup ) { diff --git a/svtools/source/uno/unogridcolumnfacade.hxx b/svtools/source/uno/unogridcolumnfacade.hxx index 6f606bb6f86b..11d40afa2984 100755 --- a/svtools/source/uno/unogridcolumnfacade.hxx +++ b/svtools/source/uno/unogridcolumnfacade.hxx @@ -90,11 +90,19 @@ namespace svt { namespace table */ void dispose(); - // callback for the XGridColumnListener + sal_Int32 + getDataColumnIndex() const { return m_nDataColumnIndex; } + + // callbacks for the XGridColumnListener void columnChanged( ColumnAttributeGroup const i_attributeGroup ); + void dataColumnIndexChanged(); + + private: + void impl_updateDataColumnIndex_nothrow(); private: - const UnoControlTableModel* m_pOwner; + UnoControlTableModel const * m_pOwner; + sal_Int32 m_nDataColumnIndex; ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > m_xGridColumn; ::rtl::Reference< ColumnChangeMultiplexer > m_pChangeMultiplexer; }; diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 80d1c9c136d3..8c50a7e62ef7 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -234,6 +234,7 @@ namespace toolkit colTitle.append( i + 1 ); pGridColumn->setTitle( colTitle.makeStringAndClear() ); pGridColumn->setPreferredWidth( 80 /* APPFONT */ ); + pGridColumn->setDataColumnIndex( i ); ContainerEvent aEvent; aEvent.Source = *this; diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 99ea4e68ce8d..60873cc1802f 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -50,6 +50,7 @@ namespace toolkit :GridColumn_Base( m_aMutex ) ,m_aIdentifier() ,m_nIndex(-1) + ,m_nDataColumnIndex(-1) ,m_nColumnWidth(4) ,m_nPreferredWidth(0) ,m_nMaxWidth(0) @@ -65,6 +66,7 @@ namespace toolkit ,GridColumn_Base( m_aMutex ) ,m_aIdentifier( i_copySource.m_aIdentifier ) ,m_nIndex( -1 ) + ,m_nDataColumnIndex( i_copySource.m_nDataColumnIndex ) ,m_nColumnWidth( i_copySource.m_nColumnWidth ) ,m_nPreferredWidth( i_copySource.m_nPreferredWidth ) ,m_nMaxWidth( i_copySource.m_nMaxWidth ) @@ -248,6 +250,19 @@ namespace toolkit m_nIndex = i_index; } + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getDataColumnIndex() throw(RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nDataColumnIndex; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(RuntimeException) + { + impl_set( m_nDataColumnIndex, i_dataColumnIndex, "DataColumnIndex" ); + } + //------------------------------------------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException) { diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index 4fbaddb3151b..a28fd5824160 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -73,6 +73,8 @@ public: virtual ::rtl::OUString SAL_CALL getHelpText() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHelpText(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getIndex() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getDataColumnIndex() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addGridColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); @@ -119,6 +121,7 @@ private: ::com::sun::star::uno::Any m_aIdentifier; sal_Int32 m_nIndex; + sal_Int32 m_nDataColumnIndex; sal_Int32 m_nColumnWidth; sal_Int32 m_nPreferredWidth; sal_Int32 m_nMaxWidth; -- cgit v1.2.3 From ab645d9d6f0f7844fe64d490445313215b50f69b Mon Sep 17 00:00:00 2001 From: "Malte Timmermann [mt]" Date: Wed, 19 Jan 2011 18:15:46 +0100 Subject: accfixes: Completed VCL Window API for accessible releations, renamed GetLabeledBy to GetAccessibleRelationLabeledBy --- svtools/source/control/toolbarmenuacc.cxx | 2 +- svtools/source/control/valueacc.cxx | 2 +- toolkit/source/awt/vclxaccessiblecomponent.cxx | 4 +- vcl/inc/vcl/window.h | 18 +++++++ vcl/inc/vcl/window.hxx | 14 ++++- vcl/source/window/dlgctrl.cxx | 73 ++++++++++++++++++++++++-- vcl/source/window/window.cxx | 60 ++++++++++++++------- 7 files changed, 144 insertions(+), 29 deletions(-) (limited to 'svtools') diff --git a/svtools/source/control/toolbarmenuacc.cxx b/svtools/source/control/toolbarmenuacc.cxx index 020467084748..d2111a9e8e1f 100644 --- a/svtools/source/control/toolbarmenuacc.cxx +++ b/svtools/source/control/toolbarmenuacc.cxx @@ -252,7 +252,7 @@ OUString SAL_CALL ToolbarMenuAcc::getAccessibleName() throw (RuntimeException) if( !aRet.getLength() ) { - Window* pLabel = mpParent->mrMenu.GetLabeledBy(); + Window* pLabel = mpParent->mrMenu.GetAccessibleRelationLabeledBy(); if( pLabel && pLabel != &mpParent->mrMenu ) aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() ); } diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx index 66da5636d89c..f94c474b5d57 100644 --- a/svtools/source/control/valueacc.cxx +++ b/svtools/source/control/valueacc.cxx @@ -317,7 +317,7 @@ sal_Int16 SAL_CALL ValueSetAcc::getAccessibleRole() if ( !aRet.Len() ) { - Window* pLabel = mpParent->GetLabeledBy(); + Window* pLabel = mpParent->GetAccessibleRelationLabeledBy(); if ( pLabel && pLabel != mpParent ) aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() ); } diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx index 175289d1ac84..83589537c62c 100644 --- a/toolkit/source/awt/vclxaccessiblecomponent.cxx +++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx @@ -445,7 +445,7 @@ void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelation Window* pWindow = GetWindow(); if ( pWindow ) { - Window *pLabeledBy = pWindow->GetLabeledBy(); + Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); if ( pLabeledBy && pLabeledBy != pWindow ) { uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); @@ -453,7 +453,7 @@ void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelation rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) ); } - Window* pLabelFor = pWindow->GetLabelFor(); + Window* pLabelFor = pWindow->GetAccessibleRelationLabelFor(); if ( pLabelFor && pLabelFor != pWindow ) { uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); diff --git a/vcl/inc/vcl/window.h b/vcl/inc/vcl/window.h index 73b6f1078ca9..ede8df9f8ac7 100644 --- a/vcl/inc/vcl/window.h +++ b/vcl/inc/vcl/window.h @@ -200,6 +200,24 @@ struct ImplFrameData BOOL mbInternalDragGestureRecognizer; }; +// ----------------------- +// - ImplAccessibleInfos - +// ----------------------- + +struct ImplAccessibleInfos +{ + USHORT nAccessibleRole; + String* pAccessibleName; + String* pAccessibleDescription; + Window* pLabeledByWindow; + Window* pLabelForWindow; + Window* pMemberOfWindow; + + ImplAccessibleInfos(); + ~ImplAccessibleInfos(); +}; + + // --------------- // - WindowImpl - // --------------- diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx index fa136f6d514d..6a773d755a77 100755 --- a/vcl/inc/vcl/window.hxx +++ b/vcl/inc/vcl/window.hxx @@ -1052,9 +1052,20 @@ public: void SetAccessibleDescription( const String& rDescr ); String GetAccessibleDescription() const; + void SetAccessibleRelationLabeledBy( Window* pLabeledBy ); + Window* GetAccessibleRelationLabeledBy() const; + + void SetAccessibleRelationLabelFor( Window* pLabelFor ); + Window* GetAccessibleRelationLabelFor() const; + + void SetAccessibleRelationMemberOf( Window* pMemberOf ); + Window* GetAccessibleRelationMemberOf() const; + + // to avoid sending accessibility events in cases like closing dialogs // by default checks complete parent path BOOL IsAccessibilityEventsSuppressed( BOOL bTraverseParentPath = TRUE ); + void SetAccessibilityEventsSuppressed(BOOL bSuppressed); /// request XCanvas render interface for this window ::com::sun::star::uno::Reference< @@ -1079,8 +1090,7 @@ public: BOOL IsCreatedWithToolkit() const; void SetCreatedWithToolkit( BOOL b ); - Window* GetLabelFor() const; - Window* GetLabeledBy() const; + // Deprecated - can use SetAccessibleRelationLabelFor/By nowadys virtual Window* GetParentLabelFor( const Window* pLabel ) const; virtual Window* GetParentLabeledBy( const Window* pLabeled ) const; KeyEvent GetActivationKey() const; diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx index 055b7e9fe80b..faef1b7ba208 100644 --- a/vcl/source/window/dlgctrl.cxx +++ b/vcl/source/window/dlgctrl.cxx @@ -1120,11 +1120,15 @@ static Window* ImplGetLabelFor( Window* pFrameWindow, WindowType nMyType, Window return pWindow; } -Window* Window::GetLabelFor() const +Window* Window::GetAccessibleRelationLabelFor() const { if ( mpWindowImpl->mbDisableAccessibleLabelForRelation ) return NULL; + if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pLabelForWindow ) + return mpWindowImpl->mpAccessibleInfos->pLabelForWindow; + + Window* pWindow = NULL; Window* pFrameWindow = ImplGetFrameWindow(); @@ -1205,11 +1209,14 @@ static Window* ImplGetLabeledBy( Window* pFrameWindow, WindowType nMyType, Windo return pWindow; } -Window* Window::GetLabeledBy() const +Window* Window::GetAccessibleRelationLabeledBy() const { if ( mpWindowImpl->mbDisableAccessibleLabeledByRelation ) return NULL; + if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pLabeledByWindow ) + return mpWindowImpl->mpAccessibleInfos->pLabeledByWindow; + Window* pWindow = NULL; Window* pFrameWindow = ImplGetFrameWindow(); @@ -1238,6 +1245,62 @@ Window* Window::GetLabeledBy() const return pWindow; } +Window* Window::GetAccessibleRelationMemberOf() const +{ + Window* pWindow = NULL; + Window* pFrameWindow = GetParent(); + if ( !pFrameWindow ) + { + pFrameWindow = ImplGetFrameWindow(); + } + // if( ! ( GetType() == WINDOW_FIXEDTEXT || + if( !( GetType() == WINDOW_FIXEDLINE || + GetType() == WINDOW_GROUPBOX ) ) + { + // search for a control that makes member of this window + // it is considered the last fixed line or group box + // that comes before this control; with the exception of push buttons + // which are labeled only if the fixed line or group box + // is directly before the control + // get form start and form end and index of this control + USHORT nIndex, nFormStart, nFormEnd; + Window* pSWindow = ::ImplFindDlgCtrlWindow( pFrameWindow, + const_cast(this), + nIndex, + nFormStart, + nFormEnd ); + if( pSWindow && nIndex != nFormStart ) + { + if( GetType() == WINDOW_PUSHBUTTON || + GetType() == WINDOW_HELPBUTTON || + GetType() == WINDOW_OKBUTTON || + GetType() == WINDOW_CANCELBUTTON ) + { + nFormStart = nIndex-1; + } + for( USHORT nSearchIndex = nIndex-1; nSearchIndex >= nFormStart; nSearchIndex-- ) + { + USHORT nFoundIndex = 0; + pSWindow = ::ImplGetChildWindow( pFrameWindow, + nSearchIndex, + nFoundIndex, + FALSE ); + if( pSWindow && pSWindow->IsVisible() && + ( pSWindow->GetType() == WINDOW_FIXEDLINE || + pSWindow->GetType() == WINDOW_GROUPBOX ) ) + { + pWindow = pSWindow; + break; + } + if( nFoundIndex > nSearchIndex || nSearchIndex == 0 ) + break; + } + } + } + return pWindow; +} +//-----IAccessibility2 Implementation 2009 + // ----------------------------------------------------------------------- KeyEvent Window::GetActivationKey() const @@ -1247,7 +1310,7 @@ KeyEvent Window::GetActivationKey() const sal_Unicode nAccel = getAccel( GetText() ); if( ! nAccel ) { - Window* pWindow = GetLabeledBy(); + Window* pWindow = GetAccessibleRelationLabeledBy(); if( pWindow ) nAccel = getAccel( pWindow->GetText() ); } @@ -1260,6 +1323,10 @@ KeyEvent Window::GetActivationKey() const nCode = KEY_A + (nAccel-'A'); else if( nAccel >= '0' && nAccel <= '9' ) nCode = KEY_0 + (nAccel-'0'); + else if( nAccel == '.' ) + nCode = KEY_POINT; + else if( nAccel == '-' ) + nCode = KEY_SUBTRACT; KeyCode aKeyCode( nCode, FALSE, FALSE, TRUE, FALSE ); aKeyEvent = KeyEvent( nAccel, aKeyCode ); } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index fe2af486c53a..c80415ca974f 100755 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -136,25 +136,21 @@ struct ImplCalcToTopData Region* mpInvalidateRegion; }; -struct ImplAccessibleInfos +ImplAccessibleInfos::ImplAccessibleInfos() { - USHORT nAccessibleRole; - String* pAccessibleName; - String* pAccessibleDescription; - - ImplAccessibleInfos() - { - nAccessibleRole = 0xFFFF; - pAccessibleName = NULL; - pAccessibleDescription = NULL; - } + nAccessibleRole = 0xFFFF; + pAccessibleName = NULL; + pAccessibleDescription = NULL; + pLabeledByWindow = NULL; + pLabelForWindow = NULL; + pMemberOfWindow = NULL; +} - ~ImplAccessibleInfos() - { - delete pAccessibleName; - delete pAccessibleDescription; - } -}; +ImplAccessibleInfos::~ImplAccessibleInfos() +{ + delete pAccessibleName; + delete pAccessibleDescription; +} // ----------------------------------------------------------------------- @@ -8066,7 +8062,7 @@ void Window::SetText( const XubString& rStr ) // name change. if ( IsReallyVisible() ) { - Window* pWindow = GetLabelFor(); + Window* pWindow = GetAccessibleRelationLabelFor(); if ( pWindow && pWindow != this ) pWindow->ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle ); } @@ -9140,7 +9136,7 @@ void Window::SetAccessibleName( const String& rName ) if ( !mpWindowImpl->mpAccessibleInfos ) mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; - DBG_ASSERT( !mpWindowImpl->mpAccessibleInfos->pAccessibleName, "AccessibleName already set!" ); + DBG_ASSERT( !mpWindowImpl->mpAccessibleInfos->pAccessibleName || !rName.Len(), "AccessibleName already set!" ); delete mpWindowImpl->mpAccessibleInfos->pAccessibleName; mpWindowImpl->mpAccessibleInfos->pAccessibleName = new String( rName ); } @@ -9183,7 +9179,7 @@ String Window::GetAccessibleName() const case WINDOW_TREELISTBOX: { - Window *pLabel = GetLabeledBy(); + Window *pLabel = GetAccessibleRelationLabeledBy(); if ( pLabel && pLabel != this ) aAccessibleName = pLabel->GetText(); } @@ -9242,6 +9238,26 @@ String Window::GetAccessibleDescription() const return aAccessibleDescription; } +void Window::SetAccessibleRelationLabeledBy( Window* pLabeledBy ) +{ + if ( !mpWindowImpl->mpAccessibleInfos ) + mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; + mpWindowImpl->mpAccessibleInfos->pLabeledByWindow = pLabeledBy; +} + +void Window::SetAccessibleRelationLabelFor( Window* pLabelFor ) +{ + if ( !mpWindowImpl->mpAccessibleInfos ) + mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; + mpWindowImpl->mpAccessibleInfos->pLabelForWindow = pLabelFor; +} + +void Window::SetAccessibleRelationMemberOf( Window* pMemberOfWin ) +{ + if ( !mpWindowImpl->mpAccessibleInfos ) + mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; + mpWindowImpl->mpAccessibleInfos->pMemberOfWindow = pMemberOfWin; +} BOOL Window::IsAccessibilityEventsSuppressed( BOOL bTraverseParentPath ) { if( !bTraverseParentPath ) @@ -9259,6 +9275,10 @@ BOOL Window::IsAccessibilityEventsSuppressed( BOOL bTraverseParentPath ) return FALSE; } } +void Window::SetAccessibilityEventsSuppressed(BOOL bSuppressed) +{ + mpWindowImpl->mbSuppressAccessibilityEvents = bSuppressed; +} void Window::RecordLayoutData( vcl::ControlLayoutData* pLayout, const Rectangle& rRect ) { -- cgit v1.2.3 From 3f195d1684cba759adce69bc4b3c53d6cb9adf23 Mon Sep 17 00:00:00 2001 From: "Malte Timmermann [mt]" Date: Wed, 19 Jan 2011 19:12:11 +0100 Subject: accfixes: Introduced WINDOW_RULER --- svtools/source/control/ruler.cxx | 1 + tools/inc/tools/wintypes.hxx | 3 ++- vcl/source/window/window.cxx | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'svtools') diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index bdbcd253c198..fc49e653d74f 100755 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -303,6 +303,7 @@ void Ruler::ImplInit( WinBits nWinBits ) else aDefSize.Width() = nDefHeight; SetOutputSizePixel( aDefSize ); + SetType(WINDOW_RULER); } // ----------------------------------------------------------------------- diff --git a/tools/inc/tools/wintypes.hxx b/tools/inc/tools/wintypes.hxx index 9c7052e22d77..abbec6b1d280 100644 --- a/tools/inc/tools/wintypes.hxx +++ b/tools/inc/tools/wintypes.hxx @@ -117,7 +117,8 @@ typedef USHORT WindowType; #define WINDOW_INTROWINDOW (WINDOW_FIRST + 0x4f) #define WINDOW_LISTBOXWINDOW (WINDOW_FIRST + 0x50) #define WINDOW_DOCKINGAREA (WINDOW_FIRST + 0x51) -#define WINDOW_LAST (WINDOW_DOCKINGAREA) +#define WINDOW_RULER (WINDOW_FIRST + 0x52) +#define WINDOW_LAST (WINDOW_RULER) // --------------- diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index c80415ca974f..94fa4a89302b 100755 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -9110,6 +9110,7 @@ USHORT Window::GetAccessibleRole() const case WINDOW_HELPTEXTWINDOW: nRole = accessibility::AccessibleRole::TOOL_TIP; break; + case WINDOW_RULER: nRole = accessibility::AccessibleRole::RULER; break; case WINDOW_WINDOW: case WINDOW_CONTROL: case WINDOW_BORDERWINDOW: -- cgit v1.2.3 From b6ac7ef63c50895d04d314491b26b3b371d5fc93 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 20 Jan 2011 13:52:50 +0100 Subject: gridsort: GridTableRenderer::impl_paintCellContent allow for XInterfaces which are NULL, without asserting them --- svtools/source/table/gridtablerenderer.cxx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 91f78ff7fbc5..3015cadff817 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -51,6 +51,8 @@ namespace svt { namespace table using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::TypeClass_INTERFACE; using ::com::sun::star::graphic::XGraphic; using ::com::sun::star::style::HorizontalAlignment; using ::com::sun::star::style::HorizontalAlignment_LEFT; @@ -520,9 +522,16 @@ namespace svt { namespace table Any aCellContent; m_pImpl->rModel.getCellContent( i_context.nColumn, m_pImpl->nCurrentRow, aCellContent ); - const Reference< XGraphic > xGraphic( aCellContent, UNO_QUERY ); - if ( xGraphic.is() ) + if ( aCellContent.getValueTypeClass() == TypeClass_INTERFACE ) { + Reference< XInterface > const xContentInterface( aCellContent, UNO_QUERY ); + if ( !xContentInterface.is() ) + // allowed. kind of. + return; + + Reference< XGraphic > const xGraphic( aCellContent, UNO_QUERY ); + ENSURE_OR_RETURN_VOID( xGraphic.is(), "GridTableRenderer::impl_paintCellContent: only XGraphic interfaces (or NULL) are supported for painting." ); + const Image aImage( xGraphic ); impl_paintCellImage( i_context, aImage ); return; @@ -568,10 +577,20 @@ namespace svt { namespace table if ( !i_cellContent.hasValue() ) return true; - Reference< XGraphic > const xGraphic( i_cellContent, UNO_QUERY ); - if ( xGraphic.is() ) - // for the moment, assume it fits. We can always scale it down during painting ... + if ( i_cellContent.getValueTypeClass() == TypeClass_INTERFACE ) + { + Reference< XInterface > const xContentInterface( i_cellContent, UNO_QUERY ); + if ( !xContentInterface.is() ) + return true; + + Reference< XGraphic > const xGraphic( i_cellContent, UNO_QUERY ); + if ( xGraphic.is() ) + // for the moment, assume it fits. We can always scale it down during painting ... + return true; + + OSL_ENSURE( false, "GridTableRenderer::FitsIntoCell: only XGraphic interfaces (or NULL) are supported for painting." ); return true; + } ::rtl::OUString const sText( CellValueConversion::convertToString( i_cellContent ) ); if ( sText.getLength() == 0 ) -- cgit v1.2.3 From 9956d0f9aa51f235c1b26e1ac38de75a5e238a79 Mon Sep 17 00:00:00 2001 From: "Malte Timmermann [mt]" Date: Fri, 21 Jan 2011 10:55:35 +0100 Subject: accfixes: added more accessibility information and fixed tab orders in multiple dialogs (svtools module) --- svtools/inc/svtools/svtools.hrc | 9 +++++++++ svtools/source/contnr/svcontnr.src | 27 ------------------------- svtools/source/control/filectrl.src | 40 +++++++++++++++---------------------- svtools/source/control/tabbar.cxx | 13 +++++++++++- svtools/source/dialogs/colrdlg.hrc | 2 ++ svtools/source/dialogs/colrdlg.src | 38 ++++++----------------------------- svtools/source/dialogs/printdlg.cxx | 5 +++++ svtools/source/inc/filectrl.hrc | 7 +++++++ 8 files changed, 57 insertions(+), 84 deletions(-) mode change 100644 => 100755 svtools/source/control/filectrl.src (limited to 'svtools') diff --git a/svtools/inc/svtools/svtools.hrc b/svtools/inc/svtools/svtools.hrc index 0461064f7d96..a4bd1733de90 100644 --- a/svtools/inc/svtools/svtools.hrc +++ b/svtools/inc/svtools/svtools.hrc @@ -249,6 +249,10 @@ #define STR_SVT_ACC_DESC_FOLDER (STR_SVT_ACC_BEGIN+4) #define STR_SVT_ACC_DESC_FILE (STR_SVT_ACC_BEGIN+5) #define STR_SVT_ACC_EMPTY_FIELD (STR_SVT_ACC_BEGIN+6) +//IAccessible2 implementation +#define STR_SVT_ACC_LISTENTRY_SELCTED_STATE (STR_SVT_ACC_BEGIN+7) +#define STR_SVT_ACC_RULER_VERT_NAME (STR_SVT_ACC_BEGIN+8) +#define STR_SVT_ACC_RULER_HORZ_NAME (STR_SVT_ACC_BEGIN+9) #define STR_SVT_ACC_END (STR_SVT_ACC_EMPTY_FIELD) #define STR_SVT_INDEXENTRY_START (STR_SVT_ACC_END + 1) @@ -387,6 +391,11 @@ #define RID_IMG_PRNDLG_COLLATE_HC (STR_SVT_PRNDLG_START + 31) #define RID_IMG_PRNDLG_NOCOLLATE_HC (STR_SVT_PRNDLG_START + 32) +// IAccessible2 implementation in 2009 +#define STR_PARAGRAPH_START (STR_SVT_PRNDLG_START + 50) +#define STR_PARAGRAPH (STR_PARAGRAPH_START + 0) +#define STR_PARAGRAPH_END (STR_PARAGRAPH) + #endif // #ifndef _SVTOOLS_HRC // ******************************************************************* EOF diff --git a/svtools/source/contnr/svcontnr.src b/svtools/source/contnr/svcontnr.src index bcd1e060664f..e0449fc3f644 100644 --- a/svtools/source/contnr/svcontnr.src +++ b/svtools/source/contnr/svcontnr.src @@ -74,30 +74,3 @@ String STR_SVT_ACC_EMPTY_FIELD Text [ en-US ] = "Empty Field"; }; - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/svtools/source/control/filectrl.src b/svtools/source/control/filectrl.src old mode 100644 new mode 100755 index dc8bbb5905d6..f9d63b65b838 --- a/svtools/source/control/filectrl.src +++ b/svtools/source/control/filectrl.src @@ -31,28 +31,20 @@ String STR_FILECTRL_BUTTONTEXT Text [ en-US ] = "Browse..." ; }; - - - - - - - - - - - - - - - - - - - - - - - - +String STR_TABBAR_PUSHBUTTON_MOVET0HOME +{ + Text [ en-US ] = "Move To Home" ; +}; +String STR_TABBAR_PUSHBUTTON_MOVELEFT +{ + Text [ en-US ] = "Move Left" ; +}; +String STR_TABBAR_PUSHBUTTON_MOVERIGHT +{ + Text [ en-US ] = "Move Right" ; +}; +String STR_TABBAR_PUSHBUTTON_MOVETOEND +{ + Text [ en-US ] = "Move To End" ; +}; diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index 0c2800246061..468ae25fca37 100755 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -38,7 +38,8 @@ #include #include #include "svtaccessiblefactory.hxx" - +#include +#include #include // ======================================================================= @@ -397,6 +398,16 @@ void TabBar::ImplInit( WinBits nWinStyle ) mnOffY++; ImplInitControls(); + + if(mpFirstBtn) + mpFirstBtn->SetAccessibleName(String(SvtResId(STR_TABBAR_PUSHBUTTON_MOVET0HOME))); + if(mpPrevBtn) + mpPrevBtn->SetAccessibleName( String(SvtResId(STR_TABBAR_PUSHBUTTON_MOVELEFT))); + if(mpNextBtn) + mpNextBtn->SetAccessibleName(String(SvtResId(STR_TABBAR_PUSHBUTTON_MOVERIGHT))); + if(mpLastBtn) + mpLastBtn->SetAccessibleName( String(SvtResId(STR_TABBAR_PUSHBUTTON_MOVETOEND))); + SetSizePixel( Size( 100, CalcWindowSizePixel().Height() ) ); ImplInitSettings( TRUE, TRUE ); } diff --git a/svtools/source/dialogs/colrdlg.hrc b/svtools/source/dialogs/colrdlg.hrc index 41329df6e366..b1e785bd2f17 100644 --- a/svtools/source/dialogs/colrdlg.hrc +++ b/svtools/source/dialogs/colrdlg.hrc @@ -65,3 +65,5 @@ #define BTN_CANCEL 1 #define BTN_HELP 1 +//IAccessibility2 Implementation 2009----- +#define STR_COLORDES 3001 diff --git a/svtools/source/dialogs/colrdlg.src b/svtools/source/dialogs/colrdlg.src index a93642b0bd05..fee6314b28cc 100644 --- a/svtools/source/dialogs/colrdlg.src +++ b/svtools/source/dialogs/colrdlg.src @@ -277,45 +277,19 @@ ModalDialog DLG_COLOR Border = TRUE ; Pos = MAP_APPFONT ( 200 , 109 ) ; Size = MAP_APPFONT ( 26 , 51 + DIFF ) ; - TabStop = TRUE ; + TabStop = FALSE ; }; Control CTL_PREVIEW { Border = TRUE ; Pos = MAP_APPFONT ( 229 , 109 ) ; Size = MAP_APPFONT ( 26 , 51 + DIFF ) ; - TabStop = TRUE ; + TabStop = FALSE ; }; }; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +String STR_COLORDES +{ + Text [ en-US ] = "RGB(%1, %2, %3) Hue:%4 Saturation:%5 Brightness:%6"; +}; diff --git a/svtools/source/dialogs/printdlg.cxx b/svtools/source/dialogs/printdlg.cxx index ab8b69fdcda1..1ae01bb96603 100644 --- a/svtools/source/dialogs/printdlg.cxx +++ b/svtools/source/dialogs/printdlg.cxx @@ -148,6 +148,11 @@ PrintDialog::PrintDialog( Window* pWindow, bool bWithSheetsAndCells ) : maRbtAll.Check(); ImplSetImages(); + + maBtnProperties.SetAccessibleRelationMemberOf(&maFlPrinter); + maEdtPages.SetAccessibleRelationLabeledBy(&maRbtPages); + maEdtPages.SetAccessibleRelationLabeledBy( &maRbtPages ); + maEdtPages.SetAccessibleName(maRbtPages.GetText()); } // ----------------------------------------------------------------------- diff --git a/svtools/source/inc/filectrl.hrc b/svtools/source/inc/filectrl.hrc index 1707e306e1b0..150bbba4ac68 100644 --- a/svtools/source/inc/filectrl.hrc +++ b/svtools/source/inc/filectrl.hrc @@ -30,5 +30,12 @@ #define STR_FILECTRL_BUTTONTEXT 333 // ID-Range?! +//IAccessibility2 Implementation 2009----- +#define STR_TABBAR_PUSHBUTTON_MOVET0HOME ( STR_FILECTRL_BUTTONTEXT+ 1) +#define STR_TABBAR_PUSHBUTTON_MOVELEFT ( STR_FILECTRL_BUTTONTEXT+ 2) +#define STR_TABBAR_PUSHBUTTON_MOVERIGHT ( STR_FILECTRL_BUTTONTEXT+ 3) +#define STR_TABBAR_PUSHBUTTON_MOVETOEND ( STR_FILECTRL_BUTTONTEXT+ 4) +//-----IAccessibility2 Implementation 2009 + #endif -- cgit v1.2.3 From 7406b40991a58899180e5dd20572d078d878881d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 24 Jan 2011 11:44:36 +0100 Subject: gridsort: re-did the column resizing - introduced XGridColumn.Flexibility, determining to which degree the column is resized during auto-column-resizing - removed XGridColumn.PreferredWidth - there really is no need for this anymore now - documented the relationship between XGridColumn.Flexibility and XGridColumn.Resizeable - re-implemented TableControl_Impl::impl_ni_updateColumnWidths, with (hopefully) less magic --- svtools/inc/svtools/table/tablemodel.hxx | 22 +- svtools/source/table/tablecontrol_impl.cxx | 352 +++++++++++++-------- svtools/source/table/tablecontrol_impl.hxx | 11 +- svtools/source/uno/unogridcolumnfacade.cxx | 32 +- svtools/source/uno/unogridcolumnfacade.hxx | 4 +- .../controls/grid/defaultgridcolumnmodel.cxx | 4 +- toolkit/source/controls/grid/gridcolumn.cxx | 32 +- toolkit/source/controls/grid/gridcolumn.hxx | 6 +- 8 files changed, 273 insertions(+), 190 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index b6c0c466edd0..6408efd249a8 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -223,7 +223,7 @@ namespace svt { namespace table */ virtual void setHelpText( const String& i_helpText ) = 0; - /** determines whether the column can be resized + /** determines whether the column can be interactively resized @see getMinWidth @see getMaxWidth @@ -239,6 +239,9 @@ namespace svt { namespace table */ virtual void setResizable( bool _bResizable ) = 0; + virtual sal_Int32 getFlexibility() const = 0; + virtual void setFlexibility( sal_Int32 const i_flexibility ) = 0; + /** returns the width of the column, in 1/100 millimeters The returned value must be a positive ->TableMetrics value. @@ -306,23 +309,6 @@ namespace svt { namespace table */ virtual void setMaxWidth( TableMetrics _nMaxWidth ) = 0; - /** returns the preferred width of the column, or 0 if the column - does not have a preferred width. - - @see setMaxWidth - @see getMinWidth - @see getWidth - */ - virtual TableMetrics getPreferredWidth() const = 0; - - /** sets the preferred width of the column, to be used when user resizes column - - @see getMaxWidth - @see setMinWidth - @see setWidth - */ - virtual void setPreferredWidth( TableMetrics _nPrefWidth ) = 0; - virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign() = 0; virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign) = 0; /// deletes the column model instance diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index e47419f2ea52..885974a21489 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -52,6 +52,8 @@ #include +#define MIN_COLUMN_WIDTH_PIXEL 4 + //...................................................................................................................... namespace svt { namespace table { @@ -67,21 +69,21 @@ namespace svt { namespace table namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId; namespace AccessibleTableModelChangeType = ::com::sun::star::accessibility::AccessibleTableModelChangeType; - //==================================================================== - //= TempHideCursor - //==================================================================== - class TempHideCursor + //================================================================================================================== + //= SuppressCursor + //================================================================================================================== + class SuppressCursor { private: ITableControl& m_rTable; public: - TempHideCursor( ITableControl& _rTable ) + SuppressCursor( ITableControl& _rTable ) :m_rTable( _rTable ) { m_rTable.hideCursor(); } - ~TempHideCursor() + ~SuppressCursor() { m_rTable.showCursor(); } @@ -425,6 +427,7 @@ namespace svt { namespace table ,m_nRowHeaderWidthPixel ( 0 ) ,m_nColumnCount ( 0 ) ,m_nRowCount ( 0 ) + ,m_bColumnsFit ( true ) ,m_nCurColumn ( COL_INVALID ) ,m_nCurRow ( ROW_INVALID ) ,m_nLeftColumn ( 0 ) @@ -438,7 +441,6 @@ namespace svt { namespace table ,m_aSelectedRows ( ) ,m_pTableFunctionSet ( new TableFunctionSet( this ) ) ,m_nAnchor ( -1 ) - ,m_bResizingGrid ( false ) ,m_bUpdatingColWidths ( false ) ,m_pAccessibleTable ( NULL ) #if DBG_UTIL @@ -469,7 +471,7 @@ namespace svt { namespace table { DBG_CHECK_ME(); - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); if ( !!m_pModel ) m_pModel->removeTableModelListener( shared_from_this() ); @@ -681,7 +683,10 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::tableMetricsChanged() { + long const oldRowHeaderWidthPixel = m_nRowHeaderWidthPixel; impl_ni_updateCachedTableMetrics(); + if ( oldRowHeaderWidthPixel != m_nRowHeaderWidthPixel ) + impl_ni_updateColumnWidths(); impl_ni_updateScrollbars(); m_rAntiImpl.Invalidate(); } @@ -712,7 +717,7 @@ namespace svt { namespace table { if ( !m_bUpdatingColWidths ) { - impl_ni_updateColumnWidths(); + impl_ni_updateColumnWidths( i_column ); impl_ni_updateScrollbars(); } @@ -804,7 +809,7 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void TableControl_Impl::impl_ni_updateColumnWidths() + void TableControl_Impl::impl_ni_updateColumnWidths( ColPos const i_assumeInflexibleColumnsUpToIncluding ) { ENSURE_OR_RETURN_VOID( !m_bUpdatingColWidths, "TableControl_Impl::impl_ni_updateColumnWidths: recursive call detected!" ); @@ -821,95 +826,223 @@ namespace svt { namespace table m_aColumnWidths.reserve( colCount ); - std::vector aPrePixelWidths(0); - long accumulatedPixelWidth = 0; - int lastResizableCol = COL_INVALID; - double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width(); - if ( m_pModel->hasRowHeaders() && ( gridWidth != 0 ) ) - { -#if OSL_DEBUG_LEVEL > 0 - const TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth(); - const long rowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width(); - OSL_ENSURE( rowHeaderWidthPixel == m_nRowHeaderWidthPixel, - "TableControl_Impl::impl_ni_updateColumnWidths: cached row header width is not correct anymore!" ); -#endif - accumulatedPixelWidth += m_nRowHeaderWidthPixel; - gridWidth -= m_nRowHeaderWidthPixel; + // the available horizontal space + long gridWidthPixel = m_rAntiImpl.GetOutputSizePixel().Width(); + if ( m_pModel->hasRowHeaders() && ( gridWidthPixel != 0 ) ) + { + gridWidthPixel -= m_nRowHeaderWidthPixel; + } + if ( m_pModel->getVerticalScrollbarVisibility() != ScrollbarShowNever ) + { + long nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); + gridWidthPixel -= nScrollbarMetrics; } - double colWidthsSum = 0.0; - double colWithoutFixedWidthsSum = 0.0; - double minColWithoutFixedSum = 0.0; + // TODO: shouldn't we take the visibility of the vertical scroll bar into account here, too? + long const gridWidthAppFont = m_rAntiImpl.PixelToLogic( Size( gridWidthPixel, 0 ), MAP_APPFONT ).Width(); + // determine the accumulated current width of all columns for ( ColPos col = 0; col < colCount; ++col ) { const PColumnModel pColumn = m_pModel->getColumnModel( col ); - ENSURE_OR_CONTINUE( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + ENSURE_OR_THROW( !!pColumn, "invalid column returned by the model!" ); + + } + + // collect some meta data for our columns: + // - their current (appt-font) metrics + long accumulatedCurrentWidth = 0; + ::std::vector< long > currentColWidths; + currentColWidths.reserve( colCount ); + // - their effective minimal and maximal width (app-font!) + typedef ::std::vector< ::std::pair< long, long > > ColumnLimits; + ColumnLimits effectiveColumnLimits; + effectiveColumnLimits.reserve( colCount ); + long accumulatedMinWidth = 0; + long accumulatedMaxWidth = 0; + // - their relative flexibility + ::std::vector< ::sal_Int32 > columnFlexibilities; + columnFlexibilities.reserve( colCount ); + long flexibilityDenominator = 0; + for ( ColPos col = 0; col < colCount; ++col ) + { + PColumnModel const pColumn = m_pModel->getColumnModel( col ); + ENSURE_OR_THROW( !!pColumn, "invalid column returned by the model!" ); + + // current width + TableMetrics const currentWidth = pColumn->getWidth(); + currentColWidths.push_back( currentWidth ); - TableMetrics colWidth = 0; - const TableMetrics colPrefWidth = pColumn->getPreferredWidth(); - const bool bResizable = pColumn->isResizable(); + // accumulated width + accumulatedCurrentWidth += currentWidth; - if ( colPrefWidth != 0) + // flexibility + ::sal_Int32 flexibility = pColumn->getFlexibility(); + OSL_ENSURE( flexibility >= 0, "TableControl_Impl::impl_ni_updateColumnWidths: a column's flexibility should be non-negative." ); + if ( ( flexibility < 0 ) // normalization + || ( !pColumn->isResizable() ) // column not resizeable => no auto-resize + || ( col <= i_assumeInflexibleColumnsUpToIncluding ) // column shall be treated as inflexible => respec this + ) + flexibility = 0; + + // min/max width + long effectiveMin = currentWidth, effectiveMax = currentWidth; + // if the column is not flexible, it will not be asked for min/max, but we assume the current width as limit then + if ( flexibility > 0 ) { - if ( m_bResizingGrid ) - { - colWidth = pColumn->getWidth(); - pColumn->setPreferredWidth(0); - } + long const minWidth = pColumn->getMinWidth(); + if ( minWidth > 0 ) + effectiveMin = minWidth; else - { - colWidth = colPrefWidth; - pColumn->setWidth( colPrefWidth ); - } - } - else - colWidth = pColumn->getWidth(); + effectiveMin = MIN_COLUMN_WIDTH_PIXEL; - const long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width(); - if ( bResizable && colPrefWidth == 0 ) - { - colWithoutFixedWidthsSum += pixelWidth; - lastResizableCol = col; + long const maxWidth = pColumn->getMaxWidth(); + OSL_ENSURE( minWidth <= maxWidth, "TableControl_Impl::impl_ni_updateColumnWidths: pretty undecided 'bout its width limits, this column!" ); + if ( ( maxWidth > 0 ) && ( maxWidth >= minWidth ) ) + effectiveMax = maxWidth; + else + effectiveMax = gridWidthAppFont; // TODO: any better guess here? + + if ( effectiveMin == effectiveMax ) + // if the min and the max are identical, this implies no flexibility at all + flexibility = 0; } - colWidthsSum += pixelWidth; - aPrePixelWidths.push_back( pixelWidth ); + + columnFlexibilities.push_back( flexibility ); + flexibilityDenominator += flexibility; + + effectiveColumnLimits.push_back( ::std::pair< long, long >( effectiveMin, effectiveMax ) ); + accumulatedMinWidth += effectiveMin; + accumulatedMaxWidth += effectiveMax; } - double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum; - double scalingFactor = 1.0; - if ( m_bResizingGrid ) + ::std::vector< long > newWidths( currentColWidths ); + if ( flexibilityDenominator == 0 ) { - if ( gridWidthWithoutFixed > ( minColWithoutFixedSum + colWidthsSum - colWithoutFixedWidthsSum ) ) - scalingFactor = gridWidthWithoutFixed / colWithoutFixedWidthsSum; + // no column is flexible => don't adjust anything } - else - { - if ( colWidthsSum < gridWidthWithoutFixed ) + else if ( gridWidthAppFont > accumulatedCurrentWidth ) + { // we have space to give away ... + long distributeAppFontUnits = gridWidthAppFont - accumulatedCurrentWidth; + if ( gridWidthAppFont > accumulatedMaxWidth ) { - if ( colWithoutFixedWidthsSum > 0 ) - scalingFactor = gridWidthWithoutFixed / colWithoutFixedWidthsSum; + // ... but the column's maximal widths are still less than we have + // => set them all to max + for ( size_t i = 0; i < size_t( colCount ); ++i ) + { + newWidths[i] = effectiveColumnLimits[i].second; + } } - } - for ( ColPos i = 0; i < colCount; ++i ) - { - const PColumnModel pColumn = m_pModel->getColumnModel( i ); - ENSURE_OR_CONTINUE( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" ); + else + { + bool startOver = false; + do + { + startOver = false; + // distribute the remaining space amongst all columns with a positive flexibility + for ( size_t i=0; i effectiveColumnLimits[i].second ) + { // that was too much, we hit the col's maximum + // set the new width to exactly this maximum + newColWidth = effectiveColumnLimits[i].second; + // adjust the flexibility denominator ... + flexibilityDenominator -= columnFlexibility; + columnFlexibilities[i] = 0; + // ... and the remaining width ... + long const difference = newColWidth - currentColWidths[i]; + distributeAppFontUnits -= difference; + // ... this way, we ensure that the width not taken up by this column is consumed by the other + // flexible ones (if there are some) + + // and start over with the first column, since there might be earlier columns which need + // to be recalculated now + startOver = true; + } - if ( pColumn->isResizable() && ( pColumn->getPreferredWidth() == 0 ) ) + newWidths[i] = newColWidth; + } + } + while ( startOver ); + } + } + else if ( gridWidthAppFont < accumulatedCurrentWidth ) + { // we need to take away some space from the columns which allow it ... + long takeAwayAppFontUnits = accumulatedCurrentWidth - gridWidthAppFont; + if ( gridWidthAppFont < accumulatedMinWidth ) + { + // ... but the column's minimal widths are still more than we have + // => set them all to min + for ( size_t i = 0; i < size_t( colCount ); ++i ) + { + newWidths[i] = effectiveColumnLimits[i].first; + } + } + else { - aPrePixelWidths[i] *= scalingFactor; - const TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width(); - pColumn->setWidth( logicColWidth ); + bool startOver = false; + do + { + startOver = false; + // take away the space we need from the columns with a positive flexibility + for ( size_t i=0; i 0 ) + && ( accumulatedWidthPixel - m_aColumnWidths[ m_nLeftColumn - 1 ].getStart() <= gridWidthPixel ) + ) + { + --m_nLeftColumn; } - // care for the horizontal scroll position (as indicated by m_nLeftColumn) + // now adjust the column metrics, since they currently ignore the horizontal scroll position if ( m_nLeftColumn > 0 ) { const long offsetPixel = m_aColumnWidths[ 0 ].getStart() - m_aColumnWidths[ m_nLeftColumn ].getStart(); @@ -921,29 +1054,6 @@ namespace svt { namespace table colPos->move( offsetPixel ); } } - - const long freeSpaceRight = gridWidth - m_aColumnWidths[ colCount-1 ].getEnd(); - if ( ( freeSpaceRight > 0 ) - && ( lastResizableCol != COL_INVALID ) - && ( lastResizableCol >= m_nLeftColumn ) - ) - { - // make the last resizable column wider - MutableColumnMetrics& rResizeColInfo( m_aColumnWidths[ lastResizableCol ] ); - rResizeColInfo.setEnd( rResizeColInfo.getEnd() + freeSpaceRight ); - - // update the column model - const TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( rResizeColInfo.getWidth(), 0 ), MAP_APPFONT ).Width(); - const PColumnModel pColumn = m_pModel->getColumnModel( lastResizableCol ); - pColumn->setWidth( logicColWidth ); - - // update all other columns after the resized one - ColPos adjustColumn = lastResizableCol; - while ( ++adjustColumn < colCount ) - { - m_aColumnWidths[ adjustColumn ].move( freeSpaceRight ); - } - } } //------------------------------------------------------------------------------------------------------------------ @@ -1055,12 +1165,10 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void TableControl_Impl::impl_ni_updateScrollbars() { - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); // the width/height of a scrollbar, needed several times below - long nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); - if ( m_rAntiImpl.IsZoom() ) - nScrollbarMetrics = (long)( nScrollbarMetrics * (double)m_rAntiImpl.GetZoom() ); + long const nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize(); // determine the playground for the data cells (excluding headers) // TODO: what if the control is smaller than needed for the headers/scrollbars? @@ -1198,32 +1306,10 @@ namespace svt { namespace table void TableControl_Impl::onResize() { DBG_CHECK_ME(); - if ( m_nRowCount != 0 ) - { - if ( m_nColumnCount != 0 ) - { - impl_ni_updateColumnWidths(); - impl_ni_updateScrollbars(); - checkCursorPosition(); - m_bResizingGrid = true; - } - } - else - { - // In the case that column headers are defined but data hasn't yet been set, - // only column headers will be shown - if ( m_pModel->hasColumnHeaders() ) - { - if ( m_nColHeaderHeightPixel > 1 ) - { - m_pDataWindow->SetSizePixel( m_rAntiImpl.GetOutputSizePixel() ); - // update column widths to fit in grid - impl_ni_updateColumnWidths(); - m_bResizingGrid = true; - } - } - impl_ni_updateScrollbars(); - } + + impl_ni_updateColumnWidths(); + impl_ni_updateScrollbars(); + checkCursorPosition(); } //------------------------------------------------------------------------------------------------------------------ @@ -1249,9 +1335,9 @@ namespace svt { namespace table // draw the header column area if ( m_pModel->hasColumnHeaders() ) { - TableRowGeometry aHeaderRow( *this, Rectangle( Point( 0, 0 ), + TableRowGeometry const aHeaderRow( *this, Rectangle( Point( 0, 0 ), aAllCellsWithHeaders.BottomRight() ), ROW_COL_HEADERS ); - Rectangle aColRect(aHeaderRow.getRect()); + Rectangle const aColRect(aHeaderRow.getRect()); pRenderer->PaintHeaderArea( *m_pDataWindow, aColRect, true, false, rStyle ); @@ -2066,7 +2152,7 @@ namespace svt { namespace table return false; } - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); m_nCurColumn = _nColumn; m_nCurRow = _nRow; @@ -2083,7 +2169,7 @@ namespace svt { namespace table && ( _nRow >= 0 ) && ( _nRow < m_nRowCount ), "TableControl_Impl::ensureVisible: invalid coordinates!" ); - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); if ( _nColumn < m_nLeftColumn ) impl_scrollColumns( _nColumn - m_nLeftColumn ); @@ -2133,7 +2219,7 @@ namespace svt { namespace table if ( m_nTopRow != nOldTopRow ) { DBG_SUSPEND_INV( INV_SCROLL_POSITION ); - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); // TODO: call a onStartScroll at our listener (or better an own onStartScroll, // which hides the cursor and then calls the listener) // Same for onEndScroll @@ -2189,7 +2275,7 @@ namespace svt { namespace table if ( m_nLeftColumn != nOldLeftColumn ) { DBG_SUSPEND_INV( INV_SCROLL_POSITION ); - TempHideCursor aHideCursor( *this ); + SuppressCursor aHideCursor( *this ); // TODO: call a onStartScroll at our listener (or better an own onStartScroll, // which hides the cursor and then calls the listener) // Same for onEndScroll diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index dfc8141fa0e9..8d370011c939 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -117,9 +117,13 @@ namespace svt { namespace table /// the number of columns in the table control. Cached model value. TableSize m_nColumnCount; + /// the number of rows in the table control. Cached model value. TableSize m_nRowCount; + /// denotes whether or not the columns fitted into the available width, last time we checked + long m_bColumnsFit; + ColPos m_nCurColumn; RowPos m_nCurRow; ColPos m_nLeftColumn; @@ -147,7 +151,6 @@ namespace svt { namespace table TableFunctionSet* m_pTableFunctionSet; //part of selection engine RowPos m_nAnchor; - bool m_bResizingGrid; bool m_bUpdatingColWidths; Link m_aSelectHdl; @@ -375,8 +378,12 @@ namespace svt { namespace table The method is not bound to the classes public invariants, as it's used in situations where the they must not necessarily be fullfilled. + + @param i_assumeInflexibleColumnsUpToIncluding + the index of a column up to which all columns should be considered as inflexible, or + COL_INVALID. */ - void impl_ni_updateColumnWidths(); + void impl_ni_updateColumnWidths( ColPos const i_assumeInflexibleColumnsUpToIncluding = COL_INVALID ); /** updates the scrollbars of the control diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index 98078b1fb2d4..c4b21d07b526 100755 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -345,10 +345,24 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - void UnoGridColumnFacade::setResizable( bool _bResizable ) + void UnoGridColumnFacade::setResizable( bool i_resizable ) { ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); - return lcl_set( m_xGridColumn, &XGridColumn::setResizeable, sal_Bool( _bResizable ) ); + lcl_set( m_xGridColumn, &XGridColumn::setResizeable, sal_Bool( i_resizable ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 UnoGridColumnFacade::getFlexibility() const + { + ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 1 ); + return lcl_get( m_xGridColumn, &XGridColumn::getFlexibility ); + } + + //------------------------------------------------------------------------------------------------------------------ + void UnoGridColumnFacade::setFlexibility( sal_Int32 const i_flexibility ) + { + ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); + lcl_set( m_xGridColumn, &XGridColumn::setFlexibility, i_flexibility ); } //------------------------------------------------------------------------------------------------------------------ @@ -393,20 +407,6 @@ namespace svt { namespace table lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMaxWidth ); } - //------------------------------------------------------------------------------------------------------------------ - TableMetrics UnoGridColumnFacade::getPreferredWidth() const - { - ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 0 ); - return lcl_get( m_xGridColumn, &XGridColumn::getPreferredWidth ); - } - - //------------------------------------------------------------------------------------------------------------------ - void UnoGridColumnFacade::setPreferredWidth( TableMetrics _nPrefWidth ) - { - ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); - lcl_set( m_xGridColumn, &XGridColumn::setPreferredWidth, _nPrefWidth ); - } - //------------------------------------------------------------------------------------------------------------------ ::com::sun::star::style::HorizontalAlignment UnoGridColumnFacade::getHorizontalAlign() { diff --git a/svtools/source/uno/unogridcolumnfacade.hxx b/svtools/source/uno/unogridcolumnfacade.hxx index 11d40afa2984..7499621ba8af 100755 --- a/svtools/source/uno/unogridcolumnfacade.hxx +++ b/svtools/source/uno/unogridcolumnfacade.hxx @@ -72,14 +72,14 @@ namespace svt { namespace table virtual void setHelpText( const String& i_helpText ); virtual bool isResizable() const; virtual void setResizable( bool _bResizable ); + virtual sal_Int32 getFlexibility() const; + virtual void setFlexibility( sal_Int32 const i_flexibility ); virtual TableMetrics getWidth() const; virtual void setWidth( TableMetrics _nWidth ); virtual TableMetrics getMinWidth() const; virtual void setMinWidth( TableMetrics _nMinWidth ); virtual TableMetrics getMaxWidth() const; virtual void setMaxWidth( TableMetrics _nMaxWidth ); - virtual TableMetrics getPreferredWidth() const; - virtual void setPreferredWidth( TableMetrics _nPrefWidth ); virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign(); virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign); diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 8c50a7e62ef7..a9d808103821 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -233,7 +233,9 @@ namespace toolkit colTitle.appendAscii( "Column " ); colTitle.append( i + 1 ); pGridColumn->setTitle( colTitle.makeStringAndClear() ); - pGridColumn->setPreferredWidth( 80 /* APPFONT */ ); + pGridColumn->setColumnWidth( 80 /* APPFONT */ ); + pGridColumn->setFlexibility( 1 ); + pGridColumn->setResizeable( sal_True ); pGridColumn->setDataColumnIndex( i ); ContainerEvent aEvent; diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 60873cc1802f..9899b517d259 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -52,9 +52,9 @@ namespace toolkit ,m_nIndex(-1) ,m_nDataColumnIndex(-1) ,m_nColumnWidth(4) - ,m_nPreferredWidth(0) ,m_nMaxWidth(0) ,m_nMinWidth(0) + ,m_nFlexibility(1) ,m_bResizeable(true) ,m_eHorizontalAlign( HorizontalAlignment_LEFT ) { @@ -68,8 +68,8 @@ namespace toolkit ,m_nIndex( -1 ) ,m_nDataColumnIndex( i_copySource.m_nDataColumnIndex ) ,m_nColumnWidth( i_copySource.m_nColumnWidth ) - ,m_nPreferredWidth( i_copySource.m_nPreferredWidth ) ,m_nMaxWidth( i_copySource.m_nMaxWidth ) + ,m_nFlexibility( i_copySource.m_nFlexibility ) ,m_nMinWidth( i_copySource.m_nMinWidth ) ,m_bResizeable( i_copySource.m_bResizeable ) ,m_eHorizontalAlign( i_copySource.m_eHorizontalAlign ) @@ -125,19 +125,6 @@ namespace toolkit impl_set( m_nColumnWidth, value, "ColumnWidth" ); } - //------------------------------------------------------------------------------------------------------------------ - ::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) - { - ::comphelper::ComponentGuard aGuard( *this, rBHelper ); - return m_nPreferredWidth; - } - - //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) - { - impl_set( m_nPreferredWidth, value, "PreferredWidth" ); - } - //------------------------------------------------------------------------------------------------------------------ ::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) { @@ -203,6 +190,21 @@ namespace toolkit impl_set( m_bResizeable, value, "Resizeable" ); } + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getFlexibility() throw (RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nFlexibility; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setFlexibility( ::sal_Int32 i_value ) throw (IllegalArgumentException, RuntimeException) + { + if ( i_value < 0 ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + impl_set( m_nFlexibility, i_value, "Flexibility" ); + } + //------------------------------------------------------------------------------------------------------------------ HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) { diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index a28fd5824160..b1be836a3862 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -60,14 +60,14 @@ public: virtual void SAL_CALL setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnWidth() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setColumnWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getPreferredWidth() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPreferredWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxWidth() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setMaxWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMinWidth() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setMinWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getResizeable() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setResizeable(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getFlexibility() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFlexibility( ::sal_Int32 _flexibility ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getHelpText() throw (::com::sun::star::uno::RuntimeException); @@ -123,9 +123,9 @@ private: sal_Int32 m_nIndex; sal_Int32 m_nDataColumnIndex; sal_Int32 m_nColumnWidth; - sal_Int32 m_nPreferredWidth; sal_Int32 m_nMaxWidth; sal_Int32 m_nMinWidth; + sal_Int32 m_nFlexibility; sal_Bool m_bResizeable; ::rtl::OUString m_sTitle; ::rtl::OUString m_sHelpText; -- cgit v1.2.3 From 38cec087c0a584ad6cbf02ff4f4b3ca3d444e494 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 24 Jan 2011 16:04:17 +0100 Subject: gridsort: adjusted ITableModel documentation to the new realities --- svtools/inc/svtools/table/tablemodel.hxx | 50 ++++++++++++++++-------------- svtools/inc/svtools/table/tabletypes.hxx | 4 --- svtools/source/table/tablecontrol_impl.hxx | 3 -- svtools/source/uno/unogridcolumnfacade.cxx | 1 + 4 files changed, 28 insertions(+), 30 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index 6408efd249a8..94f03b684e64 100755 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -239,43 +239,41 @@ namespace svt { namespace table */ virtual void setResizable( bool _bResizable ) = 0; - virtual sal_Int32 getFlexibility() const = 0; - virtual void setFlexibility( sal_Int32 const i_flexibility ) = 0; + /** denotes the relative flexibility of the column - /** returns the width of the column, in 1/100 millimeters + This flexibility is taken into account when a table control auto-resizes its columns, because the available + space changed. In this case, the columns grow or shrink according to their flexibility. - The returned value must be a positive ->TableMetrics value. + A value of 0 means the column is not auto-resized at all. + */ + virtual sal_Int32 getFlexibility() const = 0; - It can also be COLWIDTH_FIT_TO_VIEW, to indicate that the width of the column - should automatically be adjusted to completely fit the view. For instance, a - model's last column could return this value, to indicate that it is to occupy - all horizontal space remaining in the view, after all other columns have been - layouted. + /** sets a new flexibility value for the column - If there is more than one column with width COLWIDTH_FIT_TO_VIEW in a model, - they're all layouted equal-width. + @see getFlexibility + */ + virtual void setFlexibility( sal_Int32 const i_flexibility ) = 0; - If the columns with a real width (i.e. other than COLWIDTH_FIT_TO_VIEW) are, - in sum, wider than the view, then the view is free to choose a real width for any - columns which return COLWIDTH_FIT_TO_VIEW here. + /** returns the width of the column, in app-font unitss + + The returned value must be a positive ->TableMetrics value. @see setWidth @see getMinWidth @see getMaxWidth - @see COLWIDTH_FIT_TO_VIEW */ virtual TableMetrics getWidth() const = 0; /** sets a new width for the column @param _nWidth - the new width, in 1/100 millimeters + the new width, app-font units @see getWidth */ virtual void setWidth( TableMetrics _nWidth ) = 0; - /** returns the minimum width of the column, in 1/100 millimeters, or 0 if the column + /** returns the minimum width of the column, in app-font units, or 0 if the column does not have a minimal width @see setMinWidth @@ -284,7 +282,7 @@ namespace svt { namespace table */ virtual TableMetrics getMinWidth() const = 0; - /** sets the minimum width of the column, in 1/100 millimeters + /** sets the minimum width of the column, in app-font units @see getMinWidth @see setMaxWidth @@ -292,7 +290,7 @@ namespace svt { namespace table */ virtual void setMinWidth( TableMetrics _nMinWidth ) = 0; - /** returns the maximum width of the column, in 1/100 millimeters, or 0 if the column + /** returns the maximum width of the column, in app-font units, or 0 if the column does not have a minimal width @see setMaxWidth @@ -301,7 +299,7 @@ namespace svt { namespace table */ virtual TableMetrics getMaxWidth() const = 0; - /** sets the maximum width of the column, in 1/100 millimeters + /** sets the maximum width of the column, in app-font units @see getMaxWidth @see setMinWidth @@ -309,8 +307,14 @@ namespace svt { namespace table */ virtual void setMaxWidth( TableMetrics _nMaxWidth ) = 0; + /** retrieves the horizontal alignment to be used for content in this cell + */ virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign() = 0; + + /** sets a new the horizontal alignment to be used for content in this cell + */ virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign) = 0; + /// deletes the column model instance virtual ~IColumnModel() { } }; @@ -382,7 +386,7 @@ namespace svt { namespace table /** determines the height of rows in the table. @return - the logical height of rows in the table, in 1/100 millimeters. The height must be + the logical height of rows in the table, in app-font units. The height must be greater 0. */ virtual TableMetrics getRowHeight() const = 0; @@ -393,7 +397,7 @@ namespace svt { namespace table returned . @return - the logical height of the column header row, in 1/100 millimeters. + the logical height of the column header row, in app-font units. Must be greater than 0. */ virtual TableMetrics getColumnHeaderHeight() const = 0; @@ -404,7 +408,7 @@ namespace svt { namespace table returned . @return - the logical width of the row header column, in 1/100 millimeters. + the logical width of the row header column, in app-font units. Must be greater than 0. */ virtual TableMetrics getRowHeaderWidth() const = 0; diff --git a/svtools/inc/svtools/table/tabletypes.hxx b/svtools/inc/svtools/table/tabletypes.hxx index 0d285d420323..ae20851992e3 100644 --- a/svtools/inc/svtools/table/tabletypes.hxx +++ b/svtools/inc/svtools/table/tabletypes.hxx @@ -50,10 +50,6 @@ namespace svt { namespace table typedef sal_Int32 AnyPos; typedef sal_Int32 TableMetrics; -/** special column width value which indicates that the column should be - automatically resized to fit the view -*/ -#define COLWIDTH_FIT_TO_VIEW ((::svt::table::TableMetrics)-1) /// denotes the column containing the row headers #define COL_ROW_HEADERS ((::svt::table::ColPos)-1) diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 8d370011c939..be4c2c384f94 100755 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -373,9 +373,6 @@ namespace svt { namespace table /** updates ->m_aColumnWidthsPixel with the current pixel widths of all model columns - The method takes into account the current zoom factor and map mode of the table - control, plus any possible COLWIDTH_FIT_TO_VIEW widths in the model columns. - The method is not bound to the classes public invariants, as it's used in situations where the they must not necessarily be fullfilled. diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index c4b21d07b526..8fd2799f45df 100755 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -166,6 +166,7 @@ namespace svt { namespace table || i_event.AttributeName.equalsAscii( "MinWidth" ) || i_event.AttributeName.equalsAscii( "PreferredWidth" ) || i_event.AttributeName.equalsAscii( "Resizeable" ) + || i_event.AttributeName.equalsAscii( "Flexibility" ) ) nChangedAttributes |= COL_ATTRS_WIDTH; -- cgit v1.2.3 From 54d9ea315aef1d774d728e6e8cbac3183def5f0e Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 25 Jan 2011 17:40:38 +0100 Subject: gridsort: post rebase (which was implicitly done by merging CWS dba34b): re-do changes in the new build system --- svtools/Library_svt.mk | 3 ++ svtools/Package_inc.mk | 4 +- toolkit/Library_tk.mk | 2 + toolkit/prj/build.lst | 2 +- toolkit/qa/complex/toolkit/makefile.mk | 89 ++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 3 deletions(-) create mode 100755 toolkit/qa/complex/toolkit/makefile.mk (limited to 'svtools') diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 545690bd0f12..3af648e76804 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -250,6 +250,8 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/table/tablecontrol \ svtools/source/table/tablecontrol_impl \ svtools/source/table/tabledatawindow \ + svtools/source/table/mousefunction \ + svtools/source/table/cellvalueconversion \ svtools/source/table/tablegeometry \ svtools/source/toolpanel/drawerlayouter \ svtools/source/toolpanel/dummypanel \ @@ -278,6 +280,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/uno/toolboxcontroller \ svtools/source/uno/treecontrolpeer \ svtools/source/uno/unocontroltablemodel \ + svtools/source/uno/unogridcolumnfacade \ svtools/source/uno/unoevent \ svtools/source/uno/unoiface \ svtools/source/uno/unoimap \ diff --git a/svtools/Package_inc.mk b/svtools/Package_inc.mk index ef656f9ba061..2e5e1734373e 100644 --- a/svtools/Package_inc.mk +++ b/svtools/Package_inc.mk @@ -146,15 +146,15 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svxbox.hxx,svtools/svx $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/sychconv.hxx,svtools/sychconv.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/syntaxhighlight.hxx,svtools/syntaxhighlight.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/tabbar.hxx,svtools/tabbar.hxx)) -$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/abstracttablecontrol.hxx,svtools/table/abstracttablecontrol.hxx)) +$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablecontrolinterface.hxx,svtools/table/tablecontrolinterface.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/defaultinputhandler.hxx,svtools/table/defaultinputhandler.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/gridtablerenderer.hxx,svtools/table/gridtablerenderer.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablecontrol.hxx,svtools/table/tablecontrol.hxx)) -$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tabledatawindow.hxx,svtools/table/tabledatawindow.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tableinputhandler.hxx,svtools/table/tableinputhandler.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablemodel.hxx,svtools/table/tablemodel.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablerenderer.hxx,svtools/table/tablerenderer.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tabletypes.hxx,svtools/table/tabletypes.hxx)) +$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablesort.hxx,svtools/table/tablesort.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/taskbar.hxx,svtools/taskbar.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/templatefoldercache.hxx,svtools/templatefoldercache.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/templdlg.hxx,svtools/templdlg.hxx)) diff --git a/toolkit/Library_tk.mk b/toolkit/Library_tk.mk index b54bee4e231d..922f07aae53b 100644 --- a/toolkit/Library_tk.mk +++ b/toolkit/Library_tk.mk @@ -98,6 +98,8 @@ $(eval $(call gb_Library_add_exception_objects,tk,\ toolkit/source/controls/grid/defaultgridcolumnmodel \ toolkit/source/controls/grid/defaultgriddatamodel \ toolkit/source/controls/grid/gridcolumn \ + toolkit/source/controls/grid/grideventforwarder \ + toolkit/source/controls/grid/sortablegriddatamodel \ toolkit/source/controls/grid/gridcontrol \ toolkit/source/controls/roadmapcontrol \ toolkit/source/controls/roadmapentry \ diff --git a/toolkit/prj/build.lst b/toolkit/prj/build.lst index ce6e32adfe49..036fd0840930 100644 --- a/toolkit/prj/build.lst +++ b/toolkit/prj/build.lst @@ -1,3 +1,3 @@ -ti toolkit : LIBXSLT:libxslt vcl qadevOOo NULL +ti toolkit : LIBXSLT:libxslt vcl qadevOOo test NULL ti toolkit\prj nmake - all ti_prj NULL ti toolkit\qa\complex\toolkit nmake - all ti_complex_toolkit NULL diff --git a/toolkit/qa/complex/toolkit/makefile.mk b/toolkit/qa/complex/toolkit/makefile.mk new file mode 100755 index 000000000000..63605dace711 --- /dev/null +++ b/toolkit/qa/complex/toolkit/makefile.mk @@ -0,0 +1,89 @@ +#************************************************************************* +# +# 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 +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +.IF "$(OOO_JUNIT_JAR)" == "" +nothing .PHONY: + @echo ----------------------------------------------------- + @echo - JUnit not available, not building anything + @echo ----------------------------------------------------- +.ELSE # IF "$(OOO_JUNIT_JAR)" != "" + +PRJ = ../../.. +PRJNAME = toolkit +TARGET = qa_complex_toolkit +PACKAGE = complex/toolkit + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + +#----- compile .java files ----------------------------------------- + +JARFILES = OOoRunnerLight.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) + +JAVAFILES = \ + $(JAVATESTFILES) \ + accessibility/_XAccessibleComponent.java \ + accessibility/_XAccessibleContext.java \ + accessibility/_XAccessibleEventBroadcaster.java \ + accessibility/_XAccessibleExtendedComponent.java \ + accessibility/_XAccessibleText.java \ + +#----- create a jar from compiled files ---------------------------- + +JARTARGET = $(TARGET).jar + +#----- JUnit tests class ------------------------------------------- + +JAVATESTFILES = \ + UnitConversion.java \ + AccessibleStatusBar.java \ + +# fails; no issue, yet (not sure this is worth it. Don't know who to give the issue to, and don't know whether the test really makes sense) +# AccessibleStatusBarItem.java \ + + +# --- Targets ------------------------------------------------------ + +.INCLUDE: target.mk + +ALL : ALLTAR + +# --- subsequent tests --------------------------------------------- + +.IF "$(OOO_SUBSEQUENT_TESTS)" != "" + +.INCLUDE: installationtest.mk + +ALLTAR : javatest + + # Sample how to debug + # JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y + +.END # "$(OOO_SUBSEQUENT_TESTS)" == "" + +.END # ELSE "$(OOO_JUNIT_JAR)" != "" -- cgit v1.2.3 From 0dbaba1db25f7b43cac0e8783135e4c9f473a5dd Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 25 Jan 2011 20:57:27 +0100 Subject: Mac WaE --- svtools/source/uno/unogridcolumnfacade.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'svtools') diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index 8fd2799f45df..d2f5e7b565fd 100755 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -190,8 +190,8 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ UnoGridColumnFacade::UnoGridColumnFacade( UnoControlTableModel const & i_owner, Reference< XGridColumn > const & i_gridColumn ) :m_pOwner( &i_owner ) - ,m_xGridColumn( i_gridColumn, UNO_QUERY_THROW ) ,m_nDataColumnIndex( -1 ) + ,m_xGridColumn( i_gridColumn, UNO_QUERY_THROW ) ,m_pChangeMultiplexer( new ColumnChangeMultiplexer( *this ) ) { m_xGridColumn->addGridColumnListener( m_pChangeMultiplexer.get() ); -- cgit v1.2.3 From 23933ae6f6c74253a233761dfa42e488f6cabd13 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 26 Jan 2011 20:43:12 +0100 Subject: gridsort: let the sort indicator arrow point up when sorted ascending, and down otherwise. --- svtools/source/table/gridtablerenderer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'svtools') diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 3015cadff817..26d023535198 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -103,7 +103,7 @@ namespace svt { namespace table DecorationView aDecoView( &aDevice ); aDecoView.DrawSymbol( Rectangle( aBitmapPos, aBitmapSize ), - i_sortAscending ? SYMBOL_SPIN_DOWN : SYMBOL_SPIN_UP, + i_sortAscending ? SYMBOL_SPIN_UP : SYMBOL_SPIN_DOWN, i_style.GetActiveColor() ); -- cgit v1.2.3 From 75a441f652654465122bc686d8803bd887169f86 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 27 Jan 2011 08:17:57 +0100 Subject: gridsort: minor changes to the new API: - renamed XMutableGridDataModel::setRowHeading to updateRowHeading for consistency reasons - renamed XSortableGridDataModel to XSortableGridData - actually, this is not a full-fledged model in itself. --- svtools/source/uno/unocontroltablemodel.cxx | 10 +++++----- toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java | 4 ++-- toolkit/source/controls/grid/defaultgriddatamodel.cxx | 2 +- toolkit/source/controls/grid/defaultgriddatamodel.hxx | 2 +- toolkit/source/controls/grid/sortablegriddatamodel.cxx | 4 ++-- toolkit/source/controls/grid/sortablegriddatamodel.hxx | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index b6d4d0f1e451..933363115810 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -38,7 +38,7 @@ #include #include #include -#include +#include /** === end UNO includes === **/ #include @@ -74,7 +74,7 @@ namespace svt { namespace table using ::com::sun::star::style::VerticalAlignment; using ::com::sun::star::uno::WeakReference; using ::com::sun::star::awt::grid::GridDataEvent; - using ::com::sun::star::awt::grid::XSortableGridDataModel; + using ::com::sun::star::awt::grid::XSortableGridData; using ::com::sun::star::beans::Pair; /** === end UNO using === **/ @@ -748,7 +748,7 @@ namespace svt { namespace table { DBG_CHECK_ME(); - Reference< XSortableGridDataModel > const xSortAccess( getDataModel(), UNO_QUERY ); + Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY ); if ( xSortAccess.is() ) return this; return NULL; @@ -761,7 +761,7 @@ namespace svt { namespace table try { - Reference< XSortableGridDataModel > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); + Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); xSortAccess->sortByColumn( i_column, i_sortDirection == ColumnSortAscending ); } catch( const Exception& ) @@ -778,7 +778,7 @@ namespace svt { namespace table ColumnSort currentSort; try { - Reference< XSortableGridDataModel > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); + Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW ); Pair< ::sal_Int32, ::sal_Bool > const aCurrentSortOrder( xSortAccess->getCurrentSortOrder() ); currentSort.nColumnPos = aCurrentSortOrder.First; currentSort.eSortDirection = aCurrentSortOrder.Second ? ColumnSortAscending : ColumnSortDescending; diff --git a/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java b/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java index 4413118f4e80..e55b2b1bb0ad 100755 --- a/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java +++ b/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java @@ -205,7 +205,7 @@ public class TMutableGridDataModel } /** - * tests the XMutableGridDataModel.setRowHeading method + * tests the XMutableGridDataModel.updateRowHeading method */ public void testUpdateRowHeading() throws IndexOutOfBoundsException { @@ -215,7 +215,7 @@ public class TMutableGridDataModel final int rowToUpdate = 2; final String valueToUpdate = "some text"; - m_dataModel.setRowHeading( rowToUpdate, valueToUpdate ); + m_dataModel.updateRowHeading( rowToUpdate, valueToUpdate ); final GridDataEvent event = m_listener.assertSingleRowHeadingChangeEvent(); assertEquals( "row heading update notification: FirstRow is invalid", rowToUpdate, event.FirstRow ); assertEquals( "row heading update notification: FirstRow is invalid", rowToUpdate, event.LastRow ); diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 9ddb70c01760..4ef99d749ba1 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -340,7 +340,7 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL DefaultGridDataModel::setRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException) + void SAL_CALL DefaultGridDataModel::updateRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException) { ::comphelper::ComponentGuard aGuard( *this, rBHelper ); diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 13a31277e533..bf4b6cc3355e 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -69,7 +69,7 @@ public: virtual void SAL_CALL removeAllRows( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateCellData( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateRowData( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRowHeading( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Heading ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowHeading( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Heading ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateCellToolTip( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateRowToolTip( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx index 31617c3b9a77..77a2ffa1637b 100755 --- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -670,7 +670,7 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL SortableGridDataModel::setRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException) + void SAL_CALL SortableGridDataModel::updateRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException) { MethodGuard aGuard( *this, rBHelper ); DBG_CHECK_ME(); @@ -679,7 +679,7 @@ namespace toolkit Reference< XMutableGridDataModel > const delegator( m_delegator ); aGuard.clear(); - delegator->setRowHeading( rowIndex, i_heading ); + delegator->updateRowHeading( rowIndex, i_heading ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.hxx b/toolkit/source/controls/grid/sortablegriddatamodel.hxx index 26f0e63f9762..50f08d3a7113 100755 --- a/toolkit/source/controls/grid/sortablegriddatamodel.hxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.hxx @@ -77,7 +77,7 @@ namespace toolkit ~SortableGridDataModel(); public: - // XSortableGridDataModel + // XSortableGridData virtual void SAL_CALL sortByColumn( ::sal_Int32 ColumnIndex, ::sal_Bool SortAscending ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeColumnSort( ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::beans::Pair< ::sal_Int32, ::sal_Bool > SAL_CALL getCurrentSortOrder( ) throw (::com::sun::star::uno::RuntimeException); @@ -89,7 +89,7 @@ namespace toolkit virtual void SAL_CALL removeAllRows( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateCellData( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateRowData( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRowHeading( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Heading ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowHeading( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Heading ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateCellToolTip( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateRowToolTip( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); -- cgit v1.2.3 From c97ccfc7989ec992f681e8a174a07a9a48433bdf Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 27 Jan 2011 12:59:46 +0100 Subject: gridsort: properly render the sort indicator for right-aligned columns --- svtools/source/table/gridtablerenderer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'svtools') diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 26d023535198..b265b9824dea 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -300,7 +300,7 @@ namespace svt { namespace table { // text is right aligned => draw the sort indicator at the left hand side _rDevice.DrawBitmapEx( - Point( nSortIndicatorPaddingX, nSortIndicatorPaddingY ), + Point( _rArea.Left() + nSortIndicatorPaddingX, _rArea.Top() + nSortIndicatorPaddingY ), aIndicatorBitmap ); } -- cgit v1.2.3 From 475f089296d926338b018ba08301ad30a1be35c1 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 27 Jan 2011 13:06:51 +0100 Subject: gridsort: removed unused includes --- svtools/source/uno/svtxgridcontrol.cxx | 6 ------ 1 file changed, 6 deletions(-) (limited to 'svtools') diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index d61a983b309b..0e826ef6bff3 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -40,9 +40,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -56,9 +53,6 @@ using namespace ::com::sun::star::view; using namespace ::com::sun::star::style; using namespace ::com::sun::star::container; using namespace ::com::sun::star::accessibility; -using namespace ::com::sun::star::accessibility::AccessibleEventId; -using namespace ::com::sun::star::accessibility::AccessibleTableModelChangeType; -using ::com::sun::star::accessibility::AccessibleTableModelChange; SVTXGridControl::SVTXGridControl() -- cgit v1.2.3 From c9f03dd680c2274d5cf387172d9c60615a8db0df Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 27 Jan 2011 13:33:02 +0100 Subject: gridsort: impl_ni_updateColumnWidts: after calculating effective widths, forward this to the column models --- svtools/source/table/tablecontrol_impl.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index 885974a21489..edf2dbd01491 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -718,6 +718,7 @@ namespace svt { namespace table if ( !m_bUpdatingColWidths ) { impl_ni_updateColumnWidths( i_column ); + invalidate( TableAreaAll ); impl_ni_updateScrollbars(); } @@ -1031,6 +1032,11 @@ namespace svt { namespace table const long columnEnd = columnStart + colWidth; m_aColumnWidths.push_back( MutableColumnMetrics( columnStart, columnEnd ) ); accumulatedWidthPixel = columnEnd; + + // and don't forget to forward this to the column models + PColumnModel const pColumn = m_pModel->getColumnModel( col ); + ENSURE_OR_THROW( !!pColumn, "invalid column returned by the model!" ); + pColumn->setWidth( newWidths[col] ); } // if the column resizing happened to leave some space at the right, but there are columns -- cgit v1.2.3 From 9d54d880b52b4ef1c69ca96867e65ee6cd00fb9f Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Thu, 27 Jan 2011 20:09:53 +0100 Subject: locales34: #i106785# add Haitian_Haiti [ht-HT] to language list and locale data; locale data contributed by --- i18npool/inc/i18npool/lang.h | 1 + i18npool/source/isolang/isolang.cxx | 3 +- i18npool/source/localedata/data/ht_HT.xml | 358 +++++++++++++++++++++ .../source/localedata/data/localedata_others.map | 17 + i18npool/source/localedata/data/makefile.mk | 1 + i18npool/source/localedata/localedata.cxx | 3 +- svtools/source/misc/langtab.src | 1 + 7 files changed, 382 insertions(+), 2 deletions(-) create mode 100644 i18npool/source/localedata/data/ht_HT.xml (limited to 'svtools') diff --git a/i18npool/inc/i18npool/lang.h b/i18npool/inc/i18npool/lang.h index 91da0e3ec78f..5d9c3cee878c 100644 --- a/i18npool/inc/i18npool/lang.h +++ b/i18npool/inc/i18npool/lang.h @@ -519,6 +519,7 @@ typedef unsigned short LanguageType; #define LANGUAGE_USER_LIMBU 0x0657 #define LANGUAGE_USER_LOJBAN 0x0658 /* no locale */ #define LANGUAGE_USER_KABYLE 0x0659 +#define LANGUAGE_USER_HAITIAN 0x065A #endif /* INCLUDED_I18NPOOL_LANG_H */ diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx index f174ad431a57..78a66c1cc79e 100644 --- a/i18npool/source/isolang/isolang.cxx +++ b/i18npool/source/isolang/isolang.cxx @@ -292,7 +292,6 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = // { LANGUAGE_USER_CATALAN_VALENCIAN, "ca", "ES" }, // In case MS format files escaped into the wild, map them back. { LANGUAGE_FRENCH_CAMEROON, "fr", "CM" }, { LANGUAGE_FRENCH_COTE_D_IVOIRE, "fr", "CI" }, - { LANGUAGE_FRENCH_HAITI, "fr", "HT" }, { LANGUAGE_FRENCH_MALI, "fr", "ML" }, { LANGUAGE_FRENCH_SENEGAL, "fr", "SN" }, { LANGUAGE_FRENCH_ZAIRE, "fr", "CD" }, // Democratic Republic Of Congo @@ -465,6 +464,8 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = { LANGUAGE_USER_LIMBU, "lif", "NP" }, { LANGUAGE_USER_LOJBAN, "jbo", "" }, { LANGUAGE_USER_KABYLE, "kab", "DZ" }, + { LANGUAGE_USER_HAITIAN, "ht", "HT" }, + { LANGUAGE_FRENCH_HAITI, "fr", "HT" }, { LANGUAGE_NONE, "zxx", "" }, // added to ISO 639-2 on 2006-01-11: Used to declare the absence of linguistic information { LANGUAGE_DONTKNOW, "", "" } // marks end of table }; diff --git a/i18npool/source/localedata/data/ht_HT.xml b/i18npool/source/localedata/data/ht_HT.xml new file mode 100644 index 000000000000..99109c72a909 --- /dev/null +++ b/i18npool/source/localedata/data/ht_HT.xml @@ -0,0 +1,358 @@ + + + + + + ht + Haitian Creole + + + HT + Haiti + + + + + / + , + . + : + . + ; + , + , + + + + + + + + + + AM + PM + metric + + + + General + + + 0 + + + 0.00 + + + #,##0 + + + #,##0.00 + + + #,###.00 + + + 0.00E+00 + + + 0.00E+000 + + + 0% + + + 0.00% + + + [CURRENCY]#,##0;-[CURRENCY]#,##0 + + + [CURRENCY]#,##0.00;-[CURRENCY]#,##0.00 + + + [CURRENCY]#,##0;[RED]-[CURRENCY]#,##0 + + + [CURRENCY]#,##0.00;[RED]-[CURRENCY]#,##0.00 + + + CCC#,##0.00 + + + [CURRENCY]#,##0.--;[RED]-[CURRENCY]#,##0.-- + + + D/MM/YY + + + NNNNDD, MMMM YYYY + + + DD/MM/YY + + + DD/MM/YYYY + + + D, MMM YY + + + D, MMM YYYY + + + D, MMM YYYY + + + D, MMMM YYYY + + + D, MMMM YY + + + NN, DD/MMM/YY + + + NN, D, MMM YY + + + NN, D, MMMM YYYY + + + NNNND, MMMM YYYY + + + MM/DD + + + YY-MM-DD + ISO 8601 + + + YYYY-MM-DD + ISO 8601 + + + MM/YY + + + MMM/DD + + + MMMM + + + QQ YY + + + WW + + + HH:MM + + + HH:MM:SS + + + HH:MM AM/PM + + + HH:MM:SS AM/PM + + + [HH]:MM:SS + + + MM:SS.00 + + + [HH]:MM:SS.00 + + + DD/MM/YY HH:MM + + + DD/MM/YYYY HH:MM:SS AM/PM + + + + + + IGNORE_CASE + + + + + IGNORE_CASE + + + + A-Z + 0 + 1 + s + pl + + + + + + sun + Dim + Dimanch + + + mon + Len + Lendi + + + tue + Mad + Madi + + + wed + Mèk + Mèkredi + + + thu + Jed + Jedi + + + fri + Van + Vandredi + + + sat + Sam + Samdi + + + + + jan + Jan + Janvye + + + feb + Fev + Fevriye + + + mar + Mas + Mas + + + apr + Avr + Avril + + + may + Me + Me + + + jun + Jen + Jen + + + jul + Jiy + Jiyè + + + aug + Dao + Daout + + + sep + Sep + Septanm + + + oct + Okt + Oktòb + + + nov + Nov + Novanm + + + dec + Des + Desanm + + + + + bc + AJ + Avan Jezikri + + + ad + AP + Apre Jezikri + + + + sun + + 1 + + + + + HTG + G + HTG + Goud + 2 + + + + + + + + + + Vre + Fo + Trimès 1 + Trimès 2 + Trimès 3 + Trimès 4 + Anwo + Anba + Trimès 1 + Trimès 2 + Trimès 3 + Trimès 4 + + + + + + + + + + + + + + + diff --git a/i18npool/source/localedata/data/localedata_others.map b/i18npool/source/localedata/data/localedata_others.map index d644fa1607cd..73188b45d749 100644 --- a/i18npool/source/localedata/data/localedata_others.map +++ b/i18npool/source/localedata/data/localedata_others.map @@ -26,6 +26,7 @@ getAllCalendars_haw_US; getAllCalendars_he_IL; getAllCalendars_hi_IN; getAllCalendars_hil_PH; +getAllCalendars_ht_HT; getAllCalendars_hu_HU; getAllCalendars_hy_AM; getAllCalendars_ia; @@ -108,6 +109,7 @@ getAllCurrencies_haw_US; getAllCurrencies_he_IL; getAllCurrencies_hi_IN; getAllCurrencies_hil_PH; +getAllCurrencies_ht_HT; getAllCurrencies_hu_HU; getAllCurrencies_hy_AM; getAllCurrencies_ia; @@ -190,6 +192,7 @@ getAllFormats0_haw_US; getAllFormats0_he_IL; getAllFormats0_hi_IN; getAllFormats0_hil_PH; +getAllFormats0_ht_HT; getAllFormats0_hu_HU; getAllFormats0_hy_AM; getAllFormats0_ia; @@ -272,6 +275,7 @@ getBreakIteratorRules_haw_US; getBreakIteratorRules_he_IL; getBreakIteratorRules_hi_IN; getBreakIteratorRules_hil_PH; +getBreakIteratorRules_ht_HT; getBreakIteratorRules_hu_HU; getBreakIteratorRules_hy_AM; getBreakIteratorRules_ia; @@ -354,6 +358,7 @@ getCollationOptions_haw_US; getCollationOptions_he_IL; getCollationOptions_hi_IN; getCollationOptions_hil_PH; +getCollationOptions_ht_HT; getCollationOptions_hu_HU; getCollationOptions_hy_AM; getCollationOptions_ia; @@ -436,6 +441,7 @@ getCollatorImplementation_haw_US; getCollatorImplementation_he_IL; getCollatorImplementation_hi_IN; getCollatorImplementation_hil_PH; +getCollatorImplementation_ht_HT; getCollatorImplementation_hu_HU; getCollatorImplementation_hy_AM; getCollatorImplementation_ia; @@ -518,6 +524,7 @@ getContinuousNumberingLevels_haw_US; getContinuousNumberingLevels_he_IL; getContinuousNumberingLevels_hi_IN; getContinuousNumberingLevels_hil_PH; +getContinuousNumberingLevels_ht_HT; getContinuousNumberingLevels_hu_HU; getContinuousNumberingLevels_hy_AM; getContinuousNumberingLevels_ia; @@ -600,6 +607,7 @@ getFollowPageWords_haw_US; getFollowPageWords_he_IL; getFollowPageWords_hi_IN; getFollowPageWords_hil_PH; +getFollowPageWords_ht_HT; getFollowPageWords_hu_HU; getFollowPageWords_hy_AM; getFollowPageWords_ia; @@ -682,6 +690,7 @@ getForbiddenCharacters_haw_US; getForbiddenCharacters_he_IL; getForbiddenCharacters_hi_IN; getForbiddenCharacters_hil_PH; +getForbiddenCharacters_ht_HT; getForbiddenCharacters_hu_HU; getForbiddenCharacters_hy_AM; getForbiddenCharacters_ia; @@ -764,6 +773,7 @@ getIndexAlgorithm_haw_US; getIndexAlgorithm_he_IL; getIndexAlgorithm_hi_IN; getIndexAlgorithm_hil_PH; +getIndexAlgorithm_ht_HT; getIndexAlgorithm_hu_HU; getIndexAlgorithm_hy_AM; getIndexAlgorithm_ia; @@ -846,6 +856,7 @@ getLCInfo_haw_US; getLCInfo_he_IL; getLCInfo_hi_IN; getLCInfo_hil_PH; +getLCInfo_ht_HT; getLCInfo_hu_HU; getLCInfo_hy_AM; getLCInfo_ia; @@ -928,6 +939,7 @@ getLocaleItem_haw_US; getLocaleItem_he_IL; getLocaleItem_hi_IN; getLocaleItem_hil_PH; +getLocaleItem_ht_HT; getLocaleItem_hu_HU; getLocaleItem_hy_AM; getLocaleItem_ia; @@ -1010,6 +1022,7 @@ getOutlineNumberingLevels_haw_US; getOutlineNumberingLevels_he_IL; getOutlineNumberingLevels_hi_IN; getOutlineNumberingLevels_hil_PH; +getOutlineNumberingLevels_ht_HT; getOutlineNumberingLevels_hu_HU; getOutlineNumberingLevels_hy_AM; getOutlineNumberingLevels_ia; @@ -1092,6 +1105,7 @@ getReservedWords_haw_US; getReservedWords_he_IL; getReservedWords_hi_IN; getReservedWords_hil_PH; +getReservedWords_ht_HT; getReservedWords_hu_HU; getReservedWords_hy_AM; getReservedWords_ia; @@ -1174,6 +1188,7 @@ getSearchOptions_haw_US; getSearchOptions_he_IL; getSearchOptions_hi_IN; getSearchOptions_hil_PH; +getSearchOptions_ht_HT; getSearchOptions_hu_HU; getSearchOptions_hy_AM; getSearchOptions_ia; @@ -1256,6 +1271,7 @@ getTransliterations_haw_US; getTransliterations_he_IL; getTransliterations_hi_IN; getTransliterations_hil_PH; +getTransliterations_ht_HT; getTransliterations_hu_HU; getTransliterations_hy_AM; getTransliterations_ia; @@ -1338,6 +1354,7 @@ getUnicodeScripts_haw_US; getUnicodeScripts_he_IL; getUnicodeScripts_hi_IN; getUnicodeScripts_hil_PH; +getUnicodeScripts_ht_HT; getUnicodeScripts_hu_HU; getUnicodeScripts_hy_AM; getUnicodeScripts_ia; diff --git a/i18npool/source/localedata/data/makefile.mk b/i18npool/source/localedata/data/makefile.mk index b1c324695a27..0d9e186990d7 100644 --- a/i18npool/source/localedata/data/makefile.mk +++ b/i18npool/source/localedata/data/makefile.mk @@ -266,6 +266,7 @@ SHL4OBJS= \ $(SLO)$/localedata_he_IL.obj \ $(SLO)$/localedata_hi_IN.obj \ $(SLO)$/localedata_hil_PH.obj \ + $(SLO)$/localedata_ht_HT.obj \ $(SLO)$/localedata_hu_HU.obj \ $(SLO)$/localedata_hy_AM.obj \ $(SLO)$/localedata_ia.obj \ diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 9af043b5457b..8e393c1c4624 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -255,7 +255,8 @@ static const struct { { "yi_US", lcl_DATA_OTHERS }, { "haw_US", lcl_DATA_OTHERS }, { "lif_NP", lcl_DATA_OTHERS }, - { "ur_PK", lcl_DATA_OTHERS } + { "ur_PK", lcl_DATA_OTHERS }, + { "ht_HT", lcl_DATA_OTHERS } }; static const sal_Unicode under = sal_Unicode('_'); diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src index effe6506cb1f..bb5fa2dfd363 100644 --- a/svtools/source/misc/langtab.src +++ b/svtools/source/misc/langtab.src @@ -328,6 +328,7 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE < "Limbu" ; LANGUAGE_USER_LIMBU ; > ; < "Lojban" ; LANGUAGE_USER_LOJBAN ; > ; < "Kabyle" ; LANGUAGE_USER_KABYLE ; > ; + < "Haitian" ; LANGUAGE_USER_HAITIAN ; > ; }; }; -- cgit v1.2.3 From e8c91f364e10dfc20b4ea9f3b940723282c1cab0 Mon Sep 17 00:00:00 2001 From: "Matthias Huetsch [mhu]" Date: Tue, 1 Feb 2011 14:14:30 +0100 Subject: #i115784# Valgrind: conditional jump or move depends on uninitialized value(s). --- svtools/source/contnr/svlbox.cxx | 1 + vcl/source/gdi/jobset.cxx | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'svtools') diff --git a/svtools/source/contnr/svlbox.cxx b/svtools/source/contnr/svlbox.cxx index 11e19c6bab3c..abdd1c1889ee 100644 --- a/svtools/source/contnr/svlbox.cxx +++ b/svtools/source/contnr/svlbox.cxx @@ -683,6 +683,7 @@ SvViewDataEntry::~SvViewDataEntry() SvLBox_Impl::SvLBox_Impl( SvLBox& _rBox ) :m_bIsEmptyTextAllowed( true ) ,m_bEntryMnemonicsEnabled( false ) + ,m_bDoingQuickSelection( false ) ,m_pLink( NULL ) ,m_aMnemonicEngine( _rBox ) ,m_aQuickSelectionEngine( _rBox ) diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx index 2bc0addaa93c..01b80b38238f 100644 --- a/vcl/source/gdi/jobset.cxx +++ b/vcl/source/gdi/jobset.cxx @@ -299,13 +299,16 @@ SvStream& operator>>( SvStream& rIStream, JobSetup& rJobSetup ) // Zur Zeit haben wir noch kein neues FileFormat // if ( rIStream.GetVersion() < JOBSET_FILEFORMAT2 ) { - USHORT nLen; - USHORT nSystem; sal_Size nFirstPos = rIStream.Tell(); + + USHORT nLen = 0; rIStream >> nLen; if ( !nLen ) return rIStream; + + USHORT nSystem = 0; rIStream >> nSystem; + char* pTempBuf = new char[nLen]; rIStream.Read( pTempBuf, nLen - sizeof( nLen ) - sizeof( nSystem ) ); if ( nLen >= sizeof(ImplOldJobSetupData)+4 ) -- cgit v1.2.3 From acd83aa7782fcdff32785fadb1c6b61dffd465ab Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 2 Feb 2011 10:51:17 +0100 Subject: gridsort: when cancelling a column sort by releasing the mouse outside the start column, properly recover the handler state --- svtools/source/table/mousefunction.cxx | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'svtools') diff --git a/svtools/source/table/mousefunction.cxx b/svtools/source/table/mousefunction.cxx index 6d37e35b7a4c..20d505e911e9 100755 --- a/svtools/source/table/mousefunction.cxx +++ b/svtools/source/table/mousefunction.cxx @@ -296,22 +296,20 @@ namespace svt { namespace table return SkipFunction; TableCell const tableCell( i_tableControl.hitTest( i_event.GetPosPixel() ) ); - if ( ( tableCell.nRow != ROW_COL_HEADERS ) || ( tableCell.nColumn != m_nActiveColumn ) ) - // mouse was pressed on a column header, but released outside of it. - // => just deactivate, without sorting - return DeactivateFunction; - - ITableDataSort* pSort = i_tableControl.getModel()->getSortAdapter(); - ENSURE_OR_RETURN( pSort != NULL, "ColumnSortHandler::handleMouseUp: somebody is mocking with us!", DeactivateFunction ); - // in handleMousButtonDown, the model claimed to have sort support ... + if ( ( tableCell.nRow == ROW_COL_HEADERS ) && ( tableCell.nColumn == m_nActiveColumn ) ) + { + ITableDataSort* pSort = i_tableControl.getModel()->getSortAdapter(); + ENSURE_OR_RETURN( pSort != NULL, "ColumnSortHandler::handleMouseUp: somebody is mocking with us!", DeactivateFunction ); + // in handleMousButtonDown, the model claimed to have sort support ... - ColumnSortDirection eSortDirection = ColumnSortAscending; - ColumnSort const aCurrentSort = pSort->getCurrentSortOrder(); - if ( aCurrentSort.nColumnPos == m_nActiveColumn ) - // invert existing sort order - eSortDirection = ( aCurrentSort.eSortDirection == ColumnSortAscending ) ? ColumnSortDescending : ColumnSortAscending; + ColumnSortDirection eSortDirection = ColumnSortAscending; + ColumnSort const aCurrentSort = pSort->getCurrentSortOrder(); + if ( aCurrentSort.nColumnPos == m_nActiveColumn ) + // invert existing sort order + eSortDirection = ( aCurrentSort.eSortDirection == ColumnSortAscending ) ? ColumnSortDescending : ColumnSortAscending; - pSort->sortByColumn( m_nActiveColumn, eSortDirection ); + pSort->sortByColumn( m_nActiveColumn, eSortDirection ); + } m_nActiveColumn = COL_INVALID; return DeactivateFunction; -- cgit v1.2.3 From ef75ddb6d32316419b8912271e5177d3bb2c0361 Mon Sep 17 00:00:00 2001 From: os Date: Thu, 3 Feb 2011 16:51:12 +0100 Subject: initialize boolean value --- svtools/source/filter.vcl/filter/FilterConfigItem.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'svtools') diff --git a/svtools/source/filter.vcl/filter/FilterConfigItem.cxx b/svtools/source/filter.vcl/filter/FilterConfigItem.cxx index 312f62af9d84..830ee1ecf80c 100644 --- a/svtools/source/filter.vcl/filter/FilterConfigItem.cxx +++ b/svtools/source/filter.vcl/filter/FilterConfigItem.cxx @@ -428,7 +428,7 @@ void FilterConfigItem::WriteBool( const OUString& rKey, sal_Bool bNewValue ) Any aAny; if ( ImplGetPropertyValue( aAny, xPropSet, rKey, sal_True ) ) { - sal_Bool bOldValue; + sal_Bool bOldValue = false; if ( aAny >>= bOldValue ) { if ( bOldValue != bNewValue ) -- cgit v1.2.3 From ac2741f0361ea516ffe8ead57a6e43665ec99937 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 4 Feb 2011 10:11:33 +0100 Subject: gridsort: need another include after the rebase to m99 --- svtools/source/table/tablecontrol_impl.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'svtools') diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index edf2dbd01491..5cad1526aac1 100755 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -43,7 +43,7 @@ #include /** === end UNO includes === **/ -#include +#include #include #include #include -- cgit v1.2.3 From db8eb68761bee1f15efa5484c24ac8599fb5188b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 15 Feb 2011 12:12:43 +0100 Subject: gridsort: post-rebase fixes --- comphelper/Package_inc.mk | 1 + svtools/source/table/gridtablerenderer.cxx | 26 -------------------------- svtools/source/table/tabledatawindow.cxx | 4 ++-- svtools/source/table/tabledatawindow.hxx | 2 +- toolkit/prj/build.lst | 1 - 5 files changed, 4 insertions(+), 30 deletions(-) (limited to 'svtools') diff --git a/comphelper/Package_inc.mk b/comphelper/Package_inc.mk index 724959947867..5794c56ab74d 100644 --- a/comphelper/Package_inc.mk +++ b/comphelper/Package_inc.mk @@ -111,6 +111,7 @@ $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/numbers.hxx,comp $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/evtlistenerhlp.hxx,comphelper/evtlistenerhlp.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/optional.hxx,comphelper/optional.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/componentbase.hxx,comphelper/componentbase.hxx)) +$(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/componentguard.hxx,comphelper/componentguard.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/InlineContainer.hxx,comphelper/InlineContainer.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/propertybag.hxx,comphelper/propertybag.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/embeddedobjectcontainer.hxx,comphelper/embeddedobjectcontainer.hxx)) diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index 56a99a69533d..1e230d372c24 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -491,35 +491,9 @@ namespace svt { namespace table break; } -<<<<<<< local } else imageSize.Width() = i_context.aContentArea.GetWidth(); -======= - Rectangle aRect( _rArea ); - ++aRect.Left(); --aRect.Right(); - aRect.Top(); aRect.Bottom(); - if(_bSelected) - _rDevice.SetTextColor(_rStyle.GetHighlightTextColor()); - else if(m_pImpl->rModel.getTextColor() != 0x000000) - _rDevice.SetTextColor(m_pImpl->rModel.getTextColor()); - else - _rDevice.SetTextColor(_rStyle.GetFieldTextColor()); - sal_uLong nHorFlag = TEXT_DRAW_LEFT; - sal_uLong nVerFlag = TEXT_DRAW_TOP; - if(m_pImpl->rModel.getVerticalAlign() == 1) - nVerFlag = TEXT_DRAW_VCENTER; - else if(m_pImpl->rModel.getVerticalAlign() == 2) - nVerFlag = TEXT_DRAW_BOTTOM; - if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 1) - nHorFlag = TEXT_DRAW_CENTER; - else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2) - nHorFlag = TEXT_DRAW_RIGHT; - Rectangle textRect(_rArea); - textRect.Left()+=4; textRect.Right()-=4; - textRect.Bottom()-=2; - _rDevice.DrawText( textRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP); ->>>>>>> other if ( i_context.aContentArea.GetHeight() > imageSize.Height() ) { diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx index 7f1515be8b73..11605e36c8b2 100644 --- a/svtools/source/table/tabledatawindow.cxx +++ b/svtools/source/table/tabledatawindow.cxx @@ -95,7 +95,7 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void TableDataWindow::RequestHelp( const HelpEvent& rHEvt ) { - USHORT const nHelpMode = rHEvt.GetMode(); + sal_uInt16 const nHelpMode = rHEvt.GetMode(); if ( ( IsMouseCaptured() ) || ( ( nHelpMode & HELPMODE_QUICK ) == 0 ) ) @@ -105,7 +105,7 @@ namespace svt { namespace table } ::rtl::OUString sHelpText; - USHORT nHelpStyle = 0; + sal_uInt16 nHelpStyle = 0; Point const aMousePos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) ); RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos ); diff --git a/svtools/source/table/tabledatawindow.hxx b/svtools/source/table/tabledatawindow.hxx index 68532fb71793..6f78ac49c44d 100644 --- a/svtools/source/table/tabledatawindow.hxx +++ b/svtools/source/table/tabledatawindow.hxx @@ -55,7 +55,7 @@ namespace svt { namespace table Link m_aMouseButtonDownHdl; Link m_aMouseButtonUpHdl; Link m_aSelectHdl; - ULONG m_nTipWindowHandle; + sal_uLong m_nTipWindowHandle; public: TableDataWindow( TableControl_Impl& _rTableControl ); diff --git a/toolkit/prj/build.lst b/toolkit/prj/build.lst index 2d0c54e6609c..e11d32c435bf 100644 --- a/toolkit/prj/build.lst +++ b/toolkit/prj/build.lst @@ -1,4 +1,3 @@ ti toolkit : LIBXSLT:libxslt vcl qadevOOo test NULL ti toolkit\prj nmake - all ti_prj NULL -ti toolkit\qa\unoapi nmake - all ti_qa_unoapi NULL ti toolkit\qa\complex\toolkit nmake - all ti_complex_toolkit NULL -- cgit v1.2.3 From e2a3d487efb2bd5e582eb10e4150530c3f7377c5 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Tue, 22 Feb 2011 19:07:34 +0100 Subject: masterfix DEV300: #i10000# usage of L10N build_type --- svl/prj/build.lst | 2 +- svtools/prj/build.lst | 2 +- vcl/prj/build.lst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'svtools') diff --git a/svl/prj/build.lst b/svl/prj/build.lst index f41b1142ae3f..999cdf8947de 100644 --- a/svl/prj/build.lst +++ b/svl/prj/build.lst @@ -1,2 +1,2 @@ -sl svl : l10n rsc offuh ucbhelper unotools cppu cppuhelper comphelper sal sot LIBXSLT:libxslt NULL +sl svl : L10N:l10n rsc offuh ucbhelper unotools cppu cppuhelper comphelper sal sot LIBXSLT:libxslt NULL sl svl\prj nmake - all svl_prj NULL diff --git a/svtools/prj/build.lst b/svtools/prj/build.lst index fd0f1a560c18..ff9aa6a9875c 100644 --- a/svtools/prj/build.lst +++ b/svtools/prj/build.lst @@ -1,2 +1,2 @@ -st svtools : l10n svl offuh toolkit ucbhelper unotools JPEG:jpeg cppu cppuhelper comphelper sal sot jvmfwk LIBXSLT:libxslt NULL +st svtools : L10N:l10n svl offuh toolkit ucbhelper unotools JPEG:jpeg cppu cppuhelper comphelper sal sot jvmfwk LIBXSLT:libxslt NULL st svtools\prj nmake - all st_prj NULL diff --git a/vcl/prj/build.lst b/vcl/prj/build.lst index af15ad73e19d..d8426a092093 100644 --- a/vcl/prj/build.lst +++ b/vcl/prj/build.lst @@ -1,4 +1,4 @@ -vc vcl : l10n apple_remote BOOST:boost rsc sot ucbhelper unotools ICU:icu GRAPHITE:graphite i18npool i18nutil unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx basebmp tools l10ntools icc SO:print_header cpputools shell svl LIBXSLT:libxslt NULL +vc vcl : L10N:l10n apple_remote BOOST:boost rsc sot ucbhelper unotools ICU:icu GRAPHITE:graphite i18npool i18nutil unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx basebmp tools l10ntools icc SO:print_header cpputools shell svl LIBXSLT:libxslt NULL vc vcl usr1 - all vc_mkout NULL vc vcl\inc nmake - all vc_inc NULL vc vcl\source\glyphs nmake - all vc_glyphs vc_inc NULL -- cgit v1.2.3