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