summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svtools/inc/svtools/table/tablecontrol.hxx3
-rwxr-xr-xsvtools/inc/svtools/table/tablemodel.hxx2
-rw-r--r--svtools/source/table/tablecontrol.cxx6
-rwxr-xr-xsvtools/source/table/tablecontrol_impl.cxx13
-rwxr-xr-xsvtools/source/table/tablecontrol_impl.hxx2
-rw-r--r--svtools/source/uno/svtxgridcontrol.cxx15
-rw-r--r--svtools/source/uno/unocontroltablemodel.cxx49
-rw-r--r--svtools/source/uno/unocontroltablemodel.hxx10
-rwxr-xr-xsvtools/source/uno/unogridcolumnfacade.cxx34
-rwxr-xr-xsvtools/source/uno/unogridcolumnfacade.hxx12
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.cxx1
-rw-r--r--toolkit/source/controls/grid/gridcolumn.cxx15
-rw-r--r--toolkit/source/controls/grid/gridcolumn.hxx3
13 files changed, 124 insertions, 41 deletions
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
@@ -249,12 +249,6 @@ namespace svt { namespace table
}
// -----------------------------------------------------------------------------------------------------------------
- void TableControl::InvalidateDataWindow( RowPos const i_firstRow, RowPos const i_lastRow )
- {
- m_pImpl->invalidateRowRange( i_firstRow, i_lastRow );
- }
-
- // -----------------------------------------------------------------------------------------------------------------
ITableControl& TableControl::getTableControlInterface()
{
return *m_pImpl;
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();
}
//------------------------------------------------------------------------------------------------------------------
@@ -206,6 +216,30 @@ namespace svt { namespace table
}
//------------------------------------------------------------------------------------------------------------------
+ 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 )
{
DBG_TESTSOLARMUTEX();
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 )
@@ -249,6 +251,19 @@ namespace toolkit
}
//------------------------------------------------------------------------------------------------------------------
+ ::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)
{
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.GridColumn" ) );
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;