fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / data / refupdatecontext.cxx
blob07cb0602e060e39323233dd48f88b309d9befc4c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include "refupdatecontext.hxx"
11 #include <algorithm>
13 namespace sc {
15 void UpdatedRangeNames::setUpdatedName(SCTAB nTab, sal_uInt16 nIndex)
17 UpdatedNamesType::iterator it = maUpdatedNames.find(nTab);
18 if (it == maUpdatedNames.end())
20 // Insert a new container for this sheet index.
21 NameIndicesType aIndices;
22 std::pair<UpdatedNamesType::iterator,bool> r =
23 maUpdatedNames.insert(UpdatedNamesType::value_type(nTab, aIndices));
25 if (!r.second)
26 // Insertion failed for whatever reason.
27 return;
29 it = r.first;
32 NameIndicesType& rIndices = it->second;
33 rIndices.insert(nIndex);
36 bool UpdatedRangeNames::isNameUpdated(SCTAB nTab, sal_uInt16 nIndex) const
38 UpdatedNamesType::const_iterator it = maUpdatedNames.find(nTab);
39 if (it == maUpdatedNames.end())
40 return false;
42 const NameIndicesType& rIndices = it->second;
43 return rIndices.count(nIndex) > 0;
46 RefUpdateContext::RefUpdateContext(ScDocument& rDoc) :
47 mrDoc(rDoc), meMode(URM_INSDEL), mnColDelta(0), mnRowDelta(0), mnTabDelta(0) {}
49 bool RefUpdateContext::isInserted() const
51 return (meMode == URM_INSDEL) && (mnColDelta > 0 || mnRowDelta > 0 || mnTabDelta > 0);
54 bool RefUpdateContext::isDeleted() const
56 return (meMode == URM_INSDEL) && (mnColDelta < 0 || mnRowDelta < 0 || mnTabDelta < 0);
59 RefUpdateResult::RefUpdateResult() : mbValueChanged(false), mbReferenceModified(false), mbNameModified(false) {}
60 RefUpdateResult::RefUpdateResult(const RefUpdateResult& r) :
61 mbValueChanged(r.mbValueChanged),
62 mbReferenceModified(r.mbReferenceModified),
63 mbNameModified(r.mbNameModified) {}
65 RefUpdateInsertTabContext::RefUpdateInsertTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets) :
66 mrDoc(rDoc), mnInsertPos(nInsertPos), mnSheets(nSheets) {}
68 RefUpdateDeleteTabContext::RefUpdateDeleteTabContext(ScDocument& rDoc, SCTAB nDeletePos, SCTAB nSheets) :
69 mrDoc(rDoc), mnDeletePos(nDeletePos), mnSheets(nSheets) {}
71 RefUpdateMoveTabContext::RefUpdateMoveTabContext(ScDocument& rDoc, SCTAB nOldPos, SCTAB nNewPos) :
72 mrDoc(rDoc), mnOldPos(nOldPos), mnNewPos(nNewPos) {}
74 SCTAB RefUpdateMoveTabContext::getNewTab(SCTAB nOldTab) const
76 // Sheets below the lower bound or above the uppper bound will not change.
77 SCTAB nLowerBound = std::min(mnOldPos, mnNewPos);
78 SCTAB nUpperBound = std::max(mnOldPos, mnNewPos);
80 if (nOldTab < nLowerBound || nUpperBound < nOldTab)
81 // Outside the boundary. Nothing to adjust.
82 return nOldTab;
84 if (nOldTab == mnOldPos)
85 return mnNewPos;
87 // It's somewhere in between.
88 if (mnOldPos < mnNewPos)
90 // Moving a sheet to the right. The rest of the sheets shifts to the left.
91 return nOldTab - 1;
94 // Moving a sheet to the left. The rest of the sheets shifts to the right.
95 return nOldTab + 1;
98 SetFormulaDirtyContext::SetFormulaDirtyContext() :
99 mnTabDeletedStart(-1), mnTabDeletedEnd(-1), mbClearTabDeletedFlag(false) {}
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */