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

Generated by: LCOV version 1.10