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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "DataBrowserModel.hxx"
      21             : #include "DialogModel.hxx"
      22             : #include "ChartModelHelper.hxx"
      23             : #include "DiagramHelper.hxx"
      24             : #include "DataSeriesHelper.hxx"
      25             : #include "PropertyHelper.hxx"
      26             : #include "ControllerLockGuard.hxx"
      27             : #include "macros.hxx"
      28             : #include "StatisticsHelper.hxx"
      29             : #include "ContainerHelper.hxx"
      30             : #include "ChartTypeHelper.hxx"
      31             : #include "chartview/ExplicitValueProvider.hxx"
      32             : #include "ExplicitCategoriesProvider.hxx"
      33             : 
      34             : #include "ChartModel.hxx"
      35             : 
      36             : #include <com/sun/star/container/XIndexReplace.hpp>
      37             : #include <com/sun/star/chart2/XAxis.hpp>
      38             : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
      39             : #include <com/sun/star/chart2/XInternalDataProvider.hpp>
      40             : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
      41             : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
      42             : #include <com/sun/star/chart2/data/XDataSource.hpp>
      43             : #include <com/sun/star/chart2/data/XDataSink.hpp>
      44             : #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
      45             : #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
      46             : #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
      47             : #include <com/sun/star/util/XModifiable.hpp>
      48             : 
      49             : #include <rtl/math.hxx>
      50             : 
      51             : #include <algorithm>
      52             : 
      53             : #if OSL_DEBUG_LEVEL > 1
      54             : #include <cstdio>
      55             : #endif
      56             : 
      57             : using namespace ::com::sun::star;
      58             : 
      59             : using ::com::sun::star::uno::Reference;
      60             : using ::com::sun::star::uno::Sequence;
      61             : 
      62             : namespace
      63             : {
      64           0 : OUString lcl_getRole(
      65             :     const Reference< chart2::data::XDataSequence > & xSeq )
      66             : {
      67           0 :     OUString aResult;
      68           0 :     Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY );
      69           0 :     if( xProp.is())
      70             :     {
      71             :         try
      72             :         {
      73           0 :             xProp->getPropertyValue( "Role" ) >>= aResult;
      74             :         }
      75           0 :         catch( const uno::Exception & ex )
      76             :         {
      77             :             ASSERT_EXCEPTION( ex );
      78             :         }
      79             :     }
      80           0 :     return aResult;
      81             : }
      82             : 
      83           0 : OUString lcl_getRole(
      84             :     const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
      85             : {
      86           0 :     OUString aResult;
      87           0 :     if( xLSeq.is())
      88           0 :         aResult = lcl_getRole( xLSeq->getValues());
      89           0 :     return aResult;
      90             : }
      91             : 
      92           0 : OUString lcl_getUIRoleName(
      93             :     const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
      94             : {
      95           0 :     OUString aResult( lcl_getRole( xLSeq ));
      96           0 :     if( !aResult.isEmpty())
      97           0 :         aResult = ::chart::DialogModel::ConvertRoleFromInternalToUI( aResult );
      98           0 :     return aResult;
      99             : }
     100             : 
     101           0 : void lcl_copyDataSequenceProperties(
     102             :     const Reference< chart2::data::XDataSequence > & xOldSequence,
     103             :     const Reference< chart2::data::XDataSequence > & xNewSequence )
     104             : {
     105           0 :     Reference< beans::XPropertySet > xOldSeqProp( xOldSequence, uno::UNO_QUERY );
     106           0 :     Reference< beans::XPropertySet > xNewSeqProp( xNewSequence, uno::UNO_QUERY );
     107           0 :     comphelper::copyProperties( xOldSeqProp, xNewSeqProp );
     108           0 : }
     109             : 
     110           0 : bool lcl_SequenceOfSeriesIsShared(
     111             :     const Reference< chart2::XDataSeries > & xSeries,
     112             :     const Reference< chart2::data::XDataSequence > & xValues )
     113             : {
     114           0 :     bool bResult = false;
     115           0 :     if( !xValues.is())
     116           0 :         return bResult;
     117             :     try
     118             :     {
     119           0 :         OUString aValuesRole( lcl_getRole( xValues ));
     120           0 :         OUString aValuesRep( xValues->getSourceRangeRepresentation());
     121           0 :         Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY_THROW );
     122           0 :         Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeq( xSource->getDataSequences());
     123           0 :         for( sal_Int32 i=0; i<aLSeq.getLength(); ++i )
     124           0 :             if( aLSeq[i].is() &&
     125           0 :                 lcl_getRole( aLSeq[i] ).equals( aValuesRole ))
     126             :             {
     127             :                 // getValues().is(), because lcl_getRole checked that already
     128           0 :                 bResult = (aValuesRep == aLSeq[i]->getValues()->getSourceRangeRepresentation());
     129             :                 // assumption: a role appears only once in a series
     130           0 :                 break;
     131           0 :             }
     132             :     }
     133           0 :     catch( const uno::Exception & ex )
     134             :     {
     135             :         ASSERT_EXCEPTION( ex );
     136             :     }
     137           0 :     return bResult;
     138             : }
     139             : 
     140             : typedef ::std::vector< Reference< chart2::data::XLabeledDataSequence > > lcl_tSharedSeqVec;
     141             : 
     142           0 : lcl_tSharedSeqVec lcl_getSharedSequences( const Sequence< Reference< chart2::XDataSeries > > & rSeries )
     143             : {
     144             :     // @todo: if only some series share a sequence, those have to be duplicated
     145             :     // and made unshared for all series
     146           0 :     lcl_tSharedSeqVec aResult;
     147             :     // if we have only one series, we don't want any shared sequences
     148           0 :     if( rSeries.getLength() <= 1 )
     149           0 :         return aResult;
     150             : 
     151           0 :     Reference< chart2::data::XDataSource > xSource( rSeries[0], uno::UNO_QUERY );
     152           0 :     Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeq( xSource->getDataSequences());
     153           0 :     for( sal_Int32 nIdx=0; nIdx<aLSeq.getLength(); ++nIdx )
     154             :     {
     155           0 :         Reference< chart2::data::XDataSequence > xValues( aLSeq[nIdx]->getValues());
     156           0 :         bool bShared = true;
     157           0 :         for( sal_Int32 nSeriesIdx=1; nSeriesIdx<rSeries.getLength(); ++nSeriesIdx )
     158             :         {
     159           0 :             bShared = lcl_SequenceOfSeriesIsShared( rSeries[nSeriesIdx], xValues );
     160           0 :             if( !bShared )
     161           0 :                 break;
     162             :         }
     163           0 :         if( bShared )
     164           0 :             aResult.push_back( aLSeq[nIdx] );
     165           0 :     }
     166             : 
     167           0 :     return aResult;
     168             : }
     169             : 
     170           0 : sal_Int32 lcl_getValuesRepresentationIndex(
     171             :     const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
     172             : {
     173           0 :     sal_Int32 nResult = -1;
     174           0 :     if( xLSeq.is())
     175             :     {
     176           0 :         Reference< chart2::data::XDataSequence > xSeq( xLSeq->getValues());
     177           0 :         if( xSeq.is())
     178             :         {
     179           0 :             OUString aRep( xSeq->getSourceRangeRepresentation());
     180           0 :             nResult = aRep.toInt32();
     181           0 :         }
     182             :     }
     183           0 :     return nResult;
     184             : }
     185             : 
     186           0 : struct lcl_RepresentationsOfLSeqMatch : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool >
     187             : {
     188           0 :     lcl_RepresentationsOfLSeqMatch( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) :
     189           0 :             m_aValuesRep( xLSeq.is() ?
     190           0 :                           (xLSeq->getValues().is() ? xLSeq->getValues()->getSourceRangeRepresentation() : OUString())
     191           0 :                           : OUString() )
     192           0 :     {}
     193           0 :     bool operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
     194             :     {
     195           0 :         return (xLSeq.is() &&
     196           0 :                 xLSeq->getValues().is() &&
     197           0 :                 (xLSeq->getValues()->getSourceRangeRepresentation() == m_aValuesRep ));
     198             :     }
     199             : private:
     200             :     OUString m_aValuesRep;
     201             : };
     202             : 
     203           0 : struct lcl_RolesOfLSeqMatch : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool >
     204             : {
     205           0 :     lcl_RolesOfLSeqMatch( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) :
     206           0 :             m_aRole( lcl_getRole( xLSeq ))
     207           0 :     {}
     208           0 :     bool operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
     209             :     {
     210           0 :         return lcl_getRole( xLSeq ).equals( m_aRole );
     211             :     }
     212             : private:
     213             :     OUString m_aRole;
     214             : };
     215             : 
     216           0 : bool lcl_ShowCategories( const Reference< chart2::XDiagram > & /* xDiagram */ )
     217             : {
     218             :     // show categories for all charts
     219           0 :     return true;
     220             : }
     221             : 
     222           0 : bool lcl_ShowCategoriesAsDataLabel( const Reference< chart2::XDiagram > & xDiagram )
     223             : {
     224           0 :     return ! ::chart::DiagramHelper::isCategoryDiagram( xDiagram );
     225             : }
     226             : 
     227             : } // anonymous namespace
     228             : 
     229             : namespace chart
     230             : {
     231             : 
     232           0 : struct DataBrowserModel::tDataColumn
     233             : {
     234             :     ::com::sun::star::uno::Reference<
     235             :             ::com::sun::star::chart2::XDataSeries >                m_xDataSeries;
     236             :     sal_Int32                                                      m_nIndexInDataSeries;
     237             :     OUString                                                       m_aUIRoleName;
     238             :     ::com::sun::star::uno::Reference<
     239             :             ::com::sun::star::chart2::data::XLabeledDataSequence > m_xLabeledDataSequence;
     240             :     eCellType                                                  m_eCellType;
     241             :     sal_Int32                                                  m_nNumberFormatKey;
     242             : 
     243             :     // default CTOR
     244           0 :     tDataColumn() : m_nIndexInDataSeries( -1 ), m_eCellType( TEXT ), m_nNumberFormatKey( 0 ) {}
     245             :     // "full" CTOR
     246           0 :     tDataColumn(
     247             :         const ::com::sun::star::uno::Reference<
     248             :         ::com::sun::star::chart2::XDataSeries > & xDataSeries,
     249             :         sal_Int32 nIndexInDataSeries,
     250             :         const OUString& aUIRoleName,
     251             :         ::com::sun::star::uno::Reference<
     252             :         ::com::sun::star::chart2::data::XLabeledDataSequence >  xLabeledDataSequence,
     253             :         eCellType aCellType,
     254             :         sal_Int32 nNumberFormatKey ) :
     255             :             m_xDataSeries( xDataSeries ),
     256             :             m_nIndexInDataSeries( nIndexInDataSeries ),
     257             :             m_aUIRoleName( aUIRoleName ),
     258             :             m_xLabeledDataSequence( xLabeledDataSequence ),
     259             :             m_eCellType( aCellType ),
     260           0 :             m_nNumberFormatKey( nNumberFormatKey )
     261           0 :     {}
     262             : };
     263             : 
     264             : struct DataBrowserModel::implColumnLess : public ::std::binary_function<
     265             :         DataBrowserModel::tDataColumn, DataBrowserModel::tDataColumn, bool >
     266             : {
     267           0 :     bool operator() ( const first_argument_type & rLeft, const second_argument_type & rRight )
     268             :     {
     269           0 :         if( rLeft.m_xLabeledDataSequence.is() && rRight.m_xLabeledDataSequence.is())
     270             :         {
     271           0 :             return DialogModel::GetRoleIndexForSorting( lcl_getRole( rLeft.m_xLabeledDataSequence )) <
     272           0 :                 DialogModel::GetRoleIndexForSorting( lcl_getRole( rRight.m_xLabeledDataSequence ));
     273             :         }
     274           0 :         return true;
     275             :     }
     276             : };
     277             : 
     278           0 : DataBrowserModel::DataBrowserModel(
     279             :     const Reference< chart2::XChartDocument > & xChartDoc,
     280             :     const Reference< uno::XComponentContext > & xContext ) :
     281             :         m_xChartDocument( xChartDoc ),
     282             :         m_xContext( xContext ),
     283           0 :         m_apDialogModel( new DialogModel( xChartDoc, xContext ))
     284             : {
     285           0 :     updateFromModel();
     286           0 : }
     287             : 
     288           0 : DataBrowserModel::~DataBrowserModel()
     289           0 : {}
     290             : 
     291             : namespace
     292             : {
     293           0 : struct lcl_DataSeriesOfHeaderMatches : public ::std::unary_function< ::chart::DataBrowserModel::tDataHeader, bool >
     294             : {
     295           0 :     lcl_DataSeriesOfHeaderMatches(
     296             :         const Reference< chart2::XDataSeries > & xSeriesToCompareWith ) :
     297           0 :             m_xSeries( xSeriesToCompareWith )
     298           0 :     {}
     299           0 :     bool operator() ( const ::chart::DataBrowserModel::tDataHeader & rHeader )
     300             :     {
     301           0 :         return (m_xSeries == rHeader.m_xDataSeries);
     302             :     }
     303             : private:
     304             :     Reference< chart2::XDataSeries  > m_xSeries;
     305             : };
     306             : }
     307             : 
     308           0 : void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex )
     309             : {
     310             :     OSL_ASSERT( m_apDialogModel.get());
     311             :     Reference< chart2::XInternalDataProvider > xDataProvider(
     312           0 :         m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
     313           0 :     if( xDataProvider.is())
     314             :     {
     315           0 :         if( isCategoriesColumn(nAfterColumnIndex) )
     316           0 :             nAfterColumnIndex = getCategoryColumnCount()-1;
     317             : 
     318           0 :         sal_Int32 nStartCol = 0;
     319           0 :         Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument ));
     320           0 :         Reference< chart2::XChartType > xChartType;
     321           0 :         Reference< chart2::XDataSeries > xSeries;
     322           0 :         if( static_cast< tDataColumnVector::size_type >( nAfterColumnIndex ) <= m_aColumns.size())
     323           0 :             xSeries.set( m_aColumns[nAfterColumnIndex].m_xDataSeries );
     324             : 
     325           0 :         sal_Int32 nSeriesNumberFormat = 0;
     326           0 :         if( xSeries.is())
     327             :         {
     328           0 :             xChartType.set( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ));
     329             :             tDataHeaderVector::const_iterator aIt(
     330             :                 ::std::find_if( m_aHeaders.begin(), m_aHeaders.end(),
     331           0 :                                 lcl_DataSeriesOfHeaderMatches( xSeries )));
     332           0 :             if( aIt != m_aHeaders.end())
     333           0 :                 nStartCol = aIt->m_nEndColumn;
     334             : 
     335           0 :             Reference< beans::XPropertySet > xSeriesProps( xSeries, uno::UNO_QUERY );
     336           0 :             if( xSeriesProps.is() )
     337           0 :                 xSeriesProps->getPropertyValue( "NumberFormat" ) >>= nSeriesNumberFormat;
     338             :         }
     339             :         else
     340             :         {
     341           0 :             xChartType.set( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ));
     342           0 :             nStartCol = nAfterColumnIndex;
     343             :         }
     344             : 
     345           0 :         if( xChartType.is())
     346             :         {
     347           0 :             sal_Int32 nOffset = 0;
     348           0 :             if( xDiagram.is() && lcl_ShowCategories( xDiagram ))
     349           0 :                 nOffset=getCategoryColumnCount();
     350             :             // get shared sequences of current series
     351           0 :             Reference< chart2::XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY );
     352           0 :             lcl_tSharedSeqVec aSharedSequences;
     353           0 :             if( xSeriesCnt.is())
     354           0 :                 aSharedSequences = lcl_getSharedSequences( xSeriesCnt->getDataSeries());
     355             :             Reference< chart2::XDataSeries > xNewSeries(
     356           0 :                 m_apDialogModel->insertSeriesAfter( xSeries, xChartType, true /* bCreateDataCachedSequences */ ));
     357           0 :             if( xNewSeries.is())
     358             :             {
     359             :                 {
     360           0 :                     Reference< chart2::data::XDataSource > xSource( xNewSeries, uno::UNO_QUERY );
     361           0 :                     if( xSource.is())
     362             :                     {
     363             :                         Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSequences(
     364           0 :                             xSource->getDataSequences());
     365           0 :                         sal_Int32 nSeqIdx = 0;
     366           0 :                         sal_Int32 nSeqSize = aLSequences.getLength();
     367           0 :                         nStartCol -= (nOffset - 1);
     368           0 :                         for( sal_Int32 nIndex = nStartCol;
     369             :                              (nSeqIdx < nSeqSize);
     370             :                              ++nSeqIdx )
     371             :                         {
     372             :                             lcl_tSharedSeqVec::const_iterator aSharedIt(
     373             :                                 ::std::find_if( aSharedSequences.begin(), aSharedSequences.end(),
     374           0 :                                                 lcl_RolesOfLSeqMatch( aLSequences[nSeqIdx] )));
     375           0 :                             if( aSharedIt != aSharedSequences.end())
     376             :                             {
     377           0 :                                 aLSequences[nSeqIdx]->setValues( (*aSharedIt)->getValues());
     378           0 :                                 aLSequences[nSeqIdx]->setLabel( (*aSharedIt)->getLabel());
     379             :                             }
     380             :                             else
     381             :                             {
     382           0 :                                 xDataProvider->insertSequence( nIndex - 1 );
     383             : 
     384             :                                 // values
     385             :                                 Reference< chart2::data::XDataSequence > xNewSeq(
     386           0 :                                     xDataProvider->createDataSequenceByRangeRepresentation(
     387           0 :                                         OUString::number( nIndex )));
     388             :                                 lcl_copyDataSequenceProperties(
     389           0 :                                     aLSequences[nSeqIdx]->getValues(), xNewSeq );
     390           0 :                                 aLSequences[nSeqIdx]->setValues( xNewSeq );
     391             : 
     392             :                                 // labels
     393             :                                 Reference< chart2::data::XDataSequence > xNewLabelSeq(
     394           0 :                                     xDataProvider->createDataSequenceByRangeRepresentation(
     395           0 :                                         "label " +
     396           0 :                                         OUString::number( nIndex )));
     397             :                                 lcl_copyDataSequenceProperties(
     398           0 :                                     aLSequences[nSeqIdx]->getLabel(), xNewLabelSeq );
     399           0 :                                 aLSequences[nSeqIdx]->setLabel( xNewLabelSeq );
     400           0 :                                 ++nIndex;
     401             :                             }
     402           0 :                         }
     403           0 :                     }
     404             :                 }
     405           0 :                 if( nSeriesNumberFormat != 0 )
     406             :                 {
     407             :                     //give the new series the same number format as the former series especially for bubble charts thus the bubble size values can be edited with same format immidiately
     408           0 :                     Reference< beans::XPropertySet > xNewSeriesProps( xNewSeries, uno::UNO_QUERY );
     409           0 :                     if( xNewSeriesProps.is() )
     410           0 :                         xNewSeriesProps->setPropertyValue( "NumberFormat" , uno::makeAny( nSeriesNumberFormat ) );
     411             :                 }
     412             : 
     413           0 :                 updateFromModel();
     414           0 :             }
     415           0 :         }
     416           0 :     }
     417           0 : }
     418             : 
     419           0 : void DataBrowserModel::insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex )
     420             : {
     421             :     //create a new text column for complex categories
     422             : 
     423             :     OSL_ASSERT( m_apDialogModel.get());
     424           0 :     Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
     425           0 :     if( xDataProvider.is() )
     426             :     {
     427           0 :         if( !isCategoriesColumn(nAfterColumnIndex) )
     428           0 :             nAfterColumnIndex = getCategoryColumnCount()-1;
     429             : 
     430           0 :         if(nAfterColumnIndex<0)
     431             :         {
     432             :             OSL_FAIL( "wrong index for category level insertion" );
     433           0 :             return;
     434             :         }
     435             : 
     436           0 :         m_apDialogModel->startControllerLockTimer();
     437           0 :         ControllerLockGuardUNO aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) );
     438           0 :         xDataProvider->insertComplexCategoryLevel( nAfterColumnIndex+1 );
     439           0 :         updateFromModel();
     440           0 :     }
     441             : }
     442             : 
     443           0 : void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex )
     444             : {
     445             :     OSL_ASSERT( m_apDialogModel.get());
     446           0 :     if( static_cast< tDataColumnVector::size_type >( nAtColumnIndex ) < m_aColumns.size())
     447             :     {
     448           0 :         Reference< chart2::XDataSeries > xSeries( m_aColumns[nAtColumnIndex].m_xDataSeries );
     449           0 :         if( xSeries.is())
     450             :         {
     451             :             m_apDialogModel->deleteSeries(
     452           0 :                 xSeries, getHeaderForSeries( xSeries ).m_xChartType );
     453             : 
     454             :             //delete sequences from internal data provider that are not used anymore
     455             :             //but do not delete sequences that are still in use by the remaining series
     456           0 :             Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
     457           0 :             Reference< chart2::data::XDataSource > xSourceOfDeletedSeries( xSeries, uno::UNO_QUERY );
     458           0 :             if( xDataProvider.is() && xSourceOfDeletedSeries.is())
     459             :             {
     460           0 :                 ::std::vector< sal_Int32 > aSequenceIndexesToDelete;
     461           0 :                 Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequencesOfDeletedSeries( xSourceOfDeletedSeries->getDataSequences() );
     462           0 :                 Reference< chart2::XDataSeriesContainer > xSeriesCnt( getHeaderForSeries( xSeries ).m_xChartType, uno::UNO_QUERY );
     463           0 :                 if( xSeriesCnt.is())
     464             :                 {
     465           0 :                     Reference< chart2::data::XDataSource > xRemainingDataSource( DataSeriesHelper::getDataSource( xSeriesCnt->getDataSeries() ) );
     466           0 :                     if( xRemainingDataSource.is() )
     467             :                     {
     468           0 :                         ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aRemainingSeq( ContainerHelper::SequenceToVector( xRemainingDataSource->getDataSequences() ) );
     469           0 :                         for( sal_Int32 i=0; i<aSequencesOfDeletedSeries.getLength(); ++i )
     470             :                         {
     471             :                             ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::const_iterator aHitIt(
     472             :                                 ::std::find_if( aRemainingSeq.begin(), aRemainingSeq.end(),
     473           0 :                                     lcl_RepresentationsOfLSeqMatch( aSequencesOfDeletedSeries[i] )));
     474             :                             // if not used by the remaining series this sequence can be deleted
     475           0 :                             if( aHitIt == aRemainingSeq.end() )
     476           0 :                                 aSequenceIndexesToDelete.push_back( lcl_getValuesRepresentationIndex( aSequencesOfDeletedSeries[i] ) );
     477           0 :                         }
     478           0 :                     }
     479             :                 }
     480             : 
     481             :                 // delete unnecessary sequences of the internal data
     482             :                 // iterate using greatest index first, so that deletion does not
     483             :                 // shift other sequences that will be deleted later
     484           0 :                 ::std::sort( aSequenceIndexesToDelete.begin(), aSequenceIndexesToDelete.end());
     485           0 :                 for( ::std::vector< sal_Int32 >::reverse_iterator aIt(
     486           0 :                          aSequenceIndexesToDelete.rbegin()); aIt != aSequenceIndexesToDelete.rend(); ++aIt )
     487             :                 {
     488           0 :                     if( *aIt != -1 )
     489           0 :                         xDataProvider->deleteSequence( *aIt );
     490           0 :                 }
     491             :             }
     492           0 :             updateFromModel();
     493             :         }
     494             :         else
     495             :         {
     496             :             //delete a category column if there is more than one level (in case of a single column we do not get here)
     497             :             OSL_ENSURE(nAtColumnIndex>0, "wrong index for categories deletion" );
     498             : 
     499           0 :             Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
     500           0 :             if( xDataProvider.is() )
     501             :             {
     502           0 :                 m_apDialogModel->startControllerLockTimer();
     503           0 :                 ControllerLockGuardUNO aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) );
     504           0 :                 xDataProvider->deleteComplexCategoryLevel( nAtColumnIndex );
     505           0 :                 updateFromModel();
     506           0 :             }
     507           0 :         }
     508             :     }
     509           0 : }
     510             : 
     511           0 : void DataBrowserModel::swapDataSeries( sal_Int32 nFirstColumnIndex )
     512             : {
     513             :     OSL_ASSERT( m_apDialogModel.get());
     514           0 :     if( static_cast< tDataColumnVector::size_type >( nFirstColumnIndex ) < m_aColumns.size() - 1 )
     515             :     {
     516           0 :         Reference< chart2::XDataSeries > xSeries( m_aColumns[nFirstColumnIndex].m_xDataSeries );
     517           0 :         if( xSeries.is())
     518             :         {
     519           0 :             m_apDialogModel->moveSeries( xSeries, DialogModel::MOVE_DOWN );
     520           0 :             updateFromModel();
     521           0 :         }
     522             :     }
     523           0 : }
     524             : 
     525           0 : void DataBrowserModel::swapDataPointForAllSeries( sal_Int32 nFirstIndex )
     526             : {
     527             :     OSL_ASSERT( m_apDialogModel.get());
     528             :     Reference< chart2::XInternalDataProvider > xDataProvider(
     529           0 :         m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
     530             :     // lockControllers
     531           0 :     ControllerLockGuardUNO aGuard( m_apDialogModel->getChartModel());
     532           0 :     if( xDataProvider.is())
     533           0 :         xDataProvider->swapDataPointWithNextOneForAllSequences( nFirstIndex );
     534             :     // unlockControllers
     535           0 : }
     536             : 
     537           0 : void DataBrowserModel::insertDataPointForAllSeries( sal_Int32 nAfterIndex )
     538             : {
     539             :     Reference< chart2::XInternalDataProvider > xDataProvider(
     540           0 :         m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
     541             :     // lockControllers
     542           0 :     ControllerLockGuardUNO aGuard( m_apDialogModel->getChartModel());
     543           0 :     if( xDataProvider.is())
     544           0 :         xDataProvider->insertDataPointForAllSequences( nAfterIndex );
     545             :     // unlockControllers
     546           0 : }
     547             : 
     548           0 : void DataBrowserModel::removeDataPointForAllSeries( sal_Int32 nAtIndex )
     549             : {
     550             :     Reference< chart2::XInternalDataProvider > xDataProvider(
     551           0 :         m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
     552             :     // lockControllers
     553           0 :     ControllerLockGuardUNO aGuard( m_apDialogModel->getChartModel());
     554           0 :     if( xDataProvider.is())
     555           0 :         xDataProvider->deleteDataPointForAllSequences( nAtIndex );
     556             :     // unlockControllers
     557           0 : }
     558             : 
     559           0 : DataBrowserModel::tDataHeader DataBrowserModel::getHeaderForSeries(
     560             :     const Reference< chart2::XDataSeries > & xSeries ) const
     561             : {
     562           0 :     for( tDataHeaderVector::const_iterator aIt( m_aHeaders.begin());
     563           0 :          aIt != m_aHeaders.end(); ++aIt )
     564             :     {
     565           0 :         if( aIt->m_xDataSeries == xSeries )
     566           0 :             return (*aIt);
     567             :     }
     568           0 :     return tDataHeader();
     569             : }
     570             : 
     571             : Reference< chart2::XDataSeries >
     572           0 :     DataBrowserModel::getDataSeriesByColumn( sal_Int32 nColumn ) const
     573             : {
     574           0 :     tDataColumnVector::size_type nIndex( nColumn );
     575           0 :     if( nIndex < m_aColumns.size())
     576           0 :         return m_aColumns[nIndex].m_xDataSeries;
     577           0 :     return 0;
     578             : }
     579             : 
     580           0 : DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ ) const
     581             : {
     582           0 :     eCellType eResult = TEXT;
     583           0 :     tDataColumnVector::size_type nIndex( nAtColumn );
     584           0 :     if( nIndex < m_aColumns.size())
     585           0 :         eResult = m_aColumns[nIndex].m_eCellType;
     586           0 :     return eResult;
     587             : }
     588             : 
     589           0 : double DataBrowserModel::getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow )
     590             : {
     591             :     double fResult;
     592           0 :     ::rtl::math::setNan( & fResult );
     593             : 
     594           0 :     tDataColumnVector::size_type nIndex( nAtColumn );
     595           0 :     if( nIndex < m_aColumns.size() &&
     596           0 :         m_aColumns[ nIndex ].m_xLabeledDataSequence.is())
     597             :     {
     598             :         Reference< chart2::data::XNumericalDataSequence > xData(
     599           0 :             m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues(), uno::UNO_QUERY );
     600           0 :         if( xData.is())
     601             :         {
     602           0 :             Sequence< double > aValues( xData->getNumericalData());
     603           0 :             if( nAtRow < aValues.getLength())
     604           0 :                 fResult = aValues[nAtRow];
     605           0 :         }
     606             :     }
     607           0 :     return fResult;
     608             : }
     609             : 
     610           0 : uno::Any DataBrowserModel::getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow )
     611             : {
     612           0 :     uno::Any aResult;
     613             : 
     614           0 :     tDataColumnVector::size_type nIndex( nAtColumn );
     615           0 :     if( nIndex < m_aColumns.size() &&
     616           0 :         m_aColumns[ nIndex ].m_xLabeledDataSequence.is())
     617             :     {
     618             :         Reference< chart2::data::XDataSequence > xData(
     619           0 :             m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues() );
     620           0 :         if( xData.is() )
     621             :         {
     622           0 :             Sequence< uno::Any > aValues( xData->getData());
     623           0 :             if( nAtRow < aValues.getLength())
     624           0 :                 aResult = aValues[nAtRow];
     625           0 :         }
     626             :     }
     627           0 :     return aResult;
     628             : }
     629             : 
     630           0 : OUString DataBrowserModel::getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow )
     631             : {
     632           0 :     OUString aResult;
     633             : 
     634           0 :     tDataColumnVector::size_type nIndex( nAtColumn );
     635           0 :     if( nIndex < m_aColumns.size() &&
     636           0 :         m_aColumns[ nIndex ].m_xLabeledDataSequence.is())
     637             :     {
     638             :         Reference< chart2::data::XTextualDataSequence > xData(
     639           0 :             m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues(), uno::UNO_QUERY );
     640           0 :         if( xData.is())
     641             :         {
     642           0 :             Sequence< OUString > aValues( xData->getTextualData());
     643           0 :             if( nAtRow < aValues.getLength())
     644           0 :                 aResult = aValues[nAtRow];
     645           0 :         }
     646             :     }
     647           0 :     return aResult;
     648             : }
     649             : 
     650           0 : sal_uInt32 DataBrowserModel::getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ )
     651             : {
     652           0 :     tDataColumnVector::size_type nIndex( nAtColumn );
     653           0 :     if( nIndex < m_aColumns.size())
     654           0 :         return m_aColumns[ nIndex ].m_nNumberFormatKey;
     655           0 :     return 0;
     656             : }
     657             : 
     658           0 : bool DataBrowserModel::setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const uno::Any & rValue )
     659             : {
     660           0 :     bool bResult = false;
     661           0 :     tDataColumnVector::size_type nIndex( nAtColumn );
     662           0 :     if( nIndex < m_aColumns.size() &&
     663           0 :         m_aColumns[ nIndex ].m_xLabeledDataSequence.is())
     664             :     {
     665           0 :         bResult = true;
     666             :         try
     667             :         {
     668           0 :             ControllerLockGuardUNO aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) );
     669             : 
     670             :             // label
     671           0 :             if( nAtRow == -1 )
     672             :             {
     673             :                 Reference< container::XIndexReplace > xIndexReplace(
     674           0 :                     m_aColumns[ nIndex ].m_xLabeledDataSequence->getLabel(), uno::UNO_QUERY_THROW );
     675           0 :                 xIndexReplace->replaceByIndex( 0, rValue );
     676             :             }
     677             :             else
     678             :             {
     679             :                 Reference< container::XIndexReplace > xIndexReplace(
     680           0 :                     m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues(), uno::UNO_QUERY_THROW );
     681           0 :                 xIndexReplace->replaceByIndex( nAtRow, rValue );
     682             :             }
     683             : 
     684           0 :             m_apDialogModel->startControllerLockTimer();
     685             :             //notify change directly to the model (this is necessary here as sequences for complex categories not known directly to the chart model so they do not notify their changes) (for complex categories see issue #i82971#)
     686           0 :             Reference< util::XModifiable > xModifiable( m_xChartDocument, uno::UNO_QUERY );
     687           0 :             if( xModifiable.is() )
     688           0 :                 xModifiable->setModified(true);
     689             :         }
     690           0 :         catch( const uno::Exception & ex )
     691             :         {
     692             :             (void)(ex);
     693           0 :             bResult = false;
     694             :         }
     695             :     }
     696           0 :     return bResult;
     697             : }
     698             : 
     699           0 : bool DataBrowserModel::setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue )
     700             : {
     701           0 :     return (getCellType( nAtColumn, nAtRow ) == NUMBER) &&
     702           0 :         setCellAny( nAtColumn, nAtRow, uno::makeAny( fValue ));
     703             : }
     704             : 
     705           0 : bool DataBrowserModel::setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const OUString & rText )
     706             : {
     707           0 :     return (getCellType( nAtColumn, nAtRow ) == TEXT) &&
     708           0 :         setCellAny( nAtColumn, nAtRow, uno::makeAny( rText ));
     709             : }
     710             : 
     711           0 : sal_Int32 DataBrowserModel::getColumnCount() const
     712             : {
     713           0 :     return static_cast< sal_Int32 >( m_aColumns.size());
     714             : }
     715             : 
     716           0 : sal_Int32 DataBrowserModel::getMaxRowCount() const
     717             : {
     718           0 :     sal_Int32 nResult = 0;
     719           0 :     tDataColumnVector::const_iterator aIt( m_aColumns.begin());
     720           0 :     for( ; aIt != m_aColumns.end(); ++aIt )
     721             :     {
     722           0 :         if( aIt->m_xLabeledDataSequence.is())
     723             :         {
     724             :             Reference< chart2::data::XDataSequence > xSeq(
     725           0 :                 aIt->m_xLabeledDataSequence->getValues());
     726           0 :             if( !xSeq.is())
     727           0 :                 continue;
     728           0 :             sal_Int32 nLength( xSeq->getData().getLength());
     729           0 :             if( nLength > nResult )
     730           0 :                 nResult = nLength;
     731             :         }
     732             :     }
     733             : 
     734           0 :     return nResult;
     735             : }
     736             : 
     737           0 : OUString DataBrowserModel::getRoleOfColumn( sal_Int32 nColumnIndex ) const
     738             : {
     739           0 :     if( nColumnIndex != -1 &&
     740           0 :         static_cast< sal_uInt32 >( nColumnIndex ) < m_aColumns.size())
     741           0 :         return m_aColumns[ nColumnIndex ].m_aUIRoleName;
     742           0 :     return OUString();
     743             : }
     744             : 
     745           0 : bool DataBrowserModel::isCategoriesColumn( sal_Int32 nColumnIndex ) const
     746             : {
     747           0 :     bool bIsCategories = false;
     748           0 :     if( nColumnIndex>=0 && nColumnIndex<static_cast< sal_Int32 >(m_aColumns.size()) )
     749           0 :         bIsCategories = !m_aColumns[ nColumnIndex ].m_xDataSeries.is();
     750           0 :     return bIsCategories;
     751             : }
     752             : 
     753           0 : sal_Int32 DataBrowserModel::getCategoryColumnCount()
     754             : {
     755           0 :     sal_Int32 nLastTextColumnIndex = -1;
     756           0 :     tDataColumnVector::const_iterator aIt = m_aColumns.begin();
     757           0 :     for( ; aIt != m_aColumns.end(); ++aIt )
     758             :     {
     759           0 :         if( !aIt->m_xDataSeries.is() )
     760           0 :             nLastTextColumnIndex++;
     761             :         else
     762           0 :             break;
     763             :     }
     764           0 :     return nLastTextColumnIndex+1;
     765             : }
     766             : 
     767           0 : const DataBrowserModel::tDataHeaderVector& DataBrowserModel::getDataHeaders() const
     768             : {
     769           0 :     return m_aHeaders;
     770             : }
     771             : 
     772           0 : void DataBrowserModel::updateFromModel()
     773             : {
     774           0 :     if( !m_xChartDocument.is())
     775           0 :         return;
     776           0 :     m_aColumns.clear();
     777           0 :     m_aHeaders.clear();
     778             : 
     779           0 :     Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument ));
     780           0 :     if( !xDiagram.is())
     781           0 :         return;
     782             : 
     783             :     // set template at DialogModel
     784           0 :     uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY );
     785             :     DiagramHelper::tTemplateWithServiceName aTemplateAndService =
     786           0 :         DiagramHelper::getTemplateForDiagram( xDiagram, xFact );
     787           0 :     if( aTemplateAndService.first.is())
     788           0 :         m_apDialogModel->setTemplate( aTemplateAndService.first );
     789             : 
     790           0 :     sal_Int32 nHeaderStart = 0;
     791           0 :     sal_Int32 nHeaderEnd   = 0;
     792           0 :     if( lcl_ShowCategories( xDiagram ))
     793             :     {
     794           0 :         Reference< frame::XModel > xChartModel( m_xChartDocument, uno::UNO_QUERY );
     795           0 :         ChartModel* pModel = dynamic_cast<ChartModel*>(xChartModel.get());
     796           0 :         if (!pModel)
     797           0 :             return;
     798           0 :         ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), *pModel );
     799             : 
     800           0 :         const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() );
     801           0 :         sal_Int32 nLevelCount = rSplitCategoriesList.getLength();
     802           0 :         for( sal_Int32 nL = 0; nL<nLevelCount; nL++ )
     803             :         {
     804           0 :             Reference< chart2::data::XLabeledDataSequence > xCategories( rSplitCategoriesList[nL] );
     805           0 :             if( !xCategories.is() )
     806           0 :                 continue;
     807             : 
     808           0 :             tDataColumn aCategories;
     809           0 :             aCategories.m_xLabeledDataSequence.set( xCategories );
     810           0 :             if( lcl_ShowCategoriesAsDataLabel( xDiagram ))
     811           0 :                 aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel();
     812             :             else
     813           0 :                 aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories );
     814           0 :             aCategories.m_eCellType = TEXTORDATE;
     815           0 :             m_aColumns.push_back( aCategories );
     816           0 :             ++nHeaderStart;
     817           0 :         }
     818             :     }
     819             : 
     820           0 :     Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY );
     821           0 :     if( !xCooSysCnt.is())
     822           0 :         return;
     823           0 :     Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
     824           0 :     for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
     825             :     {
     826           0 :         Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
     827           0 :         Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
     828           0 :         sal_Int32 nXAxisNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( 0, aCooSysSeq[nCooSysIdx], 0, 0 );
     829             : 
     830           0 :         for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx )
     831             :         {
     832           0 :             Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nCTIdx], uno::UNO_QUERY );
     833           0 :             if( xSeriesCnt.is())
     834             :             {
     835           0 :                 OUString aRoleForDataLabelNumberFormat = ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( aChartTypes[nCTIdx] );
     836             : 
     837           0 :                 Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries());
     838           0 :                 lcl_tSharedSeqVec aSharedSequences( lcl_getSharedSequences( aSeries ));
     839           0 :                 for( lcl_tSharedSeqVec::const_iterator aIt( aSharedSequences.begin());
     840           0 :                      aIt != aSharedSequences.end(); ++aIt )
     841             :                 {
     842           0 :                     tDataColumn aSharedSequence;
     843           0 :                     aSharedSequence.m_xLabeledDataSequence = *aIt;
     844           0 :                     aSharedSequence.m_aUIRoleName = lcl_getUIRoleName( *aIt );
     845           0 :                     aSharedSequence.m_eCellType = NUMBER;
     846             :                     // as the sequences are shared it should be ok to take the first series
     847             :                     // @todo: dimension index 0 for x-values used here. This is just a guess.
     848             :                     // Also, the axis index is 0, as there is usually only one x-axis
     849           0 :                     aSharedSequence.m_nNumberFormatKey = nXAxisNumberFormat;
     850           0 :                     m_aColumns.push_back( aSharedSequence );
     851           0 :                     ++nHeaderStart;
     852           0 :                 }
     853           0 :                 for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeries.getLength(); ++nSeriesIdx )
     854             :                 {
     855           0 :                     tDataColumnVector::size_type nStartColIndex = m_aColumns.size();
     856           0 :                     Reference< chart2::XDataSeries > xSeries( aSeries[nSeriesIdx] );
     857           0 :                     Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
     858           0 :                     if( xSource.is())
     859             :                     {
     860           0 :                         Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqs( xSource->getDataSequences());
     861           0 :                         if( aLSeqs.getLength() == 0 )
     862           0 :                             continue;
     863           0 :                         nHeaderEnd = nHeaderStart;
     864             : 
     865             :                         // @todo: dimension index 1 for y-values used here. This is just a guess
     866             :                         sal_Int32 nYAxisNumberFormatKey =
     867             :                             DataSeriesHelper::getNumberFormatKeyFromAxis(
     868           0 :                                 aSeries[nSeriesIdx], aCooSysSeq[nCooSysIdx], 1 );
     869             : 
     870           0 :                         sal_Int32 nSeqIdx=0;
     871           0 :                         for( ; nSeqIdx<aLSeqs.getLength(); ++nSeqIdx )
     872             :                         {
     873           0 :                             sal_Int32 nSequenceNumberFormatKey = nYAxisNumberFormatKey;
     874           0 :                             OUString aRole = lcl_getRole( aLSeqs[nSeqIdx] );
     875             : 
     876           0 :                             if( aRole.equals( aRoleForDataLabelNumberFormat ) )
     877             :                             {
     878             :                                 nSequenceNumberFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
     879           0 :                                     Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ), xSeries, -1, xDiagram );
     880             :                             }
     881           0 :                             else if( aRole.equals( "values-x" ) )
     882           0 :                                 nSequenceNumberFormatKey = nXAxisNumberFormat;
     883             : 
     884           0 :                             if( ::std::find_if( aSharedSequences.begin(), aSharedSequences.end(),
     885           0 :                                              lcl_RepresentationsOfLSeqMatch( aLSeqs[nSeqIdx] )) == aSharedSequences.end())
     886             :                             {
     887             :                                 // no shared sequence
     888             :                                 m_aColumns.push_back(
     889             :                                     tDataColumn(
     890           0 :                                         aSeries[nSeriesIdx],
     891             :                                         nSeqIdx,
     892           0 :                                         lcl_getUIRoleName( aLSeqs[nSeqIdx] ),
     893           0 :                                         aLSeqs[nSeqIdx],
     894             :                                         NUMBER,
     895           0 :                                         nSequenceNumberFormatKey ));
     896           0 :                                 ++nHeaderEnd;
     897             :                             }
     898             :                             // else skip
     899           0 :                         }
     900           0 :                         bool bSwapXAndYAxis = false;
     901             :                         try
     902             :                         {
     903           0 :                             Reference< beans::XPropertySet > xProp( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY );
     904           0 :                             xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndYAxis;
     905             :                         }
     906           0 :                         catch( const beans::UnknownPropertyException & ex )
     907             :                         {
     908             :                             (void)ex;
     909             :                         }
     910             : 
     911             :                         // add ranges for error bars if present for a series
     912           0 :                         if( StatisticsHelper::usesErrorBarRanges( aSeries[nSeriesIdx], /* bYError = */ true ))
     913           0 :                             addErrorBarRanges( aSeries[nSeriesIdx], nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, true );
     914             : 
     915           0 :                         if( StatisticsHelper::usesErrorBarRanges( aSeries[nSeriesIdx], /* bYError = */ false ))
     916           0 :                             addErrorBarRanges( aSeries[nSeriesIdx], nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, false );
     917             : 
     918             :                         m_aHeaders.push_back(
     919             :                             tDataHeader(
     920           0 :                                 aSeries[nSeriesIdx],
     921           0 :                                 aChartTypes[nCTIdx],
     922             :                                 bSwapXAndYAxis,
     923             :                                 nHeaderStart,
     924           0 :                                 nHeaderEnd - 1 ));
     925             : 
     926           0 :                         nHeaderStart = nHeaderEnd;
     927             : 
     928           0 :                         ::std::sort( m_aColumns.begin() + nStartColIndex, m_aColumns.end(), implColumnLess() );
     929             :                     }
     930           0 :                 }
     931             :             }
     932           0 :         }
     933           0 :     }
     934             : }
     935             : 
     936           0 : void DataBrowserModel::addErrorBarRanges(
     937             :     const Reference< chart2::XDataSeries > & xDataSeries,
     938             :     sal_Int32 nNumberFormatKey,
     939             :     sal_Int32 & rInOutSequenceIndex,
     940             :     sal_Int32 & rInOutHeaderEnd, bool bYError )
     941             : {
     942             :     try
     943             :     {
     944           0 :         ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aSequences;
     945             : 
     946             :         Reference< chart2::data::XDataSource > xErrorSource(
     947           0 :             StatisticsHelper::getErrorBars( xDataSeries, bYError ), uno::UNO_QUERY );
     948             : 
     949             :         Reference< chart2::data::XLabeledDataSequence > xErrorLSequence(
     950             :             StatisticsHelper::getErrorLabeledDataSequenceFromDataSource(
     951             :                 xErrorSource,
     952             :                 /* bPositiveValue = */ true,
     953           0 :                 bYError ));
     954           0 :         if( xErrorLSequence.is())
     955           0 :             aSequences.push_back( xErrorLSequence );
     956             : 
     957             :         xErrorLSequence.set(
     958             :             StatisticsHelper::getErrorLabeledDataSequenceFromDataSource(
     959             :                 xErrorSource,
     960             :                 /* bPositiveValue = */ false,
     961           0 :                 bYError ));
     962           0 :         if( xErrorLSequence.is())
     963           0 :             aSequences.push_back( xErrorLSequence );
     964             : 
     965           0 :         for( ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::const_iterator aIt( aSequences.begin());
     966           0 :              aIt != aSequences.end(); ++aIt )
     967             :         {
     968             :             m_aColumns.push_back(
     969             :                 tDataColumn(
     970             :                     xDataSeries,
     971             :                     rInOutSequenceIndex,
     972           0 :                     lcl_getUIRoleName( *aIt ),
     973           0 :                     *aIt,
     974             :                     NUMBER,
     975           0 :                     nNumberFormatKey ));
     976           0 :             ++rInOutSequenceIndex;
     977           0 :             ++rInOutHeaderEnd;
     978           0 :         }
     979             :     }
     980           0 :     catch( const uno::Exception & ex )
     981             :     {
     982             :         ASSERT_EXCEPTION( ex );
     983             :     }
     984           0 : }
     985             : 
     986             : } //  namespace chart
     987             : 
     988             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10