LCOV - code coverage report
Current view: top level - svtools/source/uno - unocontroltablemodel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 294 0.0 %
Date: 2012-08-25 Functions: 0 65 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 426 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "unocontroltablemodel.hxx"
      30                 :            : #include "unogridcolumnfacade.hxx"
      31                 :            : 
      32                 :            : #include "svtools/table/defaultinputhandler.hxx"
      33                 :            : #include "svtools/table/gridtablerenderer.hxx"
      34                 :            : #include "svtools/table/tablecontrol.hxx"
      35                 :            : 
      36                 :            : #include <com/sun/star/awt/grid/XGridColumn.hpp>
      37                 :            : #include <com/sun/star/view/SelectionType.hpp>
      38                 :            : #include <com/sun/star/awt/grid/XGridColumnListener.hpp>
      39                 :            : #include <com/sun/star/awt/grid/XSortableGridData.hpp>
      40                 :            : 
      41                 :            : #include <comphelper/stlunosequence.hxx>
      42                 :            : #include <cppuhelper/weakref.hxx>
      43                 :            : #include <tools/debug.hxx>
      44                 :            : #include <tools/diagnose_ex.h>
      45                 :            : #include <vcl/svapp.hxx>
      46                 :            : #include <osl/mutex.hxx>
      47                 :            : 
      48                 :            : // .....................................................................................................................
      49                 :            : namespace svt { namespace table
      50                 :            : {
      51                 :            : // .....................................................................................................................
      52                 :            : 
      53                 :            :     /** === begin UNO using === **/
      54                 :            :     using ::com::sun::star::uno::Reference;
      55                 :            :     using ::com::sun::star::uno::RuntimeException;
      56                 :            :     using ::com::sun::star::uno::Sequence;
      57                 :            :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      58                 :            :     using ::com::sun::star::uno::UNO_QUERY;
      59                 :            :     using ::com::sun::star::awt::grid::XGridColumn;
      60                 :            :     using ::com::sun::star::uno::XInterface;
      61                 :            :     using ::com::sun::star::uno::Exception;
      62                 :            :     using ::com::sun::star::awt::grid::XGridColumnListener;
      63                 :            :     using ::com::sun::star::lang::EventObject;
      64                 :            :     using ::com::sun::star::awt::grid::GridColumnEvent;
      65                 :            :     using ::com::sun::star::awt::grid::XGridDataModel;
      66                 :            :     using ::com::sun::star::awt::grid::XGridColumnModel;
      67                 :            :     using ::com::sun::star::uno::Any;
      68                 :            :     using ::com::sun::star::style::HorizontalAlignment_LEFT;
      69                 :            :     using ::com::sun::star::style::HorizontalAlignment;
      70                 :            :     using ::com::sun::star::style::VerticalAlignment_TOP;
      71                 :            :     using ::com::sun::star::style::VerticalAlignment;
      72                 :            :     using ::com::sun::star::uno::WeakReference;
      73                 :            :     using ::com::sun::star::awt::grid::GridDataEvent;
      74                 :            :     using ::com::sun::star::awt::grid::XSortableGridData;
      75                 :            :     using ::com::sun::star::beans::Pair;
      76                 :            :     /** === end UNO using === **/
      77                 :            : 
      78                 :            :     //==================================================================================================================
      79                 :            :     //= UnoControlTableModel_Impl
      80                 :            :     //==================================================================================================================
      81                 :            :     typedef ::std::vector< PTableModelListener >    ModellListeners;
      82                 :            :     typedef ::std::vector< PColumnModel >           ColumnModels;
      83 [ #  # ][ #  # ]:          0 :     struct UnoControlTableModel_Impl
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      84                 :            :     {
      85                 :            :         ColumnModels                                    aColumns;
      86                 :            :         bool                                            bHasColumnHeaders;
      87                 :            :         bool                                            bHasRowHeaders;
      88                 :            :         ScrollbarVisibility                             eVScrollMode;
      89                 :            :         ScrollbarVisibility                             eHScrollMode;
      90                 :            :         PTableRenderer                                  pRenderer;
      91                 :            :         PTableInputHandler                              pInputHandler;
      92                 :            :         TableMetrics                                    nRowHeight;
      93                 :            :         TableMetrics                                    nColumnHeaderHeight;
      94                 :            :         TableMetrics                                    nRowHeaderWidth;
      95                 :            :         ::boost::optional< ::Color >                    m_aGridLineColor;
      96                 :            :         ::boost::optional< ::Color >                    m_aHeaderBackgroundColor;
      97                 :            :         ::boost::optional< ::Color >                    m_aHeaderTextColor;
      98                 :            :         ::boost::optional< ::Color >                    m_aTextColor;
      99                 :            :         ::boost::optional< ::Color >                    m_aTextLineColor;
     100                 :            :         ::boost::optional< ::std::vector< ::Color > >   m_aRowColors;
     101                 :            :         VerticalAlignment                               m_eVerticalAlign;
     102                 :            :         ModellListeners                                 m_aListeners;
     103                 :            :         WeakReference< XGridDataModel >                 m_aDataModel;
     104                 :            :         WeakReference< XGridColumnModel >               m_aColumnModel;
     105                 :            : 
     106                 :          0 :         UnoControlTableModel_Impl()
     107                 :            :             :aColumns                   ( )
     108                 :            :             ,bHasColumnHeaders          ( true      )
     109                 :            :             ,bHasRowHeaders             ( false     )
     110                 :            :             ,eVScrollMode               ( ScrollbarShowNever )
     111                 :            :             ,eHScrollMode               ( ScrollbarShowNever )
     112                 :            :             ,pRenderer                  ( )
     113                 :            :             ,pInputHandler              ( )
     114                 :            :             ,nRowHeight                 ( 10 )
     115                 :            :             ,nColumnHeaderHeight        ( 10 )
     116                 :            :             ,nRowHeaderWidth            ( 10 )
     117                 :            :             ,m_aGridLineColor           ( )
     118                 :            :             ,m_aHeaderBackgroundColor   ( )
     119                 :            :             ,m_aHeaderTextColor         ( )
     120                 :            :             ,m_aTextColor               ( )
     121                 :            :             ,m_aTextLineColor           ( )
     122                 :            :             ,m_aRowColors               ( )
     123 [ #  # ][ #  # ]:          0 :             ,m_eVerticalAlign           ( VerticalAlignment_TOP )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     124                 :            :         {
     125                 :          0 :         }
     126                 :            :     };
     127                 :            : 
     128                 :            :     //==================================================================================================================
     129                 :            :     //= UnoControlTableModel
     130                 :            :     //==================================================================================================================
     131                 :            : #ifdef DBG_UTIL
     132                 :            :     const char* UnoControlTableModel_checkInvariants( const void* _pInstance )
     133                 :            :     {
     134                 :            :         return static_cast< const UnoControlTableModel* >( _pInstance )->checkInvariants();
     135                 :            :     }
     136                 :            : 
     137                 :            :     //------------------------------------------------------------------------------------------------------------------
     138                 :            :     const char* UnoControlTableModel::checkInvariants() const
     139                 :            :     {
     140                 :            :         Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
     141                 :            :         if ( !xDataModel.is() )
     142                 :            :             return "data model anymore";
     143                 :            : 
     144                 :            :         // TODO: more?
     145                 :            : 
     146                 :            :         return NULL;
     147                 :            :     }
     148                 :            : #endif
     149                 :            : 
     150                 :            : #define DBG_CHECK_ME() \
     151                 :            :     DBG_TESTSOLARMUTEX(); \
     152                 :            :     DBG_CHKTHIS( UnoControlTableModel, UnoControlTableModel_checkInvariants )
     153                 :            : 
     154                 :            :     //------------------------------------------------------------------------------------------------------------------
     155                 :            :     DBG_NAME( UnoControlTableModel )
     156                 :          0 :     UnoControlTableModel::UnoControlTableModel()
     157 [ #  # ][ #  # ]:          0 :         :m_pImpl( new UnoControlTableModel_Impl )
     158                 :            :     {
     159                 :            :         DBG_CTOR( UnoControlTableModel, UnoControlTableModel_checkInvariants );
     160                 :          0 :         m_pImpl->bHasColumnHeaders = true;
     161                 :          0 :         m_pImpl->bHasRowHeaders = false;
     162 [ #  # ][ #  # ]:          0 :         m_pImpl->pRenderer.reset( new GridTableRenderer( *this ) );
                 [ #  # ]
     163 [ #  # ][ #  # ]:          0 :         m_pImpl->pInputHandler.reset( new DefaultInputHandler );
                 [ #  # ]
     164                 :          0 :     }
     165                 :            : 
     166                 :            :     //------------------------------------------------------------------------------------------------------------------
     167                 :          0 :     UnoControlTableModel::~UnoControlTableModel()
     168                 :            :     {
     169                 :            :         DBG_DTOR( UnoControlTableModel, UnoControlTableModel_checkInvariants );
     170 [ #  # ][ #  # ]:          0 :         DELETEZ( m_pImpl );
     171         [ #  # ]:          0 :     }
     172                 :            : 
     173                 :            :     //------------------------------------------------------------------------------------------------------------------
     174                 :          0 :     TableSize UnoControlTableModel::getColumnCount() const
     175                 :            :     {
     176                 :            :         DBG_CHECK_ME();
     177                 :          0 :         return (TableSize)m_pImpl->aColumns.size();
     178                 :            :     }
     179                 :            : 
     180                 :            :     //------------------------------------------------------------------------------------------------------------------
     181                 :          0 :     TableSize UnoControlTableModel::getRowCount() const
     182                 :            :     {
     183                 :            :         DBG_CHECK_ME();
     184                 :            : 
     185                 :          0 :         TableSize nRowCount = 0;
     186                 :            :         try
     187                 :            :         {
     188         [ #  # ]:          0 :             Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
     189 [ #  # ][ #  # ]:          0 :             ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" );
         [ #  # ][ #  # ]
     190 [ #  # ][ #  # ]:          0 :             nRowCount = xDataModel->getRowCount();
                 [ #  # ]
     191                 :            :         }
     192                 :          0 :         catch( const Exception& )
     193                 :            :         {
     194                 :            :             DBG_UNHANDLED_EXCEPTION();
     195                 :            :         }
     196                 :          0 :         return nRowCount;
     197                 :            :     }
     198                 :            : 
     199                 :            :     //------------------------------------------------------------------------------------------------------------------
     200                 :          0 :     bool UnoControlTableModel::hasColumnHeaders() const
     201                 :            :     {
     202                 :            :         DBG_CHECK_ME();
     203                 :          0 :         return m_pImpl->bHasColumnHeaders;
     204                 :            :     }
     205                 :            : 
     206                 :            :     //------------------------------------------------------------------------------------------------------------------
     207                 :          0 :     bool UnoControlTableModel::hasRowHeaders() const
     208                 :            :     {
     209                 :            :         DBG_CHECK_ME();
     210                 :          0 :         return m_pImpl->bHasRowHeaders;
     211                 :            :     }
     212                 :            : 
     213                 :            :     //------------------------------------------------------------------------------------------------------------------
     214                 :          0 :     void UnoControlTableModel::setRowHeaders(bool _bRowHeaders)
     215                 :            :     {
     216                 :            :         DBG_CHECK_ME();
     217         [ #  # ]:          0 :         if ( m_pImpl->bHasRowHeaders == _bRowHeaders )
     218                 :          0 :             return;
     219                 :            : 
     220                 :          0 :         m_pImpl->bHasRowHeaders = _bRowHeaders;
     221                 :          0 :         impl_notifyTableMetricsChanged();
     222                 :            :     }
     223                 :            : 
     224                 :            :     //------------------------------------------------------------------------------------------------------------------
     225                 :          0 :     void UnoControlTableModel::setColumnHeaders(bool _bColumnHeaders)
     226                 :            :     {
     227                 :            :         DBG_CHECK_ME();
     228         [ #  # ]:          0 :         if ( m_pImpl->bHasColumnHeaders == _bColumnHeaders )
     229                 :          0 :             return;
     230                 :            : 
     231                 :          0 :         m_pImpl->bHasColumnHeaders = _bColumnHeaders;
     232                 :          0 :         impl_notifyTableMetricsChanged();
     233                 :            :     }
     234                 :            : 
     235                 :            :     //------------------------------------------------------------------------------------------------------------------
     236                 :          0 :     bool UnoControlTableModel::isCellEditable( ColPos col, RowPos row ) const
     237                 :            :     {
     238                 :            :         DBG_CHECK_ME();
     239                 :            :         (void)col;
     240                 :            :         (void)row;
     241                 :          0 :         return false;
     242                 :            :     }
     243                 :            : 
     244                 :            :     //------------------------------------------------------------------------------------------------------------------
     245                 :          0 :     PColumnModel UnoControlTableModel::getColumnModel( ColPos column )
     246                 :            :     {
     247                 :            :         DBG_CHECK_ME();
     248 [ #  # ][ #  # ]:          0 :         ENSURE_OR_RETURN( ( column >= 0 ) && ( column < getColumnCount() ),
                 [ #  # ]
     249                 :            :             "DefaultTableModel::getColumnModel: invalid index!", PColumnModel() );
     250                 :          0 :         return m_pImpl->aColumns[ column ];
     251                 :            :     }
     252                 :            : 
     253                 :            :     //------------------------------------------------------------------------------------------------------------------
     254                 :          0 :     void UnoControlTableModel::appendColumn( Reference< XGridColumn > const & i_column )
     255                 :            :     {
     256                 :            :         DBG_CHECK_ME();
     257                 :          0 :         insertColumn( m_pImpl->aColumns.size(), i_column );
     258                 :          0 :     }
     259                 :            : 
     260                 :            :     //------------------------------------------------------------------------------------------------------------------
     261                 :          0 :     void UnoControlTableModel::insertColumn( ColPos const i_position, Reference< XGridColumn > const & i_column )
     262                 :            :     {
     263                 :            :         DBG_CHECK_ME();
     264 [ #  # ][ #  # ]:          0 :         ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ),
                 [ #  # ]
     265                 :            :             "UnoControlTableModel::insertColumn: illegal position!" );
     266                 :            : 
     267 [ #  # ][ #  # ]:          0 :         const PColumnModel pColumn( new UnoGridColumnFacade( *this, i_column ) );
                 [ #  # ]
     268 [ #  # ][ #  # ]:          0 :         m_pImpl->aColumns.insert( m_pImpl->aColumns.begin() + i_position, pColumn );
     269                 :            : 
     270                 :            :         // notify listeners
     271         [ #  # ]:          0 :         ModellListeners aListeners( m_pImpl->m_aListeners );
     272 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::const_iterator loop = aListeners.begin();
                 [ #  # ]
     273                 :          0 :                 loop != aListeners.end();
     274                 :            :                 ++loop
     275                 :            :             )
     276                 :            :         {
     277         [ #  # ]:          0 :             (*loop)->columnInserted( i_position );
     278         [ #  # ]:          0 :         }
     279                 :            :     }
     280                 :            : 
     281                 :            :     //------------------------------------------------------------------------------------------------------------------
     282                 :          0 :     void UnoControlTableModel::removeColumn( ColPos const i_position )
     283                 :            :     {
     284                 :            :         DBG_CHECK_ME();
     285 [ #  # ][ #  # ]:          0 :         ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ),
                 [ #  # ]
     286                 :            :             "UnoControlTableModel::removeColumn: illegal position!" );
     287                 :            : 
     288                 :            :         // remove the column
     289         [ #  # ]:          0 :         ColumnModels::iterator pos = m_pImpl->aColumns.begin() + i_position;
     290         [ #  # ]:          0 :         const PColumnModel pColumn = *pos;
     291         [ #  # ]:          0 :         m_pImpl->aColumns.erase( pos );
     292                 :            : 
     293                 :            :         // notify listeners
     294         [ #  # ]:          0 :         ModellListeners aListeners( m_pImpl->m_aListeners );
     295 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::const_iterator loop = aListeners.begin();
                 [ #  # ]
     296                 :          0 :                 loop != aListeners.end();
     297                 :            :                 ++loop
     298                 :            :             )
     299                 :            :         {
     300         [ #  # ]:          0 :             (*loop)->columnRemoved( i_position );
     301                 :            :         }
     302                 :            : 
     303                 :            :         // dispose the column
     304         [ #  # ]:          0 :         UnoGridColumnFacade* pColumnImpl = dynamic_cast< UnoGridColumnFacade* >( pColumn.get() );
     305                 :            :         OSL_ENSURE( pColumnImpl != NULL, "UnoControlTableModel::removeColumn: illegal column implementation!" );
     306         [ #  # ]:          0 :         if ( pColumnImpl )
     307 [ #  # ][ #  # ]:          0 :             pColumnImpl->dispose();
     308                 :            :     }
     309                 :            : 
     310                 :            :     //------------------------------------------------------------------------------------------------------------------
     311                 :          0 :     void UnoControlTableModel::removeAllColumns()
     312                 :            :     {
     313                 :            :         DBG_CHECK_ME();
     314         [ #  # ]:          0 :         if ( m_pImpl->aColumns.empty() )
     315                 :          0 :             return;
     316                 :            : 
     317                 :            :         // dispose the column instances
     318 [ #  # ][ #  # ]:          0 :         for (   ColumnModels::const_iterator col = m_pImpl->aColumns.begin();
                 [ #  # ]
     319                 :          0 :                 col != m_pImpl->aColumns.end();
     320                 :            :                 ++col
     321                 :            :             )
     322                 :            :         {
     323         [ #  # ]:          0 :             UnoGridColumnFacade* pColumn = dynamic_cast< UnoGridColumnFacade* >( col->get() );
     324         [ #  # ]:          0 :             if ( !pColumn )
     325                 :            :             {
     326                 :            :                 SAL_WARN( "svtools.uno", "UnoControlTableModel::removeAllColumns: illegal column implementation!" );
     327                 :          0 :                 continue;
     328                 :            :             }
     329                 :            : 
     330         [ #  # ]:          0 :             pColumn->dispose();
     331                 :            :         }
     332                 :          0 :         m_pImpl->aColumns.clear();
     333                 :            : 
     334                 :            :         // notify listeners
     335         [ #  # ]:          0 :         ModellListeners aListeners( m_pImpl->m_aListeners );
     336 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::const_iterator loop = aListeners.begin();
                 [ #  # ]
     337                 :          0 :                 loop != aListeners.end();
     338                 :            :                 ++loop
     339                 :            :             )
     340                 :            :         {
     341         [ #  # ]:          0 :             (*loop)->allColumnsRemoved();
     342                 :          0 :         }
     343                 :            :     }
     344                 :            : 
     345                 :            :     //------------------------------------------------------------------------------------------------------------------
     346                 :          0 :     void UnoControlTableModel::impl_notifyTableMetricsChanged() const
     347                 :            :     {
     348         [ #  # ]:          0 :         ModellListeners aListeners( m_pImpl->m_aListeners );
     349 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::const_iterator loop = aListeners.begin();
                 [ #  # ]
     350                 :          0 :                 loop != aListeners.end();
     351                 :            :                 ++loop
     352                 :            :             )
     353                 :            :         {
     354         [ #  # ]:          0 :             (*loop)->tableMetricsChanged();
     355                 :          0 :         }
     356                 :          0 :     }
     357                 :            : 
     358                 :            :     //------------------------------------------------------------------------------------------------------------------
     359                 :          0 :     PTableRenderer UnoControlTableModel::getRenderer() const
     360                 :            :     {
     361                 :            :         DBG_CHECK_ME();
     362                 :          0 :         return m_pImpl->pRenderer;
     363                 :            :     }
     364                 :            : 
     365                 :            :     //------------------------------------------------------------------------------------------------------------------
     366                 :          0 :     PTableInputHandler UnoControlTableModel::getInputHandler() const
     367                 :            :     {
     368                 :            :         DBG_CHECK_ME();
     369                 :          0 :         return m_pImpl->pInputHandler;
     370                 :            :     }
     371                 :            : 
     372                 :            :     //------------------------------------------------------------------------------------------------------------------
     373                 :          0 :     TableMetrics UnoControlTableModel::getRowHeight() const
     374                 :            :     {
     375                 :            :         DBG_CHECK_ME();
     376                 :          0 :         return m_pImpl->nRowHeight;
     377                 :            :     }
     378                 :            : 
     379                 :            :     //------------------------------------------------------------------------------------------------------------------
     380                 :          0 :     void UnoControlTableModel::setRowHeight(TableMetrics _nRowHeight)
     381                 :            :     {
     382                 :            :         DBG_CHECK_ME();
     383         [ #  # ]:          0 :         if ( m_pImpl->nRowHeight == _nRowHeight )
     384                 :          0 :             return;
     385                 :            : 
     386                 :          0 :         m_pImpl->nRowHeight = _nRowHeight;
     387                 :          0 :         impl_notifyTableMetricsChanged();
     388                 :            :     }
     389                 :            : 
     390                 :            :     //------------------------------------------------------------------------------------------------------------------
     391                 :          0 :     TableMetrics UnoControlTableModel::getColumnHeaderHeight() const
     392                 :            :     {
     393                 :            :         DBG_CHECK_ME();
     394                 :            :         DBG_ASSERT( hasColumnHeaders(), "DefaultTableModel::getColumnHeaderHeight: invalid call!" );
     395                 :          0 :         return m_pImpl->nColumnHeaderHeight;
     396                 :            :     }
     397                 :            : 
     398                 :            :     //------------------------------------------------------------------------------------------------------------------
     399                 :          0 :     TableMetrics UnoControlTableModel::getRowHeaderWidth() const
     400                 :            :     {
     401                 :            :         DBG_CHECK_ME();
     402                 :            :         DBG_ASSERT( hasRowHeaders(), "DefaultTableModel::getRowHeaderWidth: invalid call!" );
     403                 :          0 :         return m_pImpl->nRowHeaderWidth;
     404                 :            :     }
     405                 :            :     //------------------------------------------------------------------------------------------------------------------
     406                 :          0 :     void UnoControlTableModel::setColumnHeaderHeight(TableMetrics _nHeight)
     407                 :            :     {
     408                 :            :         DBG_CHECK_ME();
     409         [ #  # ]:          0 :         if ( m_pImpl->nColumnHeaderHeight == _nHeight )
     410                 :          0 :             return;
     411                 :            : 
     412                 :          0 :         m_pImpl->nColumnHeaderHeight = _nHeight;
     413                 :          0 :         impl_notifyTableMetricsChanged();
     414                 :            :     }
     415                 :            : 
     416                 :            :     //------------------------------------------------------------------------------------------------------------------
     417                 :          0 :     void UnoControlTableModel::setRowHeaderWidth(TableMetrics _nWidth)
     418                 :            :     {
     419                 :            :         DBG_CHECK_ME();
     420         [ #  # ]:          0 :         if ( m_pImpl->nRowHeaderWidth == _nWidth )
     421                 :          0 :             return;
     422                 :            : 
     423                 :          0 :         m_pImpl->nRowHeaderWidth = _nWidth;
     424                 :          0 :         impl_notifyTableMetricsChanged();
     425                 :            :     }
     426                 :            : 
     427                 :            :     //------------------------------------------------------------------------------------------------------------------
     428                 :          0 :     ScrollbarVisibility UnoControlTableModel::getVerticalScrollbarVisibility() const
     429                 :            :     {
     430                 :            :         DBG_CHECK_ME();
     431                 :          0 :         return m_pImpl->eVScrollMode;
     432                 :            :     }
     433                 :            : 
     434                 :            :     //------------------------------------------------------------------------------------------------------------------
     435                 :          0 :     ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility() const
     436                 :            :     {
     437                 :            :         DBG_CHECK_ME();
     438                 :          0 :         return m_pImpl->eHScrollMode;
     439                 :            :     }
     440                 :            : 
     441                 :            :     //------------------------------------------------------------------------------------------------------------------
     442                 :          0 :     void UnoControlTableModel::addTableModelListener( const PTableModelListener& i_listener )
     443                 :            :     {
     444                 :            :         DBG_CHECK_ME();
     445         [ #  # ]:          0 :         ENSURE_OR_RETURN_VOID( !!i_listener, "illegal NULL listener" );
     446                 :          0 :         m_pImpl->m_aListeners.push_back( i_listener );
     447                 :            :     }
     448                 :            : 
     449                 :            :     //------------------------------------------------------------------------------------------------------------------
     450                 :          0 :     void UnoControlTableModel::removeTableModelListener( const PTableModelListener& i_listener )
     451                 :            :     {
     452                 :            :         DBG_CHECK_ME();
     453 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::iterator lookup = m_pImpl->m_aListeners.begin();
     454                 :          0 :                 lookup != m_pImpl->m_aListeners.end();
     455                 :            :                 ++lookup
     456                 :            :             )
     457                 :            :         {
     458 [ #  # ][ #  # ]:          0 :             if ( *lookup == i_listener )
     459                 :            :             {
     460         [ #  # ]:          0 :                 m_pImpl->m_aListeners.erase( lookup );
     461                 :          0 :                 return;
     462                 :            :             }
     463                 :            :         }
     464                 :            :         OSL_ENSURE( false, "UnoControlTableModel::removeTableModelListener: listener is not registered - sure you're doing the right thing here?" );
     465                 :            :     }
     466                 :            : 
     467                 :            :     //------------------------------------------------------------------------------------------------------------------
     468                 :          0 :     void UnoControlTableModel::setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const
     469                 :            :     {
     470                 :            :         DBG_CHECK_ME();
     471                 :          0 :         m_pImpl->eVScrollMode = i_visibility;
     472                 :          0 :     }
     473                 :            : 
     474                 :            :     //------------------------------------------------------------------------------------------------------------------
     475                 :          0 :     void UnoControlTableModel::setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const
     476                 :            :     {
     477                 :            :         DBG_CHECK_ME();
     478                 :          0 :         m_pImpl->eHScrollMode = i_visibility;
     479                 :          0 :     }
     480                 :            : 
     481                 :            :     //------------------------------------------------------------------------------------------------------------------
     482                 :          0 :     void UnoControlTableModel::setDataModel( Reference< XGridDataModel > const & i_gridDataModel )
     483                 :            :     {
     484                 :            :         DBG_CHECK_ME();
     485                 :          0 :         m_pImpl->m_aDataModel = i_gridDataModel;
     486                 :            :         // TODO: register as listener, so we're notified of row/data changes, and can multiplex them to our
     487                 :            :         // own listeners
     488                 :          0 :     }
     489                 :            : 
     490                 :            :     //------------------------------------------------------------------------------------------------------------------
     491                 :          0 :     Reference< XGridDataModel > UnoControlTableModel::getDataModel() const
     492                 :            :     {
     493                 :          0 :         Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
     494                 :          0 :         return xDataModel;
     495                 :            :     }
     496                 :            : 
     497                 :            :     //------------------------------------------------------------------------------------------------------------------
     498                 :          0 :     bool UnoControlTableModel::hasDataModel() const
     499                 :            :     {
     500                 :          0 :         return getDataModel().is();
     501                 :            :     }
     502                 :            : 
     503                 :            :     //------------------------------------------------------------------------------------------------------------------
     504                 :          0 :     void UnoControlTableModel::setColumnModel( Reference< XGridColumnModel > const & i_gridColumnModel )
     505                 :            :     {
     506                 :            :         DBG_CHECK_ME();
     507                 :          0 :         m_pImpl->m_aColumnModel = i_gridColumnModel;
     508                 :          0 :     }
     509                 :            : 
     510                 :            :     //------------------------------------------------------------------------------------------------------------------
     511                 :          0 :     Reference< XGridColumnModel > UnoControlTableModel::getColumnModel() const
     512                 :            :     {
     513                 :          0 :         Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel );
     514                 :          0 :         return xColumnModel;
     515                 :            :     }
     516                 :            : 
     517                 :            :     //------------------------------------------------------------------------------------------------------------------
     518                 :          0 :     bool UnoControlTableModel::hasColumnModel() const
     519                 :            :     {
     520                 :          0 :         return getColumnModel().is();
     521                 :            :     }
     522                 :            : 
     523                 :            :     //------------------------------------------------------------------------------------------------------------------
     524                 :          0 :     void UnoControlTableModel::getCellContent( ColPos const i_col, RowPos const i_row, Any& o_cellContent )
     525                 :            :     {
     526                 :            :         DBG_CHECK_ME();
     527                 :            : 
     528                 :          0 :         o_cellContent.clear();
     529                 :            :         try
     530                 :            :         {
     531         [ #  # ]:          0 :             Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
     532         [ #  # ]:          0 :             ENSURE_OR_RETURN_VOID( xDataModel.is(), "UnoControlTableModel::getCellContent: no data model anymore!" );
     533                 :            : 
     534         [ #  # ]:          0 :             PColumnModel const pColumn = getColumnModel( i_col );
     535         [ #  # ]:          0 :             UnoGridColumnFacade* pColumnImpl = dynamic_cast< UnoGridColumnFacade* >( pColumn.get() );
     536         [ #  # ]:          0 :             ENSURE_OR_RETURN_VOID( pColumnImpl != NULL, "UnoControlTableModel::getCellContent: no (valid) column at this position!" );
     537         [ #  # ]:          0 :             sal_Int32 const nDataColumnIndex = pColumnImpl->getDataColumnIndex() >= 0 ? pColumnImpl->getDataColumnIndex() : i_col;
     538                 :            : 
     539 [ #  # ][ #  # ]:          0 :             if ( nDataColumnIndex >= xDataModel->getColumnCount() )
                 [ #  # ]
     540                 :            :             {
     541                 :            :                 // this is allowed, in case the column model has been dynamically extended, but the data model does
     542                 :            :                 // not (yet?) know about it.
     543                 :            :                 // So, handle it gracefully.
     544                 :            :             #if OSL_DEBUG_LEVEL > 0
     545                 :            :                 {
     546                 :            :                     Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel );
     547                 :            :                     OSL_ENSURE( xColumnModel.is() && i_col < xColumnModel->getColumnCount(),
     548                 :            :                         "UnoControlTableModel::getCellContent: request a column's value which the ColumnModel doesn't know about!" );
     549                 :            :                 }
     550                 :            :             #endif
     551                 :            :             }
     552                 :            :             else
     553                 :            :             {
     554 [ #  # ][ #  # ]:          0 :                 o_cellContent = xDataModel->getCellData( nDataColumnIndex, i_row );
     555 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
     556                 :            :         }
     557                 :          0 :         catch( const Exception& )
     558                 :            :         {
     559                 :            :             DBG_UNHANDLED_EXCEPTION();
     560                 :            :         }
     561                 :            :     }
     562                 :            : 
     563                 :            :     //------------------------------------------------------------------------------------------------------------------
     564                 :          0 :     void UnoControlTableModel::getCellToolTip( ColPos const i_col, RowPos const i_row, Any& o_cellToolTip )
     565                 :            :     {
     566                 :            :         DBG_CHECK_ME();
     567                 :            :         try
     568                 :            :         {
     569         [ #  # ]:          0 :             Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
     570 [ #  # ][ #  # ]:          0 :             ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" );
         [ #  # ][ #  # ]
     571                 :            : 
     572 [ #  # ][ #  # ]:          0 :             o_cellToolTip = xDataModel->getCellToolTip( i_col, i_row );
                 [ #  # ]
     573                 :            :         }
     574                 :          0 :         catch( const Exception& )
     575                 :            :         {
     576                 :            :             DBG_UNHANDLED_EXCEPTION();
     577                 :            :         }
     578                 :          0 :     }
     579                 :            : 
     580                 :            :     //------------------------------------------------------------------------------------------------------------------
     581                 :          0 :     Any UnoControlTableModel::getRowHeading( RowPos const i_rowPos ) const
     582                 :            :     {
     583                 :            :         DBG_CHECK_ME();
     584                 :            : 
     585                 :          0 :         Any aRowHeading;
     586                 :            : 
     587         [ #  # ]:          0 :         Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
     588         [ #  # ]:          0 :         ENSURE_OR_RETURN( xDataModel.is(), "UnoControlTableModel::getRowHeading: no data model anymore!", aRowHeading );
     589                 :            : 
     590                 :            :         try
     591                 :            :         {
     592 [ #  # ][ #  # ]:          0 :             aRowHeading = xDataModel->getRowHeading( i_rowPos );
     593                 :            :         }
     594         [ #  # ]:          0 :         catch( const Exception& )
     595                 :            :         {
     596                 :            :             DBG_UNHANDLED_EXCEPTION();
     597                 :            :         }
     598         [ #  # ]:          0 :         return aRowHeading;
     599                 :            :     }
     600                 :            : 
     601                 :            :     //------------------------------------------------------------------------------------------------------------------
     602                 :            :     namespace
     603                 :            :     {
     604                 :          0 :         void lcl_setColor( Any const & i_color, ::boost::optional< ::Color > & o_convertedColor )
     605                 :            :         {
     606         [ #  # ]:          0 :             if ( !i_color.hasValue() )
     607                 :          0 :                 o_convertedColor.reset();
     608                 :            :             else
     609                 :            :             {
     610                 :          0 :                 sal_Int32 nColor = COL_TRANSPARENT;
     611         [ #  # ]:          0 :                 if ( i_color >>= nColor )
     612                 :            :                 {
     613         [ #  # ]:          0 :                     o_convertedColor.reset( ::Color( nColor ) );
     614                 :            :                 }
     615                 :            :                 else
     616                 :            :                 {
     617                 :            :                     OSL_ENSURE( false, "lcl_setColor: could not extract color value!" );
     618                 :            :                 }
     619                 :            :             }
     620                 :          0 :         }
     621                 :            :     }
     622                 :            : 
     623                 :            :     //------------------------------------------------------------------------------------------------------------------
     624                 :          0 :     ::boost::optional< ::Color > UnoControlTableModel::getLineColor() const
     625                 :            :     {
     626                 :            :         DBG_CHECK_ME();
     627                 :          0 :         return m_pImpl->m_aGridLineColor;
     628                 :            :     }
     629                 :            : 
     630                 :            :     //------------------------------------------------------------------------------------------------------------------
     631                 :          0 :     void UnoControlTableModel::setLineColor( Any const & i_color )
     632                 :            :     {
     633                 :            :         DBG_CHECK_ME();
     634                 :          0 :         lcl_setColor( i_color, m_pImpl->m_aGridLineColor );
     635                 :          0 :     }
     636                 :            : 
     637                 :            :     //------------------------------------------------------------------------------------------------------------------
     638                 :          0 :     ::boost::optional< ::Color > UnoControlTableModel::getHeaderBackgroundColor() const
     639                 :            :     {
     640                 :            :         DBG_CHECK_ME();
     641                 :          0 :         return m_pImpl->m_aHeaderBackgroundColor;
     642                 :            :     }
     643                 :            : 
     644                 :            :     //------------------------------------------------------------------------------------------------------------------
     645                 :          0 :     void UnoControlTableModel::setHeaderBackgroundColor( Any const & i_color )
     646                 :            :     {
     647                 :            :         DBG_CHECK_ME();
     648                 :          0 :         lcl_setColor( i_color, m_pImpl->m_aHeaderBackgroundColor );
     649                 :          0 :     }
     650                 :            : 
     651                 :            :     //------------------------------------------------------------------------------------------------------------------
     652                 :          0 :     ::boost::optional< ::Color > UnoControlTableModel::getHeaderTextColor() const
     653                 :            :     {
     654                 :            :         DBG_CHECK_ME();
     655                 :          0 :         return m_pImpl->m_aHeaderTextColor;
     656                 :            :     }
     657                 :            : 
     658                 :            :     //------------------------------------------------------------------------------------------------------------------
     659                 :          0 :     void UnoControlTableModel::setHeaderTextColor( Any const & i_color )
     660                 :            :     {
     661                 :            :         DBG_CHECK_ME();
     662                 :          0 :         lcl_setColor( i_color, m_pImpl->m_aHeaderTextColor );
     663                 :          0 :     }
     664                 :            : 
     665                 :            :     //------------------------------------------------------------------------------------------------------------------
     666                 :          0 :     ::boost::optional< ::Color > UnoControlTableModel::getTextColor() const
     667                 :            :     {
     668                 :            :         DBG_CHECK_ME();
     669                 :          0 :         return m_pImpl->m_aTextColor;
     670                 :            :     }
     671                 :            : 
     672                 :            :     //------------------------------------------------------------------------------------------------------------------
     673                 :          0 :     void UnoControlTableModel::setTextColor( Any const & i_color )
     674                 :            :     {
     675                 :            :         DBG_CHECK_ME();
     676                 :          0 :         lcl_setColor( i_color, m_pImpl->m_aTextColor );
     677                 :          0 :     }
     678                 :            : 
     679                 :            :     //------------------------------------------------------------------------------------------------------------------
     680                 :          0 :     ::boost::optional< ::Color > UnoControlTableModel::getTextLineColor() const
     681                 :            :     {
     682                 :            :         DBG_CHECK_ME();
     683                 :          0 :         return m_pImpl->m_aTextColor;
     684                 :            :     }
     685                 :            : 
     686                 :            :     //------------------------------------------------------------------------------------------------------------------
     687                 :          0 :     void UnoControlTableModel::setTextLineColor( Any const & i_color )
     688                 :            :     {
     689                 :            :         DBG_CHECK_ME();
     690                 :          0 :         lcl_setColor( i_color, m_pImpl->m_aTextLineColor );
     691                 :          0 :     }
     692                 :            : 
     693                 :            :     //------------------------------------------------------------------------------------------------------------------
     694                 :          0 :     ::boost::optional< ::std::vector< ::Color > > UnoControlTableModel::getRowBackgroundColors() const
     695                 :            :     {
     696                 :            :         DBG_CHECK_ME();
     697                 :          0 :         return m_pImpl->m_aRowColors;
     698                 :            :     }
     699                 :            : 
     700                 :            :     //------------------------------------------------------------------------------------------------------------------
     701                 :          0 :     void UnoControlTableModel::setRowBackgroundColors( ::com::sun::star::uno::Any const & i_APIValue )
     702                 :            :     {
     703                 :            :         DBG_CHECK_ME();
     704         [ #  # ]:          0 :         Sequence< ::com::sun::star::util::Color > aAPIColors;
     705 [ #  # ][ #  # ]:          0 :         if ( !( i_APIValue >>= aAPIColors ) )
     706         [ #  # ]:          0 :             m_pImpl->m_aRowColors.reset();
     707                 :            :         else
     708                 :            :         {
     709         [ #  # ]:          0 :             ::std::vector< ::Color > aColors( aAPIColors.getLength() );
     710         [ #  # ]:          0 :             for ( sal_Int32 i=0; i<aAPIColors.getLength(); ++i )
     711                 :            :             {
     712 [ #  # ][ #  # ]:          0 :                 aColors[i] = ::Color( aAPIColors[i] );
     713                 :            :             }
     714         [ #  # ]:          0 :             m_pImpl->m_aRowColors.reset( aColors );
     715         [ #  # ]:          0 :         }
     716                 :          0 :     }
     717                 :            : 
     718                 :            :     //------------------------------------------------------------------------------------------------------------------
     719                 :          0 :     VerticalAlignment UnoControlTableModel::getVerticalAlign() const
     720                 :            :     {
     721                 :            :         DBG_CHECK_ME();
     722                 :          0 :         return  m_pImpl->m_eVerticalAlign;
     723                 :            :     }
     724                 :            : 
     725                 :            :     //------------------------------------------------------------------------------------------------------------------
     726                 :          0 :     void UnoControlTableModel::setVerticalAlign( VerticalAlignment _xAlign )
     727                 :            :     {
     728                 :            :         DBG_CHECK_ME();
     729                 :          0 :         m_pImpl->m_eVerticalAlign = _xAlign;
     730                 :          0 :     }
     731                 :            : 
     732                 :            :     //------------------------------------------------------------------------------------------------------------------
     733                 :          0 :     ColPos UnoControlTableModel::getColumnPos( UnoGridColumnFacade const & i_column ) const
     734                 :            :     {
     735                 :            :         DBG_CHECK_ME();
     736 [ #  # ][ #  # ]:          0 :         for (   ColumnModels::const_iterator col = m_pImpl->aColumns.begin();
                 [ #  # ]
     737                 :          0 :                 col != m_pImpl->aColumns.end();
     738                 :            :                 ++col
     739                 :            :             )
     740                 :            :         {
     741         [ #  # ]:          0 :             if ( &i_column == col->get() )
     742         [ #  # ]:          0 :                 return col - m_pImpl->aColumns.begin();
     743                 :            :         }
     744                 :            :         OSL_ENSURE( false, "UnoControlTableModel::getColumnPos: column not found!" );
     745                 :          0 :         return COL_INVALID;
     746                 :            :     }
     747                 :            : 
     748                 :            :     //------------------------------------------------------------------------------------------------------------------
     749                 :          0 :     ITableDataSort* UnoControlTableModel::getSortAdapter()
     750                 :            :     {
     751                 :            :         DBG_CHECK_ME();
     752                 :            : 
     753 [ #  # ][ #  # ]:          0 :         Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY );
     754         [ #  # ]:          0 :         if ( xSortAccess.is() )
     755                 :          0 :             return this;
     756                 :          0 :         return NULL;
     757                 :            :     }
     758                 :            : 
     759                 :            :     //------------------------------------------------------------------------------------------------------------------
     760                 :          0 :     void UnoControlTableModel::sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection )
     761                 :            :     {
     762                 :            :         DBG_CHECK_ME();
     763                 :            : 
     764                 :            :         try
     765                 :            :         {
     766 [ #  # ][ #  # ]:          0 :             Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW );
     767 [ #  # ][ #  # ]:          0 :             xSortAccess->sortByColumn( i_column, i_sortDirection == ColumnSortAscending );
                 [ #  # ]
     768                 :            :         }
     769                 :          0 :         catch( const Exception& )
     770                 :            :         {
     771                 :            :             DBG_UNHANDLED_EXCEPTION();
     772                 :            :         }
     773                 :          0 :     }
     774                 :            : 
     775                 :            :     //------------------------------------------------------------------------------------------------------------------
     776                 :          0 :     ColumnSort UnoControlTableModel::getCurrentSortOrder() const
     777                 :            :     {
     778                 :            :         DBG_CHECK_ME();
     779                 :            : 
     780                 :          0 :         ColumnSort currentSort;
     781                 :            :         try
     782                 :            :         {
     783 [ #  # ][ #  # ]:          0 :             Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW );
     784 [ #  # ][ #  # ]:          0 :             Pair< ::sal_Int32, ::sal_Bool > const aCurrentSortOrder( xSortAccess->getCurrentSortOrder() );
     785                 :          0 :             currentSort.nColumnPos = aCurrentSortOrder.First;
     786         [ #  # ]:          0 :             currentSort.eSortDirection = aCurrentSortOrder.Second ? ColumnSortAscending : ColumnSortDescending;
     787                 :            :         }
     788                 :          0 :         catch( const Exception& )
     789                 :            :         {
     790                 :            :             DBG_UNHANDLED_EXCEPTION();
     791                 :            :         }
     792                 :          0 :         return currentSort;
     793                 :            :     }
     794                 :            : 
     795                 :            :     //--------------------------------------------------------------------
     796                 :          0 :     void UnoControlTableModel::notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const
     797                 :            :     {
     798                 :            :         DBG_CHECK_ME();
     799 [ #  # ][ #  # ]:          0 :         ENSURE_OR_RETURN_VOID( ( i_columnPos >= 0 ) && ( i_columnPos < getColumnCount() ),
         [ #  # ][ #  # ]
     800                 :            :             "UnoControlTableModel::notifyColumnChange: invalid column index!" );
     801                 :            : 
     802         [ #  # ]:          0 :         ModellListeners aListeners( m_pImpl->m_aListeners );
     803 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::const_iterator loop = aListeners.begin();
                 [ #  # ]
     804                 :          0 :                 loop != aListeners.end();
     805                 :            :                 ++loop
     806                 :            :             )
     807                 :            :         {
     808         [ #  # ]:          0 :             (*loop)->columnChanged( i_columnPos, i_attributeGroup );
     809                 :          0 :         }
     810                 :            :     }
     811                 :            : 
     812                 :            :     //------------------------------------------------------------------------------------------------------------------
     813                 :          0 :     void UnoControlTableModel::notifyRowsInserted( GridDataEvent const & i_event ) const
     814                 :            :     {
     815                 :            :         // check sanity of the event
     816         [ #  # ]:          0 :         ENSURE_OR_RETURN_VOID( i_event.FirstRow >= 0, "UnoControlTableModel::notifyRowsInserted: invalid first row!" );
     817         [ #  # ]:          0 :         ENSURE_OR_RETURN_VOID( i_event.LastRow >= i_event.FirstRow, "UnoControlTableModel::notifyRowsInserted: invalid row indexes!" );
     818                 :            : 
     819                 :            :         // check own sanity
     820         [ #  # ]:          0 :         Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel );
     821         [ #  # ]:          0 :         ENSURE_OR_RETURN_VOID( xColumnModel.is(), "UnoControlTableModel::notifyRowsInserted: no column model anymore!" );
     822                 :            : 
     823         [ #  # ]:          0 :         Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
     824         [ #  # ]:          0 :         ENSURE_OR_RETURN_VOID( xDataModel.is(), "UnoControlTableModel::notifyRowsInserted: no data model anymore!" );
     825                 :            : 
     826                 :            :         // implicitly add columns to the column model
     827                 :            :         // TODO: is this really a good idea?
     828 [ #  # ][ #  # ]:          0 :         sal_Int32 const dataColumnCount = xDataModel->getColumnCount();
     829                 :            :         OSL_ENSURE( dataColumnCount > 0, "UnoControlTableModel::notifyRowsInserted: no columns at all?" );
     830                 :            : 
     831 [ #  # ][ #  # ]:          0 :         sal_Int32 const modelColumnCount = xColumnModel->getColumnCount();
     832 [ #  # ][ #  # ]:          0 :         if ( ( modelColumnCount == 0 ) && ( dataColumnCount > 0 ) )
     833                 :            :         {
     834                 :            :             // TODO: shouldn't we clear the mutexes guard for this call?
     835 [ #  # ][ #  # ]:          0 :             xColumnModel->setDefaultColumns( dataColumnCount );
     836                 :            :         }
     837                 :            : 
     838                 :            :         // multiplex the event to our own listeners
     839         [ #  # ]:          0 :         ModellListeners aListeners( m_pImpl->m_aListeners );
     840 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::const_iterator loop = aListeners.begin();
                 [ #  # ]
     841                 :          0 :                 loop != aListeners.end();
     842                 :            :                 ++loop
     843                 :            :             )
     844                 :            :         {
     845         [ #  # ]:          0 :             (*loop)->rowsInserted( i_event.FirstRow, i_event.LastRow );
     846 [ #  # ][ #  # ]:          0 :         }
     847                 :            :     }
     848                 :            : 
     849                 :            :     //------------------------------------------------------------------------------------------------------------------
     850                 :          0 :     void UnoControlTableModel::notifyRowsRemoved( GridDataEvent const & i_event ) const
     851                 :            :     {
     852         [ #  # ]:          0 :         ModellListeners aListeners( m_pImpl->m_aListeners );
     853 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::const_iterator loop = aListeners.begin();
                 [ #  # ]
     854                 :          0 :                 loop != aListeners.end();
     855                 :            :                 ++loop
     856                 :            :             )
     857                 :            :         {
     858         [ #  # ]:          0 :             (*loop)->rowsRemoved( i_event.FirstRow, i_event.LastRow );
     859                 :          0 :         }
     860                 :          0 :     }
     861                 :            : 
     862                 :            :     //------------------------------------------------------------------------------------------------------------------
     863                 :          0 :     void UnoControlTableModel::notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const
     864                 :            :     {
     865         [ #  # ]:          0 :         ColPos const firstCol = i_event.FirstColumn == -1 ? 0 : i_event.FirstColumn;
     866 [ #  # ][ #  # ]:          0 :         ColPos const lastCol = i_event.FirstColumn == -1 ? getColumnCount() - 1 : i_event.LastColumn;
     867         [ #  # ]:          0 :         RowPos const firstRow = i_event.FirstRow == -1 ? 0 : i_event.FirstRow;
     868 [ #  # ][ #  # ]:          0 :         RowPos const lastRow = i_event.FirstRow == -1 ? getRowCount() - 1 : i_event.LastRow;
     869                 :            : 
     870         [ #  # ]:          0 :         ModellListeners aListeners( m_pImpl->m_aListeners );
     871 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::const_iterator loop = aListeners.begin();
                 [ #  # ]
     872                 :          0 :                 loop != aListeners.end();
     873                 :            :                 ++loop
     874                 :            :             )
     875                 :            :         {
     876         [ #  # ]:          0 :             (*loop)->cellsUpdated( firstCol, lastCol, firstRow, lastRow );
     877                 :          0 :         }
     878                 :          0 :     }
     879                 :            : 
     880                 :            :     //------------------------------------------------------------------------------------------------------------------
     881                 :          0 :     void UnoControlTableModel::notifyAllDataChanged() const
     882                 :            :     {
     883         [ #  # ]:          0 :         ModellListeners aListeners( m_pImpl->m_aListeners );
     884 [ #  # ][ #  # ]:          0 :         for (   ModellListeners::const_iterator loop = aListeners.begin();
                 [ #  # ]
     885                 :          0 :                 loop != aListeners.end();
     886                 :            :                 ++loop
     887                 :            :             )
     888                 :            :         {
     889 [ #  # ][ #  # ]:          0 :             (*loop)->cellsUpdated( 0, getColumnCount() - 1, 0, getRowCount() - 1 );
                 [ #  # ]
     890                 :          0 :         }
     891                 :          0 :     }
     892                 :            : 
     893                 :            : // .....................................................................................................................
     894                 :            : } } // svt::table
     895                 :            : // .....................................................................................................................
     896                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10