Bump version to 6.4-15
[LibreOffice.git] / sc / inc / refupdatecontext.hxx
blobbc86cb9e1afe0a179cf4f74c17b65ec559e09c1e
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 #ifndef INCLUDED_SC_INC_REFUPDATECONTEXT_HXX
11 #define INCLUDED_SC_INC_REFUPDATECONTEXT_HXX
13 #include "global.hxx"
14 #include "address.hxx"
15 #include "columnset.hxx"
17 #include <unordered_map>
18 #include <unordered_set>
20 class ScDocument;
22 namespace sc {
24 struct ColumnBlockPosition;
25 class ColumnBlockPositionSet;
27 /**
28 * Keep track of all named expressions that have been updated during
29 * reference update.
31 * Can also be used to collect any set of named expressions / ranges.
33 class UpdatedRangeNames
35 public:
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;
43 private:
44 typedef std::unordered_map<SCTAB, NameIndicesType> UpdatedNamesType;
46 UpdatedNamesType maUpdatedNames;
49 /**
50 * Context for reference update during shifting, moving or copying of cell
51 * ranges.
53 struct RefUpdateContext
55 ScDocument& mrDoc;
57 /**
58 * update mode - insert/delete, copy, or move. The reorder mode (which
59 * corresponds with the reordering of sheets) is not used with this
60 * context.
62 UpdateRefMode meMode;
64 /**
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
68 * the source range.
70 ScRange maRange;
72 /** Amount and direction of movement in the column direction. */
73 SCCOL mnColDelta;
74 /** Amount and direction of movement in the row direction. */
75 SCROW mnRowDelta;
76 /** Amount and direction of movement in the sheet direction. */
77 SCTAB mnTabDelta;
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
95 /**
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.
100 bool mbValueChanged;
103 * This flag indicates whether any reference in the token array has been
104 * modified.
106 bool mbReferenceModified;
109 * When this flag is true, it indicates that the token array contains a
110 * range name that's been updated.
112 bool mbNameModified;
114 RefUpdateResult();
117 struct SC_DLLPUBLIC RefUpdateInsertTabContext
119 ScDocument& mrDoc;
120 SCTAB const mnInsertPos;
121 SCTAB const mnSheets;
122 UpdatedRangeNames maUpdatedNames;
124 RefUpdateInsertTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets);
127 struct SC_DLLPUBLIC RefUpdateDeleteTabContext
129 ScDocument& mrDoc;
130 SCTAB const mnDeletePos;
131 SCTAB const mnSheets;
132 UpdatedRangeNames maUpdatedNames;
134 RefUpdateDeleteTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets);
137 struct RefUpdateMoveTabContext
139 ScDocument& mrDoc;
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();
165 #endif
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */