1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CHART_DATASERIES_HXX
24 #define _CHART_DATASERIES_HXX
25 
26 // UNO types
27 #include <com/sun/star/chart2/XDataSeries.hpp>
28 #include <com/sun/star/chart2/data/XDataSink.hpp>
29 #include <com/sun/star/chart2/data/XDataSource.hpp>
30 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
31 #include <com/sun/star/util/XCloneable.hpp>
32 #include <com/sun/star/util/XModifyBroadcaster.hpp>
33 #include <com/sun/star/util/XModifyListener.hpp>
34 #include <com/sun/star/container/XIndexContainer.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 
39 // helper classes
40 #include "ServiceMacros.hxx"
41 #include <cppuhelper/implbase8.hxx>
42 #include <comphelper/uno3.hxx>
43 #include <osl/mutex.hxx>
44 
45 // STL
46 #include <vector>
47 #include <map>
48 
49 #include "MutexContainer.hxx"
50 #include "OPropertySet.hxx"
51 
52 namespace com { namespace sun { namespace star { namespace style {
53     class XStyle;
54 }}}}
55 
56 namespace chart
57 {
58 
59 namespace impl
60 {
61 typedef ::cppu::WeakImplHelper8<
62         ::com::sun::star::chart2::XDataSeries,
63         ::com::sun::star::chart2::data::XDataSink,
64         ::com::sun::star::chart2::data::XDataSource,
65         ::com::sun::star::lang::XServiceInfo,
66         ::com::sun::star::chart2::XRegressionCurveContainer,
67         ::com::sun::star::util::XCloneable,
68         ::com::sun::star::util::XModifyBroadcaster,
69         ::com::sun::star::util::XModifyListener >
70     DataSeries_Base;
71 }
72 
73 class DataSeries :
74     public MutexContainer,
75     public impl::DataSeries_Base,
76     public ::property::OPropertySet
77 {
78 public:
79     explicit DataSeries(
80         const ::com::sun::star::uno::Reference<
81             ::com::sun::star::uno::XComponentContext > & xContext );
82 	virtual ~DataSeries();
83 
84     /// establish methods for factory instatiation
85     APPHELPER_SERVICE_FACTORY_HELPER( DataSeries )
86     /// XServiceInfo declarations
87     APPHELPER_XSERVICEINFO_DECL()
88 
89     /// merge XInterface implementations
90     DECLARE_XINTERFACE()
91     /// merge XTypeProvider implementations
92     DECLARE_XTYPEPROVIDER()
93 
94 protected:
95     explicit DataSeries( const DataSeries & rOther );
96 
97     // late initialization to call after copy-constructing
98     void Init( const DataSeries & rOther );
99 
100     // ____ XDataSeries ____
101     // _____________________
102     /// @see ::com::sun::star::chart2::XDataSeries
103     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
104         SAL_CALL getDataPointByIndex( sal_Int32 nIndex )
105         throw (::com::sun::star::lang::IndexOutOfBoundsException,
106                ::com::sun::star::uno::RuntimeException);
107     virtual void SAL_CALL resetDataPoint( sal_Int32 nIndex )
108         throw (::com::sun::star::uno::RuntimeException);
109     virtual void SAL_CALL resetAllDataPoints()
110         throw (::com::sun::star::uno::RuntimeException);
111 
112     // ____ XDataSink ____
113     // ___________________
114     /// @see ::com::sun::star::chart2::data::XDataSink
115     virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > >& aData )
116         throw (::com::sun::star::uno::RuntimeException);
117 
118     // ____ XDataSource ____
119     // _____________________
120     /// @see ::com::sun::star::chart2::data::XDataSource
121     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences()
122         throw (::com::sun::star::uno::RuntimeException);
123 
124     // ____ OPropertySet ____
125     // ______________________
126     virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
127         throw(::com::sun::star::beans::UnknownPropertyException);
128 	virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
129 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast
130         ( sal_Int32 nHandle,
131           const ::com::sun::star::uno::Any& rValue )
132 		throw (::com::sun::star::uno::Exception);
133 
134 	virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
135 
136     // ____ XPropertySet ____
137     // ______________________
138     /// @see ::com::sun::star::beans::XPropertySet
139     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
140         getPropertySetInfo()
141         throw (::com::sun::star::uno::RuntimeException);
142 
143     /// make original interface function visible again
144     using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue;
145 
146     // ____ XRegressionCurveContainer ____
147     // ___________________________________
148     /// @see ::com::sun::star::chart2::XRegressionCurveContainer
149     virtual void SAL_CALL addRegressionCurve(
150         const ::com::sun::star::uno::Reference<
151             ::com::sun::star::chart2::XRegressionCurve >& aRegressionCurve )
152         throw (::com::sun::star::lang::IllegalArgumentException,
153                ::com::sun::star::uno::RuntimeException);
154     virtual void SAL_CALL removeRegressionCurve(
155         const ::com::sun::star::uno::Reference<
156             ::com::sun::star::chart2::XRegressionCurve >& aRegressionCurve )
157         throw (::com::sun::star::container::NoSuchElementException,
158                ::com::sun::star::uno::RuntimeException);
159     virtual ::com::sun::star::uno::Sequence<
160                 ::com::sun::star::uno::Reference<
161                     ::com::sun::star::chart2::XRegressionCurve > > SAL_CALL getRegressionCurves()
162         throw (::com::sun::star::uno::RuntimeException);
163     virtual void SAL_CALL setRegressionCurves(
164         const ::com::sun::star::uno::Sequence<
165             ::com::sun::star::uno::Reference<
166                 ::com::sun::star::chart2::XRegressionCurve > >& aRegressionCurves )
167         throw (::com::sun::star::uno::RuntimeException);
168 
169     // ____ XCloneable ____
170     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
171         throw (::com::sun::star::uno::RuntimeException);
172 
173     // ____ XModifyBroadcaster ____
174     virtual void SAL_CALL addModifyListener(
175         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
176         throw (::com::sun::star::uno::RuntimeException);
177     virtual void SAL_CALL removeModifyListener(
178         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
179         throw (::com::sun::star::uno::RuntimeException);
180 
181     // ____ XModifyListener ____
182     virtual void SAL_CALL modified(
183         const ::com::sun::star::lang::EventObject& aEvent )
184         throw (::com::sun::star::uno::RuntimeException);
185 
186     // ____ XEventListener (base of XModifyListener) ____
187     virtual void SAL_CALL disposing(
188         const ::com::sun::star::lang::EventObject& Source )
189         throw (::com::sun::star::uno::RuntimeException);
190 
191     // ____ OPropertySet ____
192     virtual void firePropertyChangeEvent();
193 	using OPropertySet::disposing;
194 
195     void fireModifyEvent();
196 
197 private:
198     ::com::sun::star::uno::Reference<
199         ::com::sun::star::uno::XComponentContext >
200                         m_xContext;
201     typedef ::std::vector< ::com::sun::star::uno::Reference<
202             ::com::sun::star::chart2::data::XLabeledDataSequence > > tDataSequenceContainer;
203     tDataSequenceContainer        m_aDataSequences;
204 
205     typedef ::std::map< sal_Int32,
206         ::com::sun::star::uno::Reference<
207         ::com::sun::star::beans::XPropertySet > > tDataPointAttributeContainer;
208     tDataPointAttributeContainer  m_aAttributedDataPoints;
209 
210     typedef
211         ::std::vector< ::com::sun::star::uno::Reference<
212             ::com::sun::star::chart2::XRegressionCurve > >
213         tRegressionCurveContainerType;
214     tRegressionCurveContainerType m_aRegressionCurves;
215 
216     ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyEventForwarder;
217 };
218 
219 }  // namespace chart
220 
221 // _CHART_DATASERIES_HXX
222 #endif
223