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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "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           0 : struct lcl_NumberedStringGenerator
      39             : {
      40           0 :     lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) :
      41             :             m_aStub( rStub ),
      42             :             m_nCounter( 0 ),
      43           0 :             m_nStubStartIndex( rStub.indexOf( rWildcard )),
      44           0 :             m_nWildcardLength( rWildcard.getLength())
      45             :     {
      46           0 :     }
      47           0 :     vector< uno::Any > operator()()
      48             :     {
      49           0 :         vector< uno::Any > aRet(1);
      50           0 :         aRet[0] = uno::makeAny( m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::number( ++m_nCounter )) );
      51           0 :         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           0 :     Sequence< T > lcl_ValarrayToSequence( const ::std::valarray< T > & rValarray )
      62             : {
      63             :     // is there a more elegant way of conversion?
      64           0 :     Sequence< T > aResult( rValarray.size());
      65           0 :     for( size_t i = 0; i < rValarray.size(); ++i )
      66           0 :         aResult[i] = rValarray[i];
      67           0 :     return aResult;
      68             : }
      69             : 
      70             : } // anonymous namespace
      71             : 
      72           0 : InternalData::InternalData()
      73             :     : m_nColumnCount( 0 )
      74             :     , m_nRowCount( 0 )
      75             :     , m_aRowLabels( 0 )
      76           0 :     , m_aColumnLabels( 0 )
      77           0 : {}
      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           0 : void InternalData::createDefaultData()
      87             : {
      88           0 :     const sal_Int32 nRowCount = 4;
      89           0 :     const sal_Int32 nColumnCount = 3;
      90             : 
      91           0 :     m_nRowCount = nRowCount;
      92           0 :     m_nColumnCount = nColumnCount;
      93           0 :     const sal_Int32 nSize = nColumnCount * nRowCount;
      94             :     // @todo: localize this!
      95           0 :     const OUString aRowName(SCH_RESSTR(STR_ROW_LABEL));
      96           0 :     const OUString aColName(SCH_RESSTR(STR_COLUMN_LABEL));
      97             : 
      98           0 :     m_aData.resize( nSize );
      99           0 :     for( sal_Int32 i=0; i<nSize; ++i )
     100           0 :         m_aData[i] = fDefaultData[i];
     101             : 
     102           0 :     m_aRowLabels.clear();
     103           0 :     m_aRowLabels.reserve( m_nRowCount );
     104             :     generate_n( back_inserter( m_aRowLabels ), m_nRowCount,
     105           0 :         lcl_NumberedStringGenerator( aRowName, "%ROWNUMBER" ));
     106             : 
     107           0 :     m_aColumnLabels.clear();
     108           0 :     m_aColumnLabels.reserve( m_nColumnCount );
     109             :     generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount,
     110           0 :         lcl_NumberedStringGenerator( aColName, "%COLUMNNUMBER" ));
     111           0 : }
     112             : 
     113           0 : bool InternalData::isDefaultData()
     114             : {
     115             : 
     116           0 :     if( m_nRowCount == 4 && m_nColumnCount == 3 )
     117             :     {
     118           0 :         for( sal_Int32 i=0; i<(4*3); ++i )
     119           0 :             if( m_aData[i] != fDefaultData[i] )
     120           0 :                 return false;
     121             : 
     122           0 :         return true;
     123             :     }
     124           0 :     return false;
     125             : }
     126             : 
     127           0 : void InternalData::clearDefaultData()
     128             : {
     129           0 :     if( isDefaultData() )
     130             :     {
     131           0 :         m_nRowCount = m_nColumnCount = 1;
     132           0 :         m_aData.resize( 1 );
     133           0 :         m_aRowLabels.clear();
     134           0 :         m_aColumnLabels.clear();
     135             :     }
     136           0 : }
     137             : 
     138           0 : void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )
     139             : {
     140           0 :     m_nRowCount = rDataInRows.getLength();
     141           0 :     m_nColumnCount = (m_nRowCount ? rDataInRows[0].getLength() : 0);
     142             : 
     143           0 :     if( m_aRowLabels.size() != static_cast< sal_uInt32 >( m_nRowCount ))
     144           0 :         m_aRowLabels.resize( m_nRowCount );
     145           0 :     if( m_aColumnLabels.size() != static_cast< sal_uInt32 >( m_nColumnCount ))
     146           0 :         m_aColumnLabels.resize( m_nColumnCount );
     147             : 
     148           0 :     m_aData.resize( m_nRowCount * m_nColumnCount );
     149             :     double fNan;
     150           0 :     ::rtl::math::setNan( & fNan );
     151             :     // set all values to Nan
     152           0 :     m_aData = fNan;
     153             : 
     154           0 :     for( sal_Int32 nRow=0; nRow<m_nRowCount; ++nRow )
     155             :     {
     156           0 :         int nDataIdx = nRow*m_nColumnCount;
     157           0 :         const sal_Int32 nMax = ::std::min( rDataInRows[nRow].getLength(), m_nColumnCount );
     158           0 :         for( sal_Int32 nCol=0; nCol < nMax; ++nCol )
     159             :         {
     160           0 :             m_aData[nDataIdx] = rDataInRows[nRow][nCol];
     161           0 :             nDataIdx += 1;
     162             :         }
     163             :     }
     164           0 : }
     165             : 
     166           0 : Sequence< Sequence< double > > InternalData::getData() const
     167             : {
     168           0 :     Sequence< Sequence< double > > aResult( m_nRowCount );
     169             : 
     170           0 :     for( sal_Int32 i=0; i<m_nRowCount; ++i )
     171           0 :         aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
     172           0 :             m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
     173             : 
     174           0 :     return aResult;
     175             : }
     176             : 
     177           0 : Sequence< double > InternalData::getColumnValues( sal_Int32 nColumnIndex ) const
     178             : {
     179           0 :     if( nColumnIndex >= 0 && nColumnIndex < m_nColumnCount )
     180             :         return lcl_ValarrayToSequence< tDataType::value_type >(
     181           0 :             m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] );
     182           0 :     return Sequence< double >();
     183             : }
     184           0 : Sequence< double > InternalData::getRowValues( sal_Int32 nRowIndex ) const
     185             : {
     186           0 :     if( nRowIndex >= 0 && nRowIndex < m_nRowCount )
     187             :         return lcl_ValarrayToSequence< tDataType::value_type >(
     188           0 :             m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ] );
     189           0 :     return Sequence< double >();
     190             : }
     191             : 
     192           0 : void InternalData::setColumnValues( sal_Int32 nColumnIndex, const vector< double > & rNewData )
     193             : {
     194           0 :     if( nColumnIndex < 0 )
     195           0 :         return;
     196           0 :     enlargeData( nColumnIndex + 1, rNewData.size() );
     197             : 
     198           0 :     tDataType aSlice = m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ];
     199           0 :     for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
     200           0 :         aSlice[i] = rNewData[i];
     201           0 :     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           0 : void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< uno::Any >& rComplexLabel )
     217             : {
     218           0 :     if( nColumnIndex < 0 )
     219           0 :         return;
     220           0 :     if( nColumnIndex >= static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
     221             :     {
     222           0 :         m_aColumnLabels.resize(nColumnIndex+1);
     223           0 :         enlargeData( nColumnIndex+1, 0 );
     224             :     }
     225           0 :     m_aColumnLabels[nColumnIndex]=rComplexLabel;
     226             : }
     227             : 
     228           0 : void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< uno::Any >& rComplexLabel )
     229             : {
     230           0 :     if( nRowIndex < 0 )
     231           0 :         return;
     232           0 :     if( nRowIndex >= static_cast< sal_Int32 >( m_aRowLabels.size() ) )
     233             :     {
     234           0 :         m_aRowLabels.resize(nRowIndex+1);
     235           0 :         enlargeData( 0, nRowIndex+1 );
     236             :     }
     237           0 :     m_aRowLabels[nRowIndex] = rComplexLabel;
     238             : }
     239             : 
     240           0 : vector< uno::Any > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const
     241             : {
     242           0 :     if( nColumnIndex < static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
     243           0 :         return m_aColumnLabels[nColumnIndex];
     244             :     else
     245           0 :         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           0 : bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount )
     296             : {
     297           0 :     sal_Int32 nNewColumnCount( ::std::max<sal_Int32>( m_nColumnCount, nColumnCount ) );
     298           0 :     sal_Int32 nNewRowCount( ::std::max<sal_Int32>( m_nRowCount, nRowCount ) );
     299           0 :     sal_Int32 nNewSize( nNewColumnCount*nNewRowCount );
     300             : 
     301           0 :     bool bGrow = (nNewSize > m_nColumnCount*m_nRowCount);
     302             : 
     303           0 :     if( bGrow )
     304             :     {
     305             :         double fNan;
     306           0 :         ::rtl::math::setNan( &fNan );
     307           0 :         tDataType aNewData( fNan, nNewSize );
     308             :         // copy old data
     309           0 :         for( int nCol=0; nCol<m_nColumnCount; ++nCol )
     310             :             static_cast< tDataType >(
     311           0 :                 aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] ) =
     312           0 :                 m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ];
     313             : 
     314           0 :         m_aData.resize( nNewSize );
     315           0 :         m_aData = aNewData;
     316             :     }
     317           0 :     m_nColumnCount = nNewColumnCount;
     318           0 :     m_nRowCount = nNewRowCount;
     319           0 :     return bGrow;
     320             : }
     321             : 
     322           0 : 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           0 :     if( nAfterIndex >= m_nColumnCount || nAfterIndex < -1 )
     327           0 :         return;
     328           0 :     sal_Int32 nNewColumnCount = m_nColumnCount + 1;
     329           0 :     sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
     330             : 
     331             :     double fNan;
     332           0 :     ::rtl::math::setNan( &fNan );
     333           0 :     tDataType aNewData( fNan, nNewSize );
     334             : 
     335             :     // copy old data
     336           0 :     int nCol=0;
     337           0 :     for( ; nCol<=nAfterIndex; ++nCol )
     338           0 :         aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
     339             :             static_cast< tDataType >(
     340           0 :                 m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
     341           0 :     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           0 :     m_nColumnCount = nNewColumnCount;
     347           0 :     m_aData.resize( nNewSize );
     348           0 :     m_aData = aNewData;
     349             : 
     350             :     // labels
     351           0 :     if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
     352           0 :         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           0 : sal_Int32 InternalData::appendColumn()
     360             : {
     361           0 :     insertColumn( getColumnCount() - 1 );
     362           0 :     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           0 : sal_Int32 InternalData::getRowCount() const
     488             : {
     489           0 :     return m_nRowCount;
     490             : }
     491             : 
     492           0 : sal_Int32 InternalData::getColumnCount() const
     493             : {
     494           0 :     return m_nColumnCount;
     495             : }
     496             : 
     497           0 : void InternalData::setComplexRowLabels( const vector< vector< uno::Any > >& rNewRowLabels )
     498             : {
     499           0 :     m_aRowLabels = rNewRowLabels;
     500           0 :     sal_Int32 nNewRowCount = static_cast< sal_Int32 >( m_aRowLabels.size() );
     501           0 :     if( nNewRowCount < m_nRowCount )
     502           0 :         m_aRowLabels.resize( m_nRowCount );
     503             :     else
     504           0 :         enlargeData( 0, nNewRowCount );
     505           0 : }
     506             : 
     507           0 : vector< vector< uno::Any > > InternalData::getComplexRowLabels() const
     508             : {
     509           0 :     return m_aRowLabels;
     510             : }
     511             : 
     512           0 : void InternalData::setComplexColumnLabels( const vector< vector< uno::Any > >& rNewColumnLabels )
     513             : {
     514           0 :     m_aColumnLabels = rNewColumnLabels;
     515           0 :     sal_Int32 nNewColumnCount = static_cast< sal_Int32 >( m_aColumnLabels.size() );
     516           0 :     if( nNewColumnCount < m_nColumnCount )
     517           0 :         m_aColumnLabels.resize( m_nColumnCount );
     518             :     else
     519           0 :         enlargeData( nNewColumnCount, 0 );
     520           0 : }
     521             : 
     522           0 : vector< vector< uno::Any > > InternalData::getComplexColumnLabels() const
     523             : {
     524           0 :     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