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 :
20 :
21 : #include <rtl/math.hxx>
22 :
23 : #include <valarray>
24 :
25 : #include "InternalDataProvider.hxx"
26 : #include "LabeledDataSequence.hxx"
27 : #include "DataSource.hxx"
28 : #include "PropertyHelper.hxx"
29 : #include "macros.hxx"
30 : #include "XMLRangeHelper.hxx"
31 : #include "ContainerHelper.hxx"
32 : #include "CommonConverters.hxx"
33 : #include "CommonFunctors.hxx"
34 : #include "UncachedDataSequence.hxx"
35 : #include "DataSourceHelper.hxx"
36 : #include "ChartModelHelper.hxx"
37 : #include "DiagramHelper.hxx"
38 : #include "ExplicitCategoriesProvider.hxx"
39 :
40 : #include <com/sun/star/chart2/XChartDocument.hpp>
41 : #include <com/sun/star/chart2/data/XDataSequence.hpp>
42 : #include <com/sun/star/chart/ChartDataRowSource.hpp>
43 : #include <rtl/ustrbuf.hxx>
44 : #include <unotools/charclass.hxx>
45 : #include <comphelper/sequenceashashmap.hxx>
46 :
47 : #include <vector>
48 : #include <algorithm>
49 :
50 : using namespace ::com::sun::star;
51 : using namespace ::std;
52 :
53 : using ::com::sun::star::uno::Reference;
54 : using ::com::sun::star::uno::Sequence;
55 : using ::rtl::OUString;
56 : using ::rtl::OUStringBuffer;
57 :
58 : namespace chart
59 : {
60 :
61 : // ================================================================================
62 :
63 : namespace
64 : {
65 :
66 : // note: in xmloff this name is used to indicate usage of own data
67 1 : static const ::rtl::OUString lcl_aServiceName(
68 : RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" ));
69 :
70 1 : static const ::rtl::OUString lcl_aCategoriesRangeName(
71 : RTL_CONSTASCII_USTRINGPARAM( "categories" ));
72 1 : static const ::rtl::OUString lcl_aCategoriesLevelRangeNamePrefix(
73 : RTL_CONSTASCII_USTRINGPARAM( "categoriesL " )); //L <-> level
74 1 : static const ::rtl::OUString lcl_aCategoriesPointRangeNamePrefix(
75 : RTL_CONSTASCII_USTRINGPARAM( "categoriesP " )); //P <-> point
76 1 : static const ::rtl::OUString lcl_aCategoriesRoleName(
77 : RTL_CONSTASCII_USTRINGPARAM( "categories" ));
78 1 : static const ::rtl::OUString lcl_aLabelRangePrefix(
79 : RTL_CONSTASCII_USTRINGPARAM( "label " ));
80 1 : static const ::rtl::OUString lcl_aCompleteRange(
81 : RTL_CONSTASCII_USTRINGPARAM( "all" ));
82 :
83 : typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > >
84 : lcl_tSequenceMap;
85 :
86 0 : Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq )
87 : {
88 0 : Sequence< OUString > aResult;
89 0 : aResult.realloc( aAnySeq.getLength() );
90 0 : transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(),
91 0 : aResult.getArray(), CommonFunctors::AnyToString() );
92 0 : return aResult;
93 : }
94 :
95 0 : Sequence< uno::Any > lcl_StringToAnySequence( const Sequence< OUString >& aStringSeq )
96 : {
97 0 : Sequence< uno::Any > aResult;
98 0 : aResult.realloc( aStringSeq.getLength() );
99 0 : transform( aStringSeq.getConstArray(), aStringSeq.getConstArray() + aStringSeq.getLength(),
100 0 : aResult.getArray(), CommonFunctors::makeAny< OUString >() );
101 0 : return aResult;
102 : }
103 :
104 : struct lcl_setModified : public ::std::unary_function< lcl_tSequenceMap, void >
105 : {
106 0 : void operator() ( const lcl_tSequenceMap::value_type & rMapEntry )
107 : {
108 : // convert weak reference to reference
109 0 : Reference< chart2::data::XDataSequence > xSeq( rMapEntry.second );
110 0 : if( xSeq.is())
111 : {
112 0 : Reference< util::XModifiable > xMod( xSeq, uno::UNO_QUERY );
113 0 : if( xMod.is())
114 0 : xMod->setModified( sal_True );
115 0 : }
116 0 : }
117 : };
118 :
119 : struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2::XDataSeries >, void >
120 : {
121 0 : lcl_internalizeSeries( InternalData & rInternalData,
122 : InternalDataProvider & rProvider,
123 : bool bConnectToModel, bool bDataInColumns ) :
124 : m_rInternalData( rInternalData ),
125 : m_rProvider( rProvider ),
126 : m_bConnectToModel( bConnectToModel ),
127 0 : m_bDataInColumns( bDataInColumns )
128 0 : {}
129 0 : void operator() ( const Reference< chart2::XDataSeries > & xSeries )
130 : {
131 0 : Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
132 0 : Reference< chart2::data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
133 0 : if( xSource.is() && xSink.is() )
134 : {
135 0 : Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeriesData = xSource->getDataSequences();
136 0 : Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeriesData( aOldSeriesData.getLength() );
137 0 : for( sal_Int32 i=0; i<aOldSeriesData.getLength(); ++i )
138 : {
139 0 : sal_Int32 nNewIndex( m_bDataInColumns ? m_rInternalData.appendColumn() : m_rInternalData.appendRow() );
140 0 : OUString aIdentifier( OUString::valueOf( nNewIndex ));
141 : //@todo: deal also with genericXDataSequence
142 0 : Reference< chart2::data::XNumericalDataSequence > xValues( aOldSeriesData[i]->getValues(), uno::UNO_QUERY );
143 0 : Reference< chart2::data::XTextualDataSequence > xLabel( aOldSeriesData[i]->getLabel(), uno::UNO_QUERY );
144 0 : Reference< chart2::data::XDataSequence > xNewValues;
145 :
146 0 : if( xValues.is() )
147 : {
148 0 : ::std::vector< double > aValues( ContainerHelper::SequenceToVector( xValues->getNumericalData()));
149 0 : if( m_bDataInColumns )
150 0 : m_rInternalData.setColumnValues( nNewIndex, aValues );
151 : else
152 0 : m_rInternalData.setRowValues( nNewIndex, aValues );
153 0 : if( m_bConnectToModel )
154 : {
155 0 : xNewValues.set( m_rProvider.createDataSequenceByRangeRepresentation( aIdentifier ));
156 : comphelper::copyProperties(
157 : Reference< beans::XPropertySet >( xValues, uno::UNO_QUERY ),
158 0 : Reference< beans::XPropertySet >( xNewValues, uno::UNO_QUERY ));
159 0 : }
160 : }
161 :
162 0 : if( xLabel.is() )
163 : {
164 0 : if( m_bDataInColumns )
165 0 : m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) );
166 : else
167 0 : m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) );
168 0 : if( m_bConnectToModel )
169 : {
170 : Reference< chart2::data::XDataSequence > xNewLabel(
171 0 : m_rProvider.createDataSequenceByRangeRepresentation( lcl_aLabelRangePrefix + aIdentifier ));
172 : comphelper::copyProperties(
173 : Reference< beans::XPropertySet >( xLabel, uno::UNO_QUERY ),
174 0 : Reference< beans::XPropertySet >( xNewLabel, uno::UNO_QUERY ));
175 0 : aNewSeriesData[i] = Reference< chart2::data::XLabeledDataSequence >(
176 0 : new LabeledDataSequence( xNewValues, xNewLabel ));
177 : }
178 : }
179 : else
180 : {
181 0 : if( m_bConnectToModel )
182 0 : aNewSeriesData[i] = Reference< chart2::data::XLabeledDataSequence >(
183 0 : new LabeledDataSequence( xNewValues ));
184 : }
185 0 : }
186 0 : if( m_bConnectToModel )
187 0 : xSink->setData( aNewSeriesData );
188 0 : }
189 0 : }
190 :
191 : private:
192 : InternalData & m_rInternalData;
193 : InternalDataProvider & m_rProvider;
194 : bool m_bConnectToModel;
195 : bool m_bDataInColumns;
196 : };
197 :
198 : struct lcl_copyFromLevel : public ::std::unary_function< vector< uno::Any >, uno::Any >
199 : {
200 : public:
201 :
202 164 : explicit lcl_copyFromLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
203 164 : {}
204 :
205 656 : uno::Any operator() ( const vector< uno::Any >& rVector )
206 : {
207 656 : uno::Any aRet;
208 656 : if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) )
209 656 : aRet = rVector[m_nLevel];
210 656 : return aRet;
211 : }
212 :
213 : private:
214 : sal_Int32 m_nLevel;
215 : };
216 :
217 : struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< uno::Any >, OUString >
218 : {
219 : public:
220 :
221 0 : explicit lcl_getStringFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel )
222 0 : {}
223 :
224 0 : OUString operator() ( const vector< uno::Any >& rVector )
225 : {
226 0 : OUString aString;
227 0 : if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) )
228 0 : aString = CommonFunctors::AnyToString()(rVector[m_nLevel]);
229 0 : return aString;
230 : }
231 :
232 : private:
233 : sal_Int32 m_nLevel;
234 : };
235 :
236 :
237 : struct lcl_setAnyAtLevel : public ::std::binary_function< vector< uno::Any >, uno::Any, vector< uno::Any > >
238 : {
239 : public:
240 :
241 0 : explicit lcl_setAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
242 0 : {}
243 :
244 0 : vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const uno::Any& rNewValue )
245 : {
246 0 : vector< uno::Any > aRet( rVector );
247 0 : if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) )
248 0 : aRet.resize( m_nLevel+1 );
249 0 : aRet[ m_nLevel ]=rNewValue;
250 0 : return aRet;
251 : }
252 :
253 : private:
254 : sal_Int32 m_nLevel;
255 : };
256 :
257 : struct lcl_setAnyAtLevelFromStringSequence : public ::std::binary_function< vector< uno::Any >, OUString, vector< uno::Any > >
258 : {
259 : public:
260 :
261 0 : explicit lcl_setAnyAtLevelFromStringSequence( sal_Int32 nLevel ) : m_nLevel( nLevel )
262 0 : {}
263 :
264 0 : vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const OUString& rNewValue )
265 : {
266 0 : vector< uno::Any > aRet( rVector );
267 0 : if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) )
268 0 : aRet.resize( m_nLevel+1 );
269 0 : aRet[ m_nLevel ]=uno::makeAny(rNewValue);
270 0 : return aRet;
271 : }
272 :
273 : private:
274 : sal_Int32 m_nLevel;
275 : };
276 :
277 : struct lcl_insertAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void >
278 : {
279 : public:
280 :
281 0 : explicit lcl_insertAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
282 0 : {}
283 :
284 0 : void operator() ( vector< uno::Any >& rVector )
285 : {
286 0 : if( m_nLevel > static_cast< sal_Int32 >(rVector.size()) )
287 0 : rVector.resize( m_nLevel );
288 :
289 0 : vector< uno::Any >::iterator aIt( rVector.begin() );
290 0 : for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++)
291 : {
292 0 : if( nN==m_nLevel )
293 0 : break;
294 : }
295 0 : rVector.insert( aIt, uno::Any() );
296 0 : }
297 :
298 : private:
299 : sal_Int32 m_nLevel;
300 : };
301 :
302 : struct lcl_removeAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void >
303 : {
304 : public:
305 :
306 0 : explicit lcl_removeAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
307 0 : {}
308 :
309 0 : void operator() ( vector< uno::Any >& rVector )
310 : {
311 0 : vector< uno::Any >::iterator aIt( rVector.begin() );
312 0 : for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++)
313 : {
314 0 : if( nN==m_nLevel )
315 : {
316 0 : rVector.erase( aIt );
317 0 : break;
318 : }
319 : }
320 0 : }
321 :
322 : private:
323 : sal_Int32 m_nLevel;
324 : };
325 :
326 : } // anonymous namespace
327 :
328 : // ================================================================================
329 :
330 0 : InternalDataProvider::InternalDataProvider( const Reference< uno::XComponentContext > & /*_xContext*/)
331 0 : : m_bDataInColumns( true )
332 0 : {}
333 :
334 41 : InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocument > & xChartDoc, bool bConnectToModel )
335 41 : : m_bDataInColumns( true )
336 : {
337 : try
338 : {
339 41 : Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDoc ) );
340 41 : if( xDiagram.is())
341 : {
342 0 : Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY );
343 :
344 : //data in columns?
345 : {
346 0 : ::rtl::OUString aRangeString;
347 0 : bool bFirstCellAsLabel = true;
348 0 : bool bHasCategories = true;
349 0 : uno::Sequence< sal_Int32 > aSequenceMapping;
350 0 : DataSourceHelper::detectRangeSegmentation( xChartModel, aRangeString, aSequenceMapping, m_bDataInColumns, bFirstCellAsLabel, bHasCategories );
351 : }
352 :
353 : // categories
354 : {
355 0 : vector< vector< uno::Any > > aNewCategories;//inner count is level
356 : {
357 0 : ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel );
358 :
359 0 : const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() );
360 0 : sal_Int32 nLevelCount = rSplitCategoriesList.getLength();
361 0 : for( sal_Int32 nL = 0; nL<nLevelCount; nL++ )
362 : {
363 0 : Reference< chart2::data::XLabeledDataSequence > xLDS( rSplitCategoriesList[nL] );
364 0 : if( !xLDS.is() )
365 0 : continue;
366 0 : Sequence< uno::Any > aDataSeq;
367 0 : Reference< chart2::data::XDataSequence > xSeq( xLDS->getValues() );
368 0 : if( xSeq.is() )
369 0 : aDataSeq = xSeq->getData();
370 0 : sal_Int32 nLength = aDataSeq.getLength();
371 0 : sal_Int32 nCatLength = static_cast< sal_Int32 >(aNewCategories.size());
372 0 : if( nCatLength < nLength )
373 0 : aNewCategories.resize( nLength );
374 0 : else if( nLength < nCatLength )
375 0 : aDataSeq.realloc( nCatLength );
376 : transform( aNewCategories.begin(), aNewCategories.end(), aDataSeq.getConstArray(),
377 0 : aNewCategories.begin(), lcl_setAnyAtLevel(nL) );
378 0 : }
379 0 : if( !nLevelCount )
380 : {
381 0 : Sequence< OUString > aSimplecategories = aExplicitCategoriesProvider.getSimpleCategories();
382 0 : sal_Int32 nLength = aSimplecategories.getLength();
383 0 : aNewCategories.reserve( nLength );
384 0 : for( sal_Int32 nN=0; nN<nLength; nN++)
385 : {
386 0 : vector< uno::Any > aVector(1);
387 0 : aVector[0] = uno::makeAny( aSimplecategories[nN] );
388 0 : aNewCategories.push_back( aVector );
389 0 : }
390 0 : }
391 : }
392 :
393 0 : if( m_bDataInColumns )
394 0 : m_aInternalData.setComplexRowLabels( aNewCategories );
395 : else
396 0 : m_aInternalData.setComplexColumnLabels( aNewCategories );
397 0 : if( bConnectToModel )
398 : DiagramHelper::setCategoriesToDiagram( new LabeledDataSequence(
399 0 : createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName )), xDiagram );
400 : }
401 :
402 : // data series
403 0 : ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( ChartModelHelper::getDataSeries( xChartDoc ));
404 0 : ::std::for_each( aSeriesVector.begin(), aSeriesVector.end(), lcl_internalizeSeries( m_aInternalData, *this, bConnectToModel, m_bDataInColumns ) );
405 41 : }
406 : }
407 0 : catch( const uno::Exception & ex )
408 : {
409 : ASSERT_EXCEPTION( ex );
410 : }
411 41 : }
412 :
413 : // copy-CTOR
414 0 : InternalDataProvider::InternalDataProvider( const InternalDataProvider & rOther ) :
415 : impl::InternalDataProvider_Base(),
416 : m_aSequenceMap( rOther.m_aSequenceMap ),
417 : m_aInternalData( rOther.m_aInternalData ),
418 0 : m_bDataInColumns( rOther.m_bDataInColumns )
419 0 : {}
420 :
421 82 : InternalDataProvider::~InternalDataProvider()
422 82 : {}
423 :
424 287 : void InternalDataProvider::lcl_addDataSequenceToMap(
425 : const OUString & rRangeRepresentation,
426 : const Reference< chart2::data::XDataSequence > & xSequence )
427 : {
428 : m_aSequenceMap.insert(
429 : tSequenceMap::value_type(
430 : rRangeRepresentation,
431 287 : uno::WeakReference< chart2::data::XDataSequence >( xSequence )));
432 287 : }
433 :
434 0 : void InternalDataProvider::lcl_deleteMapReferences( const OUString & rRangeRepresentation )
435 : {
436 : // set sequence to deleted by setting its range to an empty string
437 0 : tSequenceMapRange aRange( m_aSequenceMap.equal_range( rRangeRepresentation ));
438 0 : for( tSequenceMap::iterator aIt( aRange.first ); aIt != aRange.second; ++aIt )
439 : {
440 0 : Reference< chart2::data::XDataSequence > xSeq( aIt->second );
441 0 : if( xSeq.is())
442 : {
443 0 : Reference< container::XNamed > xNamed( xSeq, uno::UNO_QUERY );
444 0 : if( xNamed.is())
445 0 : xNamed->setName( OUString());
446 : }
447 0 : }
448 : // remove from map
449 0 : m_aSequenceMap.erase( aRange.first, aRange.second );
450 0 : }
451 :
452 0 : void InternalDataProvider::lcl_adaptMapReferences(
453 : const OUString & rOldRangeRepresentation,
454 : const OUString & rNewRangeRepresentation )
455 : {
456 0 : tSequenceMapRange aRange( m_aSequenceMap.equal_range( rOldRangeRepresentation ));
457 0 : tSequenceMap aNewElements;
458 0 : for( tSequenceMap::iterator aIt( aRange.first ); aIt != aRange.second; ++aIt )
459 : {
460 0 : Reference< chart2::data::XDataSequence > xSeq( aIt->second );
461 0 : if( xSeq.is())
462 : {
463 0 : Reference< container::XNamed > xNamed( xSeq, uno::UNO_QUERY );
464 0 : if( xNamed.is())
465 0 : xNamed->setName( rNewRangeRepresentation );
466 : }
467 0 : aNewElements.insert( tSequenceMap::value_type( rNewRangeRepresentation, aIt->second ));
468 0 : }
469 : // erase map values for old index
470 0 : m_aSequenceMap.erase( aRange.first, aRange.second );
471 : // add new entries for values with new index
472 : ::std::copy( aNewElements.begin(), aNewElements.end(),
473 : ::std::inserter( m_aSequenceMap,
474 0 : m_aSequenceMap.upper_bound( rNewRangeRepresentation )));
475 0 : }
476 :
477 0 : void InternalDataProvider::lcl_increaseMapReferences(
478 : sal_Int32 nBegin, sal_Int32 nEnd )
479 : {
480 0 : for( sal_Int32 nIndex = nEnd - 1; nIndex >= nBegin; --nIndex )
481 : {
482 : lcl_adaptMapReferences( OUString::valueOf( nIndex ),
483 0 : OUString::valueOf( nIndex + 1 ));
484 0 : lcl_adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
485 0 : lcl_aLabelRangePrefix + OUString::valueOf( nIndex + 1 ));
486 : }
487 0 : }
488 :
489 0 : void InternalDataProvider::lcl_decreaseMapReferences(
490 : sal_Int32 nBegin, sal_Int32 nEnd )
491 : {
492 0 : for( sal_Int32 nIndex = nBegin; nIndex < nEnd; ++nIndex )
493 : {
494 : lcl_adaptMapReferences( OUString::valueOf( nIndex ),
495 0 : OUString::valueOf( nIndex - 1 ));
496 0 : lcl_adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
497 0 : lcl_aLabelRangePrefix + OUString::valueOf( nIndex - 1 ));
498 : }
499 0 : }
500 :
501 246 : Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
502 : const OUString & rRangeRepresentation )
503 : {
504 246 : OUString aRangeRepresentation = rRangeRepresentation;
505 246 : if( aRangeRepresentation.indexOf('{') >= 0 )
506 : {
507 0 : ::std::vector< double > aNewData;
508 0 : ::std::vector< uno::Any > aNewLabels;
509 0 : OUString aToken;
510 0 : sal_Int32 nCategories = 0;
511 0 : sal_Int32 nIndex = 0;
512 0 : bool bValues = true;
513 0 : bool bLabelSet = false;
514 0 : OUString str = aRangeRepresentation.replace('{',' ').replace('}',' ');
515 :
516 0 : m_aInternalData.clearDefaultData();
517 0 : sal_Int32 n = m_aInternalData.getColumnCount();
518 0 : if( n )
519 0 : n = n - 1;
520 :
521 0 : do
522 : {
523 : // TODO: This will be problematic if ';' is used in label names
524 : // '"' character also needs to be considered in such cases
525 0 : aToken = str.getToken(0,';',nIndex);
526 0 : if( aToken.isEmpty() )
527 0 : break;
528 0 : if( aToken.indexOf('"') < 0 )
529 : {
530 0 : aNewData.push_back( aToken.toDouble() );
531 : }
532 : else
533 : {
534 0 : aNewLabels.push_back( uno::makeAny(aToken.replace('"', ' ').trim()) );
535 0 : if( !nCategories &&
536 0 : ( !m_aInternalData.getComplexColumnLabel(n).size() ||
537 0 : !m_aInternalData.getComplexColumnLabel(n).front().hasValue() ) )
538 : {
539 0 : m_aInternalData.setComplexColumnLabel( n, aNewLabels );
540 0 : bLabelSet = true;
541 : }
542 : else
543 : {
544 0 : m_aInternalData.setComplexRowLabel(nCategories, aNewLabels);
545 0 : if(nCategories==1 && bLabelSet)
546 : {
547 0 : ::std::vector< uno::Any > aLabels;
548 0 : m_aInternalData.setComplexRowLabel( 0, m_aInternalData.getComplexColumnLabel( n ) );
549 0 : m_aInternalData.setComplexColumnLabel( n, aLabels );
550 : }
551 : }
552 0 : aNewLabels.pop_back();
553 0 : nCategories++;
554 0 : bValues = false;
555 : }
556 : } while( nIndex >= 0 );
557 :
558 0 : if( bValues )
559 : {
560 0 : m_aInternalData.insertColumn( n );
561 0 : m_aInternalData.setColumnValues( n, aNewData );
562 0 : aRangeRepresentation = OUString::valueOf( n );
563 : }
564 0 : else if( nCategories > 1 )
565 : {
566 0 : aRangeRepresentation = lcl_aCategoriesRangeName;
567 : }
568 : else
569 : {
570 0 : aRangeRepresentation = lcl_aLabelRangePrefix+OUString::valueOf( n );
571 0 : }
572 : }
573 :
574 : Reference< chart2::data::XDataSequence > xSeq(
575 246 : new UncachedDataSequence( this, aRangeRepresentation ));
576 246 : lcl_addDataSequenceToMap( aRangeRepresentation, xSeq );
577 246 : return xSeq;
578 : }
579 :
580 41 : Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
581 : const OUString & rRangeRepresentation,
582 : const OUString & rRole )
583 : {
584 : Reference< chart2::data::XDataSequence > xSeq(
585 41 : new UncachedDataSequence( this, rRangeRepresentation, rRole ));
586 41 : lcl_addDataSequenceToMap( rRangeRepresentation, xSeq );
587 41 : return xSeq;
588 : }
589 :
590 41 : void InternalDataProvider::createDefaultData()
591 : {
592 41 : m_aInternalData.createDefaultData();
593 41 : }
594 :
595 : // ____ XDataProvider ____
596 0 : ::sal_Bool SAL_CALL InternalDataProvider::createDataSourcePossible( const Sequence< beans::PropertyValue >& /* aArguments */ )
597 : throw (uno::RuntimeException)
598 : {
599 0 : return true;
600 : }
601 :
602 : namespace
603 : {
604 :
605 451 : sal_Int32 lcl_getInnerLevelCount( const vector< vector< uno::Any > >& rLabels )
606 : {
607 451 : sal_Int32 nCount = 1;//minimum is 1!
608 451 : vector< vector< uno::Any > >::const_iterator aLevelIt( rLabels.begin() );
609 451 : vector< vector< uno::Any > >::const_iterator aLevelEnd( rLabels.end() );
610 2255 : for( ;aLevelIt!=aLevelEnd; ++aLevelIt )
611 : {
612 1804 : const vector< uno::Any >& rCurrentLevelLabels = *aLevelIt;
613 1804 : nCount = std::max<sal_Int32>( rCurrentLevelLabels.size(), nCount );
614 : }
615 451 : return nCount;
616 : }
617 :
618 : }//end anonymous namespace
619 :
620 287 : Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createDataSource(
621 : const Sequence< beans::PropertyValue >& aArguments )
622 : throw (lang::IllegalArgumentException,
623 : uno::RuntimeException)
624 : {
625 287 : OUString aRangeRepresentation;
626 287 : bool bUseColumns = true;
627 287 : bool bFirstCellAsLabel = true;
628 287 : bool bHasCategories = true;
629 287 : uno::Sequence< sal_Int32 > aSequenceMapping;
630 287 : DataSourceHelper::readArguments( aArguments, aRangeRepresentation, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
631 :
632 287 : if( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) )
633 : {
634 : //return split complex categories if we have any:
635 246 : ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aComplexCategories;
636 246 : vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
637 246 : if( bUseColumns==m_bDataInColumns )
638 : {
639 123 : sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories );
640 246 : for( sal_Int32 nL=0; nL<nLevelCount; nL++ )
641 : aComplexCategories.push_back( new LabeledDataSequence(
642 : new UncachedDataSequence( this
643 246 : , lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL )
644 369 : , lcl_aCategoriesRoleName ) ) );
645 : }
646 : else
647 : {
648 123 : sal_Int32 nPointCount = m_bDataInColumns ? m_aInternalData.getRowCount() : m_aInternalData.getColumnCount();
649 615 : for( sal_Int32 nP=0; nP<nPointCount; nP++ )
650 : aComplexCategories.push_back( new LabeledDataSequence(
651 : new UncachedDataSequence( this
652 984 : , lcl_aCategoriesPointRangeNamePrefix + OUString::valueOf( nP )
653 1476 : , lcl_aCategoriesRoleName ) ) );
654 : }
655 : //don't add the created sequences to the map as they are used temporarily only ...
656 246 : return new DataSource( ContainerHelper::ContainerToSequence(aComplexCategories) );
657 : }
658 :
659 : OSL_ASSERT( aRangeRepresentation.equals( lcl_aCompleteRange ));
660 :
661 41 : ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aResultLSeqVec;
662 :
663 : // categories
664 41 : if( bHasCategories )
665 : aResultLSeqVec.push_back(
666 41 : new LabeledDataSequence( lcl_createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName ) ) );
667 :
668 : // data with labels
669 41 : ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aDataVec;
670 41 : const sal_Int32 nCount = (bUseColumns ? m_aInternalData.getColumnCount() : m_aInternalData.getRowCount());
671 164 : for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
672 : {
673 : aDataVec.push_back(
674 : new LabeledDataSequence(
675 : lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIdx )),
676 123 : lcl_createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIdx ))));
677 : }
678 :
679 : // attention: this data provider has the limitation that it stores
680 : // internally if data comes from columns or rows. It is intended for
681 : // creating only one used data source.
682 : // @todo: add this information in the range representation strings
683 41 : m_bDataInColumns = bUseColumns;
684 :
685 : //reorder labeled sequences according to aSequenceMapping; ignore categories
686 41 : for( sal_Int32 nNewIndex = 0; nNewIndex < aSequenceMapping.getLength(); nNewIndex++ )
687 : {
688 0 : std::vector< LabeledDataSequence* >::size_type nOldIndex = aSequenceMapping[nNewIndex];
689 0 : if( nOldIndex < aDataVec.size() )
690 : {
691 0 : if( aDataVec[nOldIndex].is() )
692 : {
693 0 : aResultLSeqVec.push_back( aDataVec[nOldIndex] );
694 0 : aDataVec[nOldIndex] = 0;
695 : }
696 : }
697 : }
698 :
699 : //add left over data sequences to result
700 41 : ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::iterator aIt(aDataVec.begin());
701 41 : const ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::const_iterator aEndIt(aDataVec.end());
702 164 : for( ;aIt!=aEndIt; ++aIt)
703 : {
704 123 : if( aIt->is() )
705 123 : aResultLSeqVec.push_back( *aIt );
706 : }
707 :
708 41 : return new DataSource( ContainerHelper::ContainerToSequence(aResultLSeqVec) );
709 : }
710 :
711 0 : Sequence< beans::PropertyValue > SAL_CALL InternalDataProvider::detectArguments(
712 : const Reference< chart2::data::XDataSource >& /* xDataSource */ )
713 : throw (uno::RuntimeException)
714 : {
715 0 : Sequence< beans::PropertyValue > aArguments( 4 );
716 0 : aArguments[0] = beans::PropertyValue(
717 : C2U("CellRangeRepresentation"), -1, uno::makeAny( lcl_aCompleteRange ),
718 0 : beans::PropertyState_DIRECT_VALUE );
719 0 : aArguments[1] = beans::PropertyValue(
720 : C2U("DataRowSource"), -1, uno::makeAny(
721 : m_bDataInColumns
722 : ? ::com::sun::star::chart::ChartDataRowSource_COLUMNS
723 : : ::com::sun::star::chart::ChartDataRowSource_ROWS ),
724 0 : beans::PropertyState_DIRECT_VALUE );
725 : // internal data always contains labels and categories
726 0 : aArguments[2] = beans::PropertyValue(
727 0 : C2U("FirstCellAsLabel"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
728 0 : aArguments[3] = beans::PropertyValue(
729 0 : C2U("HasCategories"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
730 :
731 : // #i85913# Sequence Mapping is not needed for internal data, as it is
732 : // applied to the data when the data source is created.
733 :
734 0 : return aArguments;
735 : }
736 :
737 0 : ::sal_Bool SAL_CALL InternalDataProvider::createDataSequenceByRangeRepresentationPossible( const OUString& /* aRangeRepresentation */ )
738 : throw (uno::RuntimeException)
739 : {
740 0 : return true;
741 : }
742 :
743 0 : Reference< chart2::data::XDataSequence > SAL_CALL InternalDataProvider::createDataSequenceByRangeRepresentation(
744 : const OUString& aRangeRepresentation )
745 : throw (lang::IllegalArgumentException,
746 : uno::RuntimeException)
747 : {
748 0 : if( aRangeRepresentation.match( lcl_aCategoriesRangeName ))
749 : {
750 : OSL_ASSERT( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
751 :
752 : // categories
753 0 : return lcl_createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName );
754 : }
755 0 : else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
756 : {
757 : // label
758 0 : sal_Int32 nIndex = aRangeRepresentation.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
759 0 : return lcl_createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ));
760 : }
761 0 : else if ( aRangeRepresentation == "last" )
762 : {
763 : sal_Int32 nIndex = (m_bDataInColumns
764 0 : ? m_aInternalData.getColumnCount()
765 0 : : m_aInternalData.getRowCount()) - 1;
766 0 : return lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
767 : }
768 0 : else if( !aRangeRepresentation.isEmpty())
769 : {
770 : // data
771 0 : return lcl_createDataSequenceAndAddToMap( aRangeRepresentation );
772 : }
773 :
774 0 : return Reference< chart2::data::XDataSequence >();
775 : }
776 :
777 0 : Reference< sheet::XRangeSelection > SAL_CALL InternalDataProvider::getRangeSelection()
778 : throw (uno::RuntimeException)
779 : {
780 : // there is no range selection component
781 0 : return Reference< sheet::XRangeSelection >();
782 : }
783 :
784 : // ____ XInternalDataProvider ____
785 0 : ::sal_Bool SAL_CALL InternalDataProvider::hasDataByRangeRepresentation( const OUString& aRange )
786 : throw (uno::RuntimeException)
787 : {
788 0 : sal_Bool bResult = false;
789 :
790 0 : if( aRange.match( lcl_aCategoriesRangeName ))
791 : {
792 : OSL_ASSERT( aRange.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
793 0 : bResult = true;
794 : }
795 0 : else if( aRange.match( lcl_aLabelRangePrefix ))
796 : {
797 0 : sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
798 0 : bResult = (nIndex < (m_bDataInColumns ? m_aInternalData.getColumnCount(): m_aInternalData.getRowCount()));
799 : }
800 : else
801 : {
802 0 : sal_Int32 nIndex = aRange.toInt32();
803 0 : bResult = (nIndex < (m_bDataInColumns ? m_aInternalData.getColumnCount(): m_aInternalData.getRowCount()));
804 : }
805 :
806 0 : return bResult;
807 : }
808 :
809 574 : Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation( const OUString& aRange )
810 : throw (uno::RuntimeException)
811 : {
812 574 : Sequence< uno::Any > aResult;
813 :
814 574 : if( aRange.match( lcl_aLabelRangePrefix ) )
815 : {
816 123 : sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
817 : vector< uno::Any > aComplexLabel = m_bDataInColumns
818 : ? m_aInternalData.getComplexColumnLabel( nIndex )
819 123 : : m_aInternalData.getComplexRowLabel( nIndex );
820 123 : if( !aComplexLabel.empty() )
821 123 : aResult = ContainerHelper::ContainerToSequence(aComplexLabel);
822 : }
823 451 : else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
824 : {
825 0 : sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesPointRangeNamePrefix.getLength() ).toInt32();
826 : vector< uno::Any > aComplexCategory = m_bDataInColumns
827 : ? m_aInternalData.getComplexRowLabel( nPointIndex )
828 0 : : m_aInternalData.getComplexColumnLabel( nPointIndex );
829 0 : if( !aComplexCategory.empty() )
830 0 : aResult = ContainerHelper::ContainerToSequence(aComplexCategory);
831 : }
832 451 : else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
833 : {
834 164 : sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength() ).toInt32();
835 164 : vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
836 164 : if( nLevel < lcl_getInnerLevelCount( aCategories ) )
837 : {
838 164 : aResult.realloc( aCategories.size() );
839 : transform( aCategories.begin(), aCategories.end(),
840 164 : aResult.getArray(), lcl_copyFromLevel(nLevel) );
841 164 : }
842 : }
843 287 : else if( aRange.equals( lcl_aCategoriesRangeName ) )
844 : {
845 164 : vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
846 164 : sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories );
847 164 : if( nLevelCount == 1 )
848 : {
849 164 : sal_Int32 nL=0;
850 164 : aResult = this->getDataByRangeRepresentation( lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL ) );
851 : }
852 : else
853 : {
854 0 : Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions();
855 0 : aResult.realloc( aLabels.getLength() );
856 0 : transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(),
857 0 : aResult.getArray(), CommonFunctors::makeAny< OUString >() );
858 164 : }
859 : }
860 : else
861 : {
862 123 : sal_Int32 nIndex = aRange.toInt32();
863 123 : if( nIndex >= 0 )
864 : {
865 123 : Sequence< double > aData;
866 123 : if( m_bDataInColumns )
867 123 : aData = m_aInternalData.getColumnValues(nIndex);
868 : else
869 0 : aData = m_aInternalData.getRowValues(nIndex);
870 123 : if( aData.getLength() )
871 : {
872 123 : aResult.realloc( aData.getLength());
873 123 : transform( aData.getConstArray(), aData.getConstArray() + aData.getLength(),
874 246 : aResult.getArray(), CommonFunctors::makeAny< double >());
875 123 : }
876 : }
877 : }
878 :
879 574 : return aResult;
880 : }
881 :
882 0 : void SAL_CALL InternalDataProvider::setDataByRangeRepresentation(
883 : const OUString& aRange, const Sequence< uno::Any >& aNewData )
884 : throw (uno::RuntimeException)
885 : {
886 0 : vector< uno::Any > aNewVector( ContainerHelper::SequenceToVector(aNewData) );
887 0 : if( aRange.match( lcl_aLabelRangePrefix ) )
888 : {
889 0 : sal_uInt32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
890 0 : if( m_bDataInColumns )
891 0 : m_aInternalData.setComplexColumnLabel( nIndex, aNewVector );
892 : else
893 0 : m_aInternalData.setComplexRowLabel( nIndex, aNewVector );
894 : }
895 0 : else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
896 : {
897 0 : sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32();
898 0 : if( m_bDataInColumns )
899 0 : m_aInternalData.setComplexRowLabel( nPointIndex, aNewVector );
900 : else
901 0 : m_aInternalData.setComplexColumnLabel( nPointIndex, aNewVector );
902 : }
903 0 : else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
904 : {
905 0 : sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32();
906 0 : vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
907 :
908 : //ensure equal length
909 0 : if( aNewVector.size() > aComplexCategories.size() )
910 0 : aComplexCategories.resize( aNewVector.size() );
911 0 : else if( aNewVector.size() < aComplexCategories.size() )
912 0 : aNewVector.resize( aComplexCategories.size() );
913 :
914 : transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(),
915 0 : aComplexCategories.begin(), lcl_setAnyAtLevel(nLevel) );
916 :
917 0 : if( m_bDataInColumns )
918 0 : m_aInternalData.setComplexRowLabels( aComplexCategories );
919 : else
920 0 : m_aInternalData.setComplexColumnLabels( aComplexCategories );
921 : }
922 0 : else if( aRange.equals( lcl_aCategoriesRangeName ) )
923 : {
924 0 : vector< vector< uno::Any > > aComplexCategories;
925 0 : aComplexCategories.resize( aNewVector.size() );
926 : transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(),
927 0 : aComplexCategories.begin(), lcl_setAnyAtLevel(0) );
928 0 : if( m_bDataInColumns )
929 0 : m_aInternalData.setComplexRowLabels( aComplexCategories );
930 : else
931 0 : m_aInternalData.setComplexColumnLabels( aComplexCategories );
932 : }
933 : else
934 : {
935 0 : sal_Int32 nIndex = aRange.toInt32();
936 0 : if( nIndex>=0 )
937 : {
938 0 : vector< double > aNewDataVec;
939 0 : transform( aNewData.getConstArray(), aNewData.getConstArray() + aNewData.getLength(),
940 0 : back_inserter( aNewDataVec ), CommonFunctors::AnyToDouble());
941 0 : if( m_bDataInColumns )
942 0 : m_aInternalData.setColumnValues( nIndex, aNewDataVec );
943 : else
944 0 : m_aInternalData.setRowValues( nIndex, aNewDataVec );
945 : }
946 0 : }
947 0 : }
948 :
949 0 : void SAL_CALL InternalDataProvider::insertSequence( ::sal_Int32 nAfterIndex )
950 : throw (uno::RuntimeException)
951 : {
952 0 : if( m_bDataInColumns )
953 : {
954 0 : lcl_increaseMapReferences( nAfterIndex + 1, m_aInternalData.getColumnCount());
955 0 : m_aInternalData.insertColumn( nAfterIndex );
956 : }
957 : else
958 : {
959 0 : lcl_increaseMapReferences( nAfterIndex + 1, m_aInternalData.getRowCount());
960 0 : m_aInternalData.insertRow( nAfterIndex );
961 : }
962 0 : }
963 :
964 0 : void SAL_CALL InternalDataProvider::deleteSequence( ::sal_Int32 nAtIndex )
965 : throw (uno::RuntimeException)
966 : {
967 0 : lcl_deleteMapReferences( OUString::valueOf( nAtIndex ));
968 0 : lcl_deleteMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nAtIndex ));
969 0 : if( m_bDataInColumns )
970 : {
971 0 : lcl_decreaseMapReferences( nAtIndex + 1, m_aInternalData.getColumnCount());
972 0 : m_aInternalData.deleteColumn( nAtIndex );
973 : }
974 : else
975 : {
976 0 : lcl_decreaseMapReferences( nAtIndex + 1, m_aInternalData.getRowCount());
977 0 : m_aInternalData.deleteRow( nAtIndex );
978 : }
979 0 : }
980 :
981 0 : void SAL_CALL InternalDataProvider::appendSequence()
982 : throw (uno::RuntimeException)
983 : {
984 0 : if( m_bDataInColumns )
985 0 : m_aInternalData.appendColumn();
986 : else
987 0 : m_aInternalData.appendRow();
988 0 : }
989 :
990 0 : void SAL_CALL InternalDataProvider::insertComplexCategoryLevel( sal_Int32 nLevel )
991 : throw (uno::RuntimeException)
992 : {
993 : OSL_ENSURE( nLevel> 0, "you can only insert category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
994 0 : if( nLevel>0 )
995 : {
996 0 : vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
997 0 : ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertAnyAtLevel(nLevel) );
998 0 : if( m_bDataInColumns )
999 0 : m_aInternalData.setComplexRowLabels( aComplexCategories );
1000 : else
1001 0 : m_aInternalData.setComplexColumnLabels( aComplexCategories );
1002 :
1003 0 : tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
1004 0 : ::std::for_each( aRange.first, aRange.second, lcl_setModified());
1005 : }
1006 0 : }
1007 0 : void SAL_CALL InternalDataProvider::deleteComplexCategoryLevel( sal_Int32 nLevel )
1008 : throw (uno::RuntimeException)
1009 : {
1010 : OSL_ENSURE( nLevel>0, "you can only delete category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
1011 0 : if( nLevel>0 )
1012 : {
1013 0 : vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
1014 0 : ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeAnyAtLevel(nLevel) );
1015 0 : if( m_bDataInColumns )
1016 0 : m_aInternalData.setComplexRowLabels( aComplexCategories );
1017 : else
1018 0 : m_aInternalData.setComplexColumnLabels( aComplexCategories );
1019 :
1020 0 : tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
1021 0 : ::std::for_each( aRange.first, aRange.second, lcl_setModified());
1022 : }
1023 0 : }
1024 :
1025 0 : void SAL_CALL InternalDataProvider::insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
1026 : throw (uno::RuntimeException)
1027 : {
1028 0 : sal_Int32 nMaxRep = 0;
1029 0 : if( m_bDataInColumns )
1030 : {
1031 0 : m_aInternalData.insertRow( nAfterIndex );
1032 0 : nMaxRep = m_aInternalData.getColumnCount();
1033 : }
1034 : else
1035 : {
1036 0 : m_aInternalData.insertColumn( nAfterIndex );
1037 0 : nMaxRep = m_aInternalData.getRowCount();
1038 : }
1039 :
1040 : // notify change to all affected ranges
1041 0 : tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
1042 0 : tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
1043 0 : ::std::for_each( aBegin, aEnd, lcl_setModified());
1044 :
1045 0 : tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
1046 0 : ::std::for_each( aRange.first, aRange.second, lcl_setModified());
1047 0 : }
1048 :
1049 0 : void SAL_CALL InternalDataProvider::deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
1050 : throw (uno::RuntimeException)
1051 : {
1052 0 : sal_Int32 nMaxRep = 0;
1053 0 : if( m_bDataInColumns )
1054 : {
1055 0 : m_aInternalData.deleteRow( nAtIndex );
1056 0 : nMaxRep = m_aInternalData.getColumnCount();
1057 : }
1058 : else
1059 : {
1060 0 : m_aInternalData.deleteColumn( nAtIndex );
1061 0 : nMaxRep = m_aInternalData.getRowCount();
1062 : }
1063 :
1064 : // notify change to all affected ranges
1065 0 : tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
1066 0 : tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
1067 0 : ::std::for_each( aBegin, aEnd, lcl_setModified());
1068 :
1069 0 : tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
1070 0 : ::std::for_each( aRange.first, aRange.second, lcl_setModified());
1071 0 : }
1072 :
1073 0 : void SAL_CALL InternalDataProvider::swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex )
1074 : throw (uno::RuntimeException)
1075 : {
1076 0 : if( m_bDataInColumns )
1077 0 : m_aInternalData.swapRowWithNext( nAtIndex );
1078 : else
1079 0 : m_aInternalData.swapColumnWithNext( nAtIndex );
1080 : sal_Int32 nMaxRep = (m_bDataInColumns
1081 0 : ? m_aInternalData.getColumnCount()
1082 0 : : m_aInternalData.getRowCount());
1083 :
1084 : // notify change to all affected ranges
1085 0 : tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
1086 0 : tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
1087 0 : ::std::for_each( aBegin, aEnd, lcl_setModified());
1088 :
1089 0 : tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
1090 0 : ::std::for_each( aRange.first, aRange.second, lcl_setModified());
1091 0 : }
1092 :
1093 0 : void SAL_CALL InternalDataProvider::registerDataSequenceForChanges( const Reference< chart2::data::XDataSequence >& xSeq )
1094 : throw (uno::RuntimeException)
1095 : {
1096 0 : if( xSeq.is())
1097 0 : lcl_addDataSequenceToMap( xSeq->getSourceRangeRepresentation(), xSeq );
1098 0 : }
1099 :
1100 :
1101 : // ____ XRangeXMLConversion ____
1102 0 : OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRangeRepresentation )
1103 : throw (lang::IllegalArgumentException,
1104 : uno::RuntimeException)
1105 : {
1106 0 : XMLRangeHelper::CellRange aRange;
1107 0 : aRange.aTableName = OUString(RTL_CONSTASCII_USTRINGPARAM("local-table"));
1108 :
1109 : // attention: this data provider has the limitation that it stores
1110 : // internally if data comes from columns or rows. It is intended for
1111 : // creating only one used data source.
1112 : // @todo: add this information in the range representation strings
1113 0 : if( aRangeRepresentation.match( lcl_aCategoriesRangeName ))
1114 : {
1115 : OSL_ASSERT( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
1116 0 : aRange.aUpperLeft.bIsEmpty = false;
1117 0 : if( m_bDataInColumns )
1118 : {
1119 0 : aRange.aUpperLeft.nColumn = 0;
1120 0 : aRange.aUpperLeft.nRow = 1;
1121 0 : aRange.aLowerRight = aRange.aUpperLeft;
1122 0 : aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
1123 : }
1124 : else
1125 : {
1126 0 : aRange.aUpperLeft.nColumn = 1;
1127 0 : aRange.aUpperLeft.nRow = 0;
1128 0 : aRange.aLowerRight = aRange.aUpperLeft;
1129 0 : aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
1130 : }
1131 : }
1132 0 : else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
1133 : {
1134 0 : sal_Int32 nIndex = aRangeRepresentation.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
1135 0 : aRange.aUpperLeft.bIsEmpty = false;
1136 0 : aRange.aLowerRight.bIsEmpty = true;
1137 0 : if( m_bDataInColumns )
1138 : {
1139 0 : aRange.aUpperLeft.nColumn = nIndex + 1;
1140 0 : aRange.aUpperLeft.nRow = 0;
1141 : }
1142 : else
1143 : {
1144 0 : aRange.aUpperLeft.nColumn = 0;
1145 0 : aRange.aUpperLeft.nRow = nIndex + 1;
1146 : }
1147 : }
1148 0 : else if( aRangeRepresentation.equals( lcl_aCompleteRange ))
1149 : {
1150 0 : aRange.aUpperLeft.bIsEmpty = false;
1151 0 : aRange.aLowerRight.bIsEmpty = false;
1152 0 : aRange.aUpperLeft.nColumn = 0;
1153 0 : aRange.aUpperLeft.nRow = 0;
1154 0 : aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
1155 0 : aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
1156 : }
1157 : else
1158 : {
1159 0 : sal_Int32 nIndex = aRangeRepresentation.toInt32();
1160 0 : aRange.aUpperLeft.bIsEmpty = false;
1161 0 : if( m_bDataInColumns )
1162 : {
1163 0 : aRange.aUpperLeft.nColumn = nIndex + 1;
1164 0 : aRange.aUpperLeft.nRow = 1;
1165 0 : aRange.aLowerRight = aRange.aUpperLeft;
1166 0 : aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
1167 : }
1168 : else
1169 : {
1170 0 : aRange.aUpperLeft.nColumn = 1;
1171 0 : aRange.aUpperLeft.nRow = nIndex + 1;
1172 0 : aRange.aLowerRight = aRange.aUpperLeft;
1173 0 : aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
1174 : }
1175 : }
1176 :
1177 0 : return XMLRangeHelper::getXMLStringFromCellRange( aRange );
1178 : }
1179 :
1180 0 : OUString SAL_CALL InternalDataProvider::convertRangeFromXML( const OUString& aXMLRange )
1181 : throw (lang::IllegalArgumentException,
1182 : uno::RuntimeException)
1183 : {
1184 0 : XMLRangeHelper::CellRange aRange( XMLRangeHelper::getCellRangeFromXMLString( aXMLRange ));
1185 0 : if( aRange.aUpperLeft.bIsEmpty )
1186 : {
1187 : OSL_ENSURE( aRange.aLowerRight.bIsEmpty, "Weird Range" );
1188 0 : return OUString();
1189 : }
1190 :
1191 : // "all"
1192 0 : if( !aRange.aLowerRight.bIsEmpty &&
1193 : ( aRange.aUpperLeft.nColumn != aRange.aLowerRight.nColumn ) &&
1194 : ( aRange.aUpperLeft.nRow != aRange.aLowerRight.nRow ) )
1195 0 : return lcl_aCompleteRange;
1196 :
1197 : // attention: this data provider has the limitation that it stores
1198 : // internally if data comes from columns or rows. It is intended for
1199 : // creating only one used data source.
1200 : // @todo: add this information in the range representation strings
1201 :
1202 : // data in columns
1203 0 : if( m_bDataInColumns )
1204 : {
1205 0 : if( aRange.aUpperLeft.nColumn == 0 )
1206 0 : return lcl_aCategoriesRangeName;
1207 0 : if( aRange.aUpperLeft.nRow == 0 )
1208 0 : return lcl_aLabelRangePrefix + OUString::valueOf( aRange.aUpperLeft.nColumn - 1 );
1209 :
1210 0 : return OUString::valueOf( aRange.aUpperLeft.nColumn - 1 );
1211 : }
1212 :
1213 : // data in rows
1214 0 : if( aRange.aUpperLeft.nRow == 0 )
1215 0 : return lcl_aCategoriesRangeName;
1216 0 : if( aRange.aUpperLeft.nColumn == 0 )
1217 0 : return lcl_aLabelRangePrefix + OUString::valueOf( aRange.aUpperLeft.nRow - 1 );
1218 :
1219 0 : return OUString::valueOf( aRange.aUpperLeft.nRow - 1 );
1220 : }
1221 :
1222 : namespace
1223 : {
1224 :
1225 : template< class Type >
1226 0 : Sequence< Sequence< Type > > lcl_convertVectorVectorToSequenceSequence( const vector< vector< Type > >& rIn )
1227 : {
1228 0 : Sequence< Sequence< Type > > aRet;
1229 0 : sal_Int32 nOuterCount = rIn.size();
1230 0 : if( nOuterCount )
1231 : {
1232 0 : aRet.realloc(nOuterCount);
1233 0 : for( sal_Int32 nN=0; nN<nOuterCount; nN++)
1234 0 : aRet[nN]= ContainerHelper::ContainerToSequence( rIn[nN] );
1235 : }
1236 0 : return aRet;
1237 : }
1238 :
1239 : template< class Type >
1240 0 : vector< vector< Type > > lcl_convertSequenceSequenceToVectorVector( const Sequence< Sequence< Type > >& rIn )
1241 : {
1242 0 : vector< vector< Type > > aRet;
1243 0 : sal_Int32 nOuterCount = rIn.getLength();
1244 0 : if( nOuterCount )
1245 : {
1246 0 : aRet.resize(nOuterCount);
1247 0 : for( sal_Int32 nN=0; nN<nOuterCount; nN++)
1248 0 : aRet[nN]= ContainerHelper::SequenceToVector( rIn[nN] );
1249 : }
1250 0 : return aRet;
1251 : }
1252 :
1253 0 : Sequence< Sequence< OUString > > lcl_convertComplexAnyVectorToStringSequence( const vector< vector< uno::Any > >& rIn )
1254 : {
1255 0 : Sequence< Sequence< OUString > > aRet;
1256 0 : sal_Int32 nOuterCount = rIn.size();
1257 0 : if( nOuterCount )
1258 : {
1259 0 : aRet.realloc(nOuterCount);
1260 0 : for( sal_Int32 nN=0; nN<nOuterCount; nN++)
1261 0 : aRet[nN]= lcl_AnyToStringSequence( ContainerHelper::ContainerToSequence( rIn[nN] ) );
1262 : }
1263 0 : return aRet;
1264 : }
1265 :
1266 0 : vector< vector< uno::Any > > lcl_convertComplexStringSequenceToAnyVector( const Sequence< Sequence< OUString > >& rIn )
1267 : {
1268 0 : vector< vector< uno::Any > > aRet;
1269 0 : sal_Int32 nOuterCount = rIn.getLength();
1270 0 : for( sal_Int32 nN=0; nN<nOuterCount; nN++)
1271 0 : aRet.push_back( ContainerHelper::SequenceToVector( lcl_StringToAnySequence( rIn[nN] ) ) );
1272 0 : return aRet;
1273 : }
1274 :
1275 : class SplitCategoriesProvider_ForComplexDescriptions : public SplitCategoriesProvider
1276 : {
1277 : public:
1278 :
1279 0 : explicit SplitCategoriesProvider_ForComplexDescriptions( const ::std::vector< ::std::vector< uno::Any > >& rComplexDescriptions )
1280 0 : : m_rComplexDescriptions( rComplexDescriptions )
1281 0 : {}
1282 0 : virtual ~SplitCategoriesProvider_ForComplexDescriptions()
1283 0 : {}
1284 :
1285 : virtual sal_Int32 getLevelCount() const;
1286 : virtual uno::Sequence< rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const;
1287 :
1288 : private:
1289 : const ::std::vector< ::std::vector< uno::Any > >& m_rComplexDescriptions;
1290 : };
1291 :
1292 0 : sal_Int32 SplitCategoriesProvider_ForComplexDescriptions::getLevelCount() const
1293 : {
1294 0 : return lcl_getInnerLevelCount( m_rComplexDescriptions );
1295 : }
1296 0 : uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForComplexDescriptions::getStringsForLevel( sal_Int32 nLevel ) const
1297 : {
1298 0 : uno::Sequence< rtl::OUString > aResult;
1299 0 : if( nLevel < lcl_getInnerLevelCount( m_rComplexDescriptions ) )
1300 : {
1301 0 : aResult.realloc( m_rComplexDescriptions.size() );
1302 : transform( m_rComplexDescriptions.begin(), m_rComplexDescriptions.end(),
1303 0 : aResult.getArray(), lcl_getStringFromLevelVector(nLevel) );
1304 : }
1305 0 : return aResult;
1306 : }
1307 :
1308 : }//anonymous namespace
1309 :
1310 : // ____ XDateCategories ____
1311 0 : Sequence< double > SAL_CALL InternalDataProvider::getDateCategories() throw (uno::RuntimeException)
1312 : {
1313 0 : double fNan = InternalDataProvider::getNotANumber();
1314 0 : double fValue = fNan;
1315 0 : vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
1316 0 : sal_Int32 nCount = aCategories.size();
1317 0 : Sequence< double > aDoubles( nCount );
1318 0 : vector< vector< uno::Any > >::iterator aIt( aCategories.begin() );
1319 0 : vector< vector< uno::Any > >::const_iterator aEnd( aCategories.end() );
1320 0 : for(sal_Int32 nN=0; nN<nCount && aIt!=aEnd; ++nN, ++aIt )
1321 : {
1322 0 : if( !( !aIt->empty() && ((*aIt)[0]>>=fValue) ) )
1323 0 : fValue = fNan;
1324 0 : aDoubles[nN]=fValue;
1325 : }
1326 0 : return aDoubles;
1327 : }
1328 :
1329 0 : void SAL_CALL InternalDataProvider::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException)
1330 : {
1331 0 : sal_Int32 nCount = rDates.getLength();
1332 0 : vector< vector< uno::Any > > aNewCategories;
1333 0 : aNewCategories.reserve(nCount);
1334 0 : vector< uno::Any > aSingleLabel(1);
1335 :
1336 0 : for(sal_Int32 nN=0; nN<nCount; ++nN )
1337 : {
1338 0 : aSingleLabel[0]=uno::makeAny(rDates[nN]);
1339 0 : aNewCategories.push_back(aSingleLabel);
1340 : }
1341 :
1342 0 : if( m_bDataInColumns )
1343 0 : m_aInternalData.setComplexRowLabels( aNewCategories );
1344 : else
1345 0 : m_aInternalData.setComplexColumnLabels( aNewCategories );
1346 0 : }
1347 :
1348 : // ____ XAnyDescriptionAccess ____
1349 0 : Sequence< Sequence< uno::Any > > SAL_CALL InternalDataProvider::getAnyRowDescriptions() throw (uno::RuntimeException)
1350 : {
1351 0 : return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexRowLabels() );
1352 : }
1353 0 : void SAL_CALL InternalDataProvider::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& aRowDescriptions ) throw (uno::RuntimeException)
1354 : {
1355 0 : m_aInternalData.setComplexRowLabels( lcl_convertSequenceSequenceToVectorVector( aRowDescriptions ) );
1356 0 : }
1357 0 : Sequence< Sequence< uno::Any > > SAL_CALL InternalDataProvider::getAnyColumnDescriptions() throw (uno::RuntimeException)
1358 : {
1359 0 : return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexColumnLabels() );
1360 : }
1361 0 : void SAL_CALL InternalDataProvider::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& aColumnDescriptions ) throw (uno::RuntimeException)
1362 : {
1363 0 : m_aInternalData.setComplexColumnLabels( lcl_convertSequenceSequenceToVectorVector( aColumnDescriptions ) );
1364 0 : }
1365 :
1366 : // ____ XComplexDescriptionAccess ____
1367 0 : Sequence< Sequence< OUString > > SAL_CALL InternalDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException)
1368 : {
1369 0 : return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexRowLabels() );
1370 : }
1371 0 : void SAL_CALL InternalDataProvider::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException)
1372 : {
1373 0 : m_aInternalData.setComplexRowLabels( lcl_convertComplexStringSequenceToAnyVector(aRowDescriptions) );
1374 0 : }
1375 0 : Sequence< Sequence< ::rtl::OUString > > SAL_CALL InternalDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException)
1376 : {
1377 0 : return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexColumnLabels() );
1378 : }
1379 0 : void SAL_CALL InternalDataProvider::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException)
1380 : {
1381 0 : m_aInternalData.setComplexColumnLabels( lcl_convertComplexStringSequenceToAnyVector(aColumnDescriptions) );
1382 0 : }
1383 :
1384 : // ____ XChartDataArray ____
1385 0 : Sequence< Sequence< double > > SAL_CALL InternalDataProvider::getData()
1386 : throw (uno::RuntimeException)
1387 : {
1388 0 : return m_aInternalData.getData();
1389 : }
1390 :
1391 0 : void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double > >& rDataInRows )
1392 : throw (uno::RuntimeException)
1393 : {
1394 0 : return m_aInternalData.setData( rDataInRows );
1395 : }
1396 :
1397 0 : void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions )
1398 : throw (uno::RuntimeException)
1399 : {
1400 0 : vector< vector< uno::Any > > aComplexDescriptions( aRowDescriptions.getLength() );
1401 : transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aRowDescriptions.getConstArray(),
1402 0 : aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) );
1403 0 : m_aInternalData.setComplexRowLabels( aComplexDescriptions );
1404 0 : }
1405 :
1406 0 : void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions )
1407 : throw (uno::RuntimeException)
1408 : {
1409 0 : vector< vector< uno::Any > > aComplexDescriptions( aColumnDescriptions.getLength() );
1410 : transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aColumnDescriptions.getConstArray(),
1411 0 : aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) );
1412 0 : m_aInternalData.setComplexColumnLabels( aComplexDescriptions );
1413 0 : }
1414 :
1415 0 : Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions()
1416 : throw (uno::RuntimeException)
1417 : {
1418 0 : vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexRowLabels() );
1419 0 : SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
1420 0 : return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
1421 : }
1422 :
1423 0 : Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions()
1424 : throw (uno::RuntimeException)
1425 : {
1426 0 : vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexColumnLabels() );
1427 0 : SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
1428 0 : return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
1429 : }
1430 :
1431 : // ____ XChartData (base of XChartDataArray) ____
1432 0 : void SAL_CALL InternalDataProvider::addChartDataChangeEventListener(
1433 : const Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& )
1434 : throw (uno::RuntimeException)
1435 : {
1436 0 : }
1437 :
1438 0 : void SAL_CALL InternalDataProvider::removeChartDataChangeEventListener(
1439 : const Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& )
1440 : throw (uno::RuntimeException)
1441 : {
1442 0 : }
1443 :
1444 0 : double SAL_CALL InternalDataProvider::getNotANumber()
1445 : throw (uno::RuntimeException)
1446 : {
1447 : double fNan;
1448 0 : ::rtl::math::setNan( & fNan );
1449 0 : return fNan;
1450 : }
1451 :
1452 0 : ::sal_Bool SAL_CALL InternalDataProvider::isNotANumber( double nNumber )
1453 : throw (uno::RuntimeException)
1454 : {
1455 0 : return ::rtl::math::isNan( nNumber )
1456 0 : || ::rtl::math::isInf( nNumber );
1457 : }
1458 : // lang::XInitialization:
1459 41 : void SAL_CALL InternalDataProvider::initialize(const uno::Sequence< uno::Any > & _aArguments) throw (uno::RuntimeException, uno::Exception)
1460 : {
1461 41 : comphelper::SequenceAsHashMap aArgs(_aArguments);
1462 41 : if ( aArgs.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),sal_False) )
1463 41 : createDefaultData();
1464 41 : }
1465 : // ____ XCloneable ____
1466 0 : Reference< util::XCloneable > SAL_CALL InternalDataProvider::createClone()
1467 : throw (uno::RuntimeException)
1468 : {
1469 0 : return Reference< util::XCloneable >( new InternalDataProvider( *this ));
1470 : }
1471 :
1472 :
1473 : // ================================================================================
1474 :
1475 0 : Sequence< OUString > InternalDataProvider::getSupportedServiceNames_Static()
1476 : {
1477 0 : Sequence< OUString > aServices( 1 );
1478 0 : aServices[ 0 ] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.data.DataProvider" ));
1479 0 : return aServices;
1480 : }
1481 :
1482 : // ================================================================================
1483 :
1484 3 : APPHELPER_XSERVICEINFO_IMPL( InternalDataProvider, lcl_aServiceName );
1485 :
1486 3 : } // namespace chart
1487 :
1488 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|