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

Generated by: LCOV version 1.10