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_CHARTDATAWRAPPER_HXX
24 #define CHART_CHARTDATAWRAPPER_HXX
25 
26 #include "ServiceMacros.hxx"
27 #include "MutexContainer.hxx"
28 #include <cppuhelper/implbase5.hxx>
29 #include <cppuhelper/interfacecontainer.hxx>
30 #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
31 #include <com/sun/star/chart/XDateCategories.hpp>
32 #include <com/sun/star/lang/XComponent.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/chart2/XChartDocument.hpp>
35 #include <com/sun/star/uno/XComponentContext.hpp>
36 
37 #include <boost/shared_ptr.hpp>
38 
39 namespace chart
40 {
41 namespace wrapper
42 {
43 
44 class Chart2ModelContact;
45 struct lcl_Operator;
46 
47 class ChartDataWrapper : public MutexContainer, public
48     ::cppu::WeakImplHelper5<
49 	com::sun::star::chart2::XAnyDescriptionAccess,
50     com::sun::star::chart::XDateCategories,
51 	com::sun::star::lang::XServiceInfo,
52 	com::sun::star::lang::XEventListener,
53 	com::sun::star::lang::XComponent >
54 {
55 public:
56     ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
57     ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
58         , const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartData >& xNewData );
59 	virtual ~ChartDataWrapper();
60 
61     /// XServiceInfo declarations
62     APPHELPER_XSERVICEINFO_DECL()
63 
64 protected:
65     // ____ XDateCategories ____
66     virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException);
67     virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException);
68 
69     // ____ XAnyDescriptionAccess ____
70     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
71         getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
72     virtual void SAL_CALL setAnyRowDescriptions(
73         const ::com::sun::star::uno::Sequence<
74         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions )
75         throw (::com::sun::star::uno::RuntimeException);
76     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
77         getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
78     virtual void SAL_CALL setAnyColumnDescriptions(
79         const ::com::sun::star::uno::Sequence<
80         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions )
81         throw (::com::sun::star::uno::RuntimeException);
82 
83     // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____
84     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
85         getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
86     virtual void SAL_CALL setComplexRowDescriptions(
87         const ::com::sun::star::uno::Sequence<
88         ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions )
89         throw (::com::sun::star::uno::RuntimeException);
90     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
91         getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
92     virtual void SAL_CALL setComplexColumnDescriptions(
93         const ::com::sun::star::uno::Sequence<
94         ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions )
95         throw (::com::sun::star::uno::RuntimeException);
96 
97     // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
98     virtual ::com::sun::star::uno::Sequence<
99         ::com::sun::star::uno::Sequence<
100         double > > SAL_CALL getData()
101         throw (::com::sun::star::uno::RuntimeException);
102     virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence<
103                                    ::com::sun::star::uno::Sequence<
104                                    double > >& aData )
105         throw (::com::sun::star::uno::RuntimeException);
106     virtual ::com::sun::star::uno::Sequence<
107         ::rtl::OUString > SAL_CALL getRowDescriptions()
108         throw (::com::sun::star::uno::RuntimeException);
109     virtual void SAL_CALL setRowDescriptions( const ::com::sun::star::uno::Sequence<
110                                               ::rtl::OUString >& aRowDescriptions )
111         throw (::com::sun::star::uno::RuntimeException);
112     virtual ::com::sun::star::uno::Sequence<
113         ::rtl::OUString > SAL_CALL getColumnDescriptions()
114         throw (::com::sun::star::uno::RuntimeException);
115     virtual void SAL_CALL setColumnDescriptions( const ::com::sun::star::uno::Sequence<
116                                                  ::rtl::OUString >& aColumnDescriptions )
117         throw (::com::sun::star::uno::RuntimeException);
118 
119     // ____ XChartData (base of XChartDataArray) ____
120     virtual void SAL_CALL addChartDataChangeEventListener( const ::com::sun::star::uno::Reference<
121                                                            ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
122         throw (::com::sun::star::uno::RuntimeException);
123     virtual void SAL_CALL removeChartDataChangeEventListener( const ::com::sun::star::uno::Reference<
124                                                               ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
125         throw (::com::sun::star::uno::RuntimeException);
126     virtual double SAL_CALL getNotANumber()
127         throw (::com::sun::star::uno::RuntimeException);
128     virtual sal_Bool SAL_CALL isNotANumber( double nNumber )
129         throw (::com::sun::star::uno::RuntimeException);
130 
131     // ____ XComponent ____
132     virtual void SAL_CALL dispose()
133         throw (::com::sun::star::uno::RuntimeException);
134     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
135                                             ::com::sun::star::lang::XEventListener >& xListener )
136         throw (::com::sun::star::uno::RuntimeException);
137     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
138                                                ::com::sun::star::lang::XEventListener >& aListener )
139         throw (::com::sun::star::uno::RuntimeException);
140 
141     // ____ XEventListener ____
142     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
143         throw (::com::sun::star::uno::RuntimeException);
144 
145 
146     void fireChartDataChangeEvent( ::com::sun::star::chart::ChartDataChangeEvent& aEvent );
147 
148 private: //methods
149     void switchToInternalDataProvider();
150     void initDataAccess();
151     void applyData( lcl_Operator& rDataOperator );
152 
153 private: //member
154     ::com::sun::star::uno::Reference<
155         ::com::sun::star::chart2::XAnyDescriptionAccess > m_xDataAccess;
156 
157     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
158 	::cppu::OInterfaceContainerHelper           m_aEventListenerContainer;
159 };
160 
161 } //  namespace wrapper
162 } //  namespace chart
163 
164 // CHART_CHARTDATAWRAPPER_HXX
165 #endif
166