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

Generated by: LCOV version 1.10