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 
31 class ScDocShell;
32 class ScPatternAttr;
33 class ScRangeName;
34 class ScFormulaCell;
35 
37 {
38 public:
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 
57 private:
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 {
72 public:
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 
97 private:
98  ValuesType maOldValues;
99 
100  OUString maNewString;
101  std::unique_ptr<EditTextObject> mpNewEditData;
104 
105  void DoChange() const;
106  void SetChangeTrack();
107 };
108 
110 {
111 public:
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 
125 private:
128  double nValue;
130 
131  void SetChangeTrack();
132 };
133 
135 {
136 public:
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 
147 private:
148  void SetChangeTrack();
149  void SetValue( const ScCellValue& rVal );
150  void MoveCursorToCell();
151 
152 private:
157 };
158 
160 {
161 public:
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 
174 private:
178  bool bColumn; // Column or row break
179  bool bInsert; // Insert or Delete
180 
181  void DoChange( bool bInsert ) const;
182 };
183 
185 {
186 public:
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 
198 private:
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 {
210 public:
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 
223 private:
228 
231 
232  void DoChange( bool bUndo, const ScCellValue& rText );
233  void SetChangeTrack( const ScCellValue& rOldCell );
234 };
235 
238 {
239 public:
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 
266 private:
267  void DoInsertNote( const ScNoteData& rNoteData );
268  void DoRemoveNote( const ScNoteData& rNoteData );
269 
270 private:
274  std::unique_ptr<SdrUndoAction> mpDrawUndo;
275 };
276 
279 {
280 public:
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 
291 private:
293  bool mbShown;
294 };
295 
297 {
298 public:
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 
311 private:
312  bool bIsDelete;
313  std::unique_ptr<ScDetOpList> pOldList;
314  sal_uInt16 nAction;
316  std::unique_ptr<SdrUndoAction> pDrawUndo;
317 };
318 
320 {
321 public:
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 
334 private:
335  std::unique_ptr<ScRangeName> pOldRanges;
336  std::unique_ptr<ScRangeName> pNewRanges;
338 
339  void DoChange( bool bUndo );
340 };
341 
342 namespace sc {
343 
345 {
349 
350  void DoChange( const CellValues& rValues );
351 
352 public:
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: */
sal_uLong mnEndChangeAction
Definition: undocell.hxx:156
std::unique_ptr< SdrUndoAction > mpDrawUndo
Definition: undocell.hxx:274
void DoInsertNote(const ScNoteData &rNoteData)
Definition: undocell.cxx:802
ScUndoDetective(ScDocShell *pNewDocShell, std::unique_ptr< SdrUndoAction > pDraw, const ScDetOpData *pOperation, std::unique_ptr< ScDetOpList > pUndoList=nullptr)
Definition: undocell.cxx:872
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undocell.hxx:316
void DoRemoveNote(const ScNoteData &rNoteData)
Definition: undocell.cxx:814
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:862
virtual void Redo() override
Definition: undocell2.cxx:41
UndoSetCells(ScDocShell *pDocSh, const ScAddress &rTopPos)
Definition: undocell2.cxx:18
ScCellValue maOldCell
Definition: undocell.hxx:127
ScCellValue maCell
Definition: undocell.hxx:79
ScUndoShowHideNote(ScDocShell &rDocShell, const ScAddress &rPos, bool bShow)
Definition: undocell.cxx:831
virtual void Redo() override
Definition: undocell.cxx:546
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:153
virtual OUString GetComment() const override
Definition: undocell.cxx:992
sal_uLong nEndChangeAction
Definition: undocell.hxx:129
virtual OUString GetComment() const override
Definition: undocell.cxx:174
ScAddress maTopPos
Definition: undocell.hxx:346
virtual void Redo() override
Definition: undocell.cxx:947
virtual void Undo() override
Definition: undocell.cxx:1024
Think of this as a mini-ScColumn like storage that only stores cell values in a column.
Definition: cellvalues.hxx:40
virtual void Undo() override
Definition: undocell.cxx:612
sal_uIntPtr sal_uLong
std::unique_ptr< EditTextObject > pNewEditData
Definition: undocell.hxx:65
FilterGroup & rTarget
ScUndoEnterValue(ScDocShell *pNewDocShell, const ScAddress &rNewPos, const ScCellValue &rUndoCell, double nVal)
Definition: undocell.cxx:307
ScAddress maPos
Definition: undocell.hxx:271
sal_uInt16 nOldScale
Definition: undocell.hxx:200
virtual void Undo() override
Definition: undocell.cxx:391
std::unique_ptr< EditTextObject > mpNewEditData
Definition: undocell.hxx:101
virtual ~ScUndoThesaurus() override
Definition: undocell.cxx:654
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:378
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:553
CellValues maNewValues
Definition: undocell.hxx:348
ScUndoEnterData(ScDocShell *pNewDocShell, const ScAddress &rPos, ValuesType &rOldValues, const OUString &rNewStr, std::unique_ptr< EditTextObject > pObj)
Definition: undocell.cxx:160
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:302
virtual ~ScUndoPrintZoom() override
Definition: undocell.cxx:582
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:566
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:711
ScUndoSetCell(ScDocShell *pDocSh, const ScAddress &rPos, const ScCellValue &rOldVal, const ScCellValue &rNewVal)
Definition: undocell.cxx:383
std::unique_ptr< ScRangeName > pNewRanges
Definition: undocell.hxx:336
sal_uInt16 nNewPages
Definition: undocell.hxx:203
virtual void Undo() override
Definition: undocell.cxx:910
virtual OUString GetComment() const override
Definition: undocell.cxx:507
virtual void Undo() override
Definition: undocell.cxx:539
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:1043
virtual OUString GetComment() const override
Definition: undocell.cxx:867
ValuesType maOldValues
Definition: undocell.hxx:98
virtual void Redo() override
Definition: undocell.cxx:619
Store arbitrary cell value of any kind.
Definition: cellvalue.hxx:35
ScPatternAttr * pNewPattern
Definition: undocell.hxx:62
sal_uInt16 nAction
Definition: undocell.hxx:314
virtual ~ScUndoSetCell() override
Definition: undocell.cxx:389
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:626
ScAddress aPos
Definition: undocell.hxx:315
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:967
sal_uInt16 nNewScale
Definition: undocell.hxx:202
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:1038
void DoChange(bool bUndo, const ScCellValue &rText)
Definition: undocell.cxx:675
ScUndoRangeNames(ScDocShell *pNewDocShell, std::unique_ptr< ScRangeName > pOld, std::unique_ptr< ScRangeName > pNew, SCTAB nTab)
Definition: undocell.cxx:977
ScUndoThesaurus(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, const ScCellValue &rOldText, const ScCellValue &rNewText)
Definition: undocell.cxx:641
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:791
ScNoteData maOldData
Definition: undocell.hxx:272
virtual ~ScUndoRangeNames() override
Definition: undocell.cxx:986
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:636
virtual ~ScUndoEnterValue() override
Definition: undocell.cxx:318
virtual ~ScUndoPageBreak() override
Definition: undocell.cxx:503
virtual void Redo() override
Definition: undocell.cxx:1031
virtual OUString GetComment() const override
Definition: undocell.cxx:426
Undo action for inserting, removing, and replacing a cell note.
Definition: undocell.hxx:237
void DoChange(const ScPatternAttr *pWhichPattern, const std::unique_ptr< EditTextObject > &pEditData) const
Definition: undocell.cxx:103
void SetChangeTrack()
Definition: undocell.cxx:327
virtual void Undo() override
Definition: undocell.cxx:133
virtual OUString GetComment() const override
Definition: undocell.cxx:656
ScNoteData maNewData
Definition: undocell.hxx:273
ScPatternAttr * pApplyPattern
Definition: undocell.hxx:63
void SetValue(const ScCellValue &rVal)
Definition: undocell.cxx:448
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:972
sal_Int16 SCCOL
Definition: types.hxx:21
void DoChange(bool bUndo)
Definition: undocell.cxx:591
virtual OUString GetComment() const override
Definition: undocell.cxx:586
void SetNewValues(const std::vector< double > &rVals)
Definition: undocell2.cxx:59
virtual ~ScUndoCursorAttr() override
Definition: undocell.cxx:83
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:293
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
virtual void Undo() override
Definition: undocell.cxx:228
std::unique_ptr< ScDetOpList > pOldList
Definition: undocell.hxx:313
virtual ~ScUndoShowHideNote() override
Definition: undocell.cxx:838
void DoChange() const
Definition: undocell.cxx:179
std::unique_ptr< ScRangeName > pOldRanges
Definition: undocell.hxx:335
virtual void Undo() override
Definition: undocell.cxx:761
std::vector< Value > ValuesType
Definition: undocell.hxx:84
virtual bool CanRepeat(SfxRepeatTarget &) const override
Definition: undocell2.cxx:48
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:373
sal_uLong nEndChangeAction
Definition: undocell.hxx:227
ScUndoPrintZoom(ScDocShell *pNewDocShell, SCTAB nT, sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP)
Definition: undocell.cxx:571
sal_uLong mnEndChangeAction
Definition: undocell.hxx:102
virtual void Undo() override
Definition: undocell.cxx:694
virtual OUString GetComment() const override
Definition: undocell.cxx:796
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:147
void MoveCursorToCell()
Definition: undocell.cxx:481
ScPatternAttr * pOldPattern
Definition: undocell.hxx:61
void DoChange(bool bInsert) const
Definition: undocell.cxx:521
sal_Int32 SCROW
Definition: types.hxx:17
CellValues maOldValues
Definition: undocell.hxx:347
virtual void Redo() override
Definition: undocell.cxx:140
virtual void Redo() override
Definition: undocell.cxx:406
CellValues & GetOldValues()
Definition: undocell.hxx:362
OUString maNewString
Definition: undocell.hxx:100
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:416
virtual OUString GetComment() const override
Definition: undocell.cxx:322
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
Undo action for showing or hiding a cell note caption.
Definition: undocell.hxx:278
virtual OUString GetComment() const override
Definition: undocell.cxx:91
void DoChange(const CellValues &rValues)
Definition: undocell2.cxx:23
Internal data for a cell annotation.
Definition: postit.hxx:143
virtual void Undo() override
Definition: undocell2.cxx:34
void DoChange(bool bUndo)
Definition: undocell.cxx:997
ScCellValue maNewValue
Definition: undocell.hxx:155
ScCellValue maOldText
Definition: undocell.hxx:229
virtual void Undo() override
Definition: undocell.cxx:342
ScAddress aPos
Definition: undocell.hxx:126
ScUndoCursorAttr(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, const ScPatternAttr *pOldPat, const ScPatternAttr *pNewPat, const ScPatternAttr *pApplyPat)
Definition: undocell.cxx:66
virtual OUString GetComment() const override
Definition: undocell2.cxx:53
sal_uInt16 nOldPages
Definition: undocell.hxx:201
virtual void Redo() override
Definition: undocell.cxx:360
ScUndoPageBreak(ScDocShell *pNewDocShell, SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, bool bNewColumn, bool bNewInsert)
Definition: undocell.cxx:491
ScCellValue maNewText
Definition: undocell.hxx:230
ScAddress maPos
Definition: undocell.hxx:153
virtual void Redo() override
Definition: undocell.cxx:704
void SetChangeTrack()
Definition: undocell.cxx:431
virtual ~ScUndoDetective() override
Definition: undocell.cxx:888
virtual void Redo() override
Definition: undocell.cxx:774
ScAddress maPos
Definition: undocell.hxx:103
virtual void Undo() override
Definition: undocell.cxx:842
std::unique_ptr< EditTextObject > pOldEditData
Definition: undocell.hxx:64
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:421
ScCellValue maOldValue
Definition: undocell.hxx:154
virtual OUString GetComment() const override
Definition: undocell.cxx:894
void SetChangeTrack(const ScCellValue &rOldCell)
Definition: undocell.cxx:661
virtual ~ScUndoReplaceNote() override
Definition: undocell.cxx:756
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undocell.cxx:717
virtual ~UndoSetCells() override
Definition: undocell2.cxx:21
void SetChangeTrack()
Definition: undocell.cxx:206
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:787
sal_Int16 SCTAB
Definition: types.hxx:22
virtual void Redo() override
Definition: undocell.cxx:850
virtual void Redo() override
Definition: undocell.cxx:264
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undocell.cxx:858