fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / inc / InternalDataProvider.hxx
blob3c6477c34b25aad902f74ab852485690241be662
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_CHART2_SOURCE_INC_INTERNALDATAPROVIDER_HXX
20 #define INCLUDED_CHART2_SOURCE_INC_INTERNALDATAPROVIDER_HXX
22 #include "InternalData.hxx"
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/chart/XDateCategories.hpp>
26 #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
27 #include <com/sun/star/chart2/data/XDataProvider.hpp>
28 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
29 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
30 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
31 #include <com/sun/star/chart2/XChartDocument.hpp>
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <com/sun/star/util/XCloneable.hpp>
34 #include <cppuhelper/implbase7.hxx>
36 #include "CachedDataSequence.hxx"
38 #include <map>
40 namespace chart
43 namespace impl
46 typedef ::cppu::WeakImplHelper7<
47 ::com::sun::star::chart2::XInternalDataProvider,
48 ::com::sun::star::chart2::data::XRangeXMLConversion,
49 ::com::sun::star::chart2::XAnyDescriptionAccess,
50 ::com::sun::star::chart::XDateCategories,
51 ::com::sun::star::util::XCloneable,
52 ::com::sun::star::lang::XInitialization,
53 ::com::sun::star::lang::XServiceInfo >
54 InternalDataProvider_Base;
57 /** Data provider that handles data internally. This is used for charts with
58 their own data.
60 <p>The format for single ranges is "categories|label n|n" where n is a
61 non-negative number. Meaning return all categories, the label of sequence n,
62 or the data of sequence n.</p>
64 <p>The format for a complete range is "all". (Do we need more than
65 that?)</p>
67 class InternalDataProvider :
68 public impl::InternalDataProvider_Base
70 public:
71 explicit InternalDataProvider(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _xContext);
73 // #i120559# allow handing over a default for data orientation
74 // (DataInColumns) that will be used when no data is available
75 explicit InternalDataProvider(
76 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc,
77 bool bConnectToModel,
78 bool bDefaultDataInColumns );
79 explicit InternalDataProvider( const InternalDataProvider & rOther );
80 virtual ~InternalDataProvider();
82 void createDefaultData();
84 /// declare XServiceInfo methods
85 virtual OUString SAL_CALL getImplementationName()
86 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
87 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
88 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
89 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
90 throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
92 static OUString getImplementationName_Static();
93 static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
94 static css::uno::Reference< css::uno::XInterface > SAL_CALL create( css::uno::Reference< css::uno::XComponentContext > const & xContext)
95 throw(css::uno::Exception)
97 return (::cppu::OWeakObject *)new InternalDataProvider( xContext );
100 // ____ XInternalDataProvider ____
101 virtual sal_Bool SAL_CALL hasDataByRangeRepresentation( const OUString& aRange )
102 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
104 getDataByRangeRepresentation( const OUString& aRange )
105 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 virtual void SAL_CALL setDataByRangeRepresentation(
107 const OUString& aRange,
108 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aNewData )
109 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 virtual void SAL_CALL insertSequence( ::sal_Int32 nAfterIndex )
111 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 virtual void SAL_CALL deleteSequence( ::sal_Int32 nAtIndex )
113 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 virtual void SAL_CALL appendSequence()
115 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 virtual void SAL_CALL insertComplexCategoryLevel( ::sal_Int32 nLevel )
117 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 virtual void SAL_CALL deleteComplexCategoryLevel( ::sal_Int32 nLevel )
119 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 virtual void SAL_CALL insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
121 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 virtual void SAL_CALL deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
123 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 virtual void SAL_CALL swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex )
125 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 virtual void SAL_CALL registerDataSequenceForChanges(
127 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xSeq )
128 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
130 // ____ XDataProvider (base of XInternalDataProvider) ____
131 virtual sal_Bool SAL_CALL createDataSourcePossible(
132 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
133 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > SAL_CALL createDataSource(
135 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
136 throw (::com::sun::star::lang::IllegalArgumentException,
137 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL detectArguments(
139 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource )
140 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 virtual sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(
142 const OUString& aRangeRepresentation )
143 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(
145 const OUString& aRangeRepresentation )
146 throw (::com::sun::star::lang::IllegalArgumentException,
147 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
150 createDataSequenceByValueArray( const OUString& aRole, const OUString& aRangeRepresentation )
151 throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
153 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection()
154 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 // ____ XRangeXMLConversion ____
157 virtual OUString SAL_CALL convertRangeToXML(
158 const OUString& aRangeRepresentation )
159 throw (::com::sun::star::lang::IllegalArgumentException,
160 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 virtual OUString SAL_CALL convertRangeFromXML(
162 const OUString& aXMLRange )
163 throw (::com::sun::star::lang::IllegalArgumentException,
164 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 // ____ XDateCategories ____
167 virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 // ____ XAnyDescriptionAccess ____
171 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
172 getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 virtual void SAL_CALL setAnyRowDescriptions(
174 const ::com::sun::star::uno::Sequence<
175 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions )
176 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
178 getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 virtual void SAL_CALL setAnyColumnDescriptions(
180 const ::com::sun::star::uno::Sequence<
181 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions )
182 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____
185 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > SAL_CALL
186 getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 virtual void SAL_CALL setComplexRowDescriptions(
188 const ::com::sun::star::uno::Sequence<
189 ::com::sun::star::uno::Sequence< OUString > >& aRowDescriptions )
190 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
191 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > SAL_CALL
192 getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 virtual void SAL_CALL setComplexColumnDescriptions(
194 const ::com::sun::star::uno::Sequence<
195 ::com::sun::star::uno::Sequence< OUString > >& aColumnDescriptions )
196 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
198 // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
199 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData()
200 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
201 virtual void SAL_CALL setData(
202 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aData )
203 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
204 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getRowDescriptions()
205 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
206 virtual void SAL_CALL setRowDescriptions(
207 const ::com::sun::star::uno::Sequence< OUString >& aRowDescriptions )
208 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
209 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getColumnDescriptions()
210 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
211 virtual void SAL_CALL setColumnDescriptions(
212 const ::com::sun::star::uno::Sequence< OUString >& aColumnDescriptions )
213 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
215 // ____ XChartData (base of XChartDataArray) ____
216 virtual void SAL_CALL addChartDataChangeEventListener(
217 const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
218 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
219 virtual void SAL_CALL removeChartDataChangeEventListener(
220 const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
221 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
222 virtual double SAL_CALL getNotANumber()
223 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
224 virtual sal_Bool SAL_CALL isNotANumber(
225 double nNumber )
226 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
228 // ____ XCloneable ____
229 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
230 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
231 // ::com::sun::star::lang::XInitialization:
232 virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments)
233 throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
235 private:
236 void addDataSequenceToMap(
237 const OUString & rRangeRepresentation,
238 const ::com::sun::star::uno::Reference<
239 ::com::sun::star::chart2::data::XDataSequence > & xSequence );
241 ::com::sun::star::uno::Reference<
242 ::com::sun::star::chart2::data::XDataSequence >
243 createDataSequenceAndAddToMap( const OUString & rRangeRepresentation,
244 const OUString & rRole );
245 ::com::sun::star::uno::Reference<
246 ::com::sun::star::chart2::data::XDataSequence >
247 createDataSequenceAndAddToMap( const OUString & rRangeRepresentation );
249 css::uno::Reference<css::chart2::data::XDataSequence>
250 createDataSequenceFromArray( const OUString& rArrayStr, const OUString& rRole );
252 void deleteMapReferences( const OUString & rRangeRepresentation );
254 void adaptMapReferences(
255 const OUString & rOldRangeRepresentation,
256 const OUString & rNewRangeRepresentation );
258 void increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
259 void decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
261 typedef ::std::multimap< OUString,
262 ::com::sun::star::uno::WeakReference< ::com::sun::star::chart2::data::XDataSequence > >
263 tSequenceMap;
264 typedef ::std::pair< tSequenceMap::iterator, tSequenceMap::iterator > tSequenceMapRange;
265 typedef ::std::pair< tSequenceMap::const_iterator, tSequenceMap::const_iterator > tConstSequenceMapRange;
267 /** cache for all sequences that have been returned.
269 If the range-representation of a sequence changes and it is still
270 referred to by some component (weak reference is valid), the range will
271 be adapted.
273 tSequenceMap m_aSequenceMap;
274 InternalData m_aInternalData;
275 bool m_bDataInColumns;
278 } // namespace chart
280 // INCLUDED_CHART2_SOURCE_INC_INTERNALDATAPROVIDER_HXX
281 #endif
283 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */