LibreOffice Module sc (master)  1
undobase.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_UNDOBASE_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_UNDOBASE_HXX
22 
23 #include <svl/undo.hxx>
24 #include <address.hxx>
25 #include "docsh.hxx"
26 
27 #include <memory>
28 #include <map>
29 
30 class SdrUndoAction;
31 class ScRefUndoData;
32 class ScDBData;
33 
35 {
36  ScSimpleUndo(const ScSimpleUndo&) = delete;
37 
38 public:
39  typedef std::map<SCTAB, std::unique_ptr<sc::ColumnSpanSet>> DataSpansType;
40 
41  ScSimpleUndo( ScDocShell* pDocSh );
42 
43  virtual bool Merge( SfxUndoAction *pNextAction ) override;
45  ViewShellId GetViewShellId() const override;
46 
47 protected:
49  std::unique_ptr<SfxUndoAction>
52 
53  bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
54 
55  bool SetViewMarkData( const ScMarkData& rMarkData );
56 
57  void BeginUndo();
58  void EndUndo();
59  void BeginRedo();
60  void EndRedo();
61 
62  void BroadcastChanges( const ScRange& rRange );
63 
70  void BroadcastChanges( const DataSpansType& rSpans );
71 
72  static void ShowTable( SCTAB nTab );
73  static void ShowTable( const ScRange& rRange );
74 };
75 
77 
79 {
80 public:
81  ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
82  ScBlockUndoMode eBlockMode );
83  virtual ~ScBlockUndo() override;
84 
85 protected:
87  std::unique_ptr<SdrUndoAction> pDrawUndo;
89 
90  void BeginUndo();
91  void EndUndo();
92 // void BeginRedo();
93  void EndRedo();
94 
95  bool AdjustHeight();
96  void ShowBlock();
97 };
98 
100 {
101 public:
102  ScMultiBlockUndo(ScDocShell* pDocSh, const ScRangeList& rRanges);
103  virtual ~ScMultiBlockUndo() override;
104 
105 protected:
107  std::unique_ptr<SdrUndoAction> mpDrawUndo;
108 
109  void BeginUndo();
110  void EndUndo();
111  void EndRedo();
112 
113  void ShowBlock();
114 };
115 
116 // for functions that act on a database range - takes care of the unnamed database range
117 // (collected separately, before the undo action, for showing dialogs etc.)
118 
120 {
121 protected:
122  std::unique_ptr<ScDBData> pAutoDBRange;
124 
125 public:
126  ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal );
127  virtual ~ScDBFuncUndo() override;
128 
129  void BeginUndo();
130  void EndUndo();
131  void BeginRedo();
132  void EndRedo();
133 };
134 
135 class ScMoveUndo: public ScSimpleUndo // with references
136 {
137 public:
138  ScMoveUndo( ScDocShell* pDocSh,
139  ScDocumentUniquePtr pRefDoc, std::unique_ptr<ScRefUndoData> pRefData );
140  virtual ~ScMoveUndo() override;
141 
142 protected:
143  std::unique_ptr<SdrUndoAction> pDrawUndo;
145  std::unique_ptr<ScRefUndoData> pRefUndoData;
146 
147  void BeginUndo();
148  void EndUndo();
149 // void BeginRedo();
150 // void EndRedo();
151 
152 private:
153  void UndoRef();
154 };
155 
156 class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
157 {
158  std::unique_ptr<SfxUndoAction> pWrappedUndo;
160 
161 public:
162  ScUndoWrapper( std::unique_ptr<SfxUndoAction> pUndo );
163  virtual ~ScUndoWrapper() override;
164 
165  SfxUndoAction* GetWrappedUndo() { return pWrappedUndo.get(); }
166  void ForgetWrappedUndo();
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  virtual bool Merge( SfxUndoAction *pNextAction ) override;
173  virtual OUString GetComment() const override;
174  virtual OUString GetRepeatComment(SfxRepeatTarget&) const override;
176  ViewShellId GetViewShellId() const override;
177 };
178 
179 #endif
180 
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undobase.hxx:87
ScRange aOriginalRange
Definition: undobase.hxx:123
void EndUndo()
Definition: undobase.cxx:472
ScSimpleUndo(const ScSimpleUndo &)=delete
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
ViewShellId GetViewShellId() const override
See SfxUndoAction::GetViewShellId().
Definition: undobase.cxx:570
ViewShellId mnViewShellId
Definition: undobase.hxx:51
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undobase.cxx:602
virtual bool Merge(SfxUndoAction *pNextAction) override
Definition: undobase.cxx:65
ScBlockUndo(ScDocShell *pDocSh, const ScRange &rRange, ScBlockUndoMode eBlockMode)
Definition: undobase.cxx:241
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undobase.hxx:143
void BeginUndo()
Definition: undobase.cxx:255
bool SetViewMarkData(const ScMarkData &rMarkData)
Definition: undobase.cxx:52
void EndUndo()
Definition: undobase.cxx:122
virtual ~ScUndoWrapper() override
Definition: undobase.cxx:554
static void ShowTable(SCTAB nTab)
Definition: undobase.cxx:221
ScMultiBlockUndo(ScDocShell *pDocSh, const ScRangeList &rRanges)
Definition: undobase.cxx:343
ScRange aBlockRange
Definition: undobase.hxx:86
bool AdjustHeight()
Definition: undobase.cxx:282
void EndUndo()
Definition: undobase.cxx:442
SfxUndoAction * GetWrappedUndo()
Definition: undobase.hxx:165
std::unique_ptr< SfxUndoAction > pDetectiveUndo
Definition: undobase.hxx:50
std::unique_ptr< SfxUndoAction > pWrappedUndo
Definition: undobase.hxx:158
void BeginUndo()
Definition: undobase.cxx:466
void BeginRedo()
Definition: undobase.cxx:142
virtual void Redo() override
Definition: undobase.cxx:596
ScBlockUndoMode
Definition: undobase.hxx:76
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2613
ScDocShell * pDocShell
Definition: undobase.hxx:48
ViewShellId mnViewShellId
Definition: undobase.hxx:159
ScDocumentUniquePtr pRefUndoDoc
Definition: undobase.hxx:144
ViewShellId GetViewShellId() const override
See SfxUndoAction::GetViewShellId().
Definition: undobase.cxx:47
void EndRedo()
Definition: undobase.cxx:541
ScBlockUndoMode eMode
Definition: undobase.hxx:88
ScMoveUndo(ScDocShell *pDocSh, ScDocumentUniquePtr pRefDoc, std::unique_ptr< ScRefUndoData > pRefData)
Definition: undobase.cxx:408
ScDBFuncUndo(ScDocShell *pDocSh, const ScRange &rOriginal)
Definition: undobase.cxx:454
bool IsPaintLocked() const
Definition: undobase.hxx:53
bool IsPaintLocked() const
Definition: docsh.hxx:320
void BeginUndo()
Definition: undobase.cxx:435
void ShowBlock()
Definition: undobase.cxx:322
virtual OUString GetComment() const override
Definition: undobase.cxx:563
virtual OUString GetRepeatComment(SfxRepeatTarget &) const override
Definition: undobase.cxx:575
std::map< SCTAB, std::unique_ptr< sc::ColumnSpanSet > > DataSpansType
Definition: undobase.hxx:39
virtual ~ScMultiBlockUndo() override
Definition: undobase.cxx:351
ScRangeList maBlockRanges
Definition: undobase.hxx:106
virtual bool Merge(SfxUndoAction *pNextAction) override
Definition: undobase.cxx:582
virtual ~ScDBFuncUndo() override
Definition: undobase.cxx:461
void EndUndo()
Definition: undobase.cxx:261
std::unique_ptr< SdrUndoAction > mpDrawUndo
Definition: undobase.hxx:107
std::unique_ptr< ScDBData > pAutoDBRange
Definition: undobase.hxx:122
void EndRedo()
Definition: undobase.cxx:273
std::unique_ptr< ScRefUndoData > pRefUndoData
Definition: undobase.hxx:145
void UndoRef()
Definition: undobase.cxx:426
void BroadcastChanges(const ScRange &rRange)
Definition: undobase.cxx:174
void ForgetWrappedUndo()
Definition: undobase.cxx:558
virtual ~ScBlockUndo() override
Definition: undobase.cxx:250
void BeginRedo()
Definition: undobase.cxx:504
ScUndoWrapper(std::unique_ptr< SfxUndoAction > pUndo)
Definition: undobase.cxx:546
void EndRedo()
Definition: undobase.cxx:151
virtual ~ScMoveUndo() override
Definition: undobase.cxx:419
virtual void Undo() override
Definition: undobase.cxx:590
sal_Int16 SCTAB
Definition: types.hxx:23
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undobase.cxx:608
void BeginUndo()
Definition: undobase.cxx:87