LCOV - code coverage report
Current view: top level - chart2/source/tools - DataSourceHelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 263 0.0 %
Date: 2014-04-14 Functions: 0 24 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10