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

Generated by: LCOV version 1.10