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

Generated by: LCOV version 1.10