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

Generated by: LCOV version 1.11