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>
12 #include <clipparam.hxx>
13 #include <mtvelements.hxx>
17 void UpdatedRangeNames::setUpdatedName(SCTAB nTab
, sal_uInt16 nIndex
)
19 // Map anything <-1 to global names. Unless we really want to come up with
20 // some classification there...
24 UpdatedNamesType::iterator it
= maUpdatedNames
.find(nTab
);
25 if (it
== maUpdatedNames
.end())
27 // Insert a new container for this sheet index.
28 NameIndicesType aIndices
;
29 std::pair
<UpdatedNamesType::iterator
,bool> r
=
30 maUpdatedNames
.emplace( nTab
, aIndices
);
33 // Insertion failed for whatever reason.
39 NameIndicesType
& rIndices
= it
->second
;
40 rIndices
.insert(nIndex
);
43 bool UpdatedRangeNames::isNameUpdated(SCTAB nTab
, sal_uInt16 nIndex
) const
45 UpdatedNamesType::const_iterator it
= maUpdatedNames
.find(nTab
);
46 if (it
== maUpdatedNames
.end())
49 const NameIndicesType
& rIndices
= it
->second
;
50 return rIndices
.count(nIndex
) > 0;
53 UpdatedRangeNames::NameIndicesType
UpdatedRangeNames::getUpdatedNames(SCTAB nTab
) const
55 UpdatedNamesType::const_iterator it
= maUpdatedNames
.find(nTab
);
56 if (it
== maUpdatedNames
.end())
57 return NameIndicesType();
61 bool UpdatedRangeNames::isEmpty(SCTAB nTab
) const
63 UpdatedNamesType::const_iterator it
= maUpdatedNames
.find(nTab
);
64 return it
== maUpdatedNames
.end();
67 RefUpdateContext::RefUpdateContext(ScDocument
& rDoc
, ScDocument
* pClipdoc
)
70 , mbTransposed(pClipdoc
!= nullptr && pClipdoc
->GetClipParam().isTransposed())
76 assert((pClipdoc
== nullptr || pClipdoc
->IsClipboard()) && "only nullptr or clipdoc allowed");
79 bool RefUpdateContext::isInserted() const
81 return (meMode
== URM_INSDEL
) && (mnColDelta
> 0 || mnRowDelta
> 0 || mnTabDelta
> 0);
84 bool RefUpdateContext::isDeleted() const
86 return (meMode
== URM_INSDEL
) && (mnColDelta
< 0 || mnRowDelta
< 0 || mnTabDelta
< 0);
89 void RefUpdateContext::setBlockPositionReference( ColumnBlockPositionSet
* blockPos
)
91 mpBlockPos
= blockPos
;
94 ColumnBlockPosition
* RefUpdateContext::getBlockPosition(SCTAB nTab
, SCCOL nCol
)
96 return mpBlockPos
? mpBlockPos
->getBlockPosition(nTab
, nCol
) : nullptr;
99 RefUpdateResult::RefUpdateResult()
100 : mbValueChanged(false), mbReferenceModified(false), mbNameModified(false), mnTab(-1) {}
102 RefUpdateInsertTabContext::RefUpdateInsertTabContext(ScDocument
& rDoc
, SCTAB nInsertPos
, SCTAB nSheets
) :
103 mrDoc(rDoc
), mnInsertPos(nInsertPos
), mnSheets(nSheets
) {}
105 RefUpdateDeleteTabContext::RefUpdateDeleteTabContext(ScDocument
& rDoc
, SCTAB nDeletePos
, SCTAB nSheets
) :
106 mrDoc(rDoc
), mnDeletePos(nDeletePos
), mnSheets(nSheets
) {}
108 RefUpdateMoveTabContext::RefUpdateMoveTabContext(ScDocument
& rDoc
, SCTAB nOldPos
, SCTAB nNewPos
) :
109 mrDoc(rDoc
), mnOldPos(nOldPos
), mnNewPos(nNewPos
) {}
111 SCTAB
RefUpdateMoveTabContext::getNewTab(SCTAB nOldTab
) const
113 // Sheets below the lower bound or above the upper bound will not change.
114 SCTAB nLowerBound
= std::min(mnOldPos
, mnNewPos
);
115 SCTAB nUpperBound
= std::max(mnOldPos
, mnNewPos
);
117 if (nOldTab
< nLowerBound
|| nUpperBound
< nOldTab
)
118 // Outside the boundary. Nothing to adjust.
121 if (nOldTab
== mnOldPos
)
124 // It's somewhere in between.
125 if (mnOldPos
< mnNewPos
)
127 // Moving a sheet to the right. The rest of the sheets shifts to the left.
131 // Moving a sheet to the left. The rest of the sheets shifts to the right.
135 SetFormulaDirtyContext::SetFormulaDirtyContext() :
136 mnTabDeletedStart(-1), mnTabDeletedEnd(-1), mbClearTabDeletedFlag(false) {}
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */