Branch data 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 : :
21 : : #include "LabeledDataSequence.hxx"
22 : : #include "ModifyListenerHelper.hxx"
23 : : #include "macros.hxx"
24 : :
25 : : using namespace ::com::sun::star;
26 : :
27 : : using ::com::sun::star::uno::Reference;
28 : : using ::com::sun::star::uno::Sequence;
29 : : using ::rtl::OUString;
30 : :
31 : : namespace chart
32 : : {
33 : :
34 : 3904 : LabeledDataSequence::LabeledDataSequence( const Reference< uno::XComponentContext > & xContext ) :
35 : : m_xContext( xContext ),
36 [ + - ][ + - ]: 3904 : m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
37 : 3904 : {}
38 : :
39 : 12366 : LabeledDataSequence::LabeledDataSequence(
40 : : const uno::Reference< chart2::data::XDataSequence > & rValues ) :
41 : : m_xData( rValues ),
42 [ + - ][ + - ]: 12366 : m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
43 : : {
44 [ + - ]: 12366 : ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
45 : 12366 : }
46 : :
47 : 245 : 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 [ + - ][ + - ]: 245 : m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
53 : : {
54 [ + - ]: 245 : ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
55 [ + - ]: 245 : ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
56 : 245 : }
57 : :
58 [ + - ]: 16515 : LabeledDataSequence::~LabeledDataSequence()
59 : : {
60 [ + - ]: 16515 : if( m_xModifyEventForwarder.is())
61 : : {
62 [ + + ]: 16515 : if( m_xData.is())
63 [ + - ]: 16513 : ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
64 [ + + ]: 16515 : if( m_xLabel.is())
65 [ + - ]: 1155 : ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
66 : : }
67 [ - + ]: 33030 : }
68 : :
69 : : // ____ XLabeledDataSequence ____
70 : 71972 : uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getValues()
71 : : throw (uno::RuntimeException)
72 : : {
73 : 71972 : return m_xData;
74 : : }
75 : :
76 : 3902 : void SAL_CALL LabeledDataSequence::setValues(
77 : : const uno::Reference< chart2::data::XDataSequence >& xSequence )
78 : : throw (uno::RuntimeException)
79 : : {
80 [ + - ]: 3902 : if( m_xData != xSequence )
81 : : {
82 : 3902 : ModifyListenerHelper::removeListener( m_xData, m_xModifyEventForwarder );
83 : 3902 : m_xData = xSequence;
84 : 3902 : ModifyListenerHelper::addListener( m_xData, m_xModifyEventForwarder );
85 : : }
86 : 3902 : }
87 : :
88 : 33629 : uno::Reference< chart2::data::XDataSequence > SAL_CALL LabeledDataSequence::getLabel()
89 : : throw (uno::RuntimeException)
90 : : {
91 : 33629 : return m_xLabel;
92 : : }
93 : :
94 : 910 : void SAL_CALL LabeledDataSequence::setLabel(
95 : : const uno::Reference< chart2::data::XDataSequence >& xSequence )
96 : : throw (uno::RuntimeException)
97 : : {
98 [ + - ]: 910 : if( m_xLabel != xSequence )
99 : : {
100 : 910 : ModifyListenerHelper::removeListener( m_xLabel, m_xModifyEventForwarder );
101 : 910 : m_xLabel = xSequence;
102 : 910 : ModifyListenerHelper::addListener( m_xLabel, m_xModifyEventForwarder );
103 : : }
104 : 910 : }
105 : :
106 : : // ____ XCloneable ____
107 : 35 : uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone()
108 : : throw (uno::RuntimeException)
109 : : {
110 : 35 : uno::Reference< chart2::data::XDataSequence > xNewValues( m_xData );
111 : 35 : uno::Reference< chart2::data::XDataSequence > xNewLabel( m_xLabel );
112 : :
113 [ + - ]: 35 : uno::Reference< util::XCloneable > xLabelCloneable( m_xLabel, uno::UNO_QUERY );
114 [ + - ]: 35 : if( xLabelCloneable.is())
115 [ + - ][ + - ]: 35 : xNewLabel.set( xLabelCloneable->createClone(), uno::UNO_QUERY );
[ + - ]
116 : :
117 [ + - ]: 35 : uno::Reference< util::XCloneable > xValuesCloneable( m_xData, uno::UNO_QUERY );
118 [ + - ]: 35 : if( xValuesCloneable.is())
119 [ + - ][ + - ]: 35 : xNewValues.set( xValuesCloneable->createClone(), uno::UNO_QUERY );
[ + - ]
120 : :
121 : : return uno::Reference< util::XCloneable >(
122 [ + - ][ + - ]: 35 : new LabeledDataSequence( xNewValues, xNewLabel ) );
[ + - ]
123 : : }
124 : :
125 : : // ____ XModifyBroadcaster ____
126 : 729 : void SAL_CALL LabeledDataSequence::addModifyListener( const Reference< util::XModifyListener >& aListener )
127 : : throw (uno::RuntimeException)
128 : : {
129 : : try
130 : : {
131 [ + - ]: 729 : Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
132 [ + - ][ + - ]: 729 : xBroadcaster->addModifyListener( aListener );
[ # # ]
133 : : }
134 : 0 : catch( const uno::Exception & ex )
135 : : {
136 : : ASSERT_EXCEPTION( ex );
137 : : }
138 : 729 : }
139 : :
140 : 729 : void SAL_CALL LabeledDataSequence::removeModifyListener( const Reference< util::XModifyListener >& aListener )
141 : : throw (uno::RuntimeException)
142 : : {
143 : : try
144 : : {
145 [ + - ]: 729 : Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
146 [ + - ][ + - ]: 729 : xBroadcaster->removeModifyListener( aListener );
[ # # ]
147 : : }
148 : 0 : catch( const uno::Exception & ex )
149 : : {
150 : : ASSERT_EXCEPTION( ex );
151 : : }
152 : 729 : }
153 : :
154 : : // ================================================================================
155 : :
156 : 8 : Sequence< OUString > LabeledDataSequence::getSupportedServiceNames_Static()
157 : : {
158 : 8 : Sequence< OUString > aServices( 1 );
159 [ + - ][ + - ]: 8 : aServices[ 0 ] = C2U( "com.sun.star.chart2.data.LabeledDataSequence" );
160 : 8 : return aServices;
161 : : }
162 : :
163 : : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
164 [ # # ][ # # ]: 30 : APPHELPER_XSERVICEINFO_IMPL( LabeledDataSequence,
[ # # ][ # # ]
[ # # ]
165 : : C2U( "com.sun.star.comp.chart2.LabeledDataSequence" ))
166 : :
167 : : // ================================================================================
168 : :
169 : : } // namespace chart
170 : :
171 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|