summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-03-22 13:00:39 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-09-14 07:29:06 +0000
commit5df47e4bb0c1217e0b49468aa7c2ca2eecf6dc07 (patch)
tree6b7836c385a19f0c0560994699e262296fa08f8b /toolkit
parenta5d4e7806c6519e139962d88ec969f9baeb4a404 (diff)
gridfixes: #i117398# added XGridDataModel::getRowData
Change-Id: Ic08c2d54a76f2a2821822ec4b275883e4445c70c Reviewed-on: https://gerrit.libreoffice.org/543 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/qa/complex/toolkit/GridControl.java29
-rw-r--r--toolkit/source/controls/grid/defaultgriddatamodel.cxx13
-rw-r--r--toolkit/source/controls/grid/defaultgriddatamodel.hxx1
-rw-r--r--toolkit/source/controls/grid/sortablegriddatamodel.cxx13
-rw-r--r--toolkit/source/controls/grid/sortablegriddatamodel.hxx5
5 files changed, 58 insertions, 3 deletions
diff --git a/toolkit/qa/complex/toolkit/GridControl.java b/toolkit/qa/complex/toolkit/GridControl.java
index b26fb704e0db..249ae8c1437e 100644
--- a/toolkit/qa/complex/toolkit/GridControl.java
+++ b/toolkit/qa/complex/toolkit/GridControl.java
@@ -326,6 +326,33 @@ public class GridControl
// -----------------------------------------------------------------------------------------------------------------
@Test
+ public void testDataModel() throws Exception
+ {
+ impl_recreateGridModel();
+
+ // ensure that getCellData and getRowData have the same opinion on the data they deliver
+ final Object[][] data = new Object[][] {
+ new Object[] { 15, 17, 0 },
+ new Object[] { 9, 8, 14 },
+ new Object[] { 17, 2, 16 },
+ new Object[] { 0, 7, 14 },
+ new Object[] { 10, 16, 16 },
+ };
+ m_dataModel.addRows( new Object[ data.length ], data );
+
+ for ( int row = 0; row < data.length; ++row )
+ {
+ assertArrayEquals( "getRowData delivers wrong data in row " + row, data[row], m_dataModel.getRowData( row ) );
+ for ( int col = 0; col < data[row].length; ++col )
+ {
+ assertEquals( "getCellData delivers wrong data at position (" + col + ", " + row + ")",
+ data[row][col], m_dataModel.getCellData( col, row ) );
+ }
+ }
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ @Test
public void testSortableDataModel() throws Exception
{
impl_recreateGridModel();
@@ -408,7 +435,7 @@ public class GridControl
final List< Object > disposables = new ArrayList< Object >();
try
{
- // create a siple dialog model/control/peer trinity
+ // create a simple dialog model/control/peer trinity
final XControlModel dialogModel = createInstance( XControlModel.class, "com.sun.star.awt.UnoControlDialogModel" );
disposables.add( dialogModel );
final XPropertySet dialogProps = UnoRuntime.queryInterface( XPropertySet.class, dialogModel );
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
index f89d2ca52096..d268b62ad50e 100644
--- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx
+++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
@@ -36,6 +36,7 @@
#include <rtl/ref.hxx>
#include <algorithm>
+#include <functional>
//......................................................................................................................
namespace toolkit
@@ -174,6 +175,18 @@ namespace toolkit
}
//------------------------------------------------------------------------------------------------------------------
+ Sequence< Any > SAL_CALL DefaultGridDataModel::getRowData( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+ {
+ ::comphelper::ComponentGuard aGuard( *this, rBHelper );
+
+ Sequence< Any > resultData( m_nColumnCount );
+ RowData& rRowData = impl_getRowDataAccess_throw( i_rowIndex, m_nColumnCount );
+
+ ::std::transform( rRowData.begin(), rRowData.end(), resultData.getArray(), ::std::select1st< CellData >() );
+ return resultData;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
void SAL_CALL DefaultGridDataModel::addRow( const Any& i_heading, const Sequence< Any >& i_data ) throw (RuntimeException)
{
::comphelper::ComponentGuard aGuard( *this, rBHelper );
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx
index b7fcf01c4f5b..c9c398ede17b 100644
--- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx
+++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx
@@ -82,6 +82,7 @@ public:
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);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getRowData( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
// OComponentHelper
virtual void SAL_CALL disposing();
diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx
index 4f4f60107692..e71d218caca0 100644
--- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx
+++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx
@@ -767,6 +767,19 @@ namespace toolkit
}
//------------------------------------------------------------------------------------------------------------------
+ Sequence< Any > SAL_CALL SortableGridDataModel::getRowData( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+ {
+ MethodGuard aGuard( *this, rBHelper );
+ DBG_CHECK_ME();
+
+ ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex );
+
+ Reference< XMutableGridDataModel > const delegator( m_delegator );
+ aGuard.clear();
+ return delegator->getRowData( rowIndex );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
void SAL_CALL SortableGridDataModel::disposing()
{
m_currentSortColumn = -1;
diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.hxx b/toolkit/source/controls/grid/sortablegriddatamodel.hxx
index f29d9f302649..c31aff72a300 100644
--- a/toolkit/source/controls/grid/sortablegriddatamodel.hxx
+++ b/toolkit/source/controls/grid/sortablegriddatamodel.hxx
@@ -97,9 +97,10 @@ namespace toolkit
// 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 getCellData( ::sal_Int32 Column, ::sal_Int32 RowIndex ) 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 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);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getRowData( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
// OComponentHelper
virtual void SAL_CALL disposing();