LCOV - code coverage report
Current view: top level - sc/source/core/data - columnset.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 21 21 100.0 %
Date: 2014-04-11 Functions: 2 2 100.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 "columnset.hxx"
      11             : 
      12             : namespace sc {
      13             : 
      14          82 : void ColumnSet::set(SCTAB nTab, SCCOL nCol)
      15             : {
      16          82 :     TabsType::iterator itTab = maTabs.find(nTab);
      17          82 :     if (itTab == maTabs.end())
      18             :     {
      19             :         std::pair<TabsType::iterator,bool> r =
      20          77 :             maTabs.insert(TabsType::value_type(nTab, ColsType()));
      21             : 
      22          77 :         if (!r.second)
      23             :             // insertion failed.
      24          82 :             return;
      25             : 
      26          77 :         itTab = r.first;
      27             :     }
      28             : 
      29          82 :     ColsType& rCols = itTab->second;
      30          82 :     rCols.insert(nCol);
      31             : }
      32             : 
      33          82 : void ColumnSet::getColumns(SCTAB nTab, std::vector<SCCOL>& rCols) const
      34             : {
      35          82 :     std::vector<SCCOL> aCols;
      36          82 :     TabsType::const_iterator itTab = maTabs.find(nTab);
      37          82 :     if (itTab == maTabs.end())
      38             :     {
      39          36 :         rCols.swap(aCols); // empty it.
      40         118 :         return;
      41             :     }
      42             : 
      43          46 :     const ColsType& rTabCols = itTab->second;
      44          46 :     aCols.assign(rTabCols.begin(), rTabCols.end());
      45             : 
      46             :     // Sort and remove duplicates.
      47          46 :     std::sort(aCols.begin(), aCols.end());
      48          46 :     std::vector<SCCOL>::iterator itCol = std::unique(aCols.begin(), aCols.end());
      49          46 :     aCols.erase(itCol, aCols.end());
      50             : 
      51          46 :     rCols.swap(aCols);
      52             : }
      53             : 
      54             : }
      55             : 
      56             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10