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, const OUString& rNewStr, 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
97private:
99
100 OUString maNewString;
101 std::unique_ptr<EditTextObject> mpNewEditData;
104
105 void DoChange() const;
106 void SetChangeTrack();
107};
108
110{
111public:
113 ScDocShell* pNewDocShell, const ScAddress& rNewPos,
114 const ScCellValue& rUndoCell, double nVal );
115
116 virtual ~ScUndoEnterValue() override;
117
118 virtual void Undo() override;
119 virtual void Redo() override;
120 virtual void Repeat(SfxRepeatTarget& rTarget) override;
121 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
122
123 virtual OUString GetComment() const override;
124
125private:
128 double nValue;
130
131 void SetChangeTrack();
132};
133
135{
136public:
137 ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rOldVal, const ScCellValue& rNewVal );
138
139 virtual ~ScUndoSetCell() override;
140
141 virtual void Undo() override;
142 virtual void Redo() override;
143 virtual void Repeat( SfxRepeatTarget& rTarget ) override;
144 virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override;
145 virtual OUString GetComment() const override;
146
147private:
148 void SetChangeTrack();
149 void SetValue( const ScCellValue& rVal );
150 void MoveCursorToCell();
151
152private:
157};
158
160{
161public:
162 ScUndoPageBreak( ScDocShell* pNewDocShell,
163 SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
164 bool bNewColumn, bool bNewInsert );
165 virtual ~ScUndoPageBreak() override;
166
167 virtual void Undo() override;
168 virtual void Redo() override;
169 virtual void Repeat(SfxRepeatTarget& rTarget) override;
170 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
171
172 virtual OUString GetComment() const override;
173
174private:
178 bool bColumn; // Column or row break
179 bool bInsert; // Insert or Delete
180
181 void DoChange( bool bInsert ) const;
182};
183
185{
186public:
187 ScUndoPrintZoom( ScDocShell* pNewDocShell, SCTAB nT,
188 sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP );
189 virtual ~ScUndoPrintZoom() override;
190
191 virtual void Undo() override;
192 virtual void Redo() override;
193 virtual void Repeat(SfxRepeatTarget& rTarget) override;
194 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
195
196 virtual OUString GetComment() const override;
197
198private:
200 sal_uInt16 nOldScale;
201 sal_uInt16 nOldPages;
202 sal_uInt16 nNewScale;
203 sal_uInt16 nNewPages;
204
205 void DoChange( bool bUndo );
206};
207
209{
210public:
211 ScUndoThesaurus( ScDocShell* pNewDocShell,
212 SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
213 const ScCellValue& rOldText, const ScCellValue& rNewText );
214 virtual ~ScUndoThesaurus() override;
215
216 virtual void Undo() override;
217 virtual void Redo() override;
218 virtual void Repeat(SfxRepeatTarget& rTarget) override;
219 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
220
221 virtual OUString GetComment() const override;
222
223private:
228
231
232 void DoChange( bool bUndo, const ScCellValue& rText );
233 void SetChangeTrack( const ScCellValue& rOldCell );
234};
235
238{
239public:
240
243 ScDocShell& rDocShell,
244 const ScAddress& rPos,
245 const ScNoteData& rNoteData,
246 bool bInsert,
247 std::unique_ptr<SdrUndoAction> pDrawUndo );
248
251 ScDocShell& rDocShell,
252 const ScAddress& rPos,
253 const ScNoteData& rOldData,
254 const ScNoteData& rNewData,
255 std::unique_ptr<SdrUndoAction> pDrawUndo );
256
257 virtual ~ScUndoReplaceNote() override;
258
259 virtual void Undo() override;
260 virtual void Redo() override;
261 virtual void Repeat( SfxRepeatTarget& rTarget ) override;
262 virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override;
263
264 virtual OUString GetComment() const override;
265
266private:
267 void DoInsertNote( const ScNoteData& rNoteData );
268 void DoRemoveNote( const ScNoteData& rNoteData );
269
270private:
274 std::unique_ptr<SdrUndoAction> mpDrawUndo;
275};
276
279{
280public:
281 ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow );
282 virtual ~ScUndoShowHideNote() override;
283
284 virtual void Undo() override;
285 virtual void Redo() override;
286 virtual void Repeat( SfxRepeatTarget& rTarget ) override;
287 virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override;
288
289 virtual OUString GetComment() const override;
290
291private:
294};
295
297{
298public:
299 ScUndoDetective( ScDocShell* pNewDocShell,
300 std::unique_ptr<SdrUndoAction> pDraw, const ScDetOpData* pOperation,
301 std::unique_ptr<ScDetOpList> pUndoList = nullptr );
302 virtual ~ScUndoDetective() override;
303
304 virtual void Undo() override;
305 virtual void Redo() override;
306 virtual void Repeat(SfxRepeatTarget& rTarget) override;
307 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
308
309 virtual OUString GetComment() const override;
310
311private:
313 std::unique_ptr<ScDetOpList> pOldList;
314 sal_uInt16 nAction;
316 std::unique_ptr<SdrUndoAction> pDrawUndo;
317};
318
320{
321public:
322 //use nTab = -1 for global range names
323 ScUndoRangeNames( ScDocShell* pNewDocShell,
324 std::unique_ptr<ScRangeName> pOld, std::unique_ptr<ScRangeName> pNew , SCTAB nTab);
325 virtual ~ScUndoRangeNames() override;
326
327 virtual void Undo() override;
328 virtual void Redo() override;
329 virtual void Repeat(SfxRepeatTarget& rTarget) override;
330 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
331
332 virtual OUString GetComment() const override;
333
334private:
335 std::unique_ptr<ScRangeName> pOldRanges;
336 std::unique_ptr<ScRangeName> pNewRanges;
338
339 void DoChange( bool bUndo );
340};
341
342namespace sc {
343
345{
349
350 void DoChange( const CellValues& rValues );
351
352public:
353 UndoSetCells( ScDocShell* pDocSh, const ScAddress& rTopPos );
354 virtual ~UndoSetCells() override;
355
356 virtual void Undo() override;
357 virtual void Redo() override;
358
359 virtual bool CanRepeat( SfxRepeatTarget& ) const override;
360 virtual OUString GetComment() const override;
361
363 void SetNewValues( const std::vector<double>& rVals );
364 void SetNewValues( const std::vector<ScFormulaCell*>& rVals );
365};
366
367} // namespace sc
368
369/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< EditTextObject > pOldEditData
Definition: undocell.hxx:64
virtual void Undo() override
Definition: undocell.cxx:133
std::unique_ptr< EditTextObject > pNewEditData
Definition: undocell.hxx:65
void DoChange(const ScPatternAttr *pWhichPattern, const std::unique_ptr< EditTextObject > &pEditData) const
Definition: undocell.cxx:103
virtual void Redo() override
Definition: undocell.cxx:140
ScPatternAttr * pNewPattern
Definition: undocell.hxx:62
ScPatternAttr * pApplyPattern
Definition: undocell.hxx:63
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:153
virtual OUString GetComment() const override
Definition: undocell.cxx:91
virtual ~ScUndoCursorAttr() override
Definition: undocell.cxx:83
ScUndoCursorAttr(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, const ScPatternAttr *pOldPat, const ScPatternAttr *pNewPat, const ScPatternAttr *pApplyPat)
Definition: undocell.cxx:66
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:147
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:97
virtual void Redo() override
Definition: undocell.cxx:947
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:972
virtual void Undo() override
Definition: undocell.cxx:910
std::unique_ptr< ScDetOpList > pOldList
Definition: undocell.hxx:313
virtual ~ScUndoDetective() override
Definition: undocell.cxx:888
ScAddress aPos
Definition: undocell.hxx:315
virtual OUString GetComment() const override
Definition: undocell.cxx:894
sal_uInt16 nAction
Definition: undocell.hxx:314
ScUndoDetective(ScDocShell *pNewDocShell, std::unique_ptr< SdrUndoAction > pDraw, const ScDetOpData *pOperation, std::unique_ptr< ScDetOpList > pUndoList=nullptr)
Definition: undocell.cxx:872
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:967
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undocell.hxx:316
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:302
virtual OUString GetComment() const override
Definition: undocell.cxx:174
sal_uLong mnEndChangeAction
Definition: undocell.hxx:102
ScUndoEnterData(ScDocShell *pNewDocShell, const ScAddress &rPos, ValuesType &rOldValues, const OUString &rNewStr, std::unique_ptr< EditTextObject > pObj)
Definition: undocell.cxx:160
OUString maNewString
Definition: undocell.hxx:100
virtual void Undo() override
Definition: undocell.cxx:228
ScAddress maPos
Definition: undocell.hxx:103
void SetChangeTrack()
Definition: undocell.cxx:206
std::unique_ptr< EditTextObject > mpNewEditData
Definition: undocell.hxx:101
std::vector< Value > ValuesType
Definition: undocell.hxx:84
void DoChange() const
Definition: undocell.cxx:179
virtual void Redo() override
Definition: undocell.cxx:264
ValuesType maOldValues
Definition: undocell.hxx:98
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:293
ScCellValue maOldCell
Definition: undocell.hxx:127
ScAddress aPos
Definition: undocell.hxx:126
virtual OUString GetComment() const override
Definition: undocell.cxx:322
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:378
virtual void Redo() override
Definition: undocell.cxx:360
void SetChangeTrack()
Definition: undocell.cxx:327
sal_uLong nEndChangeAction
Definition: undocell.hxx:129
virtual ~ScUndoEnterValue() override
Definition: undocell.cxx:318
ScUndoEnterValue(ScDocShell *pNewDocShell, const ScAddress &rNewPos, const ScCellValue &rUndoCell, double nVal)
Definition: undocell.cxx:307
virtual void Undo() override
Definition: undocell.cxx:342
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:373
virtual OUString GetComment() const override
Definition: undocell.cxx:507
virtual ~ScUndoPageBreak() override
Definition: undocell.cxx:503
ScUndoPageBreak(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, bool bNewColumn, bool bNewInsert)
Definition: undocell.cxx:491
virtual void Undo() override
Definition: undocell.cxx:539
virtual void Redo() override
Definition: undocell.cxx:546
void DoChange(bool bInsert) const
Definition: undocell.cxx:521
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:553
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:566
sal_uInt16 nNewScale
Definition: undocell.hxx:202
virtual ~ScUndoPrintZoom() override
Definition: undocell.cxx:582
void DoChange(bool bUndo)
Definition: undocell.cxx:591
virtual void Undo() override
Definition: undocell.cxx:612
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:626
ScUndoPrintZoom(ScDocShell *pNewDocShell, SCTAB nT, sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP)
Definition: undocell.cxx:571
virtual OUString GetComment() const override
Definition: undocell.cxx:586
virtual void Redo() override
Definition: undocell.cxx:619
sal_uInt16 nOldPages
Definition: undocell.hxx:201
sal_uInt16 nNewPages
Definition: undocell.hxx:203
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:636
sal_uInt16 nOldScale
Definition: undocell.hxx:200
std::unique_ptr< ScRangeName > pOldRanges
Definition: undocell.hxx:335
std::unique_ptr< ScRangeName > pNewRanges
Definition: undocell.hxx:336
virtual void Undo() override
Definition: undocell.cxx:1024
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:1038
void DoChange(bool bUndo)
Definition: undocell.cxx:997
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:1043
virtual void Redo() override
Definition: undocell.cxx:1031
virtual ~ScUndoRangeNames() override
Definition: undocell.cxx:986
virtual OUString GetComment() const override
Definition: undocell.cxx:992
ScUndoRangeNames(ScDocShell *pNewDocShell, std::unique_ptr< ScRangeName > pOld, std::unique_ptr< ScRangeName > pNew, SCTAB nTab)
Definition: undocell.cxx:977
Undo action for inserting, removing, and replacing a cell note.
Definition: undocell.hxx:238
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:791
virtual OUString GetComment() const override
Definition: undocell.cxx:796
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:787
ScNoteData maNewData
Definition: undocell.hxx:273
virtual void Undo() override
Definition: undocell.cxx:761
ScAddress maPos
Definition: undocell.hxx:271
virtual void Redo() override
Definition: undocell.cxx:774
virtual ~ScUndoReplaceNote() override
Definition: undocell.cxx:756
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:723
ScNoteData maOldData
Definition: undocell.hxx:272
void DoInsertNote(const ScNoteData &rNoteData)
Definition: undocell.cxx:802
void DoRemoveNote(const ScNoteData &rNoteData)
Definition: undocell.cxx:814
std::unique_ptr< SdrUndoAction > mpDrawUndo
Definition: undocell.hxx:274
ScCellValue maNewValue
Definition: undocell.hxx:155
virtual OUString GetComment() const override
Definition: undocell.cxx:426
sal_uLong mnEndChangeAction
Definition: undocell.hxx:156
void SetChangeTrack()
Definition: undocell.cxx:431
virtual void Redo() override
Definition: undocell.cxx:406
void MoveCursorToCell()
Definition: undocell.cxx:481
ScAddress maPos
Definition: undocell.hxx:153
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:421
ScCellValue maOldValue
Definition: undocell.hxx:154
ScUndoSetCell(ScDocShell *pDocSh, const ScAddress &rPos, const ScCellValue &rOldVal, const ScCellValue &rNewVal)
Definition: undocell.cxx:383
virtual void Undo() override
Definition: undocell.cxx:391
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:416
virtual ~ScUndoSetCell() override
Definition: undocell.cxx:389
void SetValue(const ScCellValue &rVal)
Definition: undocell.cxx:448
Undo action for showing or hiding a cell note caption.
Definition: undocell.hxx:279
virtual OUString GetComment() const override
Definition: undocell.cxx:867
virtual ~ScUndoShowHideNote() override
Definition: undocell.cxx:838
virtual void Redo() override
Definition: undocell.cxx:850
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:858
ScUndoShowHideNote(ScDocShell &rDocShell, const ScAddress &rPos, bool bShow)
Definition: undocell.cxx:831
virtual void Undo() override
Definition: undocell.cxx:842
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:862
virtual OUString GetComment() const override
Definition: undocell.cxx:656
virtual void Redo() override
Definition: undocell.cxx:704
sal_uLong nEndChangeAction
Definition: undocell.hxx:227
void SetChangeTrack(const ScCellValue &rOldCell)
Definition: undocell.cxx:661
ScCellValue maNewText
Definition: undocell.hxx:230
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:711
virtual void Undo() override
Definition: undocell.cxx:694
ScUndoThesaurus(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, const ScCellValue &rOldText, const ScCellValue &rNewText)
Definition: undocell.cxx:641
ScCellValue maOldText
Definition: undocell.hxx:229
void DoChange(bool bUndo, const ScCellValue &rText)
Definition: undocell.cxx:675
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:717
virtual ~ScUndoThesaurus() override
Definition: undocell.cxx:654
Think of this as a mini-ScColumn like storage that only stores cell values in a column.
Definition: cellvalues.hxx:41
UndoSetCells(ScDocShell *pDocSh, const ScAddress &rTopPos)
Definition: undocell2.cxx:18
CellValues maNewValues
Definition: undocell.hxx:348
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:346
virtual OUString GetComment() const override
Definition: undocell2.cxx:53
CellValues maOldValues
Definition: undocell.hxx:347
CellValues & GetOldValues()
Definition: undocell.hxx:362
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.
sal_uIntPtr sal_uLong
Store arbitrary cell value of any kind.
Definition: cellvalue.hxx:32
Internal data for a cell annotation.
Definition: postit.hxx:145
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