LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - celllistsource.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 160 11.2 %
Date: 2012-08-25 Functions: 7 29 24.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 22 289 7.6 %

           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 "celllistsource.hxx"
      30                 :            : #include <tools/debug.hxx>
      31                 :            : #include <com/sun/star/text/XTextRange.hpp>
      32                 :            : #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
      33                 :            : #include <com/sun/star/util/XModifyBroadcaster.hpp>
      34                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      35                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      36                 :            : #include <com/sun/star/beans/NamedValue.hpp>
      37                 :            : 
      38                 :            : //.........................................................................
      39                 :            : namespace calc
      40                 :            : {
      41                 :            : //.........................................................................
      42                 :            : 
      43                 :            : #define PROP_HANDLE_RANGE_ADDRESS  1
      44                 :            : 
      45                 :            :     using namespace ::com::sun::star::uno;
      46                 :            :     using namespace ::com::sun::star::lang;
      47                 :            :     using namespace ::com::sun::star::table;
      48                 :            :     using namespace ::com::sun::star::text;
      49                 :            :     using namespace ::com::sun::star::sheet;
      50                 :            :     using namespace ::com::sun::star::container;
      51                 :            :     using namespace ::com::sun::star::beans;
      52                 :            :     using namespace ::com::sun::star::util;
      53                 :            :     using namespace ::com::sun::star::form::binding;
      54                 :            : 
      55                 :            :     //=====================================================================
      56                 :            :     //= OCellListSource
      57                 :            :     //=====================================================================
      58                 :            :     DBG_NAME( OCellListSource )
      59                 :            :     //---------------------------------------------------------------------
      60                 :            : #ifdef DBG_UTIL
      61                 :            :     const char* OCellListSource::checkConsistency_static( const void* _pThis )
      62                 :            :     {
      63                 :            :         return static_cast< const OCellListSource* >( _pThis )->checkConsistency( );
      64                 :            :     }
      65                 :            : 
      66                 :            :     const char* OCellListSource::checkConsistency( ) const
      67                 :            :     {
      68                 :            :         const char* pAssertion = NULL;
      69                 :            : 
      70                 :            :         // TODO: place any checks here to ensure consistency of this instance
      71                 :            : 
      72                 :            :         return pAssertion;
      73                 :            :     }
      74                 :            : #endif
      75                 :            : 
      76                 :            :     //---------------------------------------------------------------------
      77                 :          1 :     OCellListSource::OCellListSource( const Reference< XSpreadsheetDocument >& _rxDocument )
      78                 :            :         :OCellListSource_Base( m_aMutex )
      79                 :            :         ,OCellListSource_PBase( OCellListSource_Base::rBHelper )
      80                 :            :         ,m_xDocument( _rxDocument )
      81                 :            :         ,m_aListEntryListeners( m_aMutex )
      82 [ +  - ][ +  - ]:          1 :         ,m_bInitialized( false )
                 [ +  - ]
      83                 :            :     {
      84                 :            :         DBG_CTOR( OCellListSource, checkConsistency_static );
      85                 :            : 
      86                 :            :         OSL_PRECOND( m_xDocument.is(), "OCellListSource::OCellListSource: invalid document!" );
      87                 :            : 
      88                 :            :         // register our property at the base class
      89                 :          1 :         CellRangeAddress aInitialPropValue;
      90                 :            :         registerPropertyNoMember(
      91                 :            :             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellRange" )),
      92                 :            :             PROP_HANDLE_RANGE_ADDRESS,
      93                 :            :             PropertyAttribute::BOUND | PropertyAttribute::READONLY,
      94         [ +  - ]:          1 :             ::getCppuType( &aInitialPropValue ),
      95                 :            :             &aInitialPropValue
      96 [ +  - ][ +  - ]:          1 :         );
      97                 :          1 :     }
      98                 :            : 
      99                 :            :     //---------------------------------------------------------------------
     100 [ +  - ][ +  - ]:          1 :     OCellListSource::~OCellListSource( )
         [ +  - ][ +  - ]
     101                 :            :     {
     102         [ -  + ]:          1 :         if ( !OCellListSource_Base::rBHelper.bDisposed )
     103                 :            :         {
     104                 :          0 :             acquire();  // prevent duplicate dtor
     105         [ #  # ]:          0 :             dispose();
     106                 :            :         }
     107                 :            : 
     108                 :            :         DBG_DTOR( OCellListSource, checkConsistency_static );
     109         [ -  + ]:          2 :     }
     110                 :            : 
     111                 :            :     //--------------------------------------------------------------------
     112 [ -  + ][ #  # ]:         21 :     IMPLEMENT_FORWARD_XINTERFACE2( OCellListSource, OCellListSource_Base, OCellListSource_PBase )
     113                 :            : 
     114                 :            :     //--------------------------------------------------------------------
     115 [ #  # ][ #  # ]:          0 :     IMPLEMENT_FORWARD_XTYPEPROVIDER2( OCellListSource, OCellListSource_Base, OCellListSource_PBase )
                 [ #  # ]
     116                 :            : 
     117                 :            :     //--------------------------------------------------------------------
     118                 :          1 :     void SAL_CALL OCellListSource::disposing()
     119                 :            :     {
     120         [ +  - ]:          1 :         ::osl::MutexGuard aGuard( m_aMutex );
     121                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     122                 :            : 
     123         [ +  - ]:          1 :         Reference<XModifyBroadcaster> xBroadcaster( m_xRange, UNO_QUERY );
     124         [ -  + ]:          1 :         if ( xBroadcaster.is() )
     125                 :            :         {
     126 [ #  # ][ #  # ]:          0 :             xBroadcaster->removeModifyListener( this );
                 [ #  # ]
     127                 :            :         }
     128                 :            : 
     129 [ +  - ][ +  - ]:          1 :         EventObject aDisposeEvent( *this );
     130         [ +  - ]:          1 :         m_aListEntryListeners.disposeAndClear( aDisposeEvent );
     131                 :            : 
     132 [ +  - ][ +  - ]:          1 :         WeakAggComponentImplHelperBase::disposing();
                 [ +  - ]
     133                 :            : 
     134                 :            :         // TODO: clean up here whatever you need to clean up (e.g. revoking listeners etc.)
     135                 :          1 :     }
     136                 :            : 
     137                 :            :     //--------------------------------------------------------------------
     138                 :          0 :     Reference< XPropertySetInfo > SAL_CALL OCellListSource::getPropertySetInfo(  ) throw(RuntimeException)
     139                 :            :     {
     140                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     141                 :          0 :         return createPropertySetInfo( getInfoHelper() ) ;
     142                 :            :     }
     143                 :            : 
     144                 :            :     //--------------------------------------------------------------------
     145                 :          0 :     ::cppu::IPropertyArrayHelper& SAL_CALL OCellListSource::getInfoHelper()
     146                 :            :     {
     147                 :          0 :         return *OCellListSource_PABase::getArrayHelper();
     148                 :            :     }
     149                 :            : 
     150                 :            :     //--------------------------------------------------------------------
     151                 :          0 :     ::cppu::IPropertyArrayHelper* OCellListSource::createArrayHelper( ) const
     152                 :            :     {
     153         [ #  # ]:          0 :         Sequence< Property > aProps;
     154         [ #  # ]:          0 :         describeProperties( aProps );
     155 [ #  # ][ #  # ]:          0 :         return new ::cppu::OPropertyArrayHelper(aProps);
     156                 :            :     }
     157                 :            : 
     158                 :            :     //--------------------------------------------------------------------
     159                 :          0 :     void SAL_CALL OCellListSource::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
     160                 :            :     {
     161                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     162                 :            :         OSL_ENSURE( _nHandle == PROP_HANDLE_RANGE_ADDRESS, "OCellListSource::getFastPropertyValue: invalid handle!" );
     163                 :            :             // we only have this one property ....
     164                 :            :         (void)_nHandle;     // avoid warning in product version
     165                 :            : 
     166         [ #  # ]:          0 :         _rValue <<= getRangeAddress( );
     167                 :          0 :     }
     168                 :            : 
     169                 :            :     //--------------------------------------------------------------------
     170                 :          0 :     void OCellListSource::checkDisposed( ) const SAL_THROW( ( DisposedException ) )
     171                 :            :     {
     172 [ #  # ][ #  # ]:          0 :         if ( OCellListSource_Base::rBHelper.bInDispose || OCellListSource_Base::rBHelper.bDisposed )
     173         [ #  # ]:          0 :             throw DisposedException();
     174                 :            :             // TODO: is it worth having an error message here?
     175                 :          0 :     }
     176                 :            : 
     177                 :            :     //--------------------------------------------------------------------
     178                 :          0 :     void OCellListSource::checkInitialized() SAL_THROW( ( RuntimeException ) )
     179                 :            :     {
     180         [ #  # ]:          0 :         if ( !m_bInitialized )
     181         [ #  # ]:          0 :             throw RuntimeException();
     182                 :            :             // TODO: error message
     183                 :          0 :     }
     184                 :            : 
     185                 :            :     //--------------------------------------------------------------------
     186                 :          0 :     ::rtl::OUString SAL_CALL OCellListSource::getImplementationName(  ) throw (RuntimeException)
     187                 :            :     {
     188                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sheet.OCellListSource" ) );
     189                 :            :     }
     190                 :            : 
     191                 :            :     //--------------------------------------------------------------------
     192                 :          0 :     sal_Bool SAL_CALL OCellListSource::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
     193                 :            :     {
     194         [ #  # ]:          0 :         Sequence< ::rtl::OUString > aSupportedServices( getSupportedServiceNames() );
     195                 :          0 :         const ::rtl::OUString* pLookup = aSupportedServices.getConstArray();
     196                 :          0 :         const ::rtl::OUString* pLookupEnd = aSupportedServices.getConstArray() + aSupportedServices.getLength();
     197         [ #  # ]:          0 :         while ( pLookup != pLookupEnd )
     198         [ #  # ]:          0 :             if ( *pLookup++ == _rServiceName )
     199                 :          0 :                 return sal_True;
     200                 :            : 
     201         [ #  # ]:          0 :         return false;
     202                 :            :     }
     203                 :            : 
     204                 :            :     //--------------------------------------------------------------------
     205                 :          0 :     Sequence< ::rtl::OUString > SAL_CALL OCellListSource::getSupportedServiceNames(  ) throw (RuntimeException)
     206                 :            :     {
     207                 :          0 :         Sequence< ::rtl::OUString > aServices( 2 );
     208 [ #  # ][ #  # ]:          0 :         aServices[ 0 ] =  ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellRangeListSource" ) );
     209 [ #  # ][ #  # ]:          0 :         aServices[ 1 ] =  ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.binding.ListEntrySource" ) );
     210                 :          0 :         return aServices;
     211                 :            :     }
     212                 :            : 
     213                 :            :     //--------------------------------------------------------------------
     214                 :          0 :     CellRangeAddress OCellListSource::getRangeAddress( ) const
     215                 :            :     {
     216                 :            :         OSL_PRECOND( m_xRange.is(), "OCellListSource::getRangeAddress: invalid range!" );
     217                 :            : 
     218                 :          0 :         CellRangeAddress aAddress;
     219         [ #  # ]:          0 :         Reference< XCellRangeAddressable > xRangeAddress( m_xRange, UNO_QUERY );
     220         [ #  # ]:          0 :         if ( xRangeAddress.is() )
     221 [ #  # ][ #  # ]:          0 :             aAddress = xRangeAddress->getRangeAddress( );
     222                 :          0 :         return aAddress;
     223                 :            :     }
     224                 :            : 
     225                 :            :     //--------------------------------------------------------------------
     226                 :          0 :     ::rtl::OUString OCellListSource::getCellTextContent_noCheck( sal_Int32 _nRangeRelativeColumn, sal_Int32 _nRangeRelativeRow )
     227                 :            :     {
     228                 :            :         OSL_PRECOND( m_xRange.is(), "OCellListSource::getRangeAddress: invalid range!" );
     229                 :          0 :         Reference< XTextRange > xCellText;
     230         [ #  # ]:          0 :         if ( m_xRange.is() )
     231 [ #  # ][ #  # ]:          0 :             xCellText.set(xCellText.query( m_xRange->getCellByPosition( _nRangeRelativeColumn, _nRangeRelativeRow ) ));
         [ #  # ][ #  # ]
     232                 :            : 
     233                 :          0 :         ::rtl::OUString sText;
     234         [ #  # ]:          0 :         if ( xCellText.is() )
     235 [ #  # ][ #  # ]:          0 :             sText = xCellText->getString();
     236                 :          0 :         return sText;
     237                 :            :     }
     238                 :            : 
     239                 :            :     //--------------------------------------------------------------------
     240                 :          0 :     sal_Int32 SAL_CALL OCellListSource::getListEntryCount(  ) throw (RuntimeException)
     241                 :            :     {
     242         [ #  # ]:          0 :         ::osl::MutexGuard aGuard( m_aMutex );
     243                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     244         [ #  # ]:          0 :         checkDisposed();
     245         [ #  # ]:          0 :         checkInitialized();
     246                 :            : 
     247         [ #  # ]:          0 :         CellRangeAddress aAddress( getRangeAddress( ) );
     248         [ #  # ]:          0 :         return aAddress.EndRow - aAddress.StartRow + 1;
     249                 :            :     }
     250                 :            : 
     251                 :            :     //--------------------------------------------------------------------
     252                 :          0 :     ::rtl::OUString SAL_CALL OCellListSource::getListEntry( sal_Int32 _nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
     253                 :            :     {
     254         [ #  # ]:          0 :         ::osl::MutexGuard aGuard( m_aMutex );
     255                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     256         [ #  # ]:          0 :         checkDisposed();
     257         [ #  # ]:          0 :         checkInitialized();
     258                 :            : 
     259 [ #  # ][ #  # ]:          0 :         if ( _nPosition >= getListEntryCount() )
     260         [ #  # ]:          0 :             throw IndexOutOfBoundsException();
     261                 :            : 
     262 [ #  # ][ #  # ]:          0 :         return getCellTextContent_noCheck( 0, _nPosition );
     263                 :            :     }
     264                 :            : 
     265                 :            :     //--------------------------------------------------------------------
     266                 :          0 :     Sequence< ::rtl::OUString > SAL_CALL OCellListSource::getAllListEntries(  ) throw (RuntimeException)
     267                 :            :     {
     268         [ #  # ]:          0 :         ::osl::MutexGuard aGuard( m_aMutex );
     269                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     270         [ #  # ]:          0 :         checkDisposed();
     271         [ #  # ]:          0 :         checkInitialized();
     272                 :            : 
     273 [ #  # ][ #  # ]:          0 :         Sequence< ::rtl::OUString > aAllEntries( getListEntryCount() );
     274         [ #  # ]:          0 :         ::rtl::OUString* pAllEntries = aAllEntries.getArray();
     275         [ #  # ]:          0 :         for ( sal_Int32 i = 0; i < aAllEntries.getLength(); ++i )
     276                 :            :         {
     277         [ #  # ]:          0 :             *pAllEntries++ = getCellTextContent_noCheck( 0, i );
     278                 :            :         }
     279                 :            : 
     280         [ #  # ]:          0 :         return aAllEntries;
     281                 :            :     }
     282                 :            : 
     283                 :            :     //--------------------------------------------------------------------
     284                 :          0 :     void SAL_CALL OCellListSource::addListEntryListener( const Reference< XListEntryListener >& _rxListener ) throw (NullPointerException, RuntimeException)
     285                 :            :     {
     286         [ #  # ]:          0 :         ::osl::MutexGuard aGuard( m_aMutex );
     287                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     288         [ #  # ]:          0 :         checkDisposed();
     289         [ #  # ]:          0 :         checkInitialized();
     290                 :            : 
     291         [ #  # ]:          0 :         if ( !_rxListener.is() )
     292         [ #  # ]:          0 :             throw NullPointerException();
     293                 :            : 
     294 [ #  # ][ #  # ]:          0 :         m_aListEntryListeners.addInterface( _rxListener );
     295                 :          0 :     }
     296                 :            : 
     297                 :            :     //--------------------------------------------------------------------
     298                 :          0 :     void SAL_CALL OCellListSource::removeListEntryListener( const Reference< XListEntryListener >& _rxListener ) throw (NullPointerException, RuntimeException)
     299                 :            :     {
     300         [ #  # ]:          0 :         ::osl::MutexGuard aGuard( m_aMutex );
     301                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     302         [ #  # ]:          0 :         checkDisposed();
     303         [ #  # ]:          0 :         checkInitialized();
     304                 :            : 
     305         [ #  # ]:          0 :         if ( !_rxListener.is() )
     306         [ #  # ]:          0 :             throw NullPointerException();
     307                 :            : 
     308 [ #  # ][ #  # ]:          0 :         m_aListEntryListeners.removeInterface( _rxListener );
     309                 :          0 :     }
     310                 :            : 
     311                 :            :     //--------------------------------------------------------------------
     312                 :          0 :     void SAL_CALL OCellListSource::modified( const EventObject& /* aEvent */ ) throw (RuntimeException)
     313                 :            :     {
     314                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     315                 :            : 
     316                 :          0 :         notifyModified();
     317                 :          0 :     }
     318                 :            : 
     319                 :            :     //--------------------------------------------------------------------
     320                 :          0 :     void OCellListSource::notifyModified()
     321                 :            :     {
     322         [ #  # ]:          0 :         EventObject aEvent;
     323 [ #  # ][ #  # ]:          0 :         aEvent.Source.set(*this);
              [ #  #  # ]
     324                 :            : 
     325         [ #  # ]:          0 :         ::cppu::OInterfaceIteratorHelper aIter( m_aListEntryListeners );
     326         [ #  # ]:          0 :         while ( aIter.hasMoreElements() )
     327                 :            :         {
     328                 :            :             try
     329                 :            :             {
     330 [ #  # ][ #  # ]:          0 :                 static_cast< XListEntryListener* >( aIter.next() )->allEntriesChanged( aEvent );
     331                 :            :             }
     332         [ #  # ]:          0 :             catch( const RuntimeException& )
     333                 :            :             {
     334                 :            :                 // silent this
     335                 :            :             }
     336         [ #  # ]:          0 :             catch( const Exception& )
     337                 :            :             {
     338                 :            :                 OSL_FAIL( "OCellListSource::notifyModified: caught a (non-runtime) exception!" );
     339                 :            :             }
     340 [ #  # ][ #  # ]:          0 :         }
     341                 :            : 
     342                 :          0 :     }
     343                 :            : 
     344                 :            :     //--------------------------------------------------------------------
     345                 :          0 :     void SAL_CALL OCellListSource::disposing( const EventObject& aEvent ) throw (RuntimeException)
     346                 :            :     {
     347                 :            :         DBG_CHKTHIS( OCellListSource, checkConsistency_static );
     348                 :            : 
     349         [ #  # ]:          0 :         Reference<XInterface> xRangeInt( m_xRange, UNO_QUERY );
     350 [ #  # ][ #  # ]:          0 :         if ( xRangeInt == aEvent.Source )
     351                 :            :         {
     352                 :            :             // release references to range object
     353                 :          0 :             m_xRange.clear();
     354                 :          0 :         }
     355                 :          0 :     }
     356                 :            : 
     357                 :            :     //--------------------------------------------------------------------
     358                 :          0 :     void SAL_CALL OCellListSource::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
     359                 :            :     {
     360         [ #  # ]:          0 :         if ( m_bInitialized )
     361         [ #  # ]:          0 :             throw Exception();
     362                 :            :             // TODO: error message
     363                 :            : 
     364                 :            :         // get the cell address
     365                 :          0 :         CellRangeAddress aRangeAddress;
     366                 :          0 :         sal_Bool bFoundAddress = false;
     367                 :            : 
     368                 :          0 :         const Any* pLoop = _rArguments.getConstArray();
     369                 :          0 :         const Any* pLoopEnd = _rArguments.getConstArray() + _rArguments.getLength();
     370 [ #  # ][ #  # ]:          0 :         for ( ; ( pLoop != pLoopEnd ) && !bFoundAddress; ++pLoop )
                 [ #  # ]
     371                 :            :         {
     372                 :          0 :             NamedValue aValue;
     373 [ #  # ][ #  # ]:          0 :             if ( *pLoop >>= aValue )
     374                 :            :             {
     375         [ #  # ]:          0 :                 if ( aValue.Name == "CellRange" )
     376                 :            :                 {
     377 [ #  # ][ #  # ]:          0 :                     if ( aValue.Value >>= aRangeAddress )
     378                 :          0 :                         bFoundAddress = sal_True;
     379                 :            :                 }
     380                 :            :             }
     381                 :          0 :         }
     382                 :            : 
     383         [ #  # ]:          0 :         if ( !bFoundAddress )
     384                 :            :             // TODO: error message
     385         [ #  # ]:          0 :             throw Exception();
     386                 :            : 
     387                 :            :         // determine the range we're bound to
     388                 :            :         try
     389                 :            :         {
     390         [ #  # ]:          0 :             if ( m_xDocument.is() )
     391                 :            :             {
     392                 :            :                 // first the sheets collection
     393 [ #  # ][ #  # ]:          0 :                 Reference< XIndexAccess > xSheets(m_xDocument->getSheets( ), UNO_QUERY);
                 [ #  # ]
     394                 :            :                 OSL_ENSURE( xSheets.is(), "OCellListSource::initialize: could not retrieve the sheets!" );
     395                 :            : 
     396         [ #  # ]:          0 :                 if ( xSheets.is() )
     397                 :            :                 {
     398                 :            :                     // the concrete sheet
     399 [ #  # ][ #  # ]:          0 :                     Reference< XCellRange > xSheet(xSheets->getByIndex( aRangeAddress.Sheet ), UNO_QUERY);
                 [ #  # ]
     400                 :            :                     OSL_ENSURE( xSheet.is(), "OCellListSource::initialize: NULL sheet, but no exception!" );
     401                 :            : 
     402                 :            :                     // the concrete cell
     403         [ #  # ]:          0 :                     if ( xSheet.is() )
     404                 :            :                     {
     405         [ #  # ]:          0 :                         m_xRange.set(xSheet->getCellRangeByPosition(
     406                 :            :                             aRangeAddress.StartColumn, aRangeAddress.StartRow,
     407 [ #  # ][ #  # ]:          0 :                             aRangeAddress.EndColumn, aRangeAddress.EndRow));
     408                 :            :                         OSL_ENSURE( Reference< XCellRangeAddressable >( m_xRange, UNO_QUERY ).is(), "OCellListSource::initialize: either NULL range, or cell without address access!" );
     409                 :          0 :                     }
     410         [ #  # ]:          0 :                 }
     411                 :            :             }
     412                 :            :         }
     413         [ #  # ]:          0 :         catch( const Exception& )
     414                 :            :         {
     415                 :            :             OSL_FAIL( "OCellListSource::initialize: caught an exception while retrieving the cell object!" );
     416                 :            :         }
     417                 :            : 
     418                 :            : 
     419         [ #  # ]:          0 :         if ( !m_xRange.is() )
     420         [ #  # ]:          0 :             throw Exception();
     421                 :            :             // TODO error message
     422                 :            : 
     423         [ #  # ]:          0 :         Reference<XModifyBroadcaster> xBroadcaster( m_xRange, UNO_QUERY );
     424         [ #  # ]:          0 :         if ( xBroadcaster.is() )
     425                 :            :         {
     426 [ #  # ][ #  # ]:          0 :             xBroadcaster->addModifyListener( this );
                 [ #  # ]
     427                 :            :         }
     428                 :            : 
     429                 :            :         // TODO: add as XEventListener to the cell range, so we get notified when it dies,
     430                 :            :         // and can dispose ourself then
     431                 :            : 
     432                 :            :         // TODO: somehow add as listener so we get notified when the address of the cell range changes
     433                 :            :         // We need to forward this as change in our CellRange property to our property change listeners
     434                 :            : 
     435                 :            :         // TODO: somehow add as listener to the cells in the range, so that we get notified
     436                 :            :         // when their content changes. We need to forward this to our list entry listeners then
     437                 :            : 
     438                 :            :         // TODO: somehow add as listener so that we get notified of insertions and removals of rows in our
     439                 :            :         // range. In this case, we need to fire a change in our CellRange property, and additionally
     440                 :            :         // notify our XListEntryListeners
     441                 :            : 
     442                 :          0 :         m_bInitialized = sal_True;
     443                 :          0 :     }
     444                 :            : 
     445                 :            : //.........................................................................
     446                 :            : }   // namespace calc
     447                 :            : //.........................................................................
     448                 :            : 
     449                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10