LCOV - code coverage report
Current view: top level - sc/source/core/data - cellvalues.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 54 0.0 %
Date: 2014-04-14 Functions: 0 10 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             : 
      10             : #include <cellvalues.hxx>
      11             : #include <column.hxx>
      12             : 
      13             : #include <cassert>
      14             : #include <boost/noncopyable.hpp>
      15             : 
      16             : namespace sc {
      17             : 
      18           0 : struct CellValuesImpl : boost::noncopyable
      19             : {
      20             :     CellStoreType maCells;
      21             : };
      22             : 
      23           0 : CellValues::CellValues() :
      24           0 :     mpImpl(new CellValuesImpl) {}
      25             : 
      26           0 : CellValues::~CellValues()
      27             : {
      28           0 :     delete mpImpl;
      29           0 : }
      30             : 
      31           0 : void CellValues::transferFrom( ScColumn& rCol, SCROW nRow, size_t nLen )
      32             : {
      33           0 :     mpImpl->maCells.resize(nLen);
      34           0 :     rCol.maCells.transfer(nRow, nRow+nLen-1, mpImpl->maCells, 0);
      35           0 : }
      36             : 
      37           0 : void CellValues::copyTo( ScColumn& rCol, SCROW nRow ) const
      38             : {
      39           0 :     CellStoreType& rDest = rCol.maCells;
      40           0 :     const CellStoreType& rSrc = mpImpl->maCells;
      41             : 
      42             :     // Caller must ensure the destination is long enough.
      43             :     assert(rSrc.size() + static_cast<size_t>(nRow) < rDest.size());
      44             : 
      45           0 :     SCROW nCurRow = nRow;
      46           0 :     CellStoreType::iterator itPos = rDest.begin();
      47             : 
      48           0 :     CellStoreType::const_iterator itBlk = rSrc.begin(), itBlkEnd = rSrc.end();
      49           0 :     for (; itBlk != itBlkEnd; ++itBlk)
      50             :     {
      51           0 :         switch (itBlk->type)
      52             :         {
      53             :             case element_type_numeric:
      54             :             {
      55           0 :                 numeric_block::const_iterator it = numeric_block::begin(*itBlk->data);
      56           0 :                 numeric_block::const_iterator itEnd = numeric_block::end(*itBlk->data);
      57           0 :                 itPos = rDest.set(itPos, nCurRow, it, itEnd);
      58             :             }
      59           0 :             break;
      60             :             case element_type_string:
      61             :             {
      62           0 :                 string_block::const_iterator it = string_block::begin(*itBlk->data);
      63           0 :                 string_block::const_iterator itEnd = string_block::end(*itBlk->data);
      64           0 :                 itPos = rDest.set(itPos, nCurRow, it, itEnd);
      65             :             }
      66           0 :             break;
      67             :             case element_type_edittext:
      68             :             {
      69           0 :                 edittext_block::const_iterator it = edittext_block::begin(*itBlk->data);
      70           0 :                 edittext_block::const_iterator itEnd = edittext_block::end(*itBlk->data);
      71           0 :                 std::vector<EditTextObject*> aVals;
      72           0 :                 aVals.reserve(itBlk->size);
      73           0 :                 for (; it != itEnd; ++it)
      74             :                 {
      75           0 :                     const EditTextObject* p = *it;
      76           0 :                     aVals.push_back(p->Clone());
      77             :                 }
      78           0 :                 itPos = rDest.set(itPos, nCurRow, aVals.begin(), aVals.end());
      79             :             }
      80           0 :             break;
      81             :             case element_type_formula:
      82             :             {
      83           0 :                 formula_block::const_iterator it = formula_block::begin(*itBlk->data);
      84           0 :                 formula_block::const_iterator itEnd = formula_block::end(*itBlk->data);
      85           0 :                 std::vector<ScFormulaCell*> aVals;
      86           0 :                 aVals.reserve(itBlk->size);
      87           0 :                 for (; it != itEnd; ++it)
      88             :                 {
      89           0 :                     const ScFormulaCell* p = *it;
      90           0 :                     aVals.push_back(p->Clone());
      91             :                 }
      92           0 :                 itPos = rDest.set(itPos, nCurRow, aVals.begin(), aVals.end());
      93             :             }
      94           0 :             break;
      95             :             default:
      96           0 :                 itPos = rDest.set_empty(itPos, nCurRow, nCurRow+itBlk->size-1);
      97             :         }
      98             : 
      99           0 :         nCurRow += itBlk->size;
     100             :     }
     101           0 : }
     102             : 
     103           0 : void CellValues::assign( const std::vector<double>& rVals )
     104             : {
     105           0 :     mpImpl->maCells.resize(rVals.size());
     106           0 :     mpImpl->maCells.set(0, rVals.begin(), rVals.end());
     107           0 : }
     108             : 
     109           0 : size_t CellValues::size() const
     110             : {
     111           0 :     return mpImpl->maCells.size();
     112             : }
     113             : 
     114           0 : }
     115             : 
     116             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10