LCOV - code coverage report
Current view: top level - chart2/source/tools - LabeledDataSequence.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 58 60 96.7 %
Date: 2014-04-11 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        2686 : LabeledDataSequence::LabeledDataSequence( const Reference< uno::XComponentContext > & xContext ) :
      33             :         m_xContext( xContext ),
      34        2686 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
      35        2686 : {}
      36             : 
      37       10703 : LabeledDataSequence::LabeledDataSequence(
      38             :     const uno::Reference< chart2::data::XDataSequence > & rValues ) :
      39             :         m_xData( rValues ),
      40       10703 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
      41             : {
      42       10703 :     ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
      43       10703 : }
      44             : 
      45         472 : 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         472 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
      51             : {
      52         472 :     ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
      53         472 :     ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
      54         472 : }
      55             : 
      56       40275 : LabeledDataSequence::~LabeledDataSequence()
      57             : {
      58       13425 :     if( m_xModifyEventForwarder.is())
      59             :     {
      60       13425 :         if( m_xData.is())
      61       13423 :             ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
      62       13425 :         if( m_xLabel.is())
      63        1401 :             ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
      64             :     }
      65       26850 : }
      66             : 
      67             : // ____ XLabeledDataSequence ____
      68      236687 : uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getValues()
      69             :     throw (uno::RuntimeException, std::exception)
      70             : {
      71      236687 :     return m_xData;
      72             : }
      73             : 
      74        2685 : void SAL_CALL LabeledDataSequence::setValues(
      75             :     const uno::Reference< chart2::data::XDataSequence >& xSequence )
      76             :     throw (uno::RuntimeException, std::exception)
      77             : {
      78        2685 :     if( m_xData != xSequence )
      79             :     {
      80        2684 :         ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
      81        2684 :         m_xData = xSequence;
      82        2684 :         ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
      83             :     }
      84        2685 : }
      85             : 
      86       30444 : uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getLabel()
      87             :     throw (uno::RuntimeException, std::exception)
      88             : {
      89       30444 :     return m_xLabel;
      90             : }
      91             : 
      92        1330 : void SAL_CALL LabeledDataSequence::setLabel(
      93             :     const uno::Reference< chart2::data::XDataSequence >& xSequence )
      94             :     throw (uno::RuntimeException, std::exception)
      95             : {
      96        1330 :     if( m_xLabel != xSequence )
      97             :     {
      98        1264 :         ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
      99        1264 :         m_xLabel = xSequence;
     100        1264 :         ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
     101             :     }
     102        1330 : }
     103             : 
     104             : // ____ XCloneable ____
     105          30 : uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone()
     106             :     throw (uno::RuntimeException, std::exception)
     107             : {
     108          30 :     uno::Reference< chart2::data::XDataSequence > xNewValues( m_xData );
     109          60 :     uno::Reference< chart2::data::XDataSequence > xNewLabel( m_xLabel );
     110             : 
     111          60 :     uno::Reference< util::XCloneable > xLabelCloneable( m_xLabel, uno::UNO_QUERY );
     112          30 :     if( xLabelCloneable.is())
     113          30 :         xNewLabel.set( xLabelCloneable->createClone(), uno::UNO_QUERY );
     114             : 
     115          60 :     uno::Reference< util::XCloneable > xValuesCloneable( m_xData, uno::UNO_QUERY );
     116          30 :     if( xValuesCloneable.is())
     117          30 :         xNewValues.set( xValuesCloneable->createClone(), uno::UNO_QUERY );
     118             : 
     119             :     return uno::Reference< util::XCloneable >(
     120          60 :         new LabeledDataSequence( xNewValues, xNewLabel ) );
     121             : }
     122             : 
     123             : // ____ XModifyBroadcaster ____
     124        1453 : void SAL_CALL LabeledDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
     125             :     throw (uno::RuntimeException, std::exception)
     126             : {
     127             :     try
     128             :     {
     129        1453 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     130        1453 :         xBroadcaster->addModifyListener( aListener );
     131             :     }
     132           0 :     catch( const uno::Exception & ex )
     133             :     {
     134             :         ASSERT_EXCEPTION( ex );
     135             :     }
     136        1453 : }
     137             : 
     138        1010 : void SAL_CALL LabeledDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
     139             :     throw (uno::RuntimeException, std::exception)
     140             : {
     141             :     try
     142             :     {
     143        1010 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     144        1010 :         xBroadcaster->removeModifyListener( aListener );
     145             :     }
     146           0 :     catch( const uno::Exception & ex )
     147             :     {
     148             :         ASSERT_EXCEPTION( ex );
     149             :     }
     150        1010 : }
     151             : 
     152          12 : Sequence< OUString > LabeledDataSequence::getSupportedServiceNames_Static()
     153             : {
     154          12 :     Sequence< OUString > aServices( 1 );
     155          12 :     aServices[ 0 ] = "com.sun.star.chart2.data.LabeledDataSequence";
     156          12 :     return aServices;
     157             : }
     158             : 
     159             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     160          43 : 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