LCOV - code coverage report
Current view: top level - sc/source/core/data - mtvelements.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 24 32 75.0 %
Date: 2015-06-13 12:38:46 Functions: 5 6 83.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             : 
      10             : #include "mtvelements.hxx"
      11             : #include "globalnames.hxx"
      12             : #include "document.hxx"
      13             : #include "cellvalue.hxx"
      14             : 
      15             : namespace sc {
      16             : 
      17        5878 : ColumnBlockPositionSet::ColumnBlockPositionSet(ScDocument& rDoc) : mrDoc(rDoc) {}
      18             : 
      19      320752 : ColumnBlockPosition* ColumnBlockPositionSet::getBlockPosition(SCTAB nTab, SCCOL nCol)
      20             : {
      21      320752 :     osl::MutexGuard aGuard(&maMtxTables);
      22             : 
      23      320752 :     TablesType::iterator itTab = maTables.find(nTab);
      24      320752 :     if (itTab == maTables.end())
      25             :     {
      26             :         std::pair<TablesType::iterator,bool> r =
      27        1790 :             maTables.insert(TablesType::value_type(nTab, ColumnsType()));
      28        1790 :         if (!r.second)
      29             :             // insertion failed.
      30           0 :             return NULL;
      31             : 
      32        1790 :         itTab = r.first;
      33             :     }
      34             : 
      35      320752 :     ColumnsType& rCols = itTab->second;
      36             : 
      37      320752 :     ColumnsType::iterator it = rCols.find(nCol);
      38      320752 :     if (it != rCols.end())
      39             :         // Block position for this column has already been fetched.
      40      124104 :         return &it->second;
      41             : 
      42             :     std::pair<ColumnsType::iterator,bool> r =
      43             :         rCols.insert(
      44      196648 :             ColumnsType::value_type(nCol, ColumnBlockPosition()));
      45             : 
      46      196648 :     if (!r.second)
      47             :         // insertion failed.
      48           0 :         return NULL;
      49             : 
      50      196648 :     it = r.first;
      51             : 
      52      196648 :     if (!mrDoc.InitColumnBlockPosition(it->second, nTab, nCol))
      53           0 :         return NULL;
      54             : 
      55      196648 :     return &it->second;
      56             : }
      57             : 
      58           0 : void ColumnBlockPositionSet::clear()
      59             : {
      60           0 :     osl::MutexGuard aGuard(&maMtxTables);
      61           0 :     maTables.clear();
      62           0 : }
      63             : 
      64       19161 : ScRefCellValue toRefCell( const sc::CellStoreType::const_iterator& itPos, size_t nOffset )
      65             : {
      66       19161 :     switch (itPos->type)
      67             :     {
      68             :         case sc::element_type_numeric:
      69             :             // Numeric cell
      70        5847 :             return ScRefCellValue(sc::numeric_block::at(*itPos->data, nOffset));
      71             :         case sc::element_type_string:
      72             :             // String cell
      73        6848 :             return ScRefCellValue(&sc::string_block::at(*itPos->data, nOffset));
      74             :         case sc::element_type_edittext:
      75             :             // Edit cell
      76          71 :             return ScRefCellValue(sc::edittext_block::at(*itPos->data, nOffset));
      77             :         break;
      78             :         case sc::element_type_formula:
      79             :             // Formula cell
      80        6395 :             return ScRefCellValue(sc::formula_block::at(*itPos->data, nOffset));
      81             :         default:
      82             :             ;
      83             :     }
      84             : 
      85           0 :     return ScRefCellValue();
      86             : }
      87             : 
      88         156 : }
      89             : 
      90             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11