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

Generated by: LCOV version 1.11