LCOV - code coverage report
Current view: top level - chart2/source/tools - LabeledDataSequence.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 58 60 96.7 %
Date: 2014-11-03 Functions: 14 17 82.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "LabeledDataSequence.hxx"
      21             : #include "ModifyListenerHelper.hxx"
      22             : #include "macros.hxx"
      23             : 
      24             : using namespace ::com::sun::star;
      25             : 
      26             : using ::com::sun::star::uno::Reference;
      27             : using ::com::sun::star::uno::Sequence;
      28             : 
      29             : namespace chart
      30             : {
      31             : 
      32        6512 : LabeledDataSequence::LabeledDataSequence( const Reference< uno::XComponentContext > & xContext ) :
      33             :         m_xContext( xContext ),
      34        6512 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
      35        6512 : {}
      36             : 
      37        5777 : LabeledDataSequence::LabeledDataSequence(
      38             :     const uno::Reference< chart2::data::XDataSequence > & rValues ) :
      39             :         m_xData( rValues ),
      40        5777 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
      41             : {
      42        5777 :     ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
      43        5777 : }
      44             : 
      45         186 : LabeledDataSequence::LabeledDataSequence(
      46             :     const uno::Reference< chart2::data::XDataSequence > & rValues,
      47             :     const uno::Reference< chart2::data::XDataSequence > & rLabel ) :
      48             :         m_xData( rValues ),
      49             :         m_xLabel( rLabel ),
      50         186 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
      51             : {
      52         186 :     ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
      53         186 :     ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
      54         186 : }
      55             : 
      56       37128 : LabeledDataSequence::~LabeledDataSequence()
      57             : {
      58       12376 :     if( m_xModifyEventForwarder.is())
      59             :     {
      60       12376 :         if( m_xData.is())
      61       12372 :             ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
      62       12376 :         if( m_xLabel.is())
      63        3034 :             ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
      64             :     }
      65       24752 : }
      66             : 
      67             : // ____ XLabeledDataSequence ____
      68      585507 : uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getValues()
      69             :     throw (uno::RuntimeException, std::exception)
      70             : {
      71      585507 :     return m_xData;
      72             : }
      73             : 
      74        6512 : void SAL_CALL LabeledDataSequence::setValues(
      75             :     const uno::Reference< chart2::data::XDataSequence >& xSequence )
      76             :     throw (uno::RuntimeException, std::exception)
      77             : {
      78        6512 :     if( m_xData != xSequence )
      79             :     {
      80        6508 :         ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
      81        6508 :         m_xData = xSequence;
      82        6508 :         ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
      83             :     }
      84        6512 : }
      85             : 
      86       57807 : uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getLabel()
      87             :     throw (uno::RuntimeException, std::exception)
      88             : {
      89       57807 :     return m_xLabel;
      90             : }
      91             : 
      92        3164 : void SAL_CALL LabeledDataSequence::setLabel(
      93             :     const uno::Reference< chart2::data::XDataSequence >& xSequence )
      94             :     throw (uno::RuntimeException, std::exception)
      95             : {
      96        3164 :     if( m_xLabel != xSequence )
      97             :     {
      98        2920 :         ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
      99        2920 :         m_xLabel = xSequence;
     100        2920 :         ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
     101             :     }
     102        3164 : }
     103             : 
     104             : // ____ XCloneable ____
     105          22 : uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone()
     106             :     throw (uno::RuntimeException, std::exception)
     107             : {
     108          22 :     uno::Reference< chart2::data::XDataSequence > xNewValues( m_xData );
     109          44 :     uno::Reference< chart2::data::XDataSequence > xNewLabel( m_xLabel );
     110             : 
     111          44 :     uno::Reference< util::XCloneable > xLabelCloneable( m_xLabel, uno::UNO_QUERY );
     112          22 :     if( xLabelCloneable.is())
     113          22 :         xNewLabel.set( xLabelCloneable->createClone(), uno::UNO_QUERY );
     114             : 
     115          44 :     uno::Reference< util::XCloneable > xValuesCloneable( m_xData, uno::UNO_QUERY );
     116          22 :     if( xValuesCloneable.is())
     117          22 :         xNewValues.set( xValuesCloneable->createClone(), uno::UNO_QUERY );
     118             : 
     119             :     return uno::Reference< util::XCloneable >(
     120          44 :         new LabeledDataSequence( xNewValues, xNewLabel ) );
     121             : }
     122             : 
     123             : // ____ XModifyBroadcaster ____
     124        2504 : void SAL_CALL LabeledDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
     125             :     throw (uno::RuntimeException, std::exception)
     126             : {
     127             :     try
     128             :     {
     129        2504 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     130        2504 :         xBroadcaster->addModifyListener( aListener );
     131             :     }
     132           0 :     catch( const uno::Exception & ex )
     133             :     {
     134             :         ASSERT_EXCEPTION( ex );
     135             :     }
     136        2504 : }
     137             : 
     138        2382 : void SAL_CALL LabeledDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
     139             :     throw (uno::RuntimeException, std::exception)
     140             : {
     141             :     try
     142             :     {
     143        2382 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     144        2382 :         xBroadcaster->removeModifyListener( aListener );
     145             :     }
     146           0 :     catch( const uno::Exception & ex )
     147             :     {
     148             :         ASSERT_EXCEPTION( ex );
     149             :     }
     150        2382 : }
     151             : 
     152          28 : Sequence< OUString > LabeledDataSequence::getSupportedServiceNames_Static()
     153             : {
     154          28 :     Sequence< OUString > aServices( 1 );
     155          28 :     aServices[ 0 ] = "com.sun.star.chart2.data.LabeledDataSequence";
     156          28 :     return aServices;
     157             : }
     158             : 
     159             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     160          94 : APPHELPER_XSERVICEINFO_IMPL( LabeledDataSequence,
     161             :                              OUString("com.sun.star.comp.chart2.LabeledDataSequence") )
     162             : 
     163             : } //  namespace chart
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10