LCOV - code coverage report
Current view: top level - sc/source/core/tool - listenerquery.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 37 41 90.2 %
Date: 2015-06-13 12:38:46 Functions: 13 15 86.7 %
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 <listenerquery.hxx>
      11             : #include <listenerqueryids.hxx>
      12             : #include <address.hxx>
      13             : #include <rangelst.hxx>
      14             : 
      15             : namespace sc {
      16             : 
      17          28 : RefQueryFormulaGroup::RefQueryFormulaGroup() :
      18             :     SvtListener::QueryBase(SC_LISTENER_QUERY_FORMULA_GROUP_POS),
      19          28 :     maSkipRange(ScAddress::INITIALIZE_INVALID) {}
      20             : 
      21          28 : RefQueryFormulaGroup::~RefQueryFormulaGroup() {}
      22             : 
      23          28 : void RefQueryFormulaGroup::setSkipRange( const ScRange& rRange )
      24             : {
      25          28 :     maSkipRange = rRange;
      26          28 : }
      27             : 
      28          28 : void RefQueryFormulaGroup::add( const ScAddress& rPos )
      29             : {
      30          28 :     if (!rPos.IsValid())
      31           0 :         return;
      32             : 
      33          28 :     if (maSkipRange.IsValid() && maSkipRange.In(rPos))
      34             :         // This is within the skip range.  Skip it.
      35           0 :         return;
      36             : 
      37          28 :     TabsType::iterator itTab = maTabs.find(rPos.Tab());
      38          28 :     if (itTab == maTabs.end())
      39             :     {
      40             :         std::pair<TabsType::iterator,bool> r =
      41           5 :             maTabs.insert(TabsType::value_type(rPos.Tab(), ColsType()));
      42           5 :         if (!r.second)
      43             :             // Insertion failed.
      44           0 :             return;
      45             : 
      46           5 :         itTab = r.first;
      47             :     }
      48             : 
      49          28 :     ColsType& rCols = itTab->second;
      50          28 :     ColsType::iterator itCol = rCols.find(rPos.Col());
      51          28 :     if (itCol == rCols.end())
      52             :     {
      53             :         std::pair<ColsType::iterator,bool> r =
      54           5 :             rCols.insert(ColsType::value_type(rPos.Col(), ColType()));
      55           5 :         if (!r.second)
      56             :             // Insertion failed.
      57           0 :             return;
      58             : 
      59           5 :         itCol = r.first;
      60             :     }
      61             : 
      62          28 :     ColType& rCol = itCol->second;
      63          28 :     rCol.push_back(rPos.Row());
      64             : }
      65             : 
      66          28 : const RefQueryFormulaGroup::TabsType& RefQueryFormulaGroup::getAllPositions() const
      67             : {
      68          28 :     return maTabs;
      69             : }
      70             : 
      71          56 : struct QueryRange::Impl
      72             : {
      73             :     ScRangeList maRanges;
      74             : };
      75             : 
      76          28 : QueryRange::QueryRange() :
      77             :     SvtListener::QueryBase(SC_LISTENER_QUERY_FORMULA_GROUP_RANGE),
      78          28 :     mpImpl(new Impl) {}
      79             : 
      80          56 : QueryRange::~QueryRange()
      81             : {
      82          28 :     delete mpImpl;
      83          28 : }
      84             : 
      85           4 : void QueryRange::add( const ScRange& rRange )
      86             : {
      87           4 :     mpImpl->maRanges.Join(rRange);
      88           4 : }
      89             : 
      90          28 : void QueryRange::swapRanges( ScRangeList& rRanges )
      91             : {
      92          28 :     mpImpl->maRanges.swap(rRanges);
      93          28 : }
      94             : 
      95         156 : }
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11