diff options
author | Mihaela Kedikova <misheto@openoffice.org> | 2010-04-23 17:41:32 +0200 |
---|---|---|
committer | Mihaela Kedikova <misheto@openoffice.org> | 2010-04-23 17:41:32 +0200 |
commit | 5c737d12c11c1ef5b758e2045098e7037c3b56cc (patch) | |
tree | 33006cdce82ee41a8e678f5818e703c208a0b15f /toolkit/source/controls | |
parent | eea019398f2c849b702c49d9e55bdbd059a34c7b (diff) |
gridcontrol_03:bug fix for #i111107#, added update methods to xgriddatamodel
Diffstat (limited to 'toolkit/source/controls')
-rw-r--r-- | toolkit/source/controls/grid/defaultgriddatamodel.cxx | 41 | ||||
-rw-r--r-- | toolkit/source/controls/grid/defaultgriddatamodel.hxx | 4 | ||||
-rw-r--r-- | toolkit/source/controls/grid/gridcontrol.hxx | 2 |
3 files changed, 39 insertions, 8 deletions
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 38e3ec694b96..7ffafdf0ddb6 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -41,6 +41,9 @@ 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" )) +#define ROWHEADERWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaderWidth" )) namespace toolkit { @@ -83,11 +86,10 @@ void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& //--------------------------------------------------------------------- -void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ) throw (::com::sun::star::uno::RuntimeException) +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, 0, ::rtl::OUString(), - Sequence< Any >() ); + GridDataEvent aEvent( xSource, name, oldValue, newValue, index, ::rtl::OUString(), Sequence< Any >()); broadcast( data_changed, aEvent); } @@ -128,7 +130,7 @@ void SAL_CALL DefaultGridDataModel::setRowHeight(::sal_Int32 value) throw (::com sal_Int32 oldValue = rowHeight; rowHeight = value; - broadcast_changed( ROWHEIGHT, Any(oldValue), Any(value) ); + broadcast_changed( ROWHEIGHT, 0, Any(oldValue), Any(value)); } //--------------------------------------------------------------------- @@ -164,7 +166,7 @@ void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::S i++; } - broadcast_changed( ROWHEADERS, Any(oldValue), Any(comphelper::containerToSequence(rowHeaders)) ); + broadcast_changed( ROWHEADERS, 0, Any(oldValue), Any(comphelper::containerToSequence(rowHeaders)) ); } //--------------------------------------------------------------------- @@ -244,7 +246,9 @@ void SAL_CALL DefaultGridDataModel::removeAll() throw (RuntimeException) //--------------------------------------------------------------------- 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) @@ -252,6 +256,33 @@ sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeaderWidth() throw (::com::sun:: 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()) + { + if(column >= 0 && column < (signed)data[0].size()) + { + data[row][column] = value; + Sequence< Any >dataSeq(comphelper::containerToSequence(data[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()) + { + if(columns.getLength() == values.getLength()) + { + 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) ); + } + } +} +//--------------------------------------------------------------------- // XComponent //--------------------------------------------------------------------- diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index 3c10a3e3cd73..ea11a8a9a00a 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -73,6 +73,8 @@ public: 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); // XComponent virtual void SAL_CALL dispose( ) throw (RuntimeException); virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); @@ -86,7 +88,7 @@ public: private: void broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue ) 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); diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index e0f503a10aa9..0c8ddb1c02b6 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -91,8 +91,6 @@ public: 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); - //virtual void SAL_CALL addMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL removeMouseListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridSelection |