LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / refupdatecontext.hxx
blob1c50c7a2c0d1543b24eca4f9c024a41314bfc8af
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 #pragma once
12 #include "global.hxx"
13 #include "address.hxx"
14 #include "columnset.hxx"
16 #include <unordered_map>
17 #include <unordered_set>
19 class ScDocument;
21 namespace sc
23 struct ColumnBlockPosition;
24 class ColumnBlockPositionSet;
26 /**
27 * Keep track of all named expressions that have been updated during
28 * reference update.
30 * Can also be used to collect any set of named expressions / ranges.
32 class UpdatedRangeNames
34 public:
35 typedef std::unordered_set<sal_uInt16> NameIndicesType;
37 void setUpdatedName(SCTAB nTab, sal_uInt16 nIndex);
38 bool isNameUpdated(SCTAB nTab, sal_uInt16 nIndex) const;
39 NameIndicesType getUpdatedNames(SCTAB nTab) const;
40 bool isEmpty(SCTAB nTab) const;
42 private:
43 typedef std::unordered_map<SCTAB, NameIndicesType> UpdatedNamesType;
45 UpdatedNamesType maUpdatedNames;
48 /**
49 * Context for reference update during shifting, moving or copying of cell
50 * ranges.
52 struct RefUpdateContext
54 ScDocument& mrDoc;
56 /**
57 * update mode - insert/delete, copy, or move. The reorder mode (which
58 * corresponds with the reordering of sheets) is not used with this
59 * context.
61 UpdateRefMode meMode;
63 /**
64 * Range of cells that are about to be moved for insert/delete/move modes.
65 * For copy mode, it's the destination range of cells that are about to be
66 * pasted. When moving a range of cells, it's the destination range, not
67 * the source range.
69 ScRange maRange;
71 /** Are the data transposed? */
72 bool mbTransposed;
74 /** Amount and direction of movement in the column direction. */
75 SCCOL mnColDelta;
76 /** Amount and direction of movement in the row direction. */
77 SCROW mnRowDelta;
78 /** Amount and direction of movement in the sheet direction. */
79 SCTAB mnTabDelta;
81 UpdatedRangeNames maUpdatedNames;
82 ColumnSet maRegroupCols;
84 ColumnBlockPositionSet* mpBlockPos; // not owning
86 RefUpdateContext(ScDocument& rDoc, ScDocument* pClipdoc = nullptr);
88 bool isInserted() const;
89 bool isDeleted() const;
91 void setBlockPositionReference(ColumnBlockPositionSet* blockPos);
92 ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
95 struct RefUpdateResult
97 /**
98 * When this flag is true, the result of the formula needs to be
99 * re-calculated either because it contains a reference that's been
100 * deleted, or the size of a range reference has changed.
102 bool mbValueChanged;
105 * This flag indicates whether any reference in the token array has been
106 * modified.
108 bool mbReferenceModified;
111 * When this flag is true, it indicates that the token array contains a
112 * range name that's been updated.
114 bool mbNameModified;
116 RefUpdateResult();
119 struct SC_DLLPUBLIC RefUpdateInsertTabContext
121 ScDocument& mrDoc;
122 SCTAB mnInsertPos;
123 SCTAB mnSheets;
124 UpdatedRangeNames maUpdatedNames;
126 RefUpdateInsertTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets);
129 struct SC_DLLPUBLIC RefUpdateDeleteTabContext
131 ScDocument& mrDoc;
132 SCTAB mnDeletePos;
133 SCTAB mnSheets;
134 UpdatedRangeNames maUpdatedNames;
136 RefUpdateDeleteTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets);
139 struct RefUpdateMoveTabContext
141 ScDocument& mrDoc;
142 SCTAB mnOldPos;
143 SCTAB mnNewPos;
144 UpdatedRangeNames maUpdatedNames;
146 RefUpdateMoveTabContext(ScDocument& rDoc, SCTAB nOldPos, SCTAB nNewPos);
148 SCTAB getNewTab(SCTAB nOldTab) const;
151 struct SetFormulaDirtyContext
153 SCTAB mnTabDeletedStart;
154 SCTAB mnTabDeletedEnd;
157 * When true, go through all reference tokens and clears "sheet deleted"
158 * flag if its corresponding index falls within specified sheet range.
160 bool mbClearTabDeletedFlag;
162 SetFormulaDirtyContext();
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */