LibreOffice Module sc (master) 1
undocell.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include "undobase.hxx"
23#include <detdata.hxx>
24#include <postit.hxx>
25#include <cellvalue.hxx>
26#include <cellvalues.hxx>
27#include <editeng/editobj.hxx>
28
29#include <memory>
30
31class ScDocShell;
32class ScPatternAttr;
33class ScRangeName;
34class ScFormulaCell;
35
37{
38public:
39 ScUndoCursorAttr( ScDocShell* pNewDocShell,
40 SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
41 const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat,
42 const ScPatternAttr* pApplyPat );
43 virtual ~ScUndoCursorAttr() override;
44
45 virtual void Undo() override;
46 virtual void Redo() override;
47 virtual void Repeat(SfxRepeatTarget& rTarget) override;
48 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
49
50 virtual OUString GetComment() const override;
51
55 void SetEditData( std::unique_ptr<EditTextObject> pOld, std::unique_ptr<EditTextObject> pNew );
56
57private:
64 std::unique_ptr<EditTextObject> pOldEditData;
65 std::unique_ptr<EditTextObject> pNewEditData;
66
67 void DoChange( const ScPatternAttr* pWhichPattern, const std::unique_ptr<EditTextObject>& pEditData ) const;
68};
69
71{
72public:
73
74 struct Value
75 {
78 sal_uInt32 mnFormat;
80
81 Value();
82 };
83
84 typedef std::vector<Value> ValuesType;
85
87 ScDocShell* pNewDocShell, const ScAddress& rPos,
88 ValuesType& rOldValues, OUString aNewStr, std::unique_ptr<EditTextObject> pObj );
89
90 virtual void Undo() override;
91 virtual void Redo() override;
92 virtual void Repeat(SfxRepeatTarget& rTarget) override;
93 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
94
95 virtual OUString GetComment() const override;
96
97 virtual std::optional<ScRange> getAffectedRange() const override { return maPos; }
98
99private:
101
102 OUString maNewString;
103 std::unique_ptr<EditTextObject> mpNewEditData;
106
107 void DoChange() const;
108 void SetChangeTrack();
109};
110
112{
113public:
115 ScDocShell* pNewDocShell, const ScAddress& rNewPos,
116 ScCellValue aUndoCell, double nVal );
117
118 virtual ~ScUndoEnterValue() override;
119
120 virtual void Undo() override;
121 virtual void Redo() override;
122 virtual void Repeat(SfxRepeatTarget& rTarget) override;
123 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
124
125 virtual OUString GetComment() const override;
126
127 virtual std::optional<ScRange> getAffectedRange() const override { return aPos; }
128
129private:
132 double nValue;
134
135 void SetChangeTrack();
136};
137
139{
140public:
141 ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, ScCellValue aOldVal, ScCellValue aNewVal );
142
143 virtual ~ScUndoSetCell() override;
144
145 virtual void Undo() override;
146 virtual void Redo() override;
147 virtual void Repeat( SfxRepeatTarget& rTarget ) override;
148 virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override;
149 virtual OUString GetComment() const override;
150
151 virtual std::optional<ScRange> getAffectedRange() const override { return maPos; }
152
153private:
154 void SetChangeTrack();
155 void SetValue( const ScCellValue& rVal );
156 void MoveCursorToCell();
157
158private:
163};
164
166{
167public:
168 ScUndoPageBreak( ScDocShell* pNewDocShell,
169 SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
170 bool bNewColumn, bool bNewInsert );
171 virtual ~ScUndoPageBreak() override;
172
173 virtual void Undo() override;
174 virtual void Redo() override;
175 virtual void Repeat(SfxRepeatTarget& rTarget) override;
176 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
177
178 virtual OUString GetComment() const override;
179
180private:
184 bool bColumn; // Column or row break
185 bool bInsert; // Insert or Delete
186
187 void DoChange( bool bInsert ) const;
188};
189
191{
192public:
193 ScUndoPrintZoom( ScDocShell* pNewDocShell, SCTAB nT,
194 sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP );
195 virtual ~ScUndoPrintZoom() override;
196
197 virtual void Undo() override;
198 virtual void Redo() override;
199 virtual void Repeat(SfxRepeatTarget& rTarget) override;
200 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
201
202 virtual OUString GetComment() const override;
203
204private:
206 sal_uInt16 nOldScale;
207 sal_uInt16 nOldPages;
208 sal_uInt16 nNewScale;
209 sal_uInt16 nNewPages;
210
211 void DoChange( bool bUndo );
212};
213
215{
216public:
217 ScUndoThesaurus( ScDocShell* pNewDocShell,
218 SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
219 ScCellValue aOldText, ScCellValue aNewText );
220 virtual ~ScUndoThesaurus() override;
221
222 virtual void Undo() override;
223 virtual void Redo() override;
224 virtual void Repeat(SfxRepeatTarget& rTarget) override;
225 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
226
227 virtual OUString GetComment() const override;
228
229private:
234
237
238 void DoChange( bool bUndo, const ScCellValue& rText );
239 void SetChangeTrack( const ScCellValue& rOldCell );
240};
241
244{
245public:
246
249 ScDocShell& rDocShell,
250 const ScAddress& rPos,
251 const ScNoteData& rNoteData,
252 bool bInsert,
253 std::unique_ptr<SdrUndoAction> pDrawUndo );
254
257 ScDocShell& rDocShell,
258 const ScAddress& rPos,
259 ScNoteData aOldData,
260 ScNoteData aNewData,
261 std::unique_ptr<SdrUndoAction> pDrawUndo );
262
263 virtual ~ScUndoReplaceNote() override;
264
265 virtual void Undo() override;
266 virtual void Redo() override;
267 virtual void Repeat( SfxRepeatTarget& rTarget ) override;
268 virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override;
269
270 virtual OUString GetComment() const override;
271
272 virtual std::optional<ScRange> getAffectedRange() const override { return maPos; }
273
274private:
275 void DoInsertNote( const ScNoteData& rNoteData );
276 void DoRemoveNote( const ScNoteData& rNoteData );
277
278private:
282 std::unique_ptr<SdrUndoAction> mpDrawUndo;
283};
284
287{
288public:
289 ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow );
290 virtual ~ScUndoShowHideNote() override;
291
292 virtual void Undo() override;
293 virtual void Redo() override;
294 virtual void Repeat( SfxRepeatTarget& rTarget ) override;
295 virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override;
296
297 virtual OUString GetComment() const override;
298
299 virtual std::optional<ScRange> getAffectedRange() const override { return maPos; }
300
301private:
304};
305
307{
308public:
309 ScUndoDetective( ScDocShell* pNewDocShell,
310 std::unique_ptr<SdrUndoAction> pDraw, const ScDetOpData* pOperation,
311 std::unique_ptr<ScDetOpList> pUndoList = nullptr );
312 virtual ~ScUndoDetective() override;
313
314 virtual void Undo() override;
315 virtual void Redo() override;
316 virtual void Repeat(SfxRepeatTarget& rTarget) override;
317 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
318
319 virtual OUString GetComment() const override;
320
321private:
323 std::unique_ptr<ScDetOpList> pOldList;
324 sal_uInt16 nAction;
326 std::unique_ptr<SdrUndoAction> pDrawUndo;
327};
328
330{
331public:
332 //use nTab = -1 for global range names
333 ScUndoRangeNames( ScDocShell* pNewDocShell,
334 std::unique_ptr<ScRangeName> pOld, std::unique_ptr<ScRangeName> pNew , SCTAB nTab);
335 virtual ~ScUndoRangeNames() override;
336
337 virtual void Undo() override;
338 virtual void Redo() override;
339 virtual void Repeat(SfxRepeatTarget& rTarget) override;
340 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
341
342 virtual OUString GetComment() const override;
343
344private:
345 std::unique_ptr<ScRangeName> pOldRanges;
346 std::unique_ptr<ScRangeName> pNewRanges;
348
349 void DoChange( bool bUndo );
350};
351
352namespace sc {
353
355{
359
360 void DoChange( const CellValues& rValues );
361
362public:
363 UndoSetCells( ScDocShell* pDocSh, const ScAddress& rTopPos );
364 virtual ~UndoSetCells() override;
365
366 virtual void Undo() override;
367 virtual void Redo() override;
368
369 virtual bool CanRepeat( SfxRepeatTarget& ) const override;
370 virtual OUString GetComment() const override;
371
373 void SetNewValues( const std::vector<double>& rVals );
374 void SetNewValues( const std::vector<ScFormulaCell*>& rVals );
375};
376
377} // namespace sc
378
379/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< EditTextObject > pOldEditData
Definition: undocell.hxx:64
virtual void Undo() override
Definition: undocell.cxx:142
std::unique_ptr< EditTextObject > pNewEditData
Definition: undocell.hxx:65
void DoChange(const ScPatternAttr *pWhichPattern, const std::unique_ptr< EditTextObject > &pEditData) const
Definition: undocell.cxx:112
virtual void Redo() override
Definition: undocell.cxx:149
ScPatternAttr * pNewPattern
Definition: undocell.hxx:62
ScPatternAttr * pApplyPattern
Definition: undocell.hxx:63
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:162
virtual OUString GetComment() const override
Definition: undocell.cxx:100
virtual ~ScUndoCursorAttr() override
Definition: undocell.cxx:92
ScUndoCursorAttr(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, const ScPatternAttr *pOldPat, const ScPatternAttr *pNewPat, const ScPatternAttr *pApplyPat)
Definition: undocell.cxx:75
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:156
ScPatternAttr * pOldPattern
Definition: undocell.hxx:61
void SetEditData(std::unique_ptr< EditTextObject > pOld, std::unique_ptr< EditTextObject > pNew)
once the objects are passed to this class, their life-cycle is managed by this class; the calling fun...
Definition: undocell.cxx:106
virtual void Redo() override
Definition: undocell.cxx:952
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:977
virtual void Undo() override
Definition: undocell.cxx:915
std::unique_ptr< ScDetOpList > pOldList
Definition: undocell.hxx:323
virtual ~ScUndoDetective() override
Definition: undocell.cxx:893
ScAddress aPos
Definition: undocell.hxx:325
virtual OUString GetComment() const override
Definition: undocell.cxx:899
sal_uInt16 nAction
Definition: undocell.hxx:324
ScUndoDetective(ScDocShell *pNewDocShell, std::unique_ptr< SdrUndoAction > pDraw, const ScDetOpData *pOperation, std::unique_ptr< ScDetOpList > pUndoList=nullptr)
Definition: undocell.cxx:877
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:972
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undocell.hxx:326
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:311
virtual OUString GetComment() const override
Definition: undocell.cxx:183
sal_uLong mnEndChangeAction
Definition: undocell.hxx:104
OUString maNewString
Definition: undocell.hxx:102
virtual void Undo() override
Definition: undocell.cxx:237
ScAddress maPos
Definition: undocell.hxx:105
virtual std::optional< ScRange > getAffectedRange() const override
Definition: undocell.hxx:97
ScUndoEnterData(ScDocShell *pNewDocShell, const ScAddress &rPos, ValuesType &rOldValues, OUString aNewStr, std::unique_ptr< EditTextObject > pObj)
Definition: undocell.cxx:169
void SetChangeTrack()
Definition: undocell.cxx:215
std::unique_ptr< EditTextObject > mpNewEditData
Definition: undocell.hxx:103
std::vector< Value > ValuesType
Definition: undocell.hxx:84
void DoChange() const
Definition: undocell.cxx:188
virtual void Redo() override
Definition: undocell.cxx:273
ValuesType maOldValues
Definition: undocell.hxx:100
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:302
ScCellValue maOldCell
Definition: undocell.hxx:131
ScAddress aPos
Definition: undocell.hxx:130
virtual std::optional< ScRange > getAffectedRange() const override
Definition: undocell.hxx:127
virtual OUString GetComment() const override
Definition: undocell.cxx:331
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:387
virtual void Redo() override
Definition: undocell.cxx:369
void SetChangeTrack()
Definition: undocell.cxx:336
sal_uLong nEndChangeAction
Definition: undocell.hxx:133
ScUndoEnterValue(ScDocShell *pNewDocShell, const ScAddress &rNewPos, ScCellValue aUndoCell, double nVal)
Definition: undocell.cxx:316
virtual ~ScUndoEnterValue() override
Definition: undocell.cxx:327
virtual void Undo() override
Definition: undocell.cxx:351
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:382
virtual OUString GetComment() const override
Definition: undocell.cxx:516
virtual ~ScUndoPageBreak() override
Definition: undocell.cxx:512
ScUndoPageBreak(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, bool bNewColumn, bool bNewInsert)
Definition: undocell.cxx:500
virtual void Undo() override
Definition: undocell.cxx:548
virtual void Redo() override
Definition: undocell.cxx:555
void DoChange(bool bInsert) const
Definition: undocell.cxx:530
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:562
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:575
sal_uInt16 nNewScale
Definition: undocell.hxx:208
virtual ~ScUndoPrintZoom() override
Definition: undocell.cxx:591
void DoChange(bool bUndo)
Definition: undocell.cxx:600
virtual void Undo() override
Definition: undocell.cxx:621
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:635
ScUndoPrintZoom(ScDocShell *pNewDocShell, SCTAB nT, sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP)
Definition: undocell.cxx:580
virtual OUString GetComment() const override
Definition: undocell.cxx:595
virtual void Redo() override
Definition: undocell.cxx:628
sal_uInt16 nOldPages
Definition: undocell.hxx:207
sal_uInt16 nNewPages
Definition: undocell.hxx:209
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:645
sal_uInt16 nOldScale
Definition: undocell.hxx:206
std::unique_ptr< ScRangeName > pOldRanges
Definition: undocell.hxx:345
std::unique_ptr< ScRangeName > pNewRanges
Definition: undocell.hxx:346
virtual void Undo() override
Definition: undocell.cxx:1029
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:1043
void DoChange(bool bUndo)
Definition: undocell.cxx:1002
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:1048
virtual void Redo() override
Definition: undocell.cxx:1036
virtual ~ScUndoRangeNames() override
Definition: undocell.cxx:991
virtual OUString GetComment() const override
Definition: undocell.cxx:997
ScUndoRangeNames(ScDocShell *pNewDocShell, std::unique_ptr< ScRangeName > pOld, std::unique_ptr< ScRangeName > pNew, SCTAB nTab)
Definition: undocell.cxx:982
Undo action for inserting, removing, and replacing a cell note.
Definition: undocell.hxx:244
virtual std::optional< ScRange > getAffectedRange() const override
Definition: undocell.hxx:272
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:796
virtual OUString GetComment() const override
Definition: undocell.cxx:801
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:792
ScNoteData maNewData
Definition: undocell.hxx:281
virtual void Undo() override
Definition: undocell.cxx:766
ScAddress maPos
Definition: undocell.hxx:279
virtual void Redo() override
Definition: undocell.cxx:779
virtual ~ScUndoReplaceNote() override
Definition: undocell.cxx:761
ScUndoReplaceNote(ScDocShell &rDocShell, const ScAddress &rPos, const ScNoteData &rNoteData, bool bInsert, std::unique_ptr< SdrUndoAction > pDrawUndo)
Constructs an undo action for inserting or removing a cell note.
Definition: undocell.cxx:732
ScNoteData maOldData
Definition: undocell.hxx:280
void DoInsertNote(const ScNoteData &rNoteData)
Definition: undocell.cxx:807
void DoRemoveNote(const ScNoteData &rNoteData)
Definition: undocell.cxx:819
std::unique_ptr< SdrUndoAction > mpDrawUndo
Definition: undocell.hxx:282
ScCellValue maNewValue
Definition: undocell.hxx:161
virtual OUString GetComment() const override
Definition: undocell.cxx:435
sal_uLong mnEndChangeAction
Definition: undocell.hxx:162
void SetChangeTrack()
Definition: undocell.cxx:440
virtual void Redo() override
Definition: undocell.cxx:415
void MoveCursorToCell()
Definition: undocell.cxx:490
virtual std::optional< ScRange > getAffectedRange() const override
Definition: undocell.hxx:151
ScAddress maPos
Definition: undocell.hxx:159
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:430
ScCellValue maOldValue
Definition: undocell.hxx:160
virtual void Undo() override
Definition: undocell.cxx:400
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:425
virtual ~ScUndoSetCell() override
Definition: undocell.cxx:398
void SetValue(const ScCellValue &rVal)
Definition: undocell.cxx:457
ScUndoSetCell(ScDocShell *pDocSh, const ScAddress &rPos, ScCellValue aOldVal, ScCellValue aNewVal)
Definition: undocell.cxx:392
Undo action for showing or hiding a cell note caption.
Definition: undocell.hxx:287
virtual OUString GetComment() const override
Definition: undocell.cxx:872
virtual ~ScUndoShowHideNote() override
Definition: undocell.cxx:843
virtual void Redo() override
Definition: undocell.cxx:855
virtual std::optional< ScRange > getAffectedRange() const override
Definition: undocell.hxx:299
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:863
ScUndoShowHideNote(ScDocShell &rDocShell, const ScAddress &rPos, bool bShow)
Definition: undocell.cxx:836
virtual void Undo() override
Definition: undocell.cxx:847
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:867
virtual OUString GetComment() const override
Definition: undocell.cxx:665
virtual void Redo() override
Definition: undocell.cxx:713
sal_uLong nEndChangeAction
Definition: undocell.hxx:233
void SetChangeTrack(const ScCellValue &rOldCell)
Definition: undocell.cxx:670
ScCellValue maNewText
Definition: undocell.hxx:236
ScUndoThesaurus(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, ScCellValue aOldText, ScCellValue aNewText)
Definition: undocell.cxx:650
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:720
virtual void Undo() override
Definition: undocell.cxx:703
ScCellValue maOldText
Definition: undocell.hxx:235
void DoChange(bool bUndo, const ScCellValue &rText)
Definition: undocell.cxx:684
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:726
virtual ~ScUndoThesaurus() override
Definition: undocell.cxx:663
Think of this as a mini-ScColumn like storage that only stores cell values in a column.
Definition: cellvalues.hxx:42
UndoSetCells(ScDocShell *pDocSh, const ScAddress &rTopPos)
Definition: undocell2.cxx:18
CellValues maNewValues
Definition: undocell.hxx:358
virtual void Redo() override
Definition: undocell2.cxx:41
void SetNewValues(const std::vector< double > &rVals)
Definition: undocell2.cxx:59
virtual ~UndoSetCells() override
Definition: undocell2.cxx:21
void DoChange(const CellValues &rValues)
Definition: undocell2.cxx:23
virtual void Undo() override
Definition: undocell2.cxx:34
ScAddress maTopPos
Definition: undocell.hxx:356
virtual OUString GetComment() const override
Definition: undocell2.cxx:53
CellValues maOldValues
Definition: undocell.hxx:357
CellValues & GetOldValues()
Definition: undocell.hxx:372
virtual bool CanRepeat(SfxRepeatTarget &) const override
Definition: undocell2.cxx:48
FilterGroup & rTarget
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
sal_uIntPtr sal_uLong
Store arbitrary cell value of any kind.
Definition: cellvalue.hxx:32
Internal data for a cell annotation.
Definition: postit.hxx:42
ScCellValue maCell
Definition: undocell.hxx:79
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17