LCOV - code coverage report
Current view: top level - chart2/source/model/main - DataSeries.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 281 0.0 %
Date: 2014-04-14 Functions: 0 41 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10