[Libreoffice-commits] .: offapi/com toolkit/qa toolkit/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 14 00:29:25 PDT 2012


 offapi/com/sun/star/awt/grid/XGridDataModel.idl        |   22 ++++++++++--
 toolkit/qa/complex/toolkit/GridControl.java            |   29 ++++++++++++++++-
 toolkit/source/controls/grid/defaultgriddatamodel.cxx  |   13 +++++++
 toolkit/source/controls/grid/defaultgriddatamodel.hxx  |    1 
 toolkit/source/controls/grid/sortablegriddatamodel.cxx |   13 +++++++
 toolkit/source/controls/grid/sortablegriddatamodel.hxx |    5 +-
 6 files changed, 76 insertions(+), 7 deletions(-)

New commits:
commit 5df47e4bb0c1217e0b49468aa7c2ca2eecf6dc07
Author: Frank Schoenheit [fs] <frank.schoenheit at oracle.com>
Date:   Tue Mar 22 13:00:39 2011 +0100

    gridfixes: #i117398# added XGridDataModel::getRowData
    
    Change-Id: Ic08c2d54a76f2a2821822ec4b275883e4445c70c
    Reviewed-on: https://gerrit.libreoffice.org/543
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/offapi/com/sun/star/awt/grid/XGridDataModel.idl b/offapi/com/sun/star/awt/grid/XGridDataModel.idl
index 4e733eb..90188e7 100644
--- a/offapi/com/sun/star/awt/grid/XGridDataModel.idl
+++ b/offapi/com/sun/star/awt/grid/XGridDataModel.idl
@@ -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 );
 };
 
 
diff --git a/toolkit/qa/complex/toolkit/GridControl.java b/toolkit/qa/complex/toolkit/GridControl.java
index b26fb70..249ae8c 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 f89d2ca..d268b62 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 b7fcf01..c9c398e 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 4f4f601..e71d218 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 f29d9f3..c31aff7 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();


More information about the Libreoffice-commits mailing list