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 #ifndef INCLUDED_SC_SOURCE_UI_INC_UNDOCELL_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_UNDOCELL_HXX
22 
23 #include "undobase.hxx"
24 #include <detdata.hxx>
25 #include <postit.hxx>
26 #include <cellvalue.hxx>
27 #include <cellvalues.hxx>
28 #include <editeng/editobj.hxx>
29 
30 #include <memory>
31 
32 class ScDocShell;
33 class ScPatternAttr;
34 class ScRangeName;
35 class ScFormulaCell;
36 
38 {
39 public:
40  ScUndoCursorAttr( ScDocShell* pNewDocShell,
41  SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
42  const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat,
43  const ScPatternAttr* pApplyPat );
44  virtual ~ScUndoCursorAttr() override;
45 
46  virtual void Undo() override;
47  virtual void Redo() override;
48  virtual void Repeat(SfxRepeatTarget& rTarget) override;
49  virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
50 
51  virtual OUString GetComment() const override;
52 
56  void SetEditData( std::unique_ptr<EditTextObject> pOld, std::unique_ptr<EditTextObject> pNew );
57 
58 private:
65  std::unique_ptr<EditTextObject> pOldEditData;
66  std::unique_ptr<EditTextObject> pNewEditData;
67 
68  void DoChange( const ScPatternAttr* pWhichPattern, const std::unique_ptr<EditTextObject>& pEditData ) const;
69 };
70 
72 {
73 public:
74 
75  struct Value
76  {
79  sal_uInt32 mnFormat;
81 
82  Value();
83  };
84 
85  typedef std::vector<Value> ValuesType;
86 
88  ScDocShell* pNewDocShell, const ScAddress& rPos,
89  ValuesType& rOldValues, const OUString& rNewStr, std::unique_ptr<EditTextObject> pObj );
90 
91  virtual void Undo() override;
92  virtual void Redo() override;
93  virtual void Repeat(SfxRepeatTarget& rTarget) override;
94  virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
95 
96  virtual OUString GetComment() const override;
97 
98 private:
99  ValuesType maOldValues;
100 
101  OUString maNewString;
102  std::unique_ptr<EditTextObject> mpNewEditData;
105 
106  void DoChange() const;
107  void SetChangeTrack();
108 };
109 
111 {
112 public:
114  ScDocShell* pNewDocShell, const ScAddress& rNewPos,
115  const ScCellValue& rUndoCell, double nVal );
116 
117  virtual ~ScUndoEnterValue() override;
118 
119  virtual void Undo() override;
120  virtual void Redo() override;
121  virtual void Repeat(SfxRepeatTarget& rTarget) override;
122  virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
123 
124  virtual OUString GetComment() const override;
125 
126 private:
129  double nValue;
131 
132  void SetChangeTrack();
133 };
134 
136 {
137 public:
138  ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rOldVal, const ScCellValue& rNewVal );
139 
140  virtual ~ScUndoSetCell() override;
141 
142  virtual void Undo() override;
143  virtual void Redo() override;
144  virtual void Repeat( SfxRepeatTarget& rTarget ) override;
145  virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override;
146  virtual OUString GetComment() const override;
147 
148 private:
149  void SetChangeTrack();
150  void SetValue( const ScCellValue& rVal );
151  void MoveCursorToCell();
152 
153 private:
158 };
159 
161 {
162 public:
163  ScUndoPageBreak( ScDocShell* pNewDocShell,
164  SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
165  bool bNewColumn, bool bNewInsert );
166  virtual ~ScUndoPageBreak() override;
167 
168  virtual void Undo() override;
169  virtual void Redo() override;
170  virtual void Repeat(SfxRepeatTarget& rTarget) override;
171  virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
172 
173  virtual OUString GetComment() const override;
174 
175 private:
179  bool bColumn; // Column or row break
180  bool bInsert; // Insert or Delete
181 
182  void DoChange( bool bInsert ) const;
183 };
184 
186 {
187 public:
188  ScUndoPrintZoom( ScDocShell* pNewDocShell, SCTAB nT,
189  sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP );
190  virtual ~ScUndoPrintZoom() override;
191 
192  virtual void Undo() override;
193  virtual void Redo() override;
194  virtual void Repeat(SfxRepeatTarget& rTarget) override;
195  virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
196 
197  virtual OUString GetComment() const override;
198 
199 private:
201  sal_uInt16 nOldScale;
202  sal_uInt16 nOldPages;
203  sal_uInt16 nNewScale;
204  sal_uInt16 nNewPages;
205 
206  void DoChange( bool bUndo );
207 };
208 
210 {
211 public:
212  ScUndoThesaurus( ScDocShell* pNewDocShell,
213  SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
214  const ScCellValue& rOldText, const ScCellValue& rNewText );
215  virtual ~ScUndoThesaurus() override;
216 
217  virtual void Undo() override;
218  virtual void Redo() override;
219  virtual void Repeat(SfxRepeatTarget& rTarget) override;
220  virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
221 
222  virtual OUString GetComment() const override;
223 
224 private:
229 
232 
233  void DoChange( bool bUndo, const ScCellValue& rText );
234  void SetChangeTrack( const ScCellValue& rOldCell );
235 };
236 
239 {
240 public:
241 
244  ScDocShell& rDocShell,
245  const ScAddress& rPos,
246  const ScNoteData& rNoteData,
247  bool bInsert,
248  std::unique_ptr<SdrUndoAction> pDrawUndo );
249 
252  ScDocShell& rDocShell,
253  const ScAddress& rPos,
254  const ScNoteData& rOldData,
255  const ScNoteData& rNewData,
256  std::unique_ptr<SdrUndoAction> pDrawUndo );
257 
258  virtual ~ScUndoReplaceNote() override;
259 
260  virtual void Undo() override;
261  virtual void Redo() override;
262  virtual void Repeat( SfxRepeatTarget& rTarget ) override;
263  virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override;
264 
265  virtual OUString GetComment() const override;
266 
267 private:
268  void DoInsertNote( const ScNoteData& rNoteData );
269  void DoRemoveNote( const ScNoteData& rNoteData );
270 
271 private:
275  std::unique_ptr<SdrUndoAction> mpDrawUndo;
276 };
277 
280 {
281 public:
282  ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow );
283  virtual ~ScUndoShowHideNote() override;
284 
285  virtual void Undo() override;
286  virtual void Redo() override;
287  virtual void Repeat( SfxRepeatTarget& rTarget ) override;
288  virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override;
289 
290  virtual OUString GetComment() const override;
291 
292 private:
294  bool mbShown;
295 };
296 
298 {
299 public:
300  ScUndoDetective( ScDocShell* pNewDocShell,
301  std::unique_ptr<SdrUndoAction> pDraw, const ScDetOpData* pOperation,
302  std::unique_ptr<ScDetOpList> pUndoList = nullptr );
303  virtual ~ScUndoDetective() override;
304 
305  virtual void Undo() override;
306  virtual void Redo() override;
307  virtual void Repeat(SfxRepeatTarget& rTarget) override;
308  virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
309 
310  virtual OUString GetComment() const override;
311 
312 private:
313  bool bIsDelete;
314  std::unique_ptr<ScDetOpList> pOldList;
315  sal_uInt16 nAction;
317  std::unique_ptr<SdrUndoAction> pDrawUndo;
318 };
319 
321 {
322 public:
323  //use nTab = -1 for global range names
324  ScUndoRangeNames( ScDocShell* pNewDocShell,
325  std::unique_ptr<ScRangeName> pOld, std::unique_ptr<ScRangeName> pNew , SCTAB nTab);
326  virtual ~ScUndoRangeNames() override;
327 
328  virtual void Undo() override;
329  virtual void Redo() override;
330  virtual void Repeat(SfxRepeatTarget& rTarget) override;
331  virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
332 
333  virtual OUString GetComment() const override;
334 
335 private:
336  std::unique_ptr<ScRangeName> pOldRanges;
337  std::unique_ptr<ScRangeName> pNewRanges;
339 
340  void DoChange( bool bUndo );
341 };
342 
343 namespace sc {
344 
346 {
350 
351  void DoChange( const CellValues& rValues );
352 
353 public:
354  UndoSetCells( ScDocShell* pDocSh, const ScAddress& rTopPos );
355  virtual ~UndoSetCells() override;
356 
357  virtual void Undo() override;
358  virtual void Redo() override;
359 
360  virtual bool CanRepeat( SfxRepeatTarget& ) const override;
361  virtual OUString GetComment() const override;
362 
364  void SetNewValues( const std::vector<double>& rVals );
365  void SetNewValues( const std::vector<ScFormulaCell*>& rVals );
366 };
367 
368 } // namespace sc
369 
370 #endif
371 
372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uLong mnEndChangeAction
Definition: undocell.hxx:157
std::unique_ptr< SdrUndoAction > mpDrawUndo
Definition: undocell.hxx:275
void DoInsertNote(const ScNoteData &rNoteData)
Definition: undocell.cxx:801
ScUndoDetective(ScDocShell *pNewDocShell, std::unique_ptr< SdrUndoAction > pDraw, const ScDetOpData *pOperation, std::unique_ptr< ScDetOpList > pUndoList=nullptr)
Definition: undocell.cxx:871
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undocell.hxx:317
void DoRemoveNote(const ScNoteData &rNoteData)
Definition: undocell.cxx:813
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:861
virtual void Redo() override
Definition: undocell2.cxx:41
UndoSetCells(ScDocShell *pDocSh, const ScAddress &rTopPos)
Definition: undocell2.cxx:18
ScCellValue maOldCell
Definition: undocell.hxx:128
ScCellValue maCell
Definition: undocell.hxx:80
ScUndoShowHideNote(ScDocShell &rDocShell, const ScAddress &rPos, bool bShow)
Definition: undocell.cxx:830
virtual void Redo() override
Definition: undocell.cxx:545
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:152
virtual OUString GetComment() const override
Definition: undocell.cxx:991
sal_uLong nEndChangeAction
Definition: undocell.hxx:130
virtual OUString GetComment() const override
Definition: undocell.cxx:173
ScAddress maTopPos
Definition: undocell.hxx:347
virtual void Redo() override
Definition: undocell.cxx:946
virtual void Undo() override
Definition: undocell.cxx:1023
Think of this as a mini-ScColumn like storage that only stores cell values in a column.
Definition: cellvalues.hxx:42
virtual void Undo() override
Definition: undocell.cxx:611
sal_uIntPtr sal_uLong
std::unique_ptr< EditTextObject > pNewEditData
Definition: undocell.hxx:66
FilterGroup & rTarget
ScUndoEnterValue(ScDocShell *pNewDocShell, const ScAddress &rNewPos, const ScCellValue &rUndoCell, double nVal)
Definition: undocell.cxx:306
ScAddress maPos
Definition: undocell.hxx:272
sal_uInt16 nOldScale
Definition: undocell.hxx:201
virtual void Undo() override
Definition: undocell.cxx:390
std::unique_ptr< EditTextObject > mpNewEditData
Definition: undocell.hxx:102
virtual ~ScUndoThesaurus() override
Definition: undocell.cxx:653
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:377
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:552
CellValues maNewValues
Definition: undocell.hxx:349
ScUndoEnterData(ScDocShell *pNewDocShell, const ScAddress &rPos, ValuesType &rOldValues, const OUString &rNewStr, std::unique_ptr< EditTextObject > pObj)
Definition: undocell.cxx:159
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:301
virtual ~ScUndoPrintZoom() override
Definition: undocell.cxx:581
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:565
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:710
ScUndoSetCell(ScDocShell *pDocSh, const ScAddress &rPos, const ScCellValue &rOldVal, const ScCellValue &rNewVal)
Definition: undocell.cxx:382
std::unique_ptr< ScRangeName > pNewRanges
Definition: undocell.hxx:337
sal_uInt16 nNewPages
Definition: undocell.hxx:204
virtual void Undo() override
Definition: undocell.cxx:909
virtual OUString GetComment() const override
Definition: undocell.cxx:506
virtual void Undo() override
Definition: undocell.cxx:538
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:1042
virtual OUString GetComment() const override
Definition: undocell.cxx:866
ValuesType maOldValues
Definition: undocell.hxx:99
virtual void Redo() override
Definition: undocell.cxx:618
Store arbitrary cell value of any kind.
Definition: cellvalue.hxx:36
ScPatternAttr * pNewPattern
Definition: undocell.hxx:63
sal_uInt16 nAction
Definition: undocell.hxx:315
virtual ~ScUndoSetCell() override
Definition: undocell.cxx:388
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:625
ScAddress aPos
Definition: undocell.hxx:316
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:966
sal_uInt16 nNewScale
Definition: undocell.hxx:203
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:1037
void DoChange(bool bUndo, const ScCellValue &rText)
Definition: undocell.cxx:674
ScUndoRangeNames(ScDocShell *pNewDocShell, std::unique_ptr< ScRangeName > pOld, std::unique_ptr< ScRangeName > pNew, SCTAB nTab)
Definition: undocell.cxx:976
ScUndoThesaurus(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, const ScCellValue &rOldText, const ScCellValue &rNewText)
Definition: undocell.cxx:640
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:790
ScNoteData maOldData
Definition: undocell.hxx:273
virtual ~ScUndoRangeNames() override
Definition: undocell.cxx:985
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:635
virtual ~ScUndoEnterValue() override
Definition: undocell.cxx:317
virtual ~ScUndoPageBreak() override
Definition: undocell.cxx:502
virtual void Redo() override
Definition: undocell.cxx:1030
virtual OUString GetComment() const override
Definition: undocell.cxx:425
Undo action for inserting, removing, and replacing a cell note.
Definition: undocell.hxx:238
void DoChange(const ScPatternAttr *pWhichPattern, const std::unique_ptr< EditTextObject > &pEditData) const
Definition: undocell.cxx:102
void SetChangeTrack()
Definition: undocell.cxx:326
virtual void Undo() override
Definition: undocell.cxx:132
virtual OUString GetComment() const override
Definition: undocell.cxx:655
ScNoteData maNewData
Definition: undocell.hxx:274
ScPatternAttr * pApplyPattern
Definition: undocell.hxx:64
void SetValue(const ScCellValue &rVal)
Definition: undocell.cxx:447
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:971
sal_Int16 SCCOL
Definition: types.hxx:22
void DoChange(bool bUndo)
Definition: undocell.cxx:590
virtual OUString GetComment() const override
Definition: undocell.cxx:585
void SetNewValues(const std::vector< double > &rVals)
Definition: undocell2.cxx:59
virtual ~ScUndoCursorAttr() override
Definition: undocell.cxx:82
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:292
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:722
virtual void Undo() override
Definition: undocell.cxx:227
std::unique_ptr< ScDetOpList > pOldList
Definition: undocell.hxx:314
virtual ~ScUndoShowHideNote() override
Definition: undocell.cxx:837
void DoChange() const
Definition: undocell.cxx:178
std::unique_ptr< ScRangeName > pOldRanges
Definition: undocell.hxx:336
virtual void Undo() override
Definition: undocell.cxx:760
std::vector< Value > ValuesType
Definition: undocell.hxx:85
virtual bool CanRepeat(SfxRepeatTarget &) const override
Definition: undocell2.cxx:48
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:372
sal_uLong nEndChangeAction
Definition: undocell.hxx:228
ScUndoPrintZoom(ScDocShell *pNewDocShell, SCTAB nT, sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP)
Definition: undocell.cxx:570
sal_uLong mnEndChangeAction
Definition: undocell.hxx:103
virtual void Undo() override
Definition: undocell.cxx:693
virtual OUString GetComment() const override
Definition: undocell.cxx:795
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:146
void MoveCursorToCell()
Definition: undocell.cxx:480
ScPatternAttr * pOldPattern
Definition: undocell.hxx:62
void DoChange(bool bInsert) const
Definition: undocell.cxx:520
sal_Int32 SCROW
Definition: types.hxx:18
CellValues maOldValues
Definition: undocell.hxx:348
virtual void Redo() override
Definition: undocell.cxx:139
virtual void Redo() override
Definition: undocell.cxx:405
CellValues & GetOldValues()
Definition: undocell.hxx:363
OUString maNewString
Definition: undocell.hxx:101
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:415
virtual OUString GetComment() const override
Definition: undocell.cxx:321
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:96
Undo action for showing or hiding a cell note caption.
Definition: undocell.hxx:279
virtual OUString GetComment() const override
Definition: undocell.cxx:90
void DoChange(const CellValues &rValues)
Definition: undocell2.cxx:23
Internal data for a cell annotation.
Definition: postit.hxx:144
virtual void Undo() override
Definition: undocell2.cxx:34
void DoChange(bool bUndo)
Definition: undocell.cxx:996
ScCellValue maNewValue
Definition: undocell.hxx:156
ScCellValue maOldText
Definition: undocell.hxx:230
virtual void Undo() override
Definition: undocell.cxx:341
ScAddress aPos
Definition: undocell.hxx:127
ScUndoCursorAttr(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, const ScPatternAttr *pOldPat, const ScPatternAttr *pNewPat, const ScPatternAttr *pApplyPat)
Definition: undocell.cxx:65
virtual OUString GetComment() const override
Definition: undocell2.cxx:53
sal_uInt16 nOldPages
Definition: undocell.hxx:202
virtual void Redo() override
Definition: undocell.cxx:359
ScUndoPageBreak(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, bool bNewColumn, bool bNewInsert)
Definition: undocell.cxx:490
ScCellValue maNewText
Definition: undocell.hxx:231
ScAddress maPos
Definition: undocell.hxx:154
virtual void Redo() override
Definition: undocell.cxx:703
void SetChangeTrack()
Definition: undocell.cxx:430
virtual ~ScUndoDetective() override
Definition: undocell.cxx:887
virtual void Redo() override
Definition: undocell.cxx:773
ScAddress maPos
Definition: undocell.hxx:104
virtual void Undo() override
Definition: undocell.cxx:841
std::unique_ptr< EditTextObject > pOldEditData
Definition: undocell.hxx:65
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:420
ScCellValue maOldValue
Definition: undocell.hxx:155
virtual OUString GetComment() const override
Definition: undocell.cxx:893
void SetChangeTrack(const ScCellValue &rOldCell)
Definition: undocell.cxx:660
virtual ~ScUndoReplaceNote() override
Definition: undocell.cxx:755
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:716
virtual ~UndoSetCells() override
Definition: undocell2.cxx:21
void SetChangeTrack()
Definition: undocell.cxx:205
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:786
sal_Int16 SCTAB
Definition: types.hxx:23
virtual void Redo() override
Definition: undocell.cxx:849
virtual void Redo() override
Definition: undocell.cxx:263
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:857