LCOV - code coverage report
Current view: top level - toolkit/source/controls/grid - defaultgriddatamodel.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 1 191 0.5 %
Date: 2014-04-14 Functions: 2 37 5.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/awt/grid/XMutableGridDataModel.hpp>
      21             : #include <com/sun/star/lang/XServiceInfo.hpp>
      22             : #include <com/sun/star/uno/XComponentContext.hpp>
      23             : 
      24             : #include <comphelper/componentguard.hxx>
      25             : #include <cppuhelper/basemutex.hxx>
      26             : #include <cppuhelper/compbase2.hxx>
      27             : #include <cppuhelper/supportsservice.hxx>
      28             : #include <toolkit/helper/servicenames.hxx>
      29             : #include <tools/diagnose_ex.h>
      30             : #include <toolkit/helper/mutexandbroadcasthelper.hxx>
      31             : 
      32             : #include <algorithm>
      33             : #include <functional>
      34             : #include <vector>
      35             : #include <boost/bind.hpp>
      36             : 
      37             : using namespace ::com::sun::star;
      38             : using namespace ::com::sun::star::uno;
      39             : using namespace ::com::sun::star::awt;
      40             : using namespace ::com::sun::star::awt::grid;
      41             : using namespace ::com::sun::star::lang;
      42             : 
      43             : namespace {
      44             : 
      45             : enum broadcast_type { row_added, row_removed, data_changed};
      46             : 
      47             : typedef ::cppu::WeakComponentImplHelper2    <   XMutableGridDataModel
      48             :                                             ,   XServiceInfo
      49             :                                             >   DefaultGridDataModel_Base;
      50             : 
      51             : class DefaultGridDataModel  :public ::cppu::BaseMutex
      52             :                             ,public DefaultGridDataModel_Base
      53             : {
      54             : public:
      55             :     DefaultGridDataModel();
      56             :     DefaultGridDataModel( DefaultGridDataModel const & i_copySource );
      57             :     virtual ~DefaultGridDataModel();
      58             : 
      59             :     // XMutableGridDataModel
      60             :     virtual void SAL_CALL addRow( const Any& i_heading, const css::uno::Sequence< css::uno::Any >& Data ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      61             :     virtual void SAL_CALL addRows( const css::uno::Sequence< css::uno::Any>& Headings, const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& Data ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      62             :     virtual void SAL_CALL insertRow( ::sal_Int32 i_index, const css::uno::Any& i_heading, const css::uno::Sequence< css::uno::Any >& Data ) throw (css::uno::RuntimeException, css::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
      63             :     virtual void SAL_CALL insertRows( ::sal_Int32 i_index, const css::uno::Sequence< css::uno::Any>& Headings, const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& Data ) throw (css::lang::IllegalArgumentException, css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      64             :     virtual void SAL_CALL removeRow( ::sal_Int32 RowIndex ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      65             :     virtual void SAL_CALL removeAllRows(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      66             :     virtual void SAL_CALL updateCellData( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const css::uno::Any& Value ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      67             :     virtual void SAL_CALL updateRowData( const css::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const css::uno::Sequence< css::uno::Any >& Values ) throw (css::lang::IndexOutOfBoundsException, css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      68             :     virtual void SAL_CALL updateRowHeading( ::sal_Int32 RowIndex, const css::uno::Any& Heading ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      69             :     virtual void SAL_CALL updateCellToolTip( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const css::uno::Any& Value ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      70             :     virtual void SAL_CALL updateRowToolTip( ::sal_Int32 RowIndex, const css::uno::Any& Value ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      71             :     virtual void SAL_CALL addGridDataListener( const css::uno::Reference< css::awt::grid::XGridDataListener >& Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      72             :     virtual void SAL_CALL removeGridDataListener( const css::uno::Reference< css::awt::grid::XGridDataListener >& Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      73             : 
      74             :     // XGridDataModel
      75             :     virtual ::sal_Int32 SAL_CALL getRowCount() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      76             :     virtual ::sal_Int32 SAL_CALL getColumnCount() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      77             :     virtual css::uno::Any SAL_CALL getCellData( ::sal_Int32 Column, ::sal_Int32 Row ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      78             :     virtual css::uno::Any SAL_CALL getCellToolTip( ::sal_Int32 Column, ::sal_Int32 Row ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      79             :     virtual css::uno::Any SAL_CALL getRowHeading( ::sal_Int32 RowIndex ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      80             :     virtual css::uno::Sequence< css::uno::Any > SAL_CALL getRowData( ::sal_Int32 RowIndex ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      81             : 
      82             :     // OComponentHelper
      83             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
      84             : 
      85             :     // XCloneable
      86             :     virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone(  ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      87             : 
      88             :     // XServiceInfo
      89             :     virtual OUString SAL_CALL getImplementationName(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      90             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      91             :     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      92             : 
      93             : private:
      94             :     typedef ::std::pair< Any, Any >     CellData;
      95             :     typedef ::std::vector< CellData >   RowData;
      96             :     typedef ::std::vector< RowData >    GridData;
      97             : 
      98             :     void broadcast(
      99             :         GridDataEvent const & i_event,
     100             :         void ( SAL_CALL css::awt::grid::XGridDataListener::*i_listenerMethod )( css::awt::grid::GridDataEvent const & ),
     101             :         ::comphelper::ComponentGuard & i_instanceLock
     102             :     );
     103             : 
     104             :     void    impl_insertRow( sal_Int32 const i_position, Any const & i_heading, Sequence< Any > const & i_rowData, sal_Int32 const i_assumedColCount = -1 );
     105             : 
     106           0 :     ::sal_Int32 impl_getRowCount_nolck() const { return sal_Int32( m_aData.size() ); }
     107             : 
     108             :     CellData const &    impl_getCellData_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex ) const;
     109             :     CellData&           impl_getCellDataAccess_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex );
     110             :     RowData&            impl_getRowDataAccess_throw( sal_Int32 const i_rowIndex, size_t const i_requiredColumnCount );
     111             : 
     112             :     GridData m_aData;
     113             :     ::std::vector< css::uno::Any > m_aRowHeaders;
     114             :     sal_Int32 m_nColumnCount;
     115             : };
     116             : 
     117           0 :     DefaultGridDataModel::DefaultGridDataModel()
     118             :         :DefaultGridDataModel_Base( m_aMutex )
     119             :         ,m_aRowHeaders()
     120           0 :         ,m_nColumnCount(0)
     121             :     {
     122           0 :     }
     123             : 
     124             : 
     125           0 :     DefaultGridDataModel::DefaultGridDataModel( DefaultGridDataModel const & i_copySource )
     126             :         :cppu::BaseMutex()
     127             :         ,DefaultGridDataModel_Base( m_aMutex )
     128             :         ,m_aData( i_copySource.m_aData )
     129             :         ,m_aRowHeaders( i_copySource.m_aRowHeaders )
     130           0 :         ,m_nColumnCount( i_copySource.m_nColumnCount )
     131             :     {
     132           0 :     }
     133             : 
     134             : 
     135           0 :     DefaultGridDataModel::~DefaultGridDataModel()
     136             :     {
     137           0 :     }
     138             : 
     139             : 
     140           0 :     void DefaultGridDataModel::broadcast( GridDataEvent const & i_event,
     141             :         void ( SAL_CALL XGridDataListener::*i_listenerMethod )( GridDataEvent const & ), ::comphelper::ComponentGuard & i_instanceLock )
     142             :     {
     143           0 :         ::cppu::OInterfaceContainerHelper* pListeners = rBHelper.getContainer( cppu::UnoType<XGridDataListener>::get() );
     144           0 :         if ( !pListeners )
     145           0 :             return;
     146             : 
     147           0 :         i_instanceLock.clear();
     148           0 :         pListeners->notifyEach( i_listenerMethod, i_event );
     149             :     }
     150             : 
     151             : 
     152           0 :     ::sal_Int32 SAL_CALL DefaultGridDataModel::getRowCount() throw (::com::sun::star::uno::RuntimeException, std::exception)
     153             :     {
     154           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     155           0 :         return impl_getRowCount_nolck();
     156             :     }
     157             : 
     158             : 
     159           0 :     ::sal_Int32 SAL_CALL DefaultGridDataModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException, std::exception)
     160             :     {
     161           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     162           0 :         return m_nColumnCount;
     163             :     }
     164             : 
     165             : 
     166           0 :     DefaultGridDataModel::CellData const & DefaultGridDataModel::impl_getCellData_throw( sal_Int32 const i_column, sal_Int32 const i_row ) const
     167             :     {
     168           0 :         if  (   ( i_row < 0 ) || ( size_t( i_row ) > m_aData.size() )
     169           0 :             ||  ( i_column < 0 ) || ( i_column > m_nColumnCount )
     170             :             )
     171           0 :             throw IndexOutOfBoundsException( OUString(), *const_cast< DefaultGridDataModel* >( this ) );
     172             : 
     173           0 :         RowData const & rRow( m_aData[ i_row ] );
     174           0 :         if ( size_t( i_column ) < rRow.size() )
     175           0 :             return rRow[ i_column ];
     176             : 
     177           0 :         static CellData s_aEmpty;
     178           0 :         return s_aEmpty;
     179             :     }
     180             : 
     181             : 
     182           0 :     DefaultGridDataModel::RowData& DefaultGridDataModel::impl_getRowDataAccess_throw( sal_Int32 const i_rowIndex, size_t const i_requiredColumnCount )
     183             :     {
     184             :         OSL_ENSURE( i_requiredColumnCount <= size_t( m_nColumnCount ), "DefaultGridDataModel::impl_getRowDataAccess_throw: invalid column count!" );
     185           0 :         if  ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) )
     186           0 :             throw IndexOutOfBoundsException( OUString(), *this );
     187             : 
     188           0 :         RowData& rRowData( m_aData[ i_rowIndex ] );
     189           0 :         if ( rRowData.size() < i_requiredColumnCount )
     190           0 :             rRowData.resize( i_requiredColumnCount );
     191           0 :         return rRowData;
     192             :     }
     193             : 
     194             : 
     195           0 :     DefaultGridDataModel::CellData& DefaultGridDataModel::impl_getCellDataAccess_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex )
     196             :     {
     197           0 :         if  ( ( i_columnIndex < 0 ) || ( i_columnIndex >= m_nColumnCount ) )
     198           0 :             throw IndexOutOfBoundsException( OUString(), *this );
     199             : 
     200           0 :         RowData& rRowData( impl_getRowDataAccess_throw( i_rowIndex, size_t( i_columnIndex + 1 ) ) );
     201           0 :         return rRowData[ i_columnIndex ];
     202             :     }
     203             : 
     204             : 
     205           0 :     Any SAL_CALL DefaultGridDataModel::getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException, std::exception)
     206             :     {
     207           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     208           0 :         return impl_getCellData_throw( i_column, i_row ).first;
     209             :     }
     210             : 
     211             : 
     212           0 :     Any SAL_CALL DefaultGridDataModel::getCellToolTip( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException, std::exception)
     213             :     {
     214           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     215           0 :         return impl_getCellData_throw( i_column, i_row ).second;
     216             :     }
     217             : 
     218             : 
     219           0 :     Any SAL_CALL DefaultGridDataModel::getRowHeading( ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException, std::exception)
     220             :     {
     221           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     222             : 
     223           0 :         if ( ( i_row < 0 ) || ( size_t( i_row ) >= m_aRowHeaders.size() ) )
     224           0 :             throw IndexOutOfBoundsException( OUString(), *this );
     225             : 
     226           0 :         return m_aRowHeaders[ i_row ];
     227             :     }
     228             : 
     229             : 
     230           0 :     Sequence< Any > SAL_CALL DefaultGridDataModel::getRowData( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     231             :     {
     232           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     233             : 
     234           0 :         Sequence< Any > resultData( m_nColumnCount );
     235           0 :         RowData& rRowData = impl_getRowDataAccess_throw( i_rowIndex, m_nColumnCount );
     236             : 
     237             :         ::std::transform( rRowData.begin(), rRowData.end(), resultData.getArray(),
     238           0 :                           boost::bind(&CellData::first,_1));
     239           0 :         return resultData;
     240             :     }
     241             : 
     242             : 
     243           0 :     void DefaultGridDataModel::impl_insertRow( sal_Int32 const i_position, Any const & i_heading, Sequence< Any > const & i_rowData, sal_Int32 const i_assumedColCount )
     244             :     {
     245             :         OSL_PRECOND( ( i_assumedColCount <= 0 ) || ( i_assumedColCount >= i_rowData.getLength() ),
     246             :             "DefaultGridDataModel::impl_insertRow: invalid column count!" );
     247             : 
     248             :         // insert heading
     249           0 :         m_aRowHeaders.insert( m_aRowHeaders.begin() + i_position, i_heading );
     250             : 
     251             :         // create new data row
     252           0 :         RowData newRow( i_assumedColCount > 0 ? i_assumedColCount : i_rowData.getLength() );
     253           0 :         RowData::iterator cellData = newRow.begin();
     254           0 :         for ( const Any* pData = i_rowData.begin(); pData != i_rowData.end(); ++pData, ++cellData )
     255           0 :             cellData->first = *pData;
     256             : 
     257             :         // insert data row
     258           0 :         m_aData.insert( m_aData.begin() + i_position, newRow );
     259           0 :     }
     260             : 
     261             : 
     262           0 :     void SAL_CALL DefaultGridDataModel::addRow( const Any& i_heading, const Sequence< Any >& i_data ) throw (RuntimeException, std::exception)
     263             :     {
     264           0 :         insertRow( getRowCount(), i_heading, i_data );
     265           0 :     }
     266             : 
     267             : 
     268           0 :     void SAL_CALL DefaultGridDataModel::addRows( const Sequence< Any >& i_headings, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException, std::exception)
     269             :     {
     270           0 :         insertRows( getRowCount(), i_headings, i_data );
     271           0 :     }
     272             : 
     273             : 
     274           0 :     void SAL_CALL DefaultGridDataModel::insertRow( ::sal_Int32 i_index, const Any& i_heading, const Sequence< Any >& i_data ) throw (RuntimeException, IndexOutOfBoundsException, std::exception)
     275             :     {
     276           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     277             : 
     278           0 :         if ( ( i_index < 0 ) || ( i_index > impl_getRowCount_nolck() ) )
     279           0 :             throw IndexOutOfBoundsException( OUString(), *this );
     280             : 
     281             :         // actually insert the row
     282           0 :         impl_insertRow( i_index, i_heading, i_data );
     283             : 
     284             :         // update column count
     285           0 :         sal_Int32 const columnCount = i_data.getLength();
     286           0 :         if ( columnCount > m_nColumnCount )
     287           0 :             m_nColumnCount = columnCount;
     288             : 
     289             :         broadcast(
     290             :             GridDataEvent( *this, -1, -1, i_index, i_index ),
     291             :             &XGridDataListener::rowsInserted,
     292             :             aGuard
     293           0 :         );
     294           0 :     }
     295             : 
     296             : 
     297           0 :     void SAL_CALL DefaultGridDataModel::insertRows( ::sal_Int32 i_index, const Sequence< Any>& i_headings, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, IndexOutOfBoundsException, RuntimeException, std::exception)
     298             :     {
     299           0 :         if ( i_headings.getLength() != i_data.getLength() )
     300           0 :             throw IllegalArgumentException( OUString(), *this, -1 );
     301             : 
     302           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     303             : 
     304           0 :         if ( ( i_index < 0 ) || ( i_index > impl_getRowCount_nolck() ) )
     305           0 :             throw IndexOutOfBoundsException( OUString(), *this );
     306             : 
     307           0 :         sal_Int32 const rowCount = i_headings.getLength();
     308           0 :         if ( rowCount == 0 )
     309           0 :             return;
     310             : 
     311             :         // determine max col count in the new data
     312           0 :         sal_Int32 maxColCount = 0;
     313           0 :         for ( sal_Int32 row=0; row<rowCount; ++row )
     314           0 :             if ( i_data[row].getLength() > maxColCount )
     315           0 :                 maxColCount = i_data[row].getLength();
     316             : 
     317           0 :         if ( maxColCount < m_nColumnCount )
     318           0 :             maxColCount = m_nColumnCount;
     319             : 
     320           0 :         for ( sal_Int32 row=0; row<rowCount;  ++row )
     321             :         {
     322           0 :             impl_insertRow( i_index + row, i_headings[row], i_data[row], maxColCount );
     323             :         }
     324             : 
     325           0 :         if ( maxColCount > m_nColumnCount )
     326           0 :             m_nColumnCount = maxColCount;
     327             : 
     328             :         broadcast(
     329           0 :             GridDataEvent( *this, -1, -1, i_index, i_index + rowCount - 1 ),
     330             :             &XGridDataListener::rowsInserted,
     331             :             aGuard
     332           0 :         );
     333             :     }
     334             : 
     335             : 
     336           0 :     void SAL_CALL DefaultGridDataModel::removeRow( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     337             :     {
     338           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     339             : 
     340           0 :         if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) )
     341           0 :             throw IndexOutOfBoundsException( OUString(), *this );
     342             : 
     343           0 :         m_aRowHeaders.erase( m_aRowHeaders.begin() + i_rowIndex );
     344           0 :         m_aData.erase( m_aData.begin() + i_rowIndex );
     345             : 
     346             :         broadcast(
     347             :             GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ),
     348             :             &XGridDataListener::rowsRemoved,
     349             :             aGuard
     350           0 :         );
     351           0 :     }
     352             : 
     353             : 
     354           0 :     void SAL_CALL DefaultGridDataModel::removeAllRows(  ) throw (RuntimeException, std::exception)
     355             :     {
     356           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     357             : 
     358           0 :         m_aRowHeaders.clear();
     359           0 :         m_aData.clear();
     360             : 
     361             :         broadcast(
     362             :             GridDataEvent( *this, -1, -1, -1, -1 ),
     363             :             &XGridDataListener::rowsRemoved,
     364             :             aGuard
     365           0 :         );
     366           0 :     }
     367             : 
     368             : 
     369           0 :     void SAL_CALL DefaultGridDataModel::updateCellData( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     370             :     {
     371           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     372             : 
     373           0 :         impl_getCellDataAccess_throw( i_columnIndex, i_rowIndex ).first = i_value;
     374             : 
     375             :         broadcast(
     376             :             GridDataEvent( *this, i_columnIndex, i_columnIndex, i_rowIndex, i_rowIndex ),
     377             :             &XGridDataListener::dataChanged,
     378             :             aGuard
     379           0 :         );
     380           0 :     }
     381             : 
     382             : 
     383           0 :     void SAL_CALL DefaultGridDataModel::updateRowData( const Sequence< ::sal_Int32 >& i_columnIndexes, ::sal_Int32 i_rowIndex, const Sequence< Any >& i_values ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException, std::exception)
     384             :     {
     385           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     386             : 
     387           0 :         if  ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) )
     388           0 :             throw IndexOutOfBoundsException( OUString(), *this );
     389             : 
     390           0 :         if ( i_columnIndexes.getLength() != i_values.getLength() )
     391           0 :             throw IllegalArgumentException( OUString(), *this, 1 );
     392             : 
     393           0 :         sal_Int32 const columnCount = i_columnIndexes.getLength();
     394           0 :         if ( columnCount == 0 )
     395           0 :             return;
     396             : 
     397           0 :         for ( sal_Int32 col = 0; col < columnCount; ++col )
     398             :         {
     399           0 :             if ( ( i_columnIndexes[col] < 0 ) || ( i_columnIndexes[col] > m_nColumnCount ) )
     400           0 :                 throw IndexOutOfBoundsException( OUString(), *this );
     401             :         }
     402             : 
     403           0 :         RowData& rDataRow = m_aData[ i_rowIndex ];
     404           0 :         for ( sal_Int32 col = 0; col < columnCount; ++col )
     405             :         {
     406           0 :             sal_Int32 const columnIndex = i_columnIndexes[ col ];
     407           0 :             if ( size_t( columnIndex ) >= rDataRow.size() )
     408           0 :                 rDataRow.resize( columnIndex + 1 );
     409             : 
     410           0 :             rDataRow[ columnIndex ].first = i_values[ col ];
     411             :         }
     412             : 
     413           0 :         sal_Int32 const firstAffectedColumn = *::std::min_element( i_columnIndexes.begin(), i_columnIndexes.end() );
     414           0 :         sal_Int32 const lastAffectedColumn = *::std::max_element( i_columnIndexes.begin(), i_columnIndexes.end() );
     415             :         broadcast(
     416             :             GridDataEvent( *this, firstAffectedColumn, lastAffectedColumn, i_rowIndex, i_rowIndex ),
     417             :             &XGridDataListener::dataChanged,
     418             :             aGuard
     419           0 :         );
     420             :     }
     421             : 
     422             : 
     423           0 :     void SAL_CALL DefaultGridDataModel::updateRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     424             :     {
     425           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     426             : 
     427           0 :         if  ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aRowHeaders.size() ) )
     428           0 :             throw IndexOutOfBoundsException( OUString(), *this );
     429             : 
     430           0 :         m_aRowHeaders[ i_rowIndex ] = i_heading;
     431             : 
     432             :         broadcast(
     433             :             GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ),
     434             :             &XGridDataListener::rowHeadingChanged,
     435             :             aGuard
     436           0 :         );
     437           0 :     }
     438             : 
     439             : 
     440           0 :     void SAL_CALL DefaultGridDataModel::updateCellToolTip( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     441             :     {
     442           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     443           0 :         impl_getCellDataAccess_throw( i_columnIndex, i_rowIndex ).second = i_value;
     444           0 :     }
     445             : 
     446             : 
     447           0 :     void SAL_CALL DefaultGridDataModel::updateRowToolTip( ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     448             :     {
     449           0 :         ::comphelper::ComponentGuard aGuard( *this, rBHelper );
     450             : 
     451           0 :         RowData& rRowData = impl_getRowDataAccess_throw( i_rowIndex, m_nColumnCount );
     452           0 :         for ( RowData::iterator cell = rRowData.begin(); cell != rRowData.end(); ++cell )
     453           0 :             cell->second = i_value;
     454           0 :     }
     455             : 
     456             : 
     457           0 :     void SAL_CALL DefaultGridDataModel::addGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException, std::exception)
     458             :     {
     459           0 :         rBHelper.addListener( cppu::UnoType<XGridDataListener>::get(), i_listener );
     460           0 :     }
     461             : 
     462             : 
     463           0 :     void SAL_CALL DefaultGridDataModel::removeGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException, std::exception)
     464             :     {
     465           0 :         rBHelper.removeListener( cppu::UnoType<XGridDataListener>::get(), i_listener );
     466           0 :     }
     467             : 
     468             : 
     469           0 :     void SAL_CALL DefaultGridDataModel::disposing()
     470             :     {
     471           0 :         ::com::sun::star::lang::EventObject aEvent;
     472           0 :         aEvent.Source.set( *this );
     473           0 :         rBHelper.aLC.disposeAndClear( aEvent );
     474             : 
     475           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     476           0 :         GridData aEmptyData;
     477           0 :         m_aData.swap( aEmptyData );
     478             : 
     479           0 :         ::std::vector< Any > aEmptyRowHeaders;
     480           0 :         m_aRowHeaders.swap( aEmptyRowHeaders );
     481             : 
     482           0 :         m_nColumnCount = 0;
     483           0 :     }
     484             : 
     485             : 
     486           0 :     OUString SAL_CALL DefaultGridDataModel::getImplementationName(  ) throw (RuntimeException, std::exception)
     487             :     {
     488           0 :         return OUString("stardiv.Toolkit.DefaultGridDataModel");
     489             :     }
     490             : 
     491           0 :     sal_Bool SAL_CALL DefaultGridDataModel::supportsService( const OUString& ServiceName ) throw (RuntimeException, std::exception)
     492             :     {
     493           0 :         return cppu::supportsService(this, ServiceName);
     494             :     }
     495             : 
     496           0 :     Sequence< OUString > SAL_CALL DefaultGridDataModel::getSupportedServiceNames(  ) throw (RuntimeException, std::exception)
     497             :     {
     498           0 :         static const OUString aServiceName("com.sun.star.awt.grid.DefaultGridDataModel");
     499           0 :         static const Sequence< OUString > aSeq( &aServiceName, 1 );
     500           0 :         return aSeq;
     501             :     }
     502             : 
     503             : 
     504           0 :     Reference< css::util::XCloneable > SAL_CALL DefaultGridDataModel::createClone(  ) throw (RuntimeException, std::exception)
     505             :     {
     506           0 :         return new DefaultGridDataModel( *this );
     507             :     }
     508             : 
     509             : }
     510             : 
     511             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     512           0 : stardiv_Toolkit_DefaultGridDataModel_get_implementation(
     513             :     css::uno::XComponentContext *,
     514             :     css::uno::Sequence<css::uno::Any> const &)
     515             : {
     516           0 :     return cppu::acquire(new DefaultGridDataModel());
     517           3 : }
     518             : 
     519             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10