LCOV - code coverage report
Current view: top level - sc/source/core/data - refupdatecontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 44 44 100.0 %
Date: 2014-11-03 Functions: 14 14 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 "refupdatecontext.hxx"
      11             : 
      12             : namespace sc {
      13             : 
      14         146 : void UpdatedRangeNames::setUpdatedName(SCTAB nTab, sal_uInt16 nIndex)
      15             : {
      16         146 :     UpdatedNamesType::iterator it = maUpdatedNames.find(nTab);
      17         146 :     if (it == maUpdatedNames.end())
      18             :     {
      19             :         // Insert a new container for this sheet index.
      20          62 :         NameIndicesType aIndices;
      21             :         std::pair<UpdatedNamesType::iterator,bool> r =
      22          62 :             maUpdatedNames.insert(UpdatedNamesType::value_type(nTab, aIndices));
      23             : 
      24          62 :         if (!r.second)
      25             :             // Insertion failed for whatever reason.
      26         146 :             return;
      27             : 
      28          62 :         it = r.first;
      29             :     }
      30             : 
      31         146 :     NameIndicesType& rIndices = it->second;
      32         146 :     rIndices.insert(nIndex);
      33             : }
      34             : 
      35         414 : bool UpdatedRangeNames::isNameUpdated(SCTAB nTab, sal_uInt16 nIndex) const
      36             : {
      37         414 :     UpdatedNamesType::const_iterator it = maUpdatedNames.find(nTab);
      38         414 :     if (it == maUpdatedNames.end())
      39          12 :         return false;
      40             : 
      41         402 :     const NameIndicesType& rIndices = it->second;
      42         402 :     return rIndices.count(nIndex) > 0;
      43             : }
      44             : 
      45        1636 : RefUpdateContext::RefUpdateContext(ScDocument& rDoc) :
      46        1636 :     mrDoc(rDoc), meMode(URM_INSDEL), mnColDelta(0), mnRowDelta(0), mnTabDelta(0) {}
      47             : 
      48         532 : bool RefUpdateContext::isInserted() const
      49             : {
      50         532 :     return (meMode == URM_INSDEL) && (mnColDelta > 0 || mnRowDelta > 0 || mnTabDelta > 0);
      51             : }
      52             : 
      53         598 : bool RefUpdateContext::isDeleted() const
      54             : {
      55         598 :     return (meMode == URM_INSDEL) && (mnColDelta < 0 || mnRowDelta < 0 || mnTabDelta < 0);
      56             : }
      57             : 
      58        1504 : RefUpdateResult::RefUpdateResult() : mbValueChanged(false), mbReferenceModified(false), mbNameModified(false) {}
      59          46 : RefUpdateResult::RefUpdateResult(const RefUpdateResult& r) :
      60             :     mbValueChanged(r.mbValueChanged),
      61             :     mbReferenceModified(r.mbReferenceModified),
      62          46 :     mbNameModified(r.mbNameModified) {}
      63             : 
      64         138 : RefUpdateInsertTabContext::RefUpdateInsertTabContext(SCTAB nInsertPos, SCTAB nSheets) :
      65         138 :     mnInsertPos(nInsertPos), mnSheets(nSheets) {}
      66             : 
      67         176 : RefUpdateDeleteTabContext::RefUpdateDeleteTabContext(SCTAB nDeletePos, SCTAB nSheets) :
      68         176 :     mnDeletePos(nDeletePos), mnSheets(nSheets) {}
      69             : 
      70          28 : RefUpdateMoveTabContext::RefUpdateMoveTabContext(SCTAB nOldPos, SCTAB nNewPos) :
      71          28 :     mnOldPos(nOldPos), mnNewPos(nNewPos) {}
      72             : 
      73         108 : SCTAB RefUpdateMoveTabContext::getNewTab(SCTAB nOldTab) const
      74             : {
      75             :     // Sheets below the lower bound or above the uppper bound will not change.
      76         108 :     SCTAB nLowerBound = std::min(mnOldPos, mnNewPos);
      77         108 :     SCTAB nUpperBound = std::max(mnOldPos, mnNewPos);
      78             : 
      79         108 :     if (nOldTab < nLowerBound || nUpperBound < nOldTab)
      80             :         // Outside the boundary. Nothing to adjust.
      81          40 :         return nOldTab;
      82             : 
      83          68 :     if (nOldTab == mnOldPos)
      84          20 :         return mnNewPos;
      85             : 
      86             :     // It's somewhere in between.
      87          48 :     if (mnOldPos < mnNewPos)
      88             :     {
      89             :         // Moving a sheet to the right. The rest of the sheets shifts to the left.
      90          24 :         return nOldTab - 1;
      91             :     }
      92             : 
      93             :     // Moving a sheet to the left. The rest of the sheets shifts to the right.
      94          24 :     return nOldTab + 1;
      95             : }
      96             : 
      97        1042 : SetFormulaDirtyContext::SetFormulaDirtyContext() :
      98        1042 :     mnTabDeletedStart(-1), mnTabDeletedEnd(-1), mbClearTabDeletedFlag(false) {}
      99             : 
     100         228 : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10