merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / tools / LabeledDataSequence.cxx
blob21ade3aefadc6e830b894f2b8eeae5a3dd5eb998
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "LabeledDataSequence.hxx"
32 #include "ModifyListenerHelper.hxx"
33 #include "macros.hxx"
35 using namespace ::com::sun::star;
37 using ::com::sun::star::uno::Reference;
38 using ::com::sun::star::uno::Sequence;
39 using ::rtl::OUString;
41 namespace chart
44 LabeledDataSequence::LabeledDataSequence( const Reference< uno::XComponentContext > & xContext ) :
45 m_xContext( xContext ),
46 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
49 LabeledDataSequence::LabeledDataSequence(
50 const uno::Reference< chart2::data::XDataSequence > & rValues ) :
51 m_xData( rValues ),
52 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
54 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
57 LabeledDataSequence::LabeledDataSequence(
58 const uno::Reference< chart2::data::XDataSequence > & rValues,
59 const uno::Reference< chart2::data::XDataSequence > & rLabel ) :
60 m_xData( rValues ),
61 m_xLabel( rLabel ),
62 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
64 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
65 ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
68 LabeledDataSequence::~LabeledDataSequence()
70 if( m_xModifyEventForwarder.is())
72 if( m_xData.is())
73 ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
74 if( m_xLabel.is())
75 ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
79 // ____ XLabeledDataSequence ____
80 uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getValues()
81 throw (uno::RuntimeException)
83 return m_xData;
86 void SAL_CALL LabeledDataSequence::setValues(
87 const uno::Reference< chart2::data::XDataSequence >& xSequence )
88 throw (uno::RuntimeException)
90 if( m_xData != xSequence )
92 ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
93 m_xData = xSequence;
94 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
98 uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getLabel()
99 throw (uno::RuntimeException)
101 return m_xLabel;
104 void SAL_CALL LabeledDataSequence::setLabel(
105 const uno::Reference< chart2::data::XDataSequence >& xSequence )
106 throw (uno::RuntimeException)
108 if( m_xLabel != xSequence )
110 ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
111 m_xLabel = xSequence;
112 ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
116 // ____ XCloneable ____
117 uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone()
118 throw (uno::RuntimeException)
120 uno::Reference< chart2::data::XDataSequence > xNewValues( m_xData );
121 uno::Reference< chart2::data::XDataSequence > xNewLabel( m_xLabel );
123 uno::Reference< util::XCloneable > xLabelCloneable( m_xLabel, uno::UNO_QUERY );
124 if( xLabelCloneable.is())
125 xNewLabel.set( xLabelCloneable->createClone(), uno::UNO_QUERY );
127 uno::Reference< util::XCloneable > xValuesCloneable( m_xData, uno::UNO_QUERY );
128 if( xValuesCloneable.is())
129 xNewValues.set( xValuesCloneable->createClone(), uno::UNO_QUERY );
131 return uno::Reference< util::XCloneable >(
132 new LabeledDataSequence( xNewValues, xNewLabel ) );
135 // ____ XModifyBroadcaster ____
136 void SAL_CALL LabeledDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
137 throw (uno::RuntimeException)
141 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
142 xBroadcaster->addModifyListener( aListener );
144 catch( const uno::Exception & ex )
146 ASSERT_EXCEPTION( ex );
150 void SAL_CALL LabeledDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
151 throw (uno::RuntimeException)
155 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
156 xBroadcaster->removeModifyListener( aListener );
158 catch( const uno::Exception & ex )
160 ASSERT_EXCEPTION( ex );
164 // ================================================================================
166 Sequence< OUString > LabeledDataSequence::getSupportedServiceNames_Static()
168 Sequence< OUString > aServices( 1 );
169 aServices[ 0 ] = C2U( "com.sun.star.chart2.data.LabeledDataSequence" );
170 return aServices;
173 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
174 APPHELPER_XSERVICEINFO_IMPL( LabeledDataSequence,
175 C2U( "com.sun.star.comp.chart2.LabeledDataSequence" ))
177 // ================================================================================
179 } // namespace chart