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(); 67 virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ); 68 69 // ____ XAnyDescriptionAccess ____ 70 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL 71 getAnyRowDescriptions(); 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 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL 76 getAnyColumnDescriptions(); 77 virtual void SAL_CALL setAnyColumnDescriptions( 78 const ::com::sun::star::uno::Sequence< 79 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions ); 80 81 // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____ 82 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL 83 getComplexRowDescriptions(); 84 virtual void SAL_CALL setComplexRowDescriptions( 85 const ::com::sun::star::uno::Sequence< 86 ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions ); 87 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL 88 getComplexColumnDescriptions(); 89 virtual void SAL_CALL setComplexColumnDescriptions( 90 const ::com::sun::star::uno::Sequence< 91 ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions ); 92 93 // ____ XChartDataArray (base of XComplexDescriptionAccess) ____ 94 virtual ::com::sun::star::uno::Sequence< 95 ::com::sun::star::uno::Sequence< 96 double > > SAL_CALL getData(); 97 virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< 98 ::com::sun::star::uno::Sequence< 99 double > >& aData ); 100 virtual ::com::sun::star::uno::Sequence< 101 ::rtl::OUString > SAL_CALL getRowDescriptions(); 102 virtual void SAL_CALL setRowDescriptions( const ::com::sun::star::uno::Sequence< 103 ::rtl::OUString >& aRowDescriptions ); 104 virtual ::com::sun::star::uno::Sequence< 105 ::rtl::OUString > SAL_CALL getColumnDescriptions(); 106 virtual void SAL_CALL setColumnDescriptions( const ::com::sun::star::uno::Sequence< 107 ::rtl::OUString >& aColumnDescriptions ); 108 109 // ____ XChartData (base of XChartDataArray) ____ 110 virtual void SAL_CALL addChartDataChangeEventListener( const ::com::sun::star::uno::Reference< 111 ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ); 112 virtual void SAL_CALL removeChartDataChangeEventListener( const ::com::sun::star::uno::Reference< 113 ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ); 114 virtual double SAL_CALL getNotANumber(); 115 virtual sal_Bool SAL_CALL isNotANumber( double nNumber ); 116 117 // ____ XComponent ____ 118 virtual void SAL_CALL dispose(); 119 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< 120 ::com::sun::star::lang::XEventListener >& xListener ); 121 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< 122 ::com::sun::star::lang::XEventListener >& aListener ); 123 124 // ____ XEventListener ____ 125 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ); 126 127 128 void fireChartDataChangeEvent( ::com::sun::star::chart::ChartDataChangeEvent& aEvent ); 129 130 private: //methods 131 void switchToInternalDataProvider(); 132 void initDataAccess(); 133 void applyData( lcl_Operator& rDataOperator ); 134 135 private: //member 136 ::com::sun::star::uno::Reference< 137 ::com::sun::star::chart2::XAnyDescriptionAccess > m_xDataAccess; 138 139 ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; 140 ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; 141 }; 142 143 } // namespace wrapper 144 } // namespace chart 145 146 // CHART_CHARTDATAWRAPPER_HXX 147 #endif 148