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 #ifndef INCLUDED_SC_INC_REFUPDATECONTEXT_HXX
11 #define INCLUDED_SC_INC_REFUPDATECONTEXT_HXX
14 #include "address.hxx"
15 #include "columnset.hxx"
17 #include <unordered_map>
18 #include <unordered_set>
24 struct ColumnBlockPosition
;
25 class ColumnBlockPositionSet
;
28 * Keep track of all named expressions that have been updated during
31 * Can also be used to collect any set of named expressions / ranges.
33 class UpdatedRangeNames
36 typedef std::unordered_set
<sal_uInt16
> NameIndicesType
;
38 void setUpdatedName(SCTAB nTab
, sal_uInt16 nIndex
);
39 bool isNameUpdated(SCTAB nTab
, sal_uInt16 nIndex
) const;
40 NameIndicesType
getUpdatedNames(SCTAB nTab
) const;
41 bool isEmpty(SCTAB nTab
) const;
44 typedef std::unordered_map
<SCTAB
, NameIndicesType
> UpdatedNamesType
;
46 UpdatedNamesType maUpdatedNames
;
50 * Context for reference update during shifting, moving or copying of cell
53 struct RefUpdateContext
58 * update mode - insert/delete, copy, or move. The reorder mode (which
59 * corresponds with the reordering of sheets) is not used with this
65 * Range of cells that are about to be moved for insert/delete/move modes.
66 * For copy mode, it's the destination range of cells that are about to be
67 * pasted. When moving a range of cells, it's the destination range, not
72 /** Amount and direction of movement in the column direction. */
74 /** Amount and direction of movement in the row direction. */
76 /** Amount and direction of movement in the sheet direction. */
79 UpdatedRangeNames maUpdatedNames
;
80 ColumnSet maRegroupCols
;
82 ColumnBlockPositionSet
* mpBlockPos
; // not owning
84 RefUpdateContext(ScDocument
& rDoc
);
86 bool isInserted() const;
87 bool isDeleted() const;
89 void setBlockPositionReference( ColumnBlockPositionSet
* blockPos
);
90 ColumnBlockPosition
* getBlockPosition(SCTAB nTab
, SCCOL nCol
);
93 struct RefUpdateResult
96 * When this flag is true, the result of the formula needs to be
97 * re-calculated either because it contains a reference that's been
98 * deleted, or the size of a range reference has changed.
103 * This flag indicates whether any reference in the token array has been
106 bool mbReferenceModified
;
109 * When this flag is true, it indicates that the token array contains a
110 * range name that's been updated.
117 struct SC_DLLPUBLIC RefUpdateInsertTabContext
120 SCTAB
const mnInsertPos
;
121 SCTAB
const mnSheets
;
122 UpdatedRangeNames maUpdatedNames
;
124 RefUpdateInsertTabContext(ScDocument
& rDoc
, SCTAB nInsertPos
, SCTAB nSheets
);
127 struct SC_DLLPUBLIC RefUpdateDeleteTabContext
130 SCTAB
const mnDeletePos
;
131 SCTAB
const mnSheets
;
132 UpdatedRangeNames maUpdatedNames
;
134 RefUpdateDeleteTabContext(ScDocument
& rDoc
, SCTAB nInsertPos
, SCTAB nSheets
);
137 struct RefUpdateMoveTabContext
140 SCTAB
const mnOldPos
;
141 SCTAB
const mnNewPos
;
142 UpdatedRangeNames maUpdatedNames
;
144 RefUpdateMoveTabContext(ScDocument
& rDoc
, SCTAB nOldPos
, SCTAB nNewPos
);
146 SCTAB
getNewTab(SCTAB nOldTab
) const;
149 struct SetFormulaDirtyContext
151 SCTAB mnTabDeletedStart
;
152 SCTAB mnTabDeletedEnd
;
155 * When true, go through all reference tokens and clears "sheet deleted"
156 * flag if its corresponding index falls within specified sheet range.
158 bool mbClearTabDeletedFlag
;
160 SetFormulaDirtyContext();
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */