update dev300-m58
[ooovba.git] / chart2 / source / tools / LabeledDataSequence.cxx
blob2f4c16702c9694210187a5e3f3999678299f6468
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: LabeledDataSequence.cxx,v $
10 * $Revision: 1.4.44.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "LabeledDataSequence.hxx"
35 #include "ModifyListenerHelper.hxx"
36 #include "macros.hxx"
38 using namespace ::com::sun::star;
40 using ::com::sun::star::uno::Reference;
41 using ::com::sun::star::uno::Sequence;
42 using ::rtl::OUString;
44 namespace chart
47 LabeledDataSequence::LabeledDataSequence( const Reference< uno::XComponentContext > & xContext ) :
48 m_xContext( xContext ),
49 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
52 LabeledDataSequence::LabeledDataSequence(
53 const uno::Reference< chart2::data::XDataSequence > & rValues ) :
54 m_xData( rValues ),
55 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
57 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
60 LabeledDataSequence::LabeledDataSequence(
61 const uno::Reference< chart2::data::XDataSequence > & rValues,
62 const uno::Reference< chart2::data::XDataSequence > & rLabel ) :
63 m_xData( rValues ),
64 m_xLabel( rLabel ),
65 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
67 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
68 ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
71 LabeledDataSequence::~LabeledDataSequence()
73 if( m_xModifyEventForwarder.is())
75 if( m_xData.is())
76 ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
77 if( m_xLabel.is())
78 ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
82 // ____ XLabeledDataSequence ____
83 uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getValues()
84 throw (uno::RuntimeException)
86 return m_xData;
89 void SAL_CALL LabeledDataSequence::setValues(
90 const uno::Reference< chart2::data::XDataSequence >& xSequence )
91 throw (uno::RuntimeException)
93 if( m_xData != xSequence )
95 ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
96 m_xData = xSequence;
97 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
101 uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getLabel()
102 throw (uno::RuntimeException)
104 return m_xLabel;
107 void SAL_CALL LabeledDataSequence::setLabel(
108 const uno::Reference< chart2::data::XDataSequence >& xSequence )
109 throw (uno::RuntimeException)
111 if( m_xLabel != xSequence )
113 ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
114 m_xLabel = xSequence;
115 ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
119 // ____ XCloneable ____
120 uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone()
121 throw (uno::RuntimeException)
123 uno::Reference< chart2::data::XDataSequence > xNewValues( m_xData );
124 uno::Reference< chart2::data::XDataSequence > xNewLabel( m_xLabel );
126 uno::Reference< util::XCloneable > xLabelCloneable( m_xLabel, uno::UNO_QUERY );
127 if( xLabelCloneable.is())
128 xNewLabel.set( xLabelCloneable->createClone(), uno::UNO_QUERY );
130 uno::Reference< util::XCloneable > xValuesCloneable( m_xData, uno::UNO_QUERY );
131 if( xValuesCloneable.is())
132 xNewValues.set( xValuesCloneable->createClone(), uno::UNO_QUERY );
134 return uno::Reference< util::XCloneable >(
135 new LabeledDataSequence( xNewValues, xNewLabel ) );
138 // ____ XModifyBroadcaster ____
139 void SAL_CALL LabeledDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
140 throw (uno::RuntimeException)
144 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
145 xBroadcaster->addModifyListener( aListener );
147 catch( const uno::Exception & ex )
149 ASSERT_EXCEPTION( ex );
153 void SAL_CALL LabeledDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
154 throw (uno::RuntimeException)
158 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
159 xBroadcaster->removeModifyListener( aListener );
161 catch( const uno::Exception & ex )
163 ASSERT_EXCEPTION( ex );
167 // ================================================================================
169 Sequence< OUString > LabeledDataSequence::getSupportedServiceNames_Static()
171 Sequence< OUString > aServices( 1 );
172 aServices[ 0 ] = C2U( "com.sun.star.chart2.data.LabeledDataSequence" );
173 return aServices;
176 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
177 APPHELPER_XSERVICEINFO_IMPL( LabeledDataSequence,
178 C2U( "com.sun.star.comp.chart2.LabeledDataSequence" ))
180 // ================================================================================
182 } // namespace chart