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