Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef CHART2_INTERNALDATAPROVIDER_HXX
20 : #define CHART2_INTERNALDATAPROVIDER_HXX
21 :
22 : #include "InternalData.hxx"
23 :
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>
35 : #include "ServiceMacros.hxx"
36 :
37 : #include "CachedDataSequence.hxx"
38 :
39 : #include <map>
40 : #include <memory>
41 :
42 : namespace chart
43 : {
44 :
45 : namespace impl
46 : {
47 :
48 : typedef ::cppu::WeakImplHelper7<
49 : ::com::sun::star::chart2::XInternalDataProvider,
50 : ::com::sun::star::chart2::data::XRangeXMLConversion,
51 : ::com::sun::star::chart2::XAnyDescriptionAccess,
52 : ::com::sun::star::chart::XDateCategories,
53 : ::com::sun::star::util::XCloneable,
54 : ::com::sun::star::lang::XInitialization,
55 : ::com::sun::star::lang::XServiceInfo >
56 : InternalDataProvider_Base;
57 : }
58 :
59 : /** Data provider that handles data internally. This is used for charts with
60 : their own data.
61 :
62 : <p>The format for single ranges is "categories|label n|n" where n is a
63 : non-negative number. Meaning return all categories, the label of sequence n,
64 : or the data of sequence n.</p>
65 :
66 : <p>The format for a complete range is "all". (Do we need more than
67 : that?)</p>
68 : */
69 : class InternalDataProvider :
70 : public impl::InternalDataProvider_Base
71 : {
72 : public:
73 : explicit InternalDataProvider(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _xContext);
74 :
75 : // #i120559# allow handing over a default for data orientation
76 : // (DataInColumns) that will be used when no data is available
77 : explicit InternalDataProvider(
78 : const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc,
79 : bool bConnectToModel,
80 : bool bDefaultDataInColumns );
81 : explicit InternalDataProvider( const InternalDataProvider & rOther );
82 : virtual ~InternalDataProvider();
83 :
84 : void createDefaultData();
85 :
86 : /// declare XServiceInfo methods
87 : APPHELPER_XSERVICEINFO_DECL()
88 0 : APPHELPER_SERVICE_FACTORY_HELPER(InternalDataProvider)
89 :
90 : // ____ XInternalDataProvider ____
91 : virtual ::sal_Bool SAL_CALL hasDataByRangeRepresentation( const OUString& aRange )
92 : throw (::com::sun::star::uno::RuntimeException);
93 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
94 : getDataByRangeRepresentation( const OUString& aRange )
95 : throw (::com::sun::star::uno::RuntimeException);
96 : virtual void SAL_CALL setDataByRangeRepresentation(
97 : const OUString& aRange,
98 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aNewData )
99 : throw (::com::sun::star::uno::RuntimeException);
100 : virtual void SAL_CALL insertSequence( ::sal_Int32 nAfterIndex )
101 : throw (::com::sun::star::uno::RuntimeException);
102 : virtual void SAL_CALL deleteSequence( ::sal_Int32 nAtIndex )
103 : throw (::com::sun::star::uno::RuntimeException);
104 : virtual void SAL_CALL appendSequence()
105 : throw (::com::sun::star::uno::RuntimeException);
106 : virtual void SAL_CALL insertComplexCategoryLevel( ::sal_Int32 nLevel )
107 : throw (::com::sun::star::uno::RuntimeException);
108 : virtual void SAL_CALL deleteComplexCategoryLevel( ::sal_Int32 nLevel )
109 : throw (::com::sun::star::uno::RuntimeException);
110 : virtual void SAL_CALL insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
111 : throw (::com::sun::star::uno::RuntimeException);
112 : virtual void SAL_CALL deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
113 : throw (::com::sun::star::uno::RuntimeException);
114 : virtual void SAL_CALL swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex )
115 : throw (::com::sun::star::uno::RuntimeException);
116 : virtual void SAL_CALL registerDataSequenceForChanges(
117 : const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xSeq )
118 : throw (::com::sun::star::uno::RuntimeException);
119 :
120 : // ____ XDataProvider (base of XInternalDataProvider) ____
121 : virtual ::sal_Bool SAL_CALL createDataSourcePossible(
122 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
123 : throw (::com::sun::star::uno::RuntimeException);
124 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > SAL_CALL createDataSource(
125 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
126 : throw (::com::sun::star::lang::IllegalArgumentException,
127 : ::com::sun::star::uno::RuntimeException);
128 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL detectArguments(
129 : const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource )
130 : throw (::com::sun::star::uno::RuntimeException);
131 : virtual ::sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(
132 : const OUString& aRangeRepresentation )
133 : throw (::com::sun::star::uno::RuntimeException);
134 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(
135 : const OUString& aRangeRepresentation )
136 : throw (::com::sun::star::lang::IllegalArgumentException,
137 : ::com::sun::star::uno::RuntimeException);
138 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection()
139 : throw (::com::sun::star::uno::RuntimeException);
140 :
141 : // ____ XRangeXMLConversion ____
142 : virtual OUString SAL_CALL convertRangeToXML(
143 : const OUString& aRangeRepresentation )
144 : throw (::com::sun::star::lang::IllegalArgumentException,
145 : ::com::sun::star::uno::RuntimeException);
146 : virtual OUString SAL_CALL convertRangeFromXML(
147 : const OUString& aXMLRange )
148 : throw (::com::sun::star::lang::IllegalArgumentException,
149 : ::com::sun::star::uno::RuntimeException);
150 :
151 : // ____ XDateCategories ____
152 : virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException);
153 : virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException);
154 :
155 : // ____ XAnyDescriptionAccess ____
156 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
157 : getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
158 : virtual void SAL_CALL setAnyRowDescriptions(
159 : const ::com::sun::star::uno::Sequence<
160 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions )
161 : throw (::com::sun::star::uno::RuntimeException);
162 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
163 : getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
164 : virtual void SAL_CALL setAnyColumnDescriptions(
165 : const ::com::sun::star::uno::Sequence<
166 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions )
167 : throw (::com::sun::star::uno::RuntimeException);
168 :
169 : // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____
170 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > SAL_CALL
171 : getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
172 : virtual void SAL_CALL setComplexRowDescriptions(
173 : const ::com::sun::star::uno::Sequence<
174 : ::com::sun::star::uno::Sequence< OUString > >& aRowDescriptions )
175 : throw (::com::sun::star::uno::RuntimeException);
176 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > SAL_CALL
177 : getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
178 : virtual void SAL_CALL setComplexColumnDescriptions(
179 : const ::com::sun::star::uno::Sequence<
180 : ::com::sun::star::uno::Sequence< OUString > >& aColumnDescriptions )
181 : throw (::com::sun::star::uno::RuntimeException);
182 :
183 : // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
184 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData()
185 : throw (::com::sun::star::uno::RuntimeException);
186 : virtual void SAL_CALL setData(
187 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aData )
188 : throw (::com::sun::star::uno::RuntimeException);
189 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getRowDescriptions()
190 : throw (::com::sun::star::uno::RuntimeException);
191 : virtual void SAL_CALL setRowDescriptions(
192 : const ::com::sun::star::uno::Sequence< OUString >& aRowDescriptions )
193 : throw (::com::sun::star::uno::RuntimeException);
194 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getColumnDescriptions()
195 : throw (::com::sun::star::uno::RuntimeException);
196 : virtual void SAL_CALL setColumnDescriptions(
197 : const ::com::sun::star::uno::Sequence< OUString >& aColumnDescriptions )
198 : throw (::com::sun::star::uno::RuntimeException);
199 :
200 : // ____ XChartData (base of XChartDataArray) ____
201 : virtual void SAL_CALL addChartDataChangeEventListener(
202 : const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
203 : throw (::com::sun::star::uno::RuntimeException);
204 : virtual void SAL_CALL removeChartDataChangeEventListener(
205 : const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
206 : throw (::com::sun::star::uno::RuntimeException);
207 : virtual double SAL_CALL getNotANumber()
208 : throw (::com::sun::star::uno::RuntimeException);
209 : virtual ::sal_Bool SAL_CALL isNotANumber(
210 : double nNumber )
211 : throw (::com::sun::star::uno::RuntimeException);
212 :
213 : // ____ XCloneable ____
214 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
215 : throw (::com::sun::star::uno::RuntimeException);
216 : // ::com::sun::star::lang::XInitialization:
217 : virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments)
218 : throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
219 :
220 : private:
221 : void lcl_addDataSequenceToMap(
222 : const OUString & rRangeRepresentation,
223 : const ::com::sun::star::uno::Reference<
224 : ::com::sun::star::chart2::data::XDataSequence > & xSequence );
225 :
226 : ::com::sun::star::uno::Reference<
227 : ::com::sun::star::chart2::data::XDataSequence >
228 : lcl_createDataSequenceAndAddToMap( const OUString & rRangeRepresentation,
229 : const OUString & rRole );
230 : ::com::sun::star::uno::Reference<
231 : ::com::sun::star::chart2::data::XDataSequence >
232 : lcl_createDataSequenceAndAddToMap( const OUString & rRangeRepresentation );
233 :
234 : void lcl_deleteMapReferences( const OUString & rRangeRepresentation );
235 :
236 : void lcl_adaptMapReferences(
237 : const OUString & rOldRangeRepresentation,
238 : const OUString & rNewRangeRepresentation );
239 :
240 : void lcl_increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
241 : void lcl_decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
242 :
243 : typedef ::std::multimap< OUString,
244 : ::com::sun::star::uno::WeakReference< ::com::sun::star::chart2::data::XDataSequence > >
245 : tSequenceMap;
246 : typedef ::std::pair< tSequenceMap::iterator, tSequenceMap::iterator > tSequenceMapRange;
247 : typedef ::std::pair< tSequenceMap::const_iterator, tSequenceMap::const_iterator > tConstSequenceMapRange;
248 :
249 : /** cache for all sequences that have been returned.
250 :
251 : If the range-representation of a sequence changes and it is still
252 : referred to by some component (weak reference is valid), the range will
253 : be adapted.
254 : */
255 : tSequenceMap m_aSequenceMap;
256 : InternalData m_aInternalData;
257 : bool m_bDataInColumns;
258 : };
259 :
260 : } // namespace chart
261 :
262 : // CHART2_INTERNALDATAPROVIDER_HXX
263 : #endif
264 :
265 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|