nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / tools / LabeledDataSequence.cxx
blobc3a896b22ff69f3e284fce56ff1b12f6cad634ec
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 .
20 #include <LabeledDataSequence.hxx>
21 #include <ModifyListenerHelper.hxx>
22 #include <cppuhelper/supportsservice.hxx>
23 #include <tools/diagnose_ex.h>
25 namespace com::sun::star::uno { class XComponentContext; }
27 using namespace ::com::sun::star;
29 using ::com::sun::star::uno::Reference;
30 using ::com::sun::star::uno::Sequence;
32 namespace chart
35 LabeledDataSequence::LabeledDataSequence() :
36 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
39 LabeledDataSequence::LabeledDataSequence(
40 const uno::Reference< chart2::data::XDataSequence > & rValues ) :
41 m_xData( rValues ),
42 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
44 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
47 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 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
54 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
55 ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
58 LabeledDataSequence::~LabeledDataSequence()
60 if( m_xModifyEventForwarder.is())
62 if( m_xData.is())
63 ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
64 if( m_xLabel.is())
65 ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
69 // ____ XLabeledDataSequence ____
70 uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getValues()
72 return m_xData;
75 void SAL_CALL LabeledDataSequence::setValues(
76 const uno::Reference< chart2::data::XDataSequence >& xSequence )
78 if( m_xData != xSequence )
80 ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
81 m_xData = xSequence;
82 ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
86 uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getLabel()
88 return m_xLabel;
91 void SAL_CALL LabeledDataSequence::setLabel(
92 const uno::Reference< chart2::data::XDataSequence >& xSequence )
94 if( m_xLabel != xSequence )
96 ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
97 m_xLabel = xSequence;
98 ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
102 // ____ XCloneable ____
103 uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone()
105 uno::Reference< chart2::data::XDataSequence > xNewValues( m_xData );
106 uno::Reference< chart2::data::XDataSequence > xNewLabel( m_xLabel );
108 uno::Reference< util::XCloneable > xLabelCloneable( m_xLabel, uno::UNO_QUERY );
109 if( xLabelCloneable.is())
110 xNewLabel.set( xLabelCloneable->createClone(), uno::UNO_QUERY );
112 uno::Reference< util::XCloneable > xValuesCloneable( m_xData, uno::UNO_QUERY );
113 if( xValuesCloneable.is())
114 xNewValues.set( xValuesCloneable->createClone(), uno::UNO_QUERY );
116 return uno::Reference< util::XCloneable >(
117 new LabeledDataSequence( xNewValues, xNewLabel ) );
120 // ____ XModifyBroadcaster ____
121 void SAL_CALL LabeledDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
125 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
126 xBroadcaster->addModifyListener( aListener );
128 catch( const uno::Exception & )
130 DBG_UNHANDLED_EXCEPTION("chart2");
134 void SAL_CALL LabeledDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
138 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
139 xBroadcaster->removeModifyListener( aListener );
141 catch( const uno::Exception & )
143 DBG_UNHANDLED_EXCEPTION("chart2");
147 OUString SAL_CALL LabeledDataSequence::getImplementationName()
149 return "com.sun.star.comp.chart2.LabeledDataSequence";
152 sal_Bool SAL_CALL LabeledDataSequence::supportsService( const OUString& rServiceName )
154 return cppu::supportsService(this, rServiceName);
157 css::uno::Sequence< OUString > SAL_CALL LabeledDataSequence::getSupportedServiceNames()
159 return { "com.sun.star.chart2.data.LabeledDataSequence" };
162 } // namespace chart
164 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
165 com_sun_star_comp_chart2_LabeledDataSequence_get_implementation(css::uno::XComponentContext *,
166 css::uno::Sequence<css::uno::Any> const &)
168 return cppu::acquire(new ::chart::LabeledDataSequence );
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */