Kaydet (Commit) 5df47e4b authored tarafından Frank Schoenheit [fs]'s avatar Frank Schoenheit [fs] Kaydeden (comit) Miklos Vajna

gridfixes: #i117398# added XGridDataModel::getRowData

Change-Id: Ic08c2d54a76f2a2821822ec4b275883e4445c70c
Reviewed-on: https://gerrit.libreoffice.org/543Reviewed-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
Tested-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
üst a5d4e780
......@@ -44,13 +44,13 @@ module com { module sun { module star { module awt { module grid {
@since OOo 3.3
*/
interface XGridDataModel
published interface XGridDataModel
{
/** implements life time control for the component
*/
interface ::com::sun::star::lang::XComponent;
/** allows cloning the complete column model
/** allows cloning the complete data model
*/
interface ::com::sun::star::util::XCloneable;
......@@ -67,7 +67,7 @@ interface XGridDataModel
@throws ::com::sun::star::lang::IndexOutOfBoundsException
if the column or row index do not denote a valid cell position.
*/
any getCellData( [in] long Column, [in] long Row )
any getCellData( [in] long Column, [in] long RowIndex )
raises ( ::com::sun::star::lang::IndexOutOfBoundsException );
/** retrieves the tool tip to be displayed when the mouse hovers over a given cell
......@@ -80,7 +80,7 @@ interface XGridDataModel
@throws ::com::sun::star::lang::IndexOutOfBoundsException
if the column or row index do not denote a valid cell position.
*/
any getCellToolTip( [in] long Column, [in] long Row )
any getCellToolTip( [in] long Column, [in] long RowIndex )
raises ( ::com::sun::star::lang::IndexOutOfBoundsException );
/** retrieves the heading of a given row
......@@ -95,6 +95,20 @@ interface XGridDataModel
any
getRowHeading( [in] long RowIndex )
raises ( ::com::sun::star::lang::IndexOutOfBoundsException );
/** retrieves the data for a complete row
<p>This method is provided for performance and convenience reasons, it delivers the same result
as subsequent calls to <member>getCellData</member> would.</p>
@param Row
the index of the row whose data should is to be retrieved.
@raises ::com::sun::star::lang::IndexOutOfBoundsException
of the given row index does not denote a valid row.
*/
sequence< any >
getRowData( [in] long RowIndex )
raises ( ::com::sun::star::lang::IndexOutOfBoundsException );
};
......
......@@ -324,6 +324,33 @@ public class GridControl
assertEquals( insertionIndex, newColumn.getIndex() );
}
// -----------------------------------------------------------------------------------------------------------------
@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
......@@ -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 );
......
......@@ -36,6 +36,7 @@
#include <rtl/ref.hxx>
#include <algorithm>
#include <functional>
//......................................................................................................................
namespace toolkit
......@@ -173,6 +174,18 @@ namespace toolkit
return m_aRowHeaders[ i_row ];
}
//------------------------------------------------------------------------------------------------------------------
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)
{
......
......@@ -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();
......
......@@ -766,6 +766,19 @@ namespace toolkit
return delegator->getRowHeading( rowIndex );
}
//------------------------------------------------------------------------------------------------------------------
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()
{
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment