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 "DataSourceHelper.hxx"
22 : #include "macros.hxx"
23 : #include "ChartModelHelper.hxx"
24 : #include "DiagramHelper.hxx"
25 : #include "DataSeriesHelper.hxx"
26 : #include "DataSource.hxx"
27 : #include "ContainerHelper.hxx"
28 : #include "ControllerLockGuard.hxx"
29 : #include "PropertyHelper.hxx"
30 : #include "CachedDataSequence.hxx"
31 : #include "LabeledDataSequence.hxx"
32 :
33 : #include <com/sun/star/chart2/XChartDocument.hpp>
34 : #include <com/sun/star/chart2/data/XDataSource.hpp>
35 : #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
36 :
37 : #include <com/sun/star/chart/ChartDataRowSource.hpp>
38 : #include <com/sun/star/chart/ErrorBarStyle.hpp>
39 :
40 : //.............................................................................
41 : namespace chart
42 : {
43 : //.............................................................................
44 : using namespace ::com::sun::star;
45 : using namespace ::com::sun::star::chart2;
46 : using ::com::sun::star::uno::Reference;
47 : using ::com::sun::star::uno::Sequence;
48 :
49 : namespace
50 : {
51 1304 : void lcl_addRanges( ::std::vector< OUString > & rOutResult,
52 : const uno::Reference< data::XLabeledDataSequence > & xLabeledSeq )
53 : {
54 1304 : if( ! xLabeledSeq.is())
55 1304 : return;
56 1304 : uno::Reference< data::XDataSequence > xSeq( xLabeledSeq->getLabel());
57 1304 : if( xSeq.is())
58 979 : rOutResult.push_back( xSeq->getSourceRangeRepresentation());
59 1304 : xSeq.set( xLabeledSeq->getValues());
60 1304 : if( xSeq.is())
61 1304 : rOutResult.push_back( xSeq->getSourceRangeRepresentation());
62 : }
63 :
64 979 : void lcl_addDataSourceRanges(
65 : ::std::vector< OUString > & rOutResult,
66 : const uno::Reference< data::XDataSource > & xDataSource )
67 : {
68 979 : if( xDataSource.is() )
69 : {
70 979 : uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
71 1958 : for( sal_Int32 i=0; i<aDataSequences.getLength(); ++i)
72 1958 : lcl_addRanges( rOutResult, aDataSequences[i] );
73 : }
74 979 : }
75 :
76 979 : void lcl_addErrorBarRanges(
77 : ::std::vector< OUString > & rOutResult,
78 : const uno::Reference< XDataSeries > & xDataSeries )
79 : {
80 979 : uno::Reference< beans::XPropertySet > xSeriesProp( xDataSeries, uno::UNO_QUERY );
81 979 : if( !xSeriesProp.is())
82 979 : return;
83 :
84 : try
85 : {
86 979 : uno::Reference< beans::XPropertySet > xErrorBarProp;
87 1958 : if( ( xSeriesProp->getPropertyValue( "ErrorBarY") >>= xErrorBarProp ) &&
88 979 : xErrorBarProp.is())
89 : {
90 357 : sal_Int32 eStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
91 714 : if( ( xErrorBarProp->getPropertyValue( "ErrorBarStyle") >>= eStyle ) &&
92 357 : eStyle == ::com::sun::star::chart::ErrorBarStyle::FROM_DATA )
93 : {
94 0 : uno::Reference< data::XDataSource > xErrorBarDataSource( xErrorBarProp, uno::UNO_QUERY );
95 0 : if( xErrorBarDataSource.is() )
96 0 : lcl_addDataSourceRanges( rOutResult, xErrorBarDataSource );
97 : }
98 : }
99 :
100 979 : if( ( xSeriesProp->getPropertyValue("ErrorBarX") >>= xErrorBarProp ) && xErrorBarProp.is())
101 : {
102 0 : sal_Int32 eStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
103 0 : if( ( xErrorBarProp->getPropertyValue("ErrorBarStyle") >>= eStyle ) &&
104 0 : eStyle == ::com::sun::star::chart::ErrorBarStyle::FROM_DATA )
105 : {
106 0 : uno::Reference< data::XDataSource > xErrorBarDataSource( xErrorBarProp, uno::UNO_QUERY );
107 0 : if( xErrorBarDataSource.is() )
108 0 : lcl_addDataSourceRanges( rOutResult, xErrorBarDataSource );
109 : }
110 979 : }
111 : }
112 0 : catch( const uno::Exception & ex )
113 : {
114 : ASSERT_EXCEPTION( ex );
115 979 : }
116 : }
117 :
118 : } // anonymous namespace
119 :
120 7 : Reference< chart2::data::XDataSource > DataSourceHelper::createDataSource(
121 : const Sequence< Reference< chart2::data::XLabeledDataSequence > >& rSequences )
122 : {
123 7 : return new DataSource(rSequences);
124 : }
125 :
126 0 : Reference< chart2::data::XDataSequence > DataSourceHelper::createCachedDataSequence()
127 : {
128 0 : return new ::chart::CachedDataSequence();
129 : }
130 :
131 0 : Reference< chart2::data::XDataSequence > DataSourceHelper::createCachedDataSequence( const OUString& rSingleText )
132 : {
133 0 : return new ::chart::CachedDataSequence( rSingleText );
134 : }
135 :
136 0 : Reference< chart2::data::XLabeledDataSequence > DataSourceHelper::createLabeledDataSequence(
137 : const Reference< chart2::data::XDataSequence >& xValues ,
138 : const Reference< chart2::data::XDataSequence >& xLabels )
139 : {
140 0 : return new ::chart::LabeledDataSequence( xValues, xLabels );
141 : }
142 :
143 0 : Reference< chart2::data::XLabeledDataSequence > DataSourceHelper::createLabeledDataSequence(
144 : const Reference< chart2::data::XDataSequence >& xValues )
145 : {
146 0 : return new ::chart::LabeledDataSequence( xValues );
147 : }
148 :
149 0 : Reference< chart2::data::XLabeledDataSequence > DataSourceHelper::createLabeledDataSequence(
150 : const Reference< uno::XComponentContext >& xContext )
151 : {
152 0 : return new ::chart::LabeledDataSequence( xContext );
153 : }
154 :
155 2927 : uno::Sequence< beans::PropertyValue > DataSourceHelper::createArguments(
156 : bool bUseColumns, bool bFirstCellAsLabel, bool bHasCategories )
157 : {
158 2927 : ::com::sun::star::chart::ChartDataRowSource eRowSource = ::com::sun::star::chart::ChartDataRowSource_ROWS;
159 2927 : if( bUseColumns )
160 1468 : eRowSource = ::com::sun::star::chart::ChartDataRowSource_COLUMNS;
161 :
162 2927 : uno::Sequence< beans::PropertyValue > aArguments(3);
163 5854 : aArguments[0] = beans::PropertyValue( "DataRowSource"
164 : , -1, uno::makeAny( eRowSource )
165 2927 : , beans::PropertyState_DIRECT_VALUE );
166 5854 : aArguments[1] = beans::PropertyValue( "FirstCellAsLabel"
167 : , -1, uno::makeAny( bFirstCellAsLabel )
168 2927 : , beans::PropertyState_DIRECT_VALUE );
169 5854 : aArguments[2] = beans::PropertyValue( "HasCategories"
170 : , -1, uno::makeAny( bHasCategories )
171 2927 : , beans::PropertyState_DIRECT_VALUE );
172 :
173 2927 : return aArguments;
174 : }
175 :
176 2927 : uno::Sequence< beans::PropertyValue > DataSourceHelper::createArguments(
177 : const OUString & rRangeRepresentation,
178 : const uno::Sequence< sal_Int32 >& rSequenceMapping,
179 : bool bUseColumns, bool bFirstCellAsLabel, bool bHasCategories )
180 : {
181 2927 : uno::Sequence< beans::PropertyValue > aArguments( createArguments( bUseColumns, bFirstCellAsLabel, bHasCategories ));
182 2927 : aArguments.realloc( aArguments.getLength() + 1 );
183 5854 : aArguments[aArguments.getLength() - 1] =
184 : beans::PropertyValue( "CellRangeRepresentation"
185 : , -1, uno::makeAny( rRangeRepresentation )
186 2927 : , beans::PropertyState_DIRECT_VALUE );
187 2927 : if( rSequenceMapping.getLength() )
188 : {
189 0 : aArguments.realloc( aArguments.getLength() + 1 );
190 0 : aArguments[aArguments.getLength() - 1] =
191 : beans::PropertyValue( "SequenceMapping"
192 : , -1, uno::makeAny( rSequenceMapping )
193 0 : , beans::PropertyState_DIRECT_VALUE );
194 : }
195 2927 : return aArguments;
196 : }
197 :
198 2848 : void DataSourceHelper::readArguments( const uno::Sequence< beans::PropertyValue >& rArguments
199 : , OUString & rRangeRepresentation, uno::Sequence< sal_Int32 >& rSequenceMapping
200 : , bool& bUseColumns, bool& bFirstCellAsLabel, bool& bHasCategories )
201 : {
202 2848 : const beans::PropertyValue* pArguments = rArguments.getConstArray();
203 14304 : for(sal_Int32 i=0; i<rArguments.getLength(); ++i, ++pArguments)
204 : {
205 11456 : const beans::PropertyValue& aProperty = *pArguments;
206 11456 : if ( aProperty.Name == "DataRowSource" )
207 : {
208 : ::com::sun::star::chart::ChartDataRowSource eRowSource;
209 2848 : if( aProperty.Value >>= eRowSource )
210 2848 : bUseColumns = (eRowSource==::com::sun::star::chart::ChartDataRowSource_COLUMNS);
211 : }
212 8608 : else if ( aProperty.Name == "FirstCellAsLabel" )
213 : {
214 2848 : aProperty.Value >>= bFirstCellAsLabel;
215 : }
216 5760 : else if ( aProperty.Name == "HasCategories" )
217 : {
218 2848 : aProperty.Value >>= bHasCategories;
219 : }
220 2912 : else if ( aProperty.Name == "CellRangeRepresentation" )
221 : {
222 2848 : aProperty.Value >>= rRangeRepresentation;
223 : }
224 64 : else if ( aProperty.Name == "SequenceMapping" )
225 : {
226 0 : aProperty.Value >>= rSequenceMapping;
227 : }
228 : }
229 2848 : }
230 :
231 141 : uno::Reference< chart2::data::XDataSource > DataSourceHelper::pressUsedDataIntoRectangularFormat(
232 : const uno::Reference< chart2::XChartDocument >& xChartDoc, bool bWithCategories )
233 : {
234 141 : ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aResultVector;
235 :
236 : //categories are always the first sequence
237 282 : Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
238 :
239 141 : if( bWithCategories )
240 : {
241 141 : Reference< chart2::data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
242 141 : if( xCategories.is() )
243 82 : aResultVector.push_back( xCategories );
244 : }
245 :
246 282 : ::std::vector< Reference< chart2::XDataSeries > > xSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
247 : uno::Reference< chart2::data::XDataSource > xSeriesSource(
248 282 : DataSeriesHelper::getDataSource( ContainerHelper::ContainerToSequence(xSeriesVector) ) );
249 282 : Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSeqences( xSeriesSource->getDataSequences() );
250 :
251 : //the first x-values is always the next sequence //todo ... other x-values get lost for old format
252 : Reference< chart2::data::XLabeledDataSequence > xXValues(
253 282 : DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-x" ) );
254 141 : if( xXValues.is() )
255 0 : aResultVector.push_back( xXValues );
256 :
257 : //add all other sequences now without x-values
258 927 : for( sal_Int32 nN=0; nN<aDataSeqences.getLength(); nN++ )
259 : {
260 786 : OUString aRole( DataSeriesHelper::GetRole( aDataSeqences[nN] ) );
261 786 : if( !aRole.equals("values-x") )
262 786 : aResultVector.push_back( aDataSeqences[nN] );
263 786 : }
264 :
265 282 : Sequence< Reference< chart2::data::XLabeledDataSequence > > aResultSequence( aResultVector.size() );
266 141 : ::std::copy( aResultVector.begin(), aResultVector.end(), aResultSequence.getArray() );
267 :
268 282 : return new DataSource( aResultSequence );
269 : }
270 :
271 332 : uno::Sequence< OUString > DataSourceHelper::getUsedDataRanges(
272 : const uno::Reference< chart2::XDiagram > & xDiagram )
273 : {
274 332 : ::std::vector< OUString > aResult;
275 :
276 332 : if( xDiagram.is())
277 : {
278 328 : uno::Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
279 328 : if( xCategories.is() )
280 325 : lcl_addRanges( aResult, xCategories );
281 :
282 656 : ::std::vector< uno::Reference< XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
283 3921 : for( ::std::vector< uno::Reference< XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() )
284 2614 : ; aSeriesIt != aSeriesVector.end(); ++aSeriesIt )
285 : {
286 979 : uno::Reference< data::XDataSource > xDataSource( *aSeriesIt, uno::UNO_QUERY );
287 979 : lcl_addDataSourceRanges( aResult, xDataSource );
288 979 : lcl_addErrorBarRanges( aResult, *aSeriesIt );
289 1307 : }
290 : }
291 :
292 332 : return ContainerHelper::ContainerToSequence( aResult );
293 : }
294 :
295 1 : uno::Sequence< OUString > DataSourceHelper::getUsedDataRanges( const uno::Reference< frame::XModel > & xChartModel )
296 : {
297 1 : uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
298 1 : return getUsedDataRanges( xDiagram );
299 : }
300 :
301 32 : uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
302 : const uno::Reference< chart2::XChartDocument >& xChartDoc )
303 : {
304 32 : return pressUsedDataIntoRectangularFormat( xChartDoc );
305 : }
306 :
307 129 : uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
308 : const uno::Reference< frame::XModel >& xChartModel )
309 : {
310 129 : ::std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aResult;
311 :
312 258 : uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
313 258 : uno::Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ) );
314 129 : if( xCategories.is() )
315 89 : aResult.push_back( xCategories );
316 :
317 258 : ::std::vector< uno::Reference< XDataSeries > > aSeriesVector( ChartModelHelper::getDataSeries( xChartModel ) );
318 1119 : for( ::std::vector< uno::Reference< XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() )
319 746 : ; aSeriesIt != aSeriesVector.end(); ++aSeriesIt )
320 : {
321 244 : uno::Reference< data::XDataSource > xDataSource( *aSeriesIt, uno::UNO_QUERY );
322 244 : if( !xDataSource.is() )
323 0 : continue;
324 488 : uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
325 244 : ::std::copy( aDataSequences.getConstArray(), aDataSequences.getConstArray() + aDataSequences.getLength(),
326 488 : ::std::back_inserter( aResult ));
327 244 : }
328 :
329 : return uno::Reference< chart2::data::XDataSource >(
330 258 : new DataSource( ContainerHelper::ContainerToSequence( aResult )));
331 : }
332 :
333 105 : bool DataSourceHelper::detectRangeSegmentation(
334 : const uno::Reference<
335 : frame::XModel >& xChartModel
336 : , OUString& rOutRangeString
337 : , ::com::sun::star::uno::Sequence< sal_Int32 >& rSequenceMapping
338 : , bool& rOutUseColumns
339 : , bool& rOutFirstCellAsLabel
340 : , bool& rOutHasCategories )
341 : {
342 105 : bool bSomethingDetected = false;
343 :
344 105 : uno::Reference< XChartDocument > xChartDocument( xChartModel, uno::UNO_QUERY );
345 105 : if( !xChartDocument.is() )
346 0 : return bSomethingDetected;
347 210 : uno::Reference< data::XDataProvider > xDataProvider( xChartDocument->getDataProvider() );
348 105 : if( !xDataProvider.is() )
349 0 : return bSomethingDetected;
350 :
351 : try
352 : {
353 : DataSourceHelper::readArguments(
354 105 : xDataProvider->detectArguments( pressUsedDataIntoRectangularFormat( xChartDocument ) ),
355 105 : rOutRangeString, rSequenceMapping, rOutUseColumns, rOutFirstCellAsLabel, rOutHasCategories );
356 105 : bSomethingDetected = !rOutRangeString.isEmpty();
357 :
358 : uno::Reference< chart2::data::XLabeledDataSequence > xCategories(
359 105 : DiagramHelper::getCategoriesFromDiagram( xChartDocument->getFirstDiagram() ));
360 105 : rOutHasCategories = xCategories.is();
361 : }
362 0 : catch( uno::Exception & ex )
363 : {
364 : ASSERT_EXCEPTION( ex );
365 : }
366 210 : return bSomethingDetected;
367 : }
368 :
369 0 : bool DataSourceHelper::allArgumentsForRectRangeDetected(
370 : const uno::Reference< chart2::XChartDocument >& xChartDocument )
371 : {
372 0 : bool bHasDataRowSource = false;
373 0 : bool bHasFirstCellAsLabel = false;
374 0 : bool bHasCellRangeRepresentation = false;
375 :
376 0 : uno::Reference< data::XDataProvider > xDataProvider( xChartDocument->getDataProvider() );
377 0 : if( !xDataProvider.is() )
378 0 : return false;
379 :
380 : try
381 : {
382 : const uno::Sequence< beans::PropertyValue > aArguments(
383 0 : xDataProvider->detectArguments( pressUsedDataIntoRectangularFormat( xChartDocument )));
384 0 : const beans::PropertyValue* pArguments = aArguments.getConstArray();
385 0 : for(sal_Int32 i=0; i<aArguments.getLength(); ++i, ++pArguments)
386 : {
387 0 : const beans::PropertyValue& aProperty = *pArguments;
388 0 : if ( aProperty.Name == "DataRowSource" )
389 : {
390 : bHasDataRowSource =
391 0 : (aProperty.Value.hasValue() && aProperty.Value.isExtractableTo(
392 : ::getCppuType( reinterpret_cast<
393 0 : const ::com::sun::star::chart::ChartDataRowSource * >(0))));
394 : }
395 0 : else if ( aProperty.Name == "FirstCellAsLabel" )
396 : {
397 : bHasFirstCellAsLabel =
398 0 : (aProperty.Value.hasValue() && aProperty.Value.isExtractableTo(::getBooleanCppuType()));
399 : }
400 0 : else if ( aProperty.Name == "CellRangeRepresentation" )
401 : {
402 0 : OUString aRange;
403 : bHasCellRangeRepresentation =
404 0 : (aProperty.Value.hasValue() && (aProperty.Value >>= aRange) && !aRange.isEmpty());
405 : }
406 0 : }
407 : }
408 0 : catch( const uno::Exception & ex )
409 : {
410 : ASSERT_EXCEPTION( ex );
411 : }
412 :
413 0 : return (bHasCellRangeRepresentation && bHasDataRowSource && bHasFirstCellAsLabel);
414 : }
415 :
416 4 : void DataSourceHelper::setRangeSegmentation(
417 : const uno::Reference< frame::XModel >& xChartModel
418 : , const ::com::sun::star::uno::Sequence< sal_Int32 >& rSequenceMapping
419 : , bool bUseColumns , bool bFirstCellAsLabel, bool bUseCategories )
420 : {
421 4 : uno::Reference< XChartDocument > xChartDocument( xChartModel, uno::UNO_QUERY );
422 4 : if( !xChartDocument.is() )
423 0 : return;
424 8 : uno::Reference< data::XDataProvider > xDataProvider( xChartDocument->getDataProvider() );
425 4 : if( !xDataProvider.is() )
426 0 : return;
427 8 : uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
428 4 : if( !xDiagram.is() )
429 0 : return;
430 8 : uno::Reference< chart2::XChartTypeManager > xChartTypeManager( xChartDocument->getChartTypeManager() );
431 4 : if( !xChartTypeManager.is() )
432 0 : return;
433 8 : uno::Reference< lang::XMultiServiceFactory > xTemplateFactory( xChartTypeManager, uno::UNO_QUERY );
434 4 : if( !xTemplateFactory.is() )
435 0 : return;
436 :
437 8 : OUString aRangeString;
438 : bool bDummy;
439 8 : uno::Sequence< sal_Int32 > aDummy;
440 4 : readArguments( xDataProvider->detectArguments( pressUsedDataIntoRectangularFormat( xChartDocument )),
441 4 : aRangeString, aDummy, bDummy, bDummy, bDummy );
442 :
443 : uno::Sequence< beans::PropertyValue > aArguments(
444 8 : createArguments( aRangeString, rSequenceMapping, bUseColumns, bFirstCellAsLabel, bUseCategories ) );
445 :
446 4 : uno::Reference< chart2::data::XDataSource > xDataSource( xDataProvider->createDataSource(
447 8 : aArguments ) );
448 4 : if( !xDataSource.is() )
449 0 : return;
450 :
451 8 : ControllerLockGuard aCtrlLockGuard( xChartModel );
452 8 : xDiagram->setDiagramData( xDataSource, aArguments );
453 : }
454 :
455 0 : Sequence< OUString > DataSourceHelper::getRangesFromLabeledDataSequence(
456 : const Reference< data::XLabeledDataSequence > & xLSeq )
457 : {
458 0 : Sequence< OUString > aResult;
459 0 : if( xLSeq.is())
460 : {
461 0 : Reference< data::XDataSequence > xLabel( xLSeq->getLabel());
462 0 : Reference< data::XDataSequence > xValues( xLSeq->getValues());
463 :
464 0 : if( xLabel.is())
465 : {
466 0 : if( xValues.is())
467 : {
468 0 : aResult.realloc( 2 );
469 0 : aResult[0] = xLabel->getSourceRangeRepresentation();
470 0 : aResult[1] = xValues->getSourceRangeRepresentation();
471 : }
472 : else
473 : {
474 0 : aResult.realloc( 1 );
475 0 : aResult[0] = xLabel->getSourceRangeRepresentation();
476 : }
477 : }
478 0 : else if( xValues.is())
479 : {
480 0 : aResult.realloc( 1 );
481 0 : aResult[0] = xValues->getSourceRangeRepresentation();
482 0 : }
483 : }
484 0 : return aResult;
485 : }
486 :
487 1460 : OUString DataSourceHelper::getRangeFromValues(
488 : const Reference< data::XLabeledDataSequence > & xLSeq )
489 : {
490 1460 : OUString aResult;
491 1460 : if( xLSeq.is() )
492 : {
493 1460 : Reference< data::XDataSequence > xValues( xLSeq->getValues() );
494 1460 : if( xValues.is() )
495 1458 : aResult = xValues->getSourceRangeRepresentation();
496 : }
497 1460 : return aResult;
498 : }
499 :
500 0 : Sequence< OUString > DataSourceHelper::getRangesFromDataSource( const Reference< data::XDataSource > & xSource )
501 : {
502 0 : ::std::vector< OUString > aResult;
503 0 : if( xSource.is())
504 : {
505 0 : Sequence< Reference< data::XLabeledDataSequence > > aLSeqSeq( xSource->getDataSequences());
506 0 : for( sal_Int32 i=0; i<aLSeqSeq.getLength(); ++i )
507 : {
508 0 : Reference< data::XDataSequence > xLabel( aLSeqSeq[i]->getLabel());
509 0 : Reference< data::XDataSequence > xValues( aLSeqSeq[i]->getValues());
510 :
511 0 : if( xLabel.is())
512 0 : aResult.push_back( xLabel->getSourceRangeRepresentation());
513 0 : if( xValues.is())
514 0 : aResult.push_back( xValues->getSourceRangeRepresentation());
515 0 : }
516 : }
517 0 : return ContainerHelper::ContainerToSequence( aResult );
518 : }
519 :
520 : //.............................................................................
521 : } //namespace chart
522 : //.............................................................................
523 :
524 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|