update credits
[LibreOffice.git] / chart2 / source / tools / LabeledDataSequence.cxx
blob8b8785d5d353b0b768e1be98baeb368d8f24de60
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "LabeledDataSequence.hxx"
22 #include "ModifyListenerHelper.hxx"
23 #include "macros.hxx"
25 using namespace ::com::sun::star;
27 using ::com::sun::star::uno::Reference;
28 using ::com::sun::star::uno::Sequence;
30 namespace chart
33 LabeledDataSequence::LabeledDataSequence( const Reference< uno::XComponentContext > & xContext ) :
34 m_xContext( xContext ),
35 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
38 LabeledDataSequence::LabeledDataSequence(
39 const uno::Reference< chart2::data::XDataSequence > & rValues ) :
40 m_xData( rValues ),
41 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
43 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
46 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 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
53 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
54 ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
57 LabeledDataSequence::~LabeledDataSequence()
59 if( m_xModifyEventForwarder.is())
61 if( m_xData.is())
62 ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
63 if( m_xLabel.is())
64 ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
68 // ____ XLabeledDataSequence ____
69 uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getValues()
70 throw (uno::RuntimeException)
72 return m_xData;
75 void SAL_CALL LabeledDataSequence::setValues(
76 const uno::Reference< chart2::data::XDataSequence >& xSequence )
77 throw (uno::RuntimeException)
79 if( m_xData != xSequence )
81 ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
82 m_xData = xSequence;
83 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
87 uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getLabel()
88 throw (uno::RuntimeException)
90 return m_xLabel;
93 void SAL_CALL LabeledDataSequence::setLabel(
94 const uno::Reference< chart2::data::XDataSequence >& xSequence )
95 throw (uno::RuntimeException)
97 if( m_xLabel != xSequence )
99 ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
100 m_xLabel = xSequence;
101 ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
105 // ____ XCloneable ____
106 uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone()
107 throw (uno::RuntimeException)
109 uno::Reference< chart2::data::XDataSequence > xNewValues( m_xData );
110 uno::Reference< chart2::data::XDataSequence > xNewLabel( m_xLabel );
112 uno::Reference< util::XCloneable > xLabelCloneable( m_xLabel, uno::UNO_QUERY );
113 if( xLabelCloneable.is())
114 xNewLabel.set( xLabelCloneable->createClone(), uno::UNO_QUERY );
116 uno::Reference< util::XCloneable > xValuesCloneable( m_xData, uno::UNO_QUERY );
117 if( xValuesCloneable.is())
118 xNewValues.set( xValuesCloneable->createClone(), uno::UNO_QUERY );
120 return uno::Reference< util::XCloneable >(
121 new LabeledDataSequence( xNewValues, xNewLabel ) );
124 // ____ XModifyBroadcaster ____
125 void SAL_CALL LabeledDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
126 throw (uno::RuntimeException)
130 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
131 xBroadcaster->addModifyListener( aListener );
133 catch( const uno::Exception & ex )
135 ASSERT_EXCEPTION( ex );
139 void SAL_CALL LabeledDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
140 throw (uno::RuntimeException)
144 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
145 xBroadcaster->removeModifyListener( aListener );
147 catch( const uno::Exception & ex )
149 ASSERT_EXCEPTION( ex );
153 // ================================================================================
155 Sequence< OUString > LabeledDataSequence::getSupportedServiceNames_Static()
157 Sequence< OUString > aServices( 1 );
158 aServices[ 0 ] = "com.sun.star.chart2.data.LabeledDataSequence";
159 return aServices;
162 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
163 APPHELPER_XSERVICEINFO_IMPL( LabeledDataSequence,
164 OUString("com.sun.star.comp.chart2.LabeledDataSequence") )
166 // ================================================================================
168 } // namespace chart
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */