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

Generated by: LCOV version 1.10