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

Generated by: LCOV version 1.10