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

Generated by: LCOV version 1.10