LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/chart2/source/tools - InternalDataProvider.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 334 713 46.8 %
Date: 2013-07-09 Functions: 45 89 50.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10