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_CACHEDDATASEQUENCE_HXX 24 #define _CHART_CACHEDDATASEQUENCE_HXX 25 26 // helper classes 27 #include <cppuhelper/compbase7.hxx> 28 #include <comphelper/uno3.hxx> 29 #include <comphelper/broadcasthelper.hxx> 30 #include <comphelper/propertycontainer.hxx> 31 #include <comphelper/proparrhlp.hxx> 32 #include "ServiceMacros.hxx" 33 34 // interfaces and types 35 #include <com/sun/star/lang/XServiceInfo.hpp> 36 #include <com/sun/star/lang/XInitialization.hpp> 37 #include <com/sun/star/beans/XPropertySet.hpp> 38 #include <com/sun/star/uno/XComponentContext.hpp> 39 #include <com/sun/star/chart2/data/XDataSequence.hpp> 40 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> 41 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp> 42 #include <com/sun/star/util/XCloneable.hpp> 43 #include <com/sun/star/util/XModifyBroadcaster.hpp> 44 45 #include <vector> 46 47 // ____________________ 48 namespace chart 49 { 50 51 namespace impl 52 { 53 typedef ::cppu::WeakComponentImplHelper7< 54 ::com::sun::star::chart2::data::XDataSequence, 55 ::com::sun::star::chart2::data::XNumericalDataSequence, 56 ::com::sun::star::chart2::data::XTextualDataSequence, 57 ::com::sun::star::util::XCloneable, 58 ::com::sun::star::util::XModifyBroadcaster, 59 ::com::sun::star::lang::XInitialization, 60 ::com::sun::star::lang::XServiceInfo > 61 CachedDataSequence_Base; 62 } 63 64 class CachedDataSequence : 65 public ::comphelper::OMutexAndBroadcastHelper, 66 public ::comphelper::OPropertyContainer, 67 public ::comphelper::OPropertyArrayUsageHelper< CachedDataSequence >, 68 public impl::CachedDataSequence_Base 69 { 70 public: 71 /** constructs an empty sequence 72 */ 73 CachedDataSequence(); 74 75 explicit CachedDataSequence( 76 const ::com::sun::star::uno::Reference< 77 ::com::sun::star::uno::XComponentContext > & xContext ); 78 79 /** creates a sequence and initializes it with the given string. This is 80 especially useful for labels, which only have one element. 81 */ 82 explicit CachedDataSequence( const ::rtl::OUString & rSingleText ); 83 84 /// Copy CTOR 85 explicit CachedDataSequence( const CachedDataSequence & rSource ); 86 87 virtual ~CachedDataSequence(); 88 89 /// establish methods for factory instantiation 90 APPHELPER_SERVICE_FACTORY_HELPER( CachedDataSequence ) 91 /// declare XServiceInfo methods 92 APPHELPER_XSERVICEINFO_DECL() 93 94 /// merge XInterface implementations 95 DECLARE_XINTERFACE() 96 /// merge XTypeProvider implementations 97 DECLARE_XTYPEPROVIDER() 98 99 protected: 100 // ____ XPropertySet ____ 101 /// @see ::com::sun::star::beans::XPropertySet 102 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(); 103 /// @see ::comphelper::OPropertySetHelper 104 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 105 /// @see ::comphelper::OPropertyArrayUsageHelper 106 virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; 107 108 // ____ XDataSequence ____ 109 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getData(); 110 virtual ::rtl::OUString SAL_CALL getSourceRangeRepresentation(); 111 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL generateLabel( 112 ::com::sun::star::chart2::data::LabelOrigin nLabelOrigin ); 113 virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex( ::sal_Int32 nIndex ); 114 115 // ____ XNumericalDataSequence ____ 116 /// @see ::com::sun::star::chart::data::XNumericalDataSequence 117 virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getNumericalData(); 118 119 // ____ XTextualDataSequence ____ 120 /// @see ::com::sun::star::chart::data::XTextualDataSequence 121 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getTextualData(); 122 123 // ____ XCloneable ____ 124 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone(); 125 126 // ____ XModifyBroadcaster ____ 127 virtual void SAL_CALL addModifyListener( 128 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ); 129 virtual void SAL_CALL removeModifyListener( 130 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ); 131 132 // ::com::sun::star::lang::XInitialization: 133 virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments); 134 135 // <properties> 136 sal_Int32 m_nNumberFormatKey; 137 ::rtl::OUString m_sRole; 138 // </properties> 139 140 enum DataType 141 { 142 NUMERICAL, 143 TEXTUAL, 144 MIXED 145 }; 146 147 /** This method registers all properties. It should be called by all 148 constructors. 149 */ 150 void registerProperties(); 151 152 private: 153 /** is used by interface method getNumericalData(). 154 */ 155 ::com::sun::star::uno::Sequence< double > Impl_getNumericalData() const; 156 /** is used by interface method getTextualData(). 157 */ 158 ::com::sun::star::uno::Sequence< ::rtl::OUString > Impl_getTextualData() const; 159 /** is used by interface method getData(). 160 */ 161 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > Impl_getMixedData() const; 162 163 private: 164 enum DataType m_eCurrentDataType; 165 166 ::com::sun::star::uno::Sequence< double > m_aNumericalSequence; 167 ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTextualSequence; 168 ::com::sun::star::uno::Sequence< 169 ::com::sun::star::uno::Any > m_aMixedSequence; 170 ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > 171 m_xModifyEventForwarder; 172 }; 173 174 } // namespace chart 175 176 177 // _CHART_CACHEDDATASEQUENCE_HXX 178 #endif 179