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