LCOV - code coverage report
Current view: top level - chart2/source/model/main - DataSeries.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 192 287 66.9 %
Date: 2012-08-25 Functions: 28 43 65.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 204 588 34.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include "DataSeries.hxx"
      21                 :            : #include "DataSeriesProperties.hxx"
      22                 :            : #include "DataPointProperties.hxx"
      23                 :            : #include "CharacterProperties.hxx"
      24                 :            : #include "UserDefinedProperties.hxx"
      25                 :            : #include "DataPoint.hxx"
      26                 :            : #include "macros.hxx"
      27                 :            : #include "DataSeriesHelper.hxx"
      28                 :            : #include "ContainerHelper.hxx"
      29                 :            : #include "CloneHelper.hxx"
      30                 :            : #include "ModifyListenerHelper.hxx"
      31                 :            : #include "EventListenerHelper.hxx"
      32                 :            : 
      33                 :            : #include <algorithm>
      34                 :            : 
      35                 :            : using namespace ::com::sun::star;
      36                 :            : 
      37                 :            : using ::com::sun::star::beans::Property;
      38                 :            : using ::com::sun::star::uno::Sequence;
      39                 :            : using ::com::sun::star::uno::Reference;
      40                 :            : using ::com::sun::star::uno::Any;
      41                 :            : using ::rtl::OUString;
      42                 :            : using ::osl::MutexGuard;
      43                 :            : 
      44                 :            : // ----------------------------------------
      45                 :            : 
      46                 :            : namespace
      47                 :            : {
      48                 :            : 
      49                 :            : struct StaticDataSeriesDefaults_Initializer
      50                 :            : {
      51                 :         14 :     ::chart::tPropertyValueMap* operator()()
      52                 :            :     {
      53 [ +  - ][ +  - ]:         14 :         static ::chart::tPropertyValueMap aStaticDefaults;
         [ +  - ][ #  # ]
      54                 :         14 :         lcl_AddDefaultsToMap( aStaticDefaults );
      55                 :         14 :         return &aStaticDefaults;
      56                 :            :     }
      57                 :            : private:
      58                 :         14 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      59                 :            :     {
      60         [ +  - ]:         14 :         ::chart::DataSeriesProperties::AddDefaultsToMap( rOutMap );
      61         [ +  - ]:         14 :         ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
      62                 :            : 
      63                 :         14 :         float fDefaultCharHeight = 10.0;
      64         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
      65         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
      66         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
      67                 :         14 :     }
      68                 :            : };
      69                 :            : 
      70                 :            : struct StaticDataSeriesDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDataSeriesDefaults_Initializer >
      71                 :            : {
      72                 :            : };
      73                 :            : 
      74                 :            : struct StaticDataSeriesInfoHelper_Initializer
      75                 :            : {
      76                 :         14 :     ::cppu::OPropertyArrayHelper* operator()()
      77                 :            :     {
      78 [ +  - ][ +  - ]:         14 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
      79                 :         14 :         return &aPropHelper;
      80                 :            :     }
      81                 :            : 
      82                 :            : private:
      83                 :         14 :     uno::Sequence< Property > lcl_GetPropertySequence()
      84                 :            :     {
      85         [ +  - ]:         14 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      86         [ +  - ]:         14 :         ::chart::DataSeriesProperties::AddPropertiesToVector( aProperties );
      87         [ +  - ]:         14 :         ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
      88         [ +  - ]:         14 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      89                 :            : 
      90                 :            :         ::std::sort( aProperties.begin(), aProperties.end(),
      91         [ +  - ]:         14 :                      ::chart::PropertyNameLess() );
      92                 :            : 
      93         [ +  - ]:         14 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      94                 :            :     }
      95                 :            : 
      96                 :            : };
      97                 :            : 
      98                 :            : struct StaticDataSeriesInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDataSeriesInfoHelper_Initializer >
      99                 :            : {
     100                 :            : };
     101                 :            : 
     102                 :            : struct StaticDataSeriesInfo_Initializer
     103                 :            : {
     104                 :          0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     105                 :            :     {
     106                 :            :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     107 [ #  # ][ #  # ]:          0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDataSeriesInfoHelper::get() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     108                 :          0 :         return &xPropertySetInfo;
     109                 :            :     }
     110                 :            : };
     111                 :            : 
     112                 :            : struct StaticDataSeriesInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDataSeriesInfo_Initializer >
     113                 :            : {
     114                 :            : };
     115                 :            : 
     116                 :          0 : void lcl_SetParent(
     117                 :            :     const uno::Reference< uno::XInterface > & xChildInterface,
     118                 :            :     const uno::Reference< uno::XInterface > & xParentInterface )
     119                 :            : {
     120         [ #  # ]:          0 :     uno::Reference< container::XChild > xChild( xChildInterface, uno::UNO_QUERY );
     121         [ #  # ]:          0 :     if( xChild.is())
     122 [ #  # ][ #  # ]:          0 :         xChild->setParent( xParentInterface );
     123                 :          0 : }
     124                 :            : 
     125                 :            : typedef ::std::map< sal_Int32, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > >
     126                 :            :     lcl_tDataPointMap;
     127                 :            : 
     128                 :          0 : void lcl_CloneAttributedDataPoints(
     129                 :            :     const lcl_tDataPointMap & rSource, lcl_tDataPointMap & rDestination,
     130                 :            :     const uno::Reference< uno::XInterface > & xSeries )
     131                 :            : {
     132         [ #  # ]:          0 :     for( lcl_tDataPointMap::const_iterator aIt( rSource.begin());
     133                 :          0 :          aIt != rSource.end(); ++aIt )
     134                 :            :     {
     135                 :          0 :         Reference< beans::XPropertySet > xPoint( (*aIt).second );
     136         [ #  # ]:          0 :         if( xPoint.is())
     137                 :            :         {
     138         [ #  # ]:          0 :             Reference< util::XCloneable > xCloneable( xPoint, uno::UNO_QUERY );
     139         [ #  # ]:          0 :             if( xCloneable.is())
     140                 :            :             {
     141 [ #  # ][ #  # ]:          0 :                 xPoint.set( xCloneable->createClone(), uno::UNO_QUERY );
                 [ #  # ]
     142         [ #  # ]:          0 :                 if( xPoint.is())
     143                 :            :                 {
     144         [ #  # ]:          0 :                     lcl_SetParent( xPoint, xSeries );
     145 [ #  # ][ #  # ]:          0 :                     rDestination.insert( lcl_tDataPointMap::value_type( (*aIt).first, xPoint ));
                 [ #  # ]
     146                 :            :                 }
     147                 :          0 :             }
     148                 :            :         }
     149                 :          0 :     }
     150                 :          0 : }
     151                 :            : 
     152                 :            : } // anonymous namespace
     153                 :            : 
     154                 :            : // ----------------------------------------
     155                 :            : 
     156                 :            : namespace chart
     157                 :            : {
     158                 :            : 
     159                 :        287 : DataSeries::DataSeries( const uno::Reference< uno::XComponentContext > & xContext ) :
     160                 :            :         ::property::OPropertySet( m_aMutex ),
     161                 :            :         m_xContext( xContext ),
     162 [ +  - ][ +  - ]:        287 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     163                 :            : {
     164                 :        287 : }
     165                 :            : 
     166                 :         35 : DataSeries::DataSeries( const DataSeries & rOther ) :
     167                 :            :         MutexContainer(),
     168                 :            :         impl::DataSeries_Base(),
     169                 :            :         ::property::OPropertySet( rOther, m_aMutex ),
     170                 :            :     m_xContext( rOther.m_xContext ),
     171 [ +  - ][ +  - ]:         35 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     172                 :            : {
     173         [ +  - ]:         35 :     if( ! rOther.m_aDataSequences.empty())
     174                 :            :     {
     175                 :            :         CloneHelper::CloneRefVector< tDataSequenceContainer::value_type >(
     176         [ +  - ]:         35 :             rOther.m_aDataSequences, m_aDataSequences );
     177         [ +  - ]:         35 :         ModifyListenerHelper::addListenerToAllElements( m_aDataSequences, m_xModifyEventForwarder );
     178                 :            :     }
     179                 :            : 
     180         [ +  - ]:         35 :     CloneHelper::CloneRefVector< Reference< chart2::XRegressionCurve > >( rOther.m_aRegressionCurves, m_aRegressionCurves );
     181         [ +  - ]:         35 :     ModifyListenerHelper::addListenerToAllElements( m_aRegressionCurves, m_xModifyEventForwarder );
     182                 :            : 
     183                 :            :     // add as listener to XPropertySet properties
     184                 :         35 :     Reference< beans::XPropertySet > xPropertySet;
     185                 :         35 :     uno::Any aValue;
     186                 :            : 
     187         [ +  - ]:         35 :     getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X );
     188         [ +  - ]:         70 :     if( ( aValue >>= xPropertySet )
           [ +  -  -  + ]
                 [ -  + ]
     189                 :         35 :         && xPropertySet.is())
     190         [ #  # ]:          0 :         ModifyListenerHelper::addListener( xPropertySet, m_xModifyEventForwarder );
     191                 :            : 
     192         [ +  - ]:         35 :     getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y );
     193         [ +  - ]:         70 :     if( ( aValue >>= xPropertySet )
           [ +  -  -  + ]
                 [ -  + ]
     194                 :         35 :         && xPropertySet.is())
     195         [ #  # ]:         35 :         ModifyListenerHelper::addListener( xPropertySet, m_xModifyEventForwarder );
     196                 :         35 : }
     197                 :            : 
     198                 :            : // late initialization to call after copy-constructing
     199                 :         35 : void DataSeries::Init( const DataSeries & rOther )
     200                 :            : {
     201         [ +  - ]:         35 :     if( ! rOther.m_aDataSequences.empty())
     202 [ +  - ][ +  - ]:         35 :         EventListenerHelper::addListenerToAllElements( m_aDataSequences, this );
     203                 :            : 
     204         [ +  - ]:         35 :     Reference< uno::XInterface > xThisInterface( static_cast< ::cppu::OWeakObject * >( this ));
     205         [ -  + ]:         35 :     if( ! rOther.m_aAttributedDataPoints.empty())
     206                 :            :     {
     207                 :            :         lcl_CloneAttributedDataPoints(
     208         [ #  # ]:          0 :             rOther.m_aAttributedDataPoints, m_aAttributedDataPoints, xThisInterface );
     209         [ #  # ]:          0 :         ModifyListenerHelper::addListenerToAllMapElements( m_aAttributedDataPoints, m_xModifyEventForwarder );
     210                 :            :     }
     211                 :            : 
     212                 :            :     // add as parent to error bars
     213                 :         35 :     Reference< beans::XPropertySet > xPropertySet;
     214                 :         35 :     uno::Any aValue;
     215                 :            : 
     216         [ +  - ]:         35 :     getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X );
     217         [ +  - ]:         70 :     if( ( aValue >>= xPropertySet )
           [ +  -  -  + ]
                 [ -  + ]
     218                 :         35 :         && xPropertySet.is())
     219         [ #  # ]:          0 :         lcl_SetParent( xPropertySet, xThisInterface );
     220                 :            : 
     221         [ +  - ]:         35 :     getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y );
     222         [ +  - ]:         70 :     if( ( aValue >>= xPropertySet )
           [ +  -  -  + ]
                 [ -  + ]
     223                 :         35 :         && xPropertySet.is())
     224         [ #  # ]:         35 :         lcl_SetParent( xPropertySet, xThisInterface );
     225                 :         35 : }
     226                 :            : 
     227 [ +  - ][ +  - ]:        322 : DataSeries::~DataSeries()
     228                 :            : {
     229                 :            :     try
     230                 :            :     {
     231         [ +  - ]:        322 :         ModifyListenerHelper::removeListenerFromAllMapElements( m_aAttributedDataPoints, m_xModifyEventForwarder );
     232         [ +  - ]:        322 :         ModifyListenerHelper::removeListenerFromAllElements( m_aRegressionCurves, m_xModifyEventForwarder );
     233         [ +  - ]:        322 :         ModifyListenerHelper::removeListenerFromAllElements( m_aDataSequences, m_xModifyEventForwarder );
     234                 :            : 
     235                 :            :         // remove listener from XPropertySet properties
     236                 :        322 :         Reference< beans::XPropertySet > xPropertySet;
     237                 :        322 :         uno::Any aValue;
     238                 :            : 
     239         [ +  - ]:        322 :         getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X );
     240         [ +  - ]:        644 :         if( ( aValue >>= xPropertySet )
           [ +  -  -  + ]
                 [ -  + ]
     241                 :        322 :             && xPropertySet.is())
     242         [ #  # ]:          0 :             ModifyListenerHelper::removeListener( xPropertySet, m_xModifyEventForwarder );
     243                 :            : 
     244         [ +  - ]:        322 :         getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y );
     245         [ +  - ]:        644 :         if( ( aValue >>= xPropertySet )
           [ +  -  +  + ]
                 [ +  + ]
     246                 :        322 :             && xPropertySet.is())
     247 [ +  - ][ #  # ]:        322 :             ModifyListenerHelper::removeListener( xPropertySet, m_xModifyEventForwarder );
     248                 :            :     }
     249         [ #  # ]:          0 :     catch( const uno::Exception & ex )
     250                 :            :     {
     251                 :            :         ASSERT_EXCEPTION( ex );
     252                 :            :     }
     253         [ -  + ]:        644 : }
     254                 :            : 
     255                 :            : // ____ XCloneable ____
     256                 :         35 : uno::Reference< util::XCloneable > SAL_CALL DataSeries::createClone()
     257                 :            :     throw (uno::RuntimeException)
     258                 :            : {
     259         [ +  - ]:         35 :     DataSeries * pNewSeries( new DataSeries( *this ));
     260                 :            :     // hold a reference to the clone
     261         [ +  - ]:         35 :     uno::Reference< util::XCloneable > xResult( pNewSeries );
     262                 :            :     // do initialization that uses uno references to the clone
     263         [ +  - ]:         35 :     pNewSeries->Init( *this );
     264                 :            : 
     265                 :         35 :     return xResult;
     266                 :            : }
     267                 :            : 
     268                 :          5 : Sequence< OUString > DataSeries::getSupportedServiceNames_Static()
     269                 :            : {
     270                 :          5 :     Sequence< OUString > aServices( 3 );
     271 [ +  - ][ +  - ]:          5 :     aServices[ 0 ] = C2U( "com.sun.star.chart2.DataSeries" );
     272 [ +  - ][ +  - ]:          5 :     aServices[ 1 ] = C2U( "com.sun.star.chart2.DataPointProperties" );
     273 [ +  - ][ +  - ]:          5 :     aServices[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
     274                 :          5 :     return aServices;
     275                 :            : }
     276                 :            : 
     277                 :            : // ____ OPropertySet ____
     278                 :     370432 : uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const
     279                 :            :     throw(beans::UnknownPropertyException)
     280                 :            : {
     281         [ +  - ]:     370432 :     const tPropertyValueMap& rStaticDefaults = *StaticDataSeriesDefaults::get();
     282         [ +  - ]:     370432 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     283         [ +  + ]:     370432 :     if( aFound == rStaticDefaults.end() )
     284                 :      25824 :         return uno::Any();
     285                 :     370432 :     return (*aFound).second;
     286                 :            : }
     287                 :            : 
     288                 :            : // ____ OPropertySet ____
     289                 :     866532 : ::cppu::IPropertyArrayHelper & SAL_CALL DataSeries::getInfoHelper()
     290                 :            : {
     291                 :     866532 :     return *StaticDataSeriesInfoHelper::get();
     292                 :            : }
     293                 :            : 
     294                 :            : // ____ XPropertySet ____
     295                 :          0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL DataSeries::getPropertySetInfo()
     296                 :            :     throw (uno::RuntimeException)
     297                 :            : {
     298                 :          0 :     return *StaticDataSeriesInfo::get();
     299                 :            : }
     300                 :            : 
     301                 :     434431 : void SAL_CALL DataSeries::getFastPropertyValue
     302                 :            :     ( uno::Any& rValue,
     303                 :            :       sal_Int32 nHandle ) const
     304                 :            : {
     305                 :            :     // special handling for get.  set is not possible for this property
     306         [ +  + ]:     434431 :     if( nHandle == DataSeriesProperties::PROP_DATASERIES_ATTRIBUTED_DATA_POINTS )
     307                 :            :     {
     308                 :            :         // ToDo: only add those property sets that are really modified
     309         [ +  - ]:       9995 :         uno::Sequence< sal_Int32 > aSeq( m_aAttributedDataPoints.size());
     310         [ +  - ]:       9995 :         sal_Int32 * pIndexArray = aSeq.getArray();
     311                 :       9995 :         sal_Int32 i = 0;
     312                 :            : 
     313         [ +  + ]:      21302 :         for( tDataPointAttributeContainer::const_iterator aIt( m_aAttributedDataPoints.begin());
     314                 :      10651 :              aIt != m_aAttributedDataPoints.end(); ++aIt )
     315                 :            :         {
     316                 :        656 :             pIndexArray[ i ] = (*aIt).first;
     317                 :        656 :             ++i;
     318                 :            :         }
     319                 :            : 
     320 [ +  - ][ +  - ]:       9995 :         rValue <<= aSeq;
     321                 :            :     }
     322                 :            :     else
     323                 :     424436 :         OPropertySet::getFastPropertyValue( rValue, nHandle );
     324                 :     434431 : }
     325                 :            : 
     326                 :       1274 : void SAL_CALL DataSeries::setFastPropertyValue_NoBroadcast(
     327                 :            :     sal_Int32 nHandle, const uno::Any& rValue )
     328                 :            :     throw (uno::Exception)
     329                 :            : {
     330 [ +  + ][ -  + ]:       1274 :     if(    nHandle == DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y
     331                 :            :         || nHandle == DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X )
     332                 :            :     {
     333                 :         24 :         uno::Any aOldValue;
     334                 :         24 :         Reference< util::XModifyBroadcaster > xBroadcaster;
     335         [ +  - ]:         24 :         this->getFastPropertyValue( aOldValue, nHandle );
     336         [ +  - ]:         72 :         if( aOldValue.hasValue() &&
           [ +  -  -  + ]
                 [ -  + ]
     337         [ +  - ]:         24 :             (aOldValue >>= xBroadcaster) &&
     338                 :         24 :             xBroadcaster.is())
     339                 :            :         {
     340         [ #  # ]:          0 :             ModifyListenerHelper::removeListener( xBroadcaster, m_xModifyEventForwarder );
     341                 :            :         }
     342                 :            : 
     343                 :            :         OSL_ASSERT( rValue.getValueType().getTypeClass() == uno::TypeClass_INTERFACE );
     344         [ +  - ]:         72 :         if( rValue.hasValue() &&
           [ +  -  +  - ]
                 [ +  - ]
     345         [ +  - ]:         24 :             (rValue >>= xBroadcaster) &&
     346                 :         24 :             xBroadcaster.is())
     347                 :            :         {
     348         [ +  - ]:         24 :             ModifyListenerHelper::addListener( xBroadcaster, m_xModifyEventForwarder );
     349                 :         24 :         }
     350                 :            :     }
     351                 :            : 
     352                 :       1274 :     ::property::OPropertySet::setFastPropertyValue_NoBroadcast( nHandle, rValue );
     353                 :       1274 : }
     354                 :            : 
     355                 :            : Reference< beans::XPropertySet >
     356                 :       3934 :     SAL_CALL DataSeries::getDataPointByIndex( sal_Int32 nIndex )
     357                 :            :     throw (lang::IndexOutOfBoundsException,
     358                 :            :            uno::RuntimeException)
     359                 :            : {
     360                 :       3934 :     Reference< beans::XPropertySet > xResult;
     361                 :            : 
     362         [ +  - ]:       3934 :     Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences;
     363                 :            :     {
     364 [ +  - ][ +  - ]:       3934 :         MutexGuard aGuard( GetMutex() );
     365 [ +  - ][ +  - ]:       3934 :         aSequences = ContainerHelper::ContainerToSequence( m_aDataSequences );
         [ +  - ][ +  - ]
     366                 :            :     }
     367                 :            : 
     368                 :            :     ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
     369 [ +  - ][ +  - ]:       3934 :         DataSeriesHelper::getAllDataSequencesByRole( aSequences , C2U("values"), true ) );
     370         [ +  - ]:       3934 :     if( !aValuesSeries.empty() )
     371                 :            :     {
     372 [ +  - ][ +  - ]:       3934 :         Reference< chart2::data::XDataSequence > xSeq( aValuesSeries.front()->getValues() );
                 [ +  - ]
     373 [ +  - ][ +  - ]:       3934 :         if( 0 <= nIndex && nIndex < xSeq->getData().getLength() )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
           [ +  -  #  # ]
     374                 :            :         {
     375                 :            :             {
     376 [ +  - ][ +  - ]:       3934 :                 MutexGuard aGuard( GetMutex() );
     377         [ +  - ]:       3934 :                 tDataPointAttributeContainer::iterator aIt( m_aAttributedDataPoints.find( nIndex ) );
     378         [ +  + ]:       3934 :                 if( aIt != m_aAttributedDataPoints.end() )
     379 [ +  - ][ +  - ]:       3934 :                     xResult = (*aIt).second;
     380                 :            :             }
     381         [ +  + ]:       3934 :             if( !xResult.is() )
     382                 :            :             {
     383                 :          2 :                 Reference< beans::XPropertySet > xParentProperties;
     384                 :          2 :                 Reference< util::XModifyListener > xModifyEventForwarder;
     385                 :            :                 {
     386 [ +  - ][ +  - ]:          2 :                     MutexGuard aGuard( GetMutex() );
     387         [ +  - ]:          2 :                     xParentProperties = this;
     388 [ +  - ][ +  - ]:          2 :                     xModifyEventForwarder = m_xModifyEventForwarder;
     389                 :            :                 }
     390                 :            : 
     391                 :            :                 // create a new XPropertySet for this data point
     392 [ +  - ][ +  - ]:          2 :                 xResult.set( new DataPoint( xParentProperties ) );
                 [ +  - ]
     393                 :            :                 {
     394 [ +  - ][ +  - ]:          2 :                     MutexGuard aGuard( GetMutex() );
     395 [ +  - ][ +  - ]:          2 :                     m_aAttributedDataPoints[ nIndex ] = xResult;
                 [ +  - ]
     396                 :            :                 }
     397         [ +  - ]:          2 :                 ModifyListenerHelper::addListener( xResult, xModifyEventForwarder );
     398                 :            :             }
     399                 :       3934 :         }
     400                 :            :     }
     401                 :            :     else
     402                 :            :     {
     403         [ #  # ]:       3934 :         throw lang::IndexOutOfBoundsException();
     404                 :            :     }
     405                 :            : 
     406         [ +  - ]:       7868 :     return xResult;
     407                 :            : }
     408                 :            : 
     409                 :          0 : void SAL_CALL DataSeries::resetDataPoint( sal_Int32 nIndex )
     410                 :            :         throw (uno::RuntimeException)
     411                 :            : {
     412                 :          0 :     Reference< beans::XPropertySet > xDataPointProp;
     413                 :          0 :     Reference< util::XModifyListener > xModifyEventForwarder;
     414                 :            :     {
     415 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( GetMutex() );
     416         [ #  # ]:          0 :         xModifyEventForwarder = m_xModifyEventForwarder;
     417         [ #  # ]:          0 :         tDataPointAttributeContainer::iterator aIt( m_aAttributedDataPoints.find( nIndex ));
     418         [ #  # ]:          0 :         if( aIt != m_aAttributedDataPoints.end())
     419                 :            :         {
     420         [ #  # ]:          0 :             xDataPointProp = (*aIt).second;
     421         [ #  # ]:          0 :             m_aAttributedDataPoints.erase(aIt);
     422         [ #  # ]:          0 :         }
     423                 :            : 
     424                 :            :     }
     425         [ #  # ]:          0 :     if( xDataPointProp.is() )
     426                 :            :     {
     427         [ #  # ]:          0 :         Reference< util::XModifyBroadcaster > xBroadcaster( xDataPointProp, uno::UNO_QUERY );
     428 [ #  # ][ #  # ]:          0 :         if( xBroadcaster.is() && xModifyEventForwarder.is())
                 [ #  # ]
     429 [ #  # ][ #  # ]:          0 :             xBroadcaster->removeModifyListener( xModifyEventForwarder );
     430         [ #  # ]:          0 :         fireModifyEvent();
     431                 :          0 :     }
     432                 :          0 : }
     433                 :            : 
     434                 :          0 : void SAL_CALL DataSeries::resetAllDataPoints()
     435                 :            :         throw (uno::RuntimeException)
     436                 :            : {
     437         [ #  # ]:          0 :     tDataPointAttributeContainer  aOldAttributedDataPoints;
     438                 :          0 :     Reference< util::XModifyListener > xModifyEventForwarder;
     439                 :            :     {
     440 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( GetMutex() );
     441         [ #  # ]:          0 :         xModifyEventForwarder = m_xModifyEventForwarder;
     442 [ #  # ][ #  # ]:          0 :         std::swap( aOldAttributedDataPoints, m_aAttributedDataPoints );
     443                 :            :     }
     444         [ #  # ]:          0 :     ModifyListenerHelper::removeListenerFromAllMapElements( aOldAttributedDataPoints, xModifyEventForwarder );
     445                 :          0 :     aOldAttributedDataPoints.clear();
     446         [ #  # ]:          0 :     fireModifyEvent();
     447                 :          0 : }
     448                 :            : 
     449                 :            : // ____ XDataSink ____
     450                 :        553 : void SAL_CALL DataSeries::setData( const uno::Sequence< Reference< chart2::data::XLabeledDataSequence > >& aData )
     451                 :            :     throw (uno::RuntimeException)
     452                 :            : {
     453         [ +  - ]:        553 :     tDataSequenceContainer aOldDataSequences;
     454         [ +  - ]:        553 :     tDataSequenceContainer aNewDataSequences;
     455                 :        553 :     Reference< util::XModifyListener > xModifyEventForwarder;
     456                 :        553 :     Reference< lang::XEventListener > xListener;
     457                 :            :     {
     458 [ +  - ][ +  - ]:        553 :         MutexGuard aGuard( GetMutex() );
     459         [ +  - ]:        553 :         xModifyEventForwarder = m_xModifyEventForwarder;
     460         [ +  - ]:        553 :         xListener = this;
     461                 :        553 :         std::swap( aOldDataSequences, m_aDataSequences );
     462         [ +  - ]:        553 :         aNewDataSequences = ContainerHelper::SequenceToVector( aData );
     463 [ +  - ][ +  - ]:        553 :         m_aDataSequences = aNewDataSequences;
     464                 :            :     }
     465         [ +  - ]:        553 :     ModifyListenerHelper::removeListenerFromAllElements( aOldDataSequences, xModifyEventForwarder );
     466         [ +  - ]:        553 :     EventListenerHelper::removeListenerFromAllElements( aOldDataSequences, xListener );
     467         [ +  - ]:        553 :     EventListenerHelper::addListenerToAllElements( aNewDataSequences, xListener );
     468         [ +  - ]:        553 :     ModifyListenerHelper::addListenerToAllElements( aNewDataSequences, xModifyEventForwarder );
     469         [ +  - ]:        553 :     fireModifyEvent();
     470                 :        553 : }
     471                 :            : 
     472                 :            : // ____ XDataSource ____
     473                 :      20437 : Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL DataSeries::getDataSequences()
     474                 :            :     throw (uno::RuntimeException)
     475                 :            : {
     476 [ +  - ][ +  - ]:      20437 :     MutexGuard aGuard( GetMutex() );
     477 [ +  - ][ +  - ]:      20437 :     return ContainerHelper::ContainerToSequence( m_aDataSequences );
     478                 :            : }
     479                 :            : 
     480                 :            : 
     481                 :            : // ____ XRegressionCurveContainer ____
     482                 :         14 : void SAL_CALL DataSeries::addRegressionCurve(
     483                 :            :     const uno::Reference< chart2::XRegressionCurve >& xRegressionCurve )
     484                 :            :     throw (lang::IllegalArgumentException,
     485                 :            :            uno::RuntimeException)
     486                 :            : {
     487                 :         14 :     Reference< util::XModifyListener > xModifyEventForwarder;
     488                 :            :     {
     489 [ +  - ][ +  - ]:         14 :         MutexGuard aGuard( GetMutex() );
     490         [ +  - ]:         14 :         xModifyEventForwarder = m_xModifyEventForwarder;
     491 [ +  - ][ -  + ]:         28 :         if( ::std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve )
     492         [ +  - ]:         28 :             != m_aRegressionCurves.end())
     493         [ #  # ]:          0 :             throw lang::IllegalArgumentException();
     494 [ +  - ][ +  - ]:         14 :         m_aRegressionCurves.push_back( xRegressionCurve );
     495                 :            :     }
     496         [ +  - ]:         14 :     ModifyListenerHelper::addListener( xRegressionCurve, xModifyEventForwarder );
     497         [ +  - ]:         14 :     fireModifyEvent();
     498                 :         14 : }
     499                 :            : 
     500                 :          0 : void SAL_CALL DataSeries::removeRegressionCurve(
     501                 :            :     const uno::Reference< chart2::XRegressionCurve >& xRegressionCurve )
     502                 :            :     throw (container::NoSuchElementException,
     503                 :            :            uno::RuntimeException)
     504                 :            : {
     505         [ #  # ]:          0 :     if( !xRegressionCurve.is() )
     506         [ #  # ]:          0 :         throw container::NoSuchElementException();
     507                 :            : 
     508                 :          0 :     Reference< util::XModifyListener > xModifyEventForwarder;
     509                 :            :     {
     510 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( GetMutex() );
     511         [ #  # ]:          0 :         xModifyEventForwarder = m_xModifyEventForwarder;
     512                 :            :         tRegressionCurveContainerType::iterator aIt(
     513         [ #  # ]:          0 :             ::std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve ) );
     514 [ #  # ][ #  # ]:          0 :         if( aIt == m_aRegressionCurves.end())
     515                 :            :             throw container::NoSuchElementException(
     516                 :            :                 C2U( "The given regression curve is no element of this series" ),
     517 [ #  # ][ #  # ]:          0 :                 static_cast< uno::XWeak * >( this ));
                 [ #  # ]
     518 [ #  # ][ #  # ]:          0 :         m_aRegressionCurves.erase( aIt );
     519                 :            :     }
     520                 :            : 
     521         [ #  # ]:          0 :     ModifyListenerHelper::removeListener( xRegressionCurve, xModifyEventForwarder );
     522         [ #  # ]:          0 :     fireModifyEvent();
     523                 :          0 : }
     524                 :            : 
     525                 :      16329 : uno::Sequence< uno::Reference< chart2::XRegressionCurve > > SAL_CALL DataSeries::getRegressionCurves()
     526                 :            :     throw (uno::RuntimeException)
     527                 :            : {
     528 [ +  - ][ +  - ]:      16329 :     MutexGuard aGuard( GetMutex() );
     529 [ +  - ][ +  - ]:      16329 :     return ContainerHelper::ContainerToSequence( m_aRegressionCurves );
     530                 :            : }
     531                 :            : 
     532                 :          0 : void SAL_CALL DataSeries::setRegressionCurves(
     533                 :            :     const Sequence< Reference< chart2::XRegressionCurve > >& aRegressionCurves )
     534                 :            :     throw (uno::RuntimeException)
     535                 :            : {
     536         [ #  # ]:          0 :     tRegressionCurveContainerType aOldCurves;
     537         [ #  # ]:          0 :     tRegressionCurveContainerType aNewCurves( ContainerHelper::SequenceToVector( aRegressionCurves ) );
     538                 :          0 :     Reference< util::XModifyListener > xModifyEventForwarder;
     539                 :            :     {
     540 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( GetMutex() );
     541         [ #  # ]:          0 :         xModifyEventForwarder = m_xModifyEventForwarder;
     542                 :          0 :         std::swap( aOldCurves, m_aRegressionCurves );
     543 [ #  # ][ #  # ]:          0 :         m_aRegressionCurves = aNewCurves;
     544                 :            :     }
     545         [ #  # ]:          0 :     ModifyListenerHelper::removeListenerFromAllElements( aOldCurves, xModifyEventForwarder );
     546         [ #  # ]:          0 :     ModifyListenerHelper::addListenerToAllElements( aNewCurves, xModifyEventForwarder );
     547         [ #  # ]:          0 :     fireModifyEvent();
     548                 :          0 : }
     549                 :            : 
     550                 :            : // ____ XModifyBroadcaster ____
     551                 :        629 : void SAL_CALL DataSeries::addModifyListener( const Reference< util::XModifyListener >& aListener )
     552                 :            :     throw (uno::RuntimeException)
     553                 :            : {
     554                 :            :     try
     555                 :            :     {
     556         [ +  - ]:        629 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     557 [ +  - ][ +  - ]:        629 :         xBroadcaster->addModifyListener( aListener );
                 [ #  # ]
     558                 :            :     }
     559                 :          0 :     catch( const uno::Exception & ex )
     560                 :            :     {
     561                 :            :         ASSERT_EXCEPTION( ex );
     562                 :            :     }
     563                 :        629 : }
     564                 :            : 
     565                 :        629 : void SAL_CALL DataSeries::removeModifyListener( const Reference< util::XModifyListener >& aListener )
     566                 :            :     throw (uno::RuntimeException)
     567                 :            : {
     568                 :            :     try
     569                 :            :     {
     570         [ +  - ]:        629 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     571 [ +  - ][ +  - ]:        629 :         xBroadcaster->removeModifyListener( aListener );
                 [ #  # ]
     572                 :            :     }
     573                 :          0 :     catch( const uno::Exception & ex )
     574                 :            :     {
     575                 :            :         ASSERT_EXCEPTION( ex );
     576                 :            :     }
     577                 :        629 : }
     578                 :            : 
     579                 :            : // ____ XModifyListener ____
     580                 :          0 : void SAL_CALL DataSeries::modified( const lang::EventObject& aEvent )
     581                 :            :     throw (uno::RuntimeException)
     582                 :            : {
     583                 :          0 :     m_xModifyEventForwarder->modified( aEvent );
     584                 :          0 : }
     585                 :            : 
     586                 :            : // ____ XEventListener (base of XModifyListener) ____
     587                 :          0 : void SAL_CALL DataSeries::disposing( const lang::EventObject& rEventObject )
     588                 :            :     throw (uno::RuntimeException)
     589                 :            : {
     590                 :            :     // forget disposed data sequences
     591                 :            :     tDataSequenceContainer::iterator aIt(
     592         [ #  # ]:          0 :         ::std::find( m_aDataSequences.begin(), m_aDataSequences.end(), rEventObject.Source ));
     593 [ #  # ][ #  # ]:          0 :     if( aIt != m_aDataSequences.end())
     594         [ #  # ]:          0 :         m_aDataSequences.erase( aIt );
     595                 :          0 : }
     596                 :            : 
     597                 :            : // ____ OPropertySet ____
     598                 :       2562 : void DataSeries::firePropertyChangeEvent()
     599                 :            : {
     600                 :       2562 :     fireModifyEvent();
     601                 :       2562 : }
     602                 :            : 
     603                 :       3129 : void DataSeries::fireModifyEvent()
     604                 :            : {
     605 [ +  - ][ +  - ]:       3129 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
                 [ +  - ]
     606                 :       3129 : }
     607                 :            : 
     608                 :            : 
     609                 :            : // ================================================================================
     610                 :            : 
     611                 :            : using impl::DataSeries_Base;
     612                 :            : using ::property::OPropertySet;
     613                 :            : 
     614 [ +  + ][ +  - ]:    1185710 : IMPLEMENT_FORWARD_XINTERFACE2( DataSeries, DataSeries_Base, OPropertySet )
     615 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataSeries, DataSeries_Base, OPropertySet )
                 [ #  # ]
     616                 :            : 
     617                 :            : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     618 [ #  # ][ #  # ]:        173 : APPHELPER_XSERVICEINFO_IMPL( DataSeries,
         [ #  # ][ #  # ]
                 [ #  # ]
     619                 :            :                              C2U( "com.sun.star.comp.chart.DataSeries" ));
     620                 :            : 
     621                 :            : }  // namespace chart
     622                 :            : 
     623                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10