LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/chart2/source/tools - InternalData.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 126 265 47.5 %
Date: 2013-07-09 Functions: 21 33 63.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10