LCOV - code coverage report
Current view: top level - chart2/source/tools - InternalData.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 160 265 60.4 %
Date: 2014-04-11 Functions: 25 33 75.8 %
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 "InternalData.hxx"
      21             : #include "ResId.hxx"
      22             : #include "Strings.hrc"
      23             : 
      24             : #include <rtl/math.hxx>
      25             : #include <algorithm>
      26             : #include <iterator>
      27             : 
      28             : using ::com::sun::star::uno::Sequence;
      29             : 
      30             : using namespace ::com::sun::star;
      31             : using namespace ::std;
      32             : 
      33             : namespace chart
      34             : {
      35             : 
      36             : namespace
      37             : {
      38         268 : struct lcl_NumberedStringGenerator
      39             : {
      40         268 :     lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) :
      41             :             m_aStub( rStub ),
      42             :             m_nCounter( 0 ),
      43         268 :             m_nStubStartIndex( rStub.indexOf( rWildcard )),
      44         536 :             m_nWildcardLength( rWildcard.getLength())
      45             :     {
      46         268 :     }
      47         938 :     vector< uno::Any > operator()()
      48             :     {
      49         938 :         vector< uno::Any > aRet(1);
      50         938 :         aRet[0] = uno::makeAny( m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::number( ++m_nCounter )) );
      51         938 :         return aRet;
      52             :     }
      53             : private:
      54             :     OUString m_aStub;
      55             :     sal_Int32 m_nCounter;
      56             :     const sal_Int32 m_nStubStartIndex;
      57             :     const sal_Int32 m_nWildcardLength;
      58             : };
      59             : 
      60             : template< typename T >
      61       76950 :     Sequence< T > lcl_ValarrayToSequence( const ::std::valarray< T > & rValarray )
      62             : {
      63             :     // is there a more elegant way of conversion?
      64       76950 :     Sequence< T > aResult( rValarray.size());
      65      967227 :     for( size_t i = 0; i < rValarray.size(); ++i )
      66      890277 :         aResult[i] = rValarray[i];
      67       76950 :     return aResult;
      68             : }
      69             : 
      70             : } // anonymous namespace
      71             : 
      72         212 : InternalData::InternalData()
      73             :     : m_nColumnCount( 0 )
      74             :     , m_nRowCount( 0 )
      75             :     , m_aRowLabels( 0 )
      76         212 :     , m_aColumnLabels( 0 )
      77         212 : {}
      78             : 
      79             : static const double fDefaultData[] = {
      80             :     9.10, 3.20, 4.54,
      81             :     2.40, 8.80, 9.65,
      82             :     3.10, 1.50, 3.70,
      83             :     4.30, 9.02, 6.20
      84             : };
      85             : 
      86         134 : void InternalData::createDefaultData()
      87             : {
      88         134 :     const sal_Int32 nRowCount = 4;
      89         134 :     const sal_Int32 nColumnCount = 3;
      90             : 
      91         134 :     m_nRowCount = nRowCount;
      92         134 :     m_nColumnCount = nColumnCount;
      93         134 :     const sal_Int32 nSize = nColumnCount * nRowCount;
      94             :     // @todo: localize this!
      95         134 :     const OUString aRowName(SCH_RESSTR(STR_ROW_LABEL));
      96         268 :     const OUString aColName(SCH_RESSTR(STR_COLUMN_LABEL));
      97             : 
      98         134 :     m_aData.resize( nSize );
      99        1742 :     for( sal_Int32 i=0; i<nSize; ++i )
     100        1608 :         m_aData[i] = fDefaultData[i];
     101             : 
     102         134 :     m_aRowLabels.clear();
     103         134 :     m_aRowLabels.reserve( m_nRowCount );
     104             :     generate_n( back_inserter( m_aRowLabels ), m_nRowCount,
     105         134 :         lcl_NumberedStringGenerator( aRowName, "%ROWNUMBER" ));
     106             : 
     107         134 :     m_aColumnLabels.clear();
     108         134 :     m_aColumnLabels.reserve( m_nColumnCount );
     109             :     generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount,
     110         268 :         lcl_NumberedStringGenerator( aColName, "%COLUMNNUMBER" ));
     111         134 : }
     112             : 
     113         329 : bool InternalData::isDefaultData()
     114             : {
     115             : 
     116         329 :     if( m_nRowCount == 4 && m_nColumnCount == 3 )
     117             :     {
     118         781 :         for( sal_Int32 i=0; i<(4*3); ++i )
     119         726 :             if( m_aData[i] != fDefaultData[i] )
     120          62 :                 return false;
     121             : 
     122          55 :         return true;
     123             :     }
     124         212 :     return false;
     125             : }
     126             : 
     127         329 : void InternalData::clearDefaultData()
     128             : {
     129         329 :     if( isDefaultData() )
     130             :     {
     131          55 :         m_nRowCount = m_nColumnCount = 1;
     132          55 :         m_aData.resize( 1 );
     133          55 :         m_aRowLabels.clear();
     134          55 :         m_aColumnLabels.clear();
     135             :     }
     136         329 : }
     137             : 
     138          59 : void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )
     139             : {
     140          59 :     m_nRowCount = rDataInRows.getLength();
     141          59 :     m_nColumnCount = (m_nRowCount ? rDataInRows[0].getLength() : 0);
     142             : 
     143          59 :     if( m_aRowLabels.size() != static_cast< sal_uInt32 >( m_nRowCount ))
     144          54 :         m_aRowLabels.resize( m_nRowCount );
     145          59 :     if( m_aColumnLabels.size() != static_cast< sal_uInt32 >( m_nColumnCount ))
     146          54 :         m_aColumnLabels.resize( m_nColumnCount );
     147             : 
     148          59 :     m_aData.resize( m_nRowCount * m_nColumnCount );
     149             :     double fNan;
     150          59 :     ::rtl::math::setNan( & fNan );
     151             :     // set all values to Nan
     152          59 :     m_aData = fNan;
     153             : 
     154         333 :     for( sal_Int32 nRow=0; nRow<m_nRowCount; ++nRow )
     155             :     {
     156         274 :         int nDataIdx = nRow*m_nColumnCount;
     157         274 :         const sal_Int32 nMax = ::std::min( rDataInRows[nRow].getLength(), m_nColumnCount );
     158         984 :         for( sal_Int32 nCol=0; nCol < nMax; ++nCol )
     159             :         {
     160         710 :             m_aData[nDataIdx] = rDataInRows[nRow][nCol];
     161         710 :             nDataIdx += 1;
     162             :         }
     163             :     }
     164          59 : }
     165             : 
     166           6 : Sequence< Sequence< double > > InternalData::getData() const
     167             : {
     168           6 :     Sequence< Sequence< double > > aResult( m_nRowCount );
     169             : 
     170          30 :     for( sal_Int32 i=0; i<m_nRowCount; ++i )
     171          48 :         aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
     172          72 :             m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
     173             : 
     174           6 :     return aResult;
     175             : }
     176             : 
     177       76920 : Sequence< double > InternalData::getColumnValues( sal_Int32 nColumnIndex ) const
     178             : {
     179       76920 :     if( nColumnIndex >= 0 && nColumnIndex < m_nColumnCount )
     180             :         return lcl_ValarrayToSequence< tDataType::value_type >(
     181       76920 :             m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] );
     182           0 :     return Sequence< double >();
     183             : }
     184           6 : Sequence< double > InternalData::getRowValues( sal_Int32 nRowIndex ) const
     185             : {
     186           6 :     if( nRowIndex >= 0 && nRowIndex < m_nRowCount )
     187             :         return lcl_ValarrayToSequence< tDataType::value_type >(
     188           6 :             m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ] );
     189           0 :     return Sequence< double >();
     190             : }
     191             : 
     192         287 : void InternalData::setColumnValues( sal_Int32 nColumnIndex, const vector< double > & rNewData )
     193             : {
     194         287 :     if( nColumnIndex < 0 )
     195         287 :         return;
     196         287 :     enlargeData( nColumnIndex + 1, rNewData.size() );
     197             : 
     198         287 :     tDataType aSlice = m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ];
     199        1413 :     for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
     200        1126 :         aSlice[i] = rNewData[i];
     201         287 :     m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] = aSlice;
     202             : }
     203             : 
     204           0 : void InternalData::setRowValues( sal_Int32 nRowIndex, const vector< double > & rNewData )
     205             : {
     206           0 :     if( nRowIndex < 0 )
     207           0 :         return;
     208           0 :     enlargeData( rNewData.size(), nRowIndex+1 );
     209             : 
     210           0 :     tDataType aSlice = m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ];
     211           0 :     for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
     212           0 :         aSlice[i] = rNewData[i];
     213           0 :     m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ]= aSlice;
     214             : }
     215             : 
     216         380 : void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< uno::Any >& rComplexLabel )
     217             : {
     218         380 :     if( nColumnIndex < 0 )
     219         380 :         return;
     220         380 :     if( nColumnIndex >= static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
     221             :     {
     222          55 :         m_aColumnLabels.resize(nColumnIndex+1);
     223          55 :         enlargeData( nColumnIndex+1, 0 );
     224             :     }
     225         380 :     m_aColumnLabels[nColumnIndex]=rComplexLabel;
     226             : }
     227             : 
     228         338 : void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< uno::Any >& rComplexLabel )
     229             : {
     230         338 :     if( nRowIndex < 0 )
     231         338 :         return;
     232         338 :     if( nRowIndex >= static_cast< sal_Int32 >( m_aRowLabels.size() ) )
     233             :     {
     234         249 :         m_aRowLabels.resize(nRowIndex+1);
     235         249 :         enlargeData( 0, nRowIndex+1 );
     236             :     }
     237         338 :     m_aRowLabels[nRowIndex] = rComplexLabel;
     238             : }
     239             : 
     240        4683 : vector< uno::Any > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const
     241             : {
     242        4683 :     if( nColumnIndex < static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
     243        4628 :         return m_aColumnLabels[nColumnIndex];
     244             :     else
     245          55 :         return vector< uno::Any >();
     246             : }
     247           0 : vector< uno::Any > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const
     248             : {
     249           0 :     if( nRowIndex < static_cast< sal_Int32 >( m_aRowLabels.size() ) )
     250           0 :         return m_aRowLabels[nRowIndex];
     251             :     else
     252           0 :         return vector< uno::Any >();
     253             : }
     254             : 
     255           0 : void InternalData::swapRowWithNext( sal_Int32 nRowIndex )
     256             : {
     257           0 :     if( nRowIndex < m_nRowCount - 1 )
     258             :     {
     259           0 :         const sal_Int32 nMax = m_nColumnCount;
     260           0 :         for( sal_Int32 nColIdx=0; nColIdx<nMax; ++nColIdx )
     261             :         {
     262           0 :             size_t nIndex1 = nColIdx + nRowIndex*m_nColumnCount;
     263           0 :             size_t nIndex2 = nIndex1 + m_nColumnCount;
     264           0 :             double fTemp = m_aData[nIndex1];
     265           0 :             m_aData[nIndex1] = m_aData[nIndex2];
     266           0 :             m_aData[nIndex2] = fTemp;
     267             :         }
     268             : 
     269           0 :         vector< uno::Any > aTemp( m_aRowLabels[nRowIndex] );
     270           0 :         m_aRowLabels[nRowIndex] = m_aRowLabels[nRowIndex + 1];
     271           0 :         m_aRowLabels[nRowIndex + 1] = aTemp;
     272             :     }
     273           0 : }
     274             : 
     275           0 : void InternalData::swapColumnWithNext( sal_Int32 nColumnIndex )
     276             : {
     277           0 :     if( nColumnIndex < m_nColumnCount - 1 )
     278             :     {
     279           0 :         const sal_Int32 nMax = m_nRowCount;
     280           0 :         for( sal_Int32 nRowIdx=0; nRowIdx<nMax; ++nRowIdx )
     281             :         {
     282           0 :             size_t nIndex1 = nColumnIndex + nRowIdx*m_nColumnCount;
     283           0 :             size_t nIndex2 = nIndex1 + 1;
     284           0 :             double fTemp = m_aData[nIndex1];
     285           0 :             m_aData[nIndex1] = m_aData[nIndex2];
     286           0 :             m_aData[nIndex2] = fTemp;
     287             :         }
     288             : 
     289           0 :         vector< uno::Any > aTemp( m_aColumnLabels[nColumnIndex] );
     290           0 :         m_aColumnLabels[nColumnIndex] = m_aColumnLabels[nColumnIndex + 1];
     291           0 :         m_aColumnLabels[nColumnIndex + 1] = aTemp;
     292             :     }
     293           0 : }
     294             : 
     295         725 : bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount )
     296             : {
     297         725 :     sal_Int32 nNewColumnCount( ::std::max<sal_Int32>( m_nColumnCount, nColumnCount ) );
     298         725 :     sal_Int32 nNewRowCount( ::std::max<sal_Int32>( m_nRowCount, nRowCount ) );
     299         725 :     sal_Int32 nNewSize( nNewColumnCount*nNewRowCount );
     300             : 
     301         725 :     bool bGrow = (nNewSize > m_nColumnCount*m_nRowCount);
     302             : 
     303         725 :     if( bGrow )
     304             :     {
     305             :         double fNan;
     306         207 :         ::rtl::math::setNan( &fNan );
     307         207 :         tDataType aNewData( fNan, nNewSize );
     308             :         // copy old data
     309         416 :         for( int nCol=0; nCol<m_nColumnCount; ++nCol )
     310             :             static_cast< tDataType >(
     311         418 :                 aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] ) =
     312         209 :                 m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ];
     313             : 
     314         207 :         m_aData.resize( nNewSize );
     315         207 :         m_aData = aNewData;
     316             :     }
     317         725 :     m_nColumnCount = nNewColumnCount;
     318         725 :     m_nRowCount = nNewRowCount;
     319         725 :     return bGrow;
     320             : }
     321             : 
     322         287 : void InternalData::insertColumn( sal_Int32 nAfterIndex )
     323             : {
     324             :     // note: -1 is allowed, as we insert after the given index
     325             :     OSL_ASSERT( nAfterIndex < m_nColumnCount && nAfterIndex >= -1 );
     326         287 :     if( nAfterIndex >= m_nColumnCount || nAfterIndex < -1 )
     327         287 :         return;
     328         287 :     sal_Int32 nNewColumnCount = m_nColumnCount + 1;
     329         287 :     sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
     330             : 
     331             :     double fNan;
     332         287 :     ::rtl::math::setNan( &fNan );
     333         287 :     tDataType aNewData( fNan, nNewSize );
     334             : 
     335             :     // copy old data
     336         287 :     int nCol=0;
     337        1288 :     for( ; nCol<=nAfterIndex; ++nCol )
     338        2002 :         aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
     339             :             static_cast< tDataType >(
     340        1001 :                 m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
     341         287 :     for( ++nCol; nCol<nNewColumnCount; ++nCol )
     342           0 :         aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
     343             :             static_cast< tDataType >(
     344           0 :                 m_aData[ ::std::slice( nCol - 1, m_nRowCount, m_nColumnCount ) ] );
     345             : 
     346         287 :     m_nColumnCount = nNewColumnCount;
     347         287 :     m_aData.resize( nNewSize );
     348         287 :     m_aData = aNewData;
     349             : 
     350             :     // labels
     351         287 :     if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
     352         285 :         m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< uno::Any >(1) );
     353             : 
     354             : #if OSL_DEBUG_LEVEL > 1
     355             :     traceData();
     356             : #endif
     357             : }
     358             : 
     359         150 : sal_Int32 InternalData::appendColumn()
     360             : {
     361         150 :     insertColumn( getColumnCount() - 1 );
     362         150 :     return getColumnCount() - 1;
     363             : }
     364             : 
     365           0 : sal_Int32 InternalData::appendRow()
     366             : {
     367           0 :     insertRow( getRowCount() - 1 );
     368           0 :     return getRowCount() - 1;
     369             : }
     370             : 
     371           0 : void InternalData::insertRow( sal_Int32 nAfterIndex )
     372             : {
     373             :     // note: -1 is allowed, as we insert after the given index
     374             :     OSL_ASSERT( nAfterIndex < m_nRowCount && nAfterIndex >= -1 );
     375           0 :     if( nAfterIndex >= m_nRowCount || nAfterIndex < -1 )
     376           0 :         return;
     377           0 :     sal_Int32 nNewRowCount = m_nRowCount + 1;
     378           0 :     sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
     379             : 
     380             :     double fNan;
     381           0 :     ::rtl::math::setNan( &fNan );
     382           0 :     tDataType aNewData( fNan, nNewSize );
     383             : 
     384             :     // copy old data
     385           0 :     sal_Int32 nIndex = nAfterIndex + 1;
     386           0 :     aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
     387             :         static_cast< tDataType >(
     388           0 :             m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
     389             : 
     390           0 :     if( nIndex < m_nRowCount )
     391             :     {
     392           0 :         sal_Int32 nRemainingCount = m_nColumnCount * (m_nRowCount - nIndex);
     393           0 :         aNewData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] =
     394             :             static_cast< tDataType >(
     395           0 :                 m_aData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] );
     396             :     }
     397             : 
     398           0 :     m_nRowCount = nNewRowCount;
     399           0 :     m_aData.resize( nNewSize );
     400           0 :     m_aData = aNewData;
     401             : 
     402             :     // labels
     403           0 :     if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
     404           0 :         m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< uno::Any > (1));
     405             : 
     406             : #if OSL_DEBUG_LEVEL > 1
     407             :     traceData();
     408             : #endif
     409             : }
     410             : 
     411           0 : void InternalData::deleteColumn( sal_Int32 nAtIndex )
     412             : {
     413             :     OSL_ASSERT( nAtIndex < m_nColumnCount && nAtIndex >= 0 );
     414           0 :     if( nAtIndex >= m_nColumnCount || m_nColumnCount < 1 || nAtIndex < 0 )
     415           0 :         return;
     416           0 :     sal_Int32 nNewColumnCount = m_nColumnCount - 1;
     417           0 :     sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
     418             : 
     419             :     double fNan;
     420           0 :     ::rtl::math::setNan( &fNan );
     421           0 :     tDataType aNewData( fNan, nNewSize );
     422             : 
     423             :     // copy old data
     424           0 :     int nCol=0;
     425           0 :     for( ; nCol<nAtIndex; ++nCol )
     426           0 :         aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
     427             :             static_cast< tDataType >(
     428           0 :                 m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
     429           0 :     for( ; nCol<nNewColumnCount; ++nCol )
     430           0 :         aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
     431             :             static_cast< tDataType >(
     432           0 :                 m_aData[ ::std::slice( nCol + 1, m_nRowCount, m_nColumnCount ) ] );
     433             : 
     434           0 :     m_nColumnCount = nNewColumnCount;
     435           0 :     m_aData.resize( nNewSize );
     436           0 :     m_aData = aNewData;
     437             : 
     438             :     // labels
     439           0 :     if( nAtIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
     440           0 :         m_aColumnLabels.erase( m_aColumnLabels.begin() + nAtIndex );
     441             : 
     442             : #if OSL_DEBUG_LEVEL > 1
     443             :     traceData();
     444             : #endif
     445             : }
     446             : 
     447           0 : void InternalData::deleteRow( sal_Int32 nAtIndex )
     448             : {
     449             :     OSL_ASSERT( nAtIndex < m_nRowCount && nAtIndex >= 0 );
     450           0 :     if( nAtIndex >= m_nRowCount || m_nRowCount < 1 || nAtIndex < 0 )
     451           0 :         return;
     452           0 :     sal_Int32 nNewRowCount = m_nRowCount - 1;
     453           0 :     sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
     454             : 
     455             :     double fNan;
     456           0 :     ::rtl::math::setNan( &fNan );
     457           0 :     tDataType aNewData( fNan, nNewSize );
     458             : 
     459             :     // copy old data
     460           0 :     sal_Int32 nIndex = nAtIndex;
     461           0 :     if( nIndex )
     462           0 :         aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
     463             :             static_cast< tDataType >(
     464           0 :                 m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
     465             : 
     466           0 :     if( nIndex < nNewRowCount )
     467             :     {
     468           0 :         sal_Int32 nRemainingCount = m_nColumnCount * (nNewRowCount - nIndex);
     469           0 :         aNewData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] =
     470             :             static_cast< tDataType >(
     471           0 :                 m_aData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] );
     472             :     }
     473             : 
     474           0 :     m_nRowCount = nNewRowCount;
     475           0 :     m_aData.resize( nNewSize );
     476           0 :     m_aData = aNewData;
     477             : 
     478             :     // labels
     479           0 :     if( nAtIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
     480           0 :         m_aRowLabels.erase( m_aRowLabels.begin() + nAtIndex );
     481             : 
     482             : #if OSL_DEBUG_LEVEL > 1
     483             :     traceData();
     484             : #endif
     485             : }
     486             : 
     487        3686 : sal_Int32 InternalData::getRowCount() const
     488             : {
     489        3686 :     return m_nRowCount;
     490             : }
     491             : 
     492        1297 : sal_Int32 InternalData::getColumnCount() const
     493             : {
     494        1297 :     return m_nColumnCount;
     495             : }
     496             : 
     497          79 : void InternalData::setComplexRowLabels( const vector< vector< uno::Any > >& rNewRowLabels )
     498             : {
     499          79 :     m_aRowLabels = rNewRowLabels;
     500          79 :     sal_Int32 nNewRowCount = static_cast< sal_Int32 >( m_aRowLabels.size() );
     501          79 :     if( nNewRowCount < m_nRowCount )
     502           0 :         m_aRowLabels.resize( m_nRowCount );
     503             :     else
     504          79 :         enlargeData( 0, nNewRowCount );
     505          79 : }
     506             : 
     507        9772 : vector< vector< uno::Any > > InternalData::getComplexRowLabels() const
     508             : {
     509        9772 :     return m_aRowLabels;
     510             : }
     511             : 
     512          55 : void InternalData::setComplexColumnLabels( const vector< vector< uno::Any > >& rNewColumnLabels )
     513             : {
     514          55 :     m_aColumnLabels = rNewColumnLabels;
     515          55 :     sal_Int32 nNewColumnCount = static_cast< sal_Int32 >( m_aColumnLabels.size() );
     516          55 :     if( nNewColumnCount < m_nColumnCount )
     517           0 :         m_aColumnLabels.resize( m_nColumnCount );
     518             :     else
     519          55 :         enlargeData( nNewColumnCount, 0 );
     520          55 : }
     521             : 
     522          18 : vector< vector< uno::Any > > InternalData::getComplexColumnLabels() const
     523             : {
     524          18 :     return m_aColumnLabels;
     525             : }
     526             : 
     527             : #if OSL_DEBUG_LEVEL > 1
     528             : void InternalData::traceData() const
     529             : {
     530             :     OSL_TRACE( "InternalData: Data in rows" );
     531             : 
     532             :     for( sal_Int32 i=0; i<m_nRowCount; ++i )
     533             :     {
     534             :         tDataType aSlice( m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
     535             :         for( sal_Int32 j=0; j<m_nColumnCount; ++j )
     536             :             OSL_TRACE( "%lf ", aSlice[j] );
     537             :         OSL_TRACE( "\n" );
     538             :     }
     539             :     OSL_TRACE( "\n" );
     540             : }
     541             : #endif
     542             : 
     543             : } //  namespace chart
     544             : 
     545             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10