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_UNCACHEDDATASEQUENCE_HXX
24 #define _CHART_UNCACHEDDATASEQUENCE_HXX
25 
26 // helper classes
27 #include <cppuhelper/compbase8.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 #include "charttoolsdllapi.hxx"
34 
35 // interfaces and types
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
40 #include <com/sun/star/chart2/data/XDataSequence.hpp>
41 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
42 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
43 #include <com/sun/star/container/XIndexReplace.hpp>
44 #include <com/sun/star/container/XNamed.hpp>
45 #include <com/sun/star/util/XCloneable.hpp>
46 #include <com/sun/star/util/XModifyBroadcaster.hpp>
47 #include <com/sun/star/util/XModifiable.hpp>
48 
49 #include <vector>
50 
51 // ____________________
52 namespace chart
53 {
54 
55 namespace impl
56 {
57 typedef ::cppu::WeakComponentImplHelper8<
58     ::com::sun::star::chart2::data::XDataSequence,
59     ::com::sun::star::chart2::data::XNumericalDataSequence,
60     ::com::sun::star::chart2::data::XTextualDataSequence,
61     ::com::sun::star::util::XCloneable,
62     ::com::sun::star::util::XModifiable, // contains util::XModifyBroadcaster
63     ::com::sun::star::container::XIndexReplace,
64     ::com::sun::star::container::XNamed, // for setting a new range representation
65     ::com::sun::star::lang::XServiceInfo >
66     UncachedDataSequence_Base;
67 }
68 
69 class UncachedDataSequence :
70         public ::comphelper::OMutexAndBroadcastHelper,
71         public ::comphelper::OPropertyContainer,
72         public ::comphelper::OPropertyArrayUsageHelper< UncachedDataSequence >,
73         public impl::UncachedDataSequence_Base
74 {
75 public:
76     /** The referring data provider is held as uno reference to ensure its
77         lifetime is at least as long as the one of this object.
78      */
79     UncachedDataSequence(
80         const ::com::sun::star::uno::Reference<
81             ::com::sun::star::chart2::XInternalDataProvider > & xIntDataProv,
82         const ::rtl::OUString & rRangeRepresentation );
83     UncachedDataSequence(
84         const ::com::sun::star::uno::Reference<
85             ::com::sun::star::chart2::XInternalDataProvider > & xIntDataProv,
86         const ::rtl::OUString & rRangeRepresentation,
87         const ::rtl::OUString & rRole );
88     UncachedDataSequence( const UncachedDataSequence & rSource );
89 	virtual ~UncachedDataSequence();
90 
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         throw (::com::sun::star::uno::RuntimeException);
104     /// @see ::comphelper::OPropertySetHelper
105 	virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
106     /// @see ::comphelper::OPropertyArrayUsageHelper
107 	virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
108 
109     // ____ XDataSequence ____
110     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getData()
111         throw (::com::sun::star::uno::RuntimeException);
112     virtual ::rtl::OUString SAL_CALL getSourceRangeRepresentation()
113         throw (::com::sun::star::uno::RuntimeException);
114     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL generateLabel(
115         ::com::sun::star::chart2::data::LabelOrigin nLabelOrigin )
116         throw (::com::sun::star::uno::RuntimeException);
117     virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex( ::sal_Int32 nIndex )
118         throw (::com::sun::star::lang::IndexOutOfBoundsException,
119                ::com::sun::star::uno::RuntimeException);
120 
121     // ____ XNumericalDataSequence ____
122     /// @see ::com::sun::star::chart::data::XNumericalDataSequence
123     virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getNumericalData() throw (::com::sun::star::uno::RuntimeException);
124 
125     // ____ XTextualDataSequence ____
126     /// @see ::com::sun::star::chart::data::XTextualDataSequence
127     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getTextualData() throw (::com::sun::star::uno::RuntimeException);
128 
129     // ____ XIndexReplace ____
130     virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
131         throw (::com::sun::star::lang::IllegalArgumentException,
132                ::com::sun::star::lang::IndexOutOfBoundsException,
133                ::com::sun::star::lang::WrappedTargetException,
134                ::com::sun::star::uno::RuntimeException);
135 
136     // ____ XIndexAccess (base of XIndexReplace) ____
137     virtual ::sal_Int32 SAL_CALL getCount()
138         throw (::com::sun::star::uno::RuntimeException);
139     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index )
140         throw (::com::sun::star::lang::IndexOutOfBoundsException,
141                ::com::sun::star::lang::WrappedTargetException,
142                ::com::sun::star::uno::RuntimeException);
143 
144     // ____ XElementAccess (base of XIndexAccess) ____
145     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
146         throw (::com::sun::star::uno::RuntimeException);
147     virtual ::sal_Bool SAL_CALL hasElements()
148         throw (::com::sun::star::uno::RuntimeException);
149 
150     // ____ XNamed (for setting a new range representation) ____
151     virtual ::rtl::OUString SAL_CALL getName()
152         throw (::com::sun::star::uno::RuntimeException);
153     virtual void SAL_CALL setName( const ::rtl::OUString& aName )
154         throw (::com::sun::star::uno::RuntimeException);
155 
156     // ____ XCloneable ____
157     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
158         throw (::com::sun::star::uno::RuntimeException);
159 
160     // ____ XModifiable ____
161     virtual ::sal_Bool SAL_CALL isModified()
162         throw (::com::sun::star::uno::RuntimeException);
163     virtual void SAL_CALL setModified( ::sal_Bool bModified )
164         throw (::com::sun::star::beans::PropertyVetoException,
165                ::com::sun::star::uno::RuntimeException);
166 
167     // ____ XModifyBroadcaster (base of XModifiable) ____
168     virtual void SAL_CALL addModifyListener(
169         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
170         throw (::com::sun::star::uno::RuntimeException);
171     virtual void SAL_CALL removeModifyListener(
172         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
173         throw (::com::sun::star::uno::RuntimeException);
174 
175     void fireModifyEvent();
176 
177     mutable ::osl::Mutex                  m_aMutex;
178 
179     // <properties>
180     sal_Int32                                       m_nNumberFormatKey;
181     ::rtl::OUString                                 m_sRole;
182     ::rtl::OUString                                 m_aXMLRange;
183     // </properties>
184 
185     /** This method registers all properties.  It should be called by all
186         constructors.
187      */
188     void registerProperties();
189 
190 private:
191     ::com::sun::star::uno::Reference<
192             ::com::sun::star::chart2::XInternalDataProvider > m_xDataProvider;
193     ::rtl::OUString                 m_aSourceRepresentation;
194     ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >
195         m_xModifyEventForwarder;
196 };
197 
198 }  // namespace chart
199 
200 
201 // _CHART_UNCACHEDDATASEQUENCE_HXX
202 #endif
203