1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include "refupdatecontext.hxx"
14 void UpdatedRangeNames::setUpdatedName(SCTAB nTab
, sal_uInt16 nIndex
)
16 UpdatedNamesType::iterator it
= maUpdatedNames
.find(nTab
);
17 if (it
== maUpdatedNames
.end())
19 // Insert a new container for this sheet index.
20 NameIndicesType aIndices
;
21 std::pair
<UpdatedNamesType::iterator
,bool> r
=
22 maUpdatedNames
.insert(UpdatedNamesType::value_type(nTab
, aIndices
));
25 // Insertion failed for whatever reason.
31 NameIndicesType
& rIndices
= it
->second
;
32 rIndices
.insert(nIndex
);
35 bool UpdatedRangeNames::isNameUpdated(SCTAB nTab
, sal_uInt16 nIndex
) const
37 UpdatedNamesType::const_iterator it
= maUpdatedNames
.find(nTab
);
38 if (it
== maUpdatedNames
.end())
41 const NameIndicesType
& rIndices
= it
->second
;
42 return rIndices
.count(nIndex
) > 0;
45 RefUpdateContext::RefUpdateContext(ScDocument
& rDoc
) :
46 mrDoc(rDoc
), meMode(URM_INSDEL
), mnColDelta(0), mnRowDelta(0), mnTabDelta(0) {}
48 bool RefUpdateContext::isInserted() const
50 return (meMode
== URM_INSDEL
) && (mnColDelta
> 0 || mnRowDelta
> 0 || mnTabDelta
> 0);
53 bool RefUpdateContext::isDeleted() const
55 return (meMode
== URM_INSDEL
) && (mnColDelta
< 0 || mnRowDelta
< 0 || mnTabDelta
< 0);
58 RefUpdateResult::RefUpdateResult() : mbValueChanged(false), mbReferenceModified(false), mbNameModified(false) {}
59 RefUpdateResult::RefUpdateResult(const RefUpdateResult
& r
) :
60 mbValueChanged(r
.mbValueChanged
),
61 mbReferenceModified(r
.mbReferenceModified
),
62 mbNameModified(r
.mbNameModified
) {}
64 RefUpdateInsertTabContext::RefUpdateInsertTabContext(SCTAB nInsertPos
, SCTAB nSheets
) :
65 mnInsertPos(nInsertPos
), mnSheets(nSheets
) {}
67 RefUpdateDeleteTabContext::RefUpdateDeleteTabContext(SCTAB nDeletePos
, SCTAB nSheets
) :
68 mnDeletePos(nDeletePos
), mnSheets(nSheets
) {}
70 RefUpdateMoveTabContext::RefUpdateMoveTabContext(SCTAB nOldPos
, SCTAB nNewPos
) :
71 mnOldPos(nOldPos
), mnNewPos(nNewPos
) {}
73 SCTAB
RefUpdateMoveTabContext::getNewTab(SCTAB nOldTab
) const
75 // Sheets below the lower bound or above the uppper bound will not change.
76 SCTAB nLowerBound
= std::min(mnOldPos
, mnNewPos
);
77 SCTAB nUpperBound
= std::max(mnOldPos
, mnNewPos
);
79 if (nOldTab
< nLowerBound
|| nUpperBound
< nOldTab
)
80 // Outside the boundary. Nothing to adjust.
83 if (nOldTab
== mnOldPos
)
86 // It's somewhere in between.
87 if (mnOldPos
< mnNewPos
)
89 // Moving a sheet to the right. The rest of the sheets shifts to the left.
93 // Moving a sheet to the left. The rest of the sheets shifts to the right.
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */