LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/chart2/source/tools - LabeledDataSequence.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 60 96.7 %
Date: 2013-07-09 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             : 
      21             : #include "LabeledDataSequence.hxx"
      22             : #include "ModifyListenerHelper.hxx"
      23             : #include "macros.hxx"
      24             : 
      25             : using namespace ::com::sun::star;
      26             : 
      27             : using ::com::sun::star::uno::Reference;
      28             : using ::com::sun::star::uno::Sequence;
      29             : 
      30             : namespace chart
      31             : {
      32             : 
      33        2130 : LabeledDataSequence::LabeledDataSequence( const Reference< uno::XComponentContext > & xContext ) :
      34             :         m_xContext( xContext ),
      35        2130 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
      36        2130 : {}
      37             : 
      38        6730 : LabeledDataSequence::LabeledDataSequence(
      39             :     const uno::Reference< chart2::data::XDataSequence > & rValues ) :
      40             :         m_xData( rValues ),
      41        6730 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
      42             : {
      43        6730 :     ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
      44        6730 : }
      45             : 
      46         261 : LabeledDataSequence::LabeledDataSequence(
      47             :     const uno::Reference< chart2::data::XDataSequence > & rValues,
      48             :     const uno::Reference< chart2::data::XDataSequence > & rLabel ) :
      49             :         m_xData( rValues ),
      50             :         m_xLabel( rLabel ),
      51         261 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
      52             : {
      53         261 :     ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
      54         261 :     ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
      55         261 : }
      56             : 
      57       27363 : LabeledDataSequence::~LabeledDataSequence()
      58             : {
      59        9121 :     if( m_xModifyEventForwarder.is())
      60             :     {
      61        9121 :         if( m_xData.is())
      62        9120 :             ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
      63        9121 :         if( m_xLabel.is())
      64        1155 :             ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
      65             :     }
      66       18242 : }
      67             : 
      68             : // ____ XLabeledDataSequence ____
      69       51183 : uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getValues()
      70             :     throw (uno::RuntimeException)
      71             : {
      72       51183 :     return m_xData;
      73             : }
      74             : 
      75        2129 : void SAL_CALL LabeledDataSequence::setValues(
      76             :     const uno::Reference< chart2::data::XDataSequence >& xSequence )
      77             :     throw (uno::RuntimeException)
      78             : {
      79        2129 :     if( m_xData != xSequence )
      80             :     {
      81        2129 :         ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
      82        2129 :         m_xData = xSequence;
      83        2129 :         ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
      84             :     }
      85        2129 : }
      86             : 
      87       28411 : uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getLabel()
      88             :     throw (uno::RuntimeException)
      89             : {
      90       28411 :     return m_xLabel;
      91             : }
      92             : 
      93         896 : void SAL_CALL LabeledDataSequence::setLabel(
      94             :     const uno::Reference< chart2::data::XDataSequence >& xSequence )
      95             :     throw (uno::RuntimeException)
      96             : {
      97         896 :     if( m_xLabel != xSequence )
      98             :     {
      99         894 :         ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
     100         894 :         m_xLabel = xSequence;
     101         894 :         ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
     102             :     }
     103         896 : }
     104             : 
     105             : // ____ XCloneable ____
     106          30 : uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone()
     107             :     throw (uno::RuntimeException)
     108             : {
     109          30 :     uno::Reference< chart2::data::XDataSequence > xNewValues( m_xData );
     110          60 :     uno::Reference< chart2::data::XDataSequence > xNewLabel( m_xLabel );
     111             : 
     112          60 :     uno::Reference< util::XCloneable > xLabelCloneable( m_xLabel, uno::UNO_QUERY );
     113          30 :     if( xLabelCloneable.is())
     114          30 :         xNewLabel.set( xLabelCloneable->createClone(), uno::UNO_QUERY );
     115             : 
     116          60 :     uno::Reference< util::XCloneable > xValuesCloneable( m_xData, uno::UNO_QUERY );
     117          30 :     if( xValuesCloneable.is())
     118          30 :         xNewValues.set( xValuesCloneable->createClone(), uno::UNO_QUERY );
     119             : 
     120             :     return uno::Reference< util::XCloneable >(
     121          60 :         new LabeledDataSequence( xNewValues, xNewLabel ) );
     122             : }
     123             : 
     124             : // ____ XModifyBroadcaster ____
     125         722 : void SAL_CALL LabeledDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
     126             :     throw (uno::RuntimeException)
     127             : {
     128             :     try
     129             :     {
     130         722 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     131         722 :         xBroadcaster->addModifyListener( aListener );
     132             :     }
     133           0 :     catch( const uno::Exception & ex )
     134             :     {
     135             :         ASSERT_EXCEPTION( ex );
     136             :     }
     137         722 : }
     138             : 
     139         718 : void SAL_CALL LabeledDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
     140             :     throw (uno::RuntimeException)
     141             : {
     142             :     try
     143             :     {
     144         718 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     145         718 :         xBroadcaster->removeModifyListener( aListener );
     146             :     }
     147           0 :     catch( const uno::Exception & ex )
     148             :     {
     149             :         ASSERT_EXCEPTION( ex );
     150             :     }
     151         718 : }
     152             : 
     153             : // ================================================================================
     154             : 
     155           7 : Sequence< OUString > LabeledDataSequence::getSupportedServiceNames_Static()
     156             : {
     157           7 :     Sequence< OUString > aServices( 1 );
     158           7 :     aServices[ 0 ] = "com.sun.star.chart2.data.LabeledDataSequence";
     159           7 :     return aServices;
     160             : }
     161             : 
     162             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     163          25 : APPHELPER_XSERVICEINFO_IMPL( LabeledDataSequence,
     164             :                              OUString("com.sun.star.comp.chart2.LabeledDataSequence") )
     165             : 
     166             : // ================================================================================
     167             : 
     168             : } //  namespace chart
     169             : 
     170             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10