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
29class SdrUndoAction;
30class ScRefUndoData;
31class ScDBData;
32
34{
35 ScSimpleUndo(const ScSimpleUndo&) = delete;
36
37public:
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
46protected:
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{
79public:
80 ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
81 ScBlockUndoMode eBlockMode );
82 virtual ~ScBlockUndo() override;
83
84protected:
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{
100public:
101 ScMultiBlockUndo(ScDocShell* pDocSh, const ScRangeList& rRanges);
102 virtual ~ScMultiBlockUndo() override;
103
104protected:
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{
120protected:
121 std::unique_ptr<ScDBData> pAutoDBRange;
123
124public:
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
134class ScMoveUndo: public ScSimpleUndo // with references
135{
136public:
137 ScMoveUndo( ScDocShell* pDocSh,
138 ScDocumentUniquePtr pRefDoc, std::unique_ptr<ScRefUndoData> pRefData );
139 virtual ~ScMoveUndo() override;
140
141protected:
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
151private:
152 void UndoRef();
153};
154
155class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
156{
157 std::unique_ptr<SfxUndoAction> pWrappedUndo;
159
160public:
161 ScUndoWrapper( std::unique_ptr<SfxUndoAction> pUndo );
162 virtual ~ScUndoWrapper() override;
163
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: */
ScRange aBlockRange
Definition: undobase.hxx:85
bool AdjustHeight()
Definition: undobase.cxx:282
void ShowBlock()
Definition: undobase.cxx:322
void EndRedo()
Definition: undobase.cxx:273
virtual ~ScBlockUndo() override
Definition: undobase.cxx:250
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undobase.hxx:86
void BeginUndo()
Definition: undobase.cxx:255
ScBlockUndoMode eMode
Definition: undobase.hxx:87
void EndUndo()
Definition: undobase.cxx:261
ScBlockUndo(ScDocShell *pDocSh, const ScRange &rRange, ScBlockUndoMode eBlockMode)
Definition: undobase.cxx:241
std::unique_ptr< ScDBData > pAutoDBRange
Definition: undobase.hxx:121
ScDBFuncUndo(ScDocShell *pDocSh, const ScRange &rOriginal)
Definition: undobase.cxx:454
void EndUndo()
Definition: undobase.cxx:472
virtual ~ScDBFuncUndo() override
Definition: undobase.cxx:461
void EndRedo()
Definition: undobase.cxx:541
void BeginUndo()
Definition: undobase.cxx:466
ScRange aOriginalRange
Definition: undobase.hxx:122
void BeginRedo()
Definition: undobase.cxx:504
bool IsPaintLocked() const
Definition: docsh.hxx:326
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undobase.hxx:142
void BeginUndo()
Definition: undobase.cxx:435
virtual ~ScMoveUndo() override
Definition: undobase.cxx:419
ScDocumentUniquePtr pRefUndoDoc
Definition: undobase.hxx:143
void EndUndo()
Definition: undobase.cxx:442
void UndoRef()
Definition: undobase.cxx:426
std::unique_ptr< ScRefUndoData > pRefUndoData
Definition: undobase.hxx:144
ScMoveUndo(ScDocShell *pDocSh, ScDocumentUniquePtr pRefDoc, std::unique_ptr< ScRefUndoData > pRefData)
Definition: undobase.cxx:408
ScRangeList maBlockRanges
Definition: undobase.hxx:105
std::unique_ptr< SdrUndoAction > mpDrawUndo
Definition: undobase.hxx:106
ScSimpleUndo(const ScSimpleUndo &)=delete
std::map< SCTAB, std::unique_ptr< sc::ColumnSpanSet > > DataSpansType
Definition: undobase.hxx:38
std::unique_ptr< SfxUndoAction > pDetectiveUndo
Definition: undobase.hxx:49
ViewShellId mnViewShellId
Definition: undobase.hxx:50
bool IsPaintLocked() const
Definition: undobase.hxx:52
ScDocShell * pDocShell
Definition: undobase.hxx:47
ViewShellId mnViewShellId
Definition: undobase.hxx:158
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undobase.cxx:608
virtual OUString GetRepeatComment(SfxRepeatTarget &) const override
Definition: undobase.cxx:575
std::unique_ptr< SfxUndoAction > pWrappedUndo
Definition: undobase.hxx:157
virtual OUString GetComment() const override
Definition: undobase.cxx:563
void ForgetWrappedUndo()
Definition: undobase.cxx:558
virtual void Redo() override
Definition: undobase.cxx:596
ViewShellId GetViewShellId() const override
See SfxUndoAction::GetViewShellId().
Definition: undobase.cxx:570
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undobase.cxx:602
virtual bool Merge(SfxUndoAction *pNextAction) override
Definition: undobase.cxx:582
SfxUndoAction * GetWrappedUndo()
Definition: undobase.hxx:164
virtual void Undo() override
Definition: undobase.cxx:590
ScUndoWrapper(std::unique_ptr< SfxUndoAction > pUndo)
Definition: undobase.cxx:546
virtual ~ScUndoWrapper() override
Definition: undobase.cxx:554
virtual ViewShellId GetViewShellId() const
virtual bool Merge(SfxUndoAction *pNextAction)
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2715
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
sal_Int16 SCTAB
Definition: types.hxx:22
ScBlockUndoMode
Definition: undobase.hxx:75
@ SC_UNDO_SIMPLE
Definition: undobase.hxx:75
@ SC_UNDO_AUTOHEIGHT
Definition: undobase.hxx:75
@ SC_UNDO_MANUALHEIGHT
Definition: undobase.hxx:75