LibreOffice Module sw (master) 1
UndoAttribute.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_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX
21#define INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX
22
23#include <undobj.hxx>
24#include <memory>
25#include <rtl/ustring.hxx>
26#include <svl/itemset.hxx>
27#include <swtypes.hxx>
28#include <calbck.hxx>
30
31class SvxTabStopItem;
32class SwFormat;
33class SwFootnoteInfo;
34class SwEndNoteInfo;
35class SwDoc;
36
37class SwUndoAttr final : public SwUndo, private SwUndRng
38{
39 SfxItemSet m_AttrSet; // attributes for Redo
40 const std::unique_ptr<SwHistory> m_pHistory; // History for Undo
41 std::unique_ptr<SwRedlineData> m_pRedlineData; // Redlining
42 std::unique_ptr<SwRedlineSaveDatas> m_pRedlineSaveData;
43 SwNodeOffset m_nNodeIndex; // Offset: for Redlining
44 const SetAttrMode m_nInsertFlags; // insert flags
46
47 void RemoveIdx( SwDoc& rDoc );
48
49public:
50 SwUndoAttr( const SwPaM&, SfxItemSet, const SetAttrMode nFlags );
51 SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags );
52
53 virtual ~SwUndoAttr() override;
54
55 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
56 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
57 virtual void RepeatImpl( ::sw::RepeatContext & ) override;
58
59 void SaveRedlineData( const SwPaM& rPam, bool bInsContent );
60
62};
63
64class SwUndoResetAttr final : public SwUndo, private SwUndRng
65{
66 const std::unique_ptr<SwHistory> m_pHistory;
68 const sal_uInt16 m_nFormatId; // Format-Id for Redo
69
70public:
71 SwUndoResetAttr( const SwPaM&, sal_uInt16 nFormatId );
72 SwUndoResetAttr( const SwPosition&, sal_uInt16 nFormatId );
73
74 virtual ~SwUndoResetAttr() override;
75
76 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
77 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
78 virtual void RepeatImpl( ::sw::RepeatContext & ) override;
79
81
83};
84
85class SwUndoFormatAttr final : public SwUndo
86{
87 friend class SwUndoDefaultAttr;
88 OUString m_sFormatName;
89 std::optional<SfxItemSet> m_oOldSet; // old attributes
91 const sal_uInt16 m_nFormatWhich;
92 const bool m_bSaveDrawPt;
93
94 void SaveFlyAnchor( const SwFormat * pFormat, bool bSaveDrawPt = false );
95 // #i35443# - Add return value, type <bool>.
96 // Return value indicates, if anchor attribute is restored.
97 // Notes: - If anchor attribute is restored, all other existing attributes
98 // are also restored.
99 // - Anchor attribute isn't restored successfully, if it contains
100 // an invalid anchor position and all other existing attributes
101 // aren't restored.
102 // This situation occurs for undo of styles.
104 // --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet>
105 void Init( const SwFormat & rFormat );
106
107public:
108 // register at the Format and save old attributes
109 // --> OD 2008-02-27 #refactorlists# - removed <rNewSet>
110 SwUndoFormatAttr( SfxItemSet&& rOldSet,
111 SwFormat& rFormat,
112 bool bSaveDrawPt );
113 SwUndoFormatAttr( const SfxPoolItem& rItem,
114 SwFormat& rFormat,
115 bool bSaveDrawPt );
116
117 virtual ~SwUndoFormatAttr() override;
118
119 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
120 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
121 virtual void RepeatImpl( ::sw::RepeatContext & ) override;
122
123 virtual SwRewriter GetRewriter() const override;
124
125 void PutAttr( const SfxPoolItem& rItem, const SwDoc& rDoc );
126 SwFormat* GetFormat( const SwDoc& rDoc ); // checks if it is still in the Doc!
127};
128
129// --> OD 2008-02-12 #newlistlevelattrs#
130class SwUndoFormatResetAttr final : public SwUndo
131{
132 public:
133 SwUndoFormatResetAttr( SwFormat& rChangedFormat,
134 const sal_uInt16 nWhichId );
135 virtual ~SwUndoFormatResetAttr() override;
136
137 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
138 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
139
140 private:
141 // format at which a certain attribute is reset.
143 // which ID of the reset attribute
144 const sal_uInt16 m_nWhichId;
145 // old attribute which has been reset - needed for undo.
146 std::unique_ptr<SfxPoolItem> m_pOldItem;
147};
148
149class SwUndoDontExpandFormat final : public SwUndo
150{
152 const sal_Int32 m_nContentIndex;
153
154public:
155 SwUndoDontExpandFormat( const SwPosition& rPos );
156
157 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
158 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
159 virtual void RepeatImpl( ::sw::RepeatContext & ) override;
160};
161
162// helper class to receive changed attribute sets
164{
166 std::unique_ptr<SwUndoFormatAttr> m_pUndo;
167 const bool m_bSaveDrawPt;
168
169public:
170 SwUndoFormatAttrHelper(SwFormat& rFormat, bool bSaveDrawPt = true);
171
172 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
173
174 SwUndoFormatAttr* GetUndo() const { return m_pUndo.get(); }
175 // release the undo object (so it is not deleted here), and return it
176 std::unique_ptr<SwUndoFormatAttr> ReleaseUndo() { return std::move(m_pUndo); }
177};
178
179class SwUndoMoveLeftMargin final : public SwUndo, private SwUndRng
180{
181 const std::unique_ptr<SwHistory> m_pHistory;
182 const bool m_bModulus;
183
184public:
185 SwUndoMoveLeftMargin( const SwPaM&, bool bRight, bool bModulus );
186
187 virtual ~SwUndoMoveLeftMargin() override;
188
189 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
190 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
191 virtual void RepeatImpl( ::sw::RepeatContext & ) override;
192
194
195};
196
197class SwUndoDefaultAttr final : public SwUndo
198{
199 std::optional<SfxItemSet> m_oOldSet; // the old attributes
200 std::unique_ptr<SvxTabStopItem> m_pTabStop;
201
202public:
203 // registers at the format and saves old attributes
204 SwUndoDefaultAttr( const SfxItemSet& rOldSet, const SwDoc& rDoc );
205
206 virtual ~SwUndoDefaultAttr() override;
207
208 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
209 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
210};
211
212class SwUndoChangeFootNote final : public SwUndo, private SwUndRng
213{
214 const std::unique_ptr<SwHistory> m_pHistory;
215 const OUString m_Text;
216 const bool m_bEndNote;
217
218public:
219 SwUndoChangeFootNote( const SwPaM& rRange, OUString aText,
220 bool bIsEndNote );
221 virtual ~SwUndoChangeFootNote() override;
222
223 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
224 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
225 virtual void RepeatImpl( ::sw::RepeatContext & ) override;
226
228};
229
230class SwUndoFootNoteInfo final : public SwUndo
231{
232 std::unique_ptr<SwFootnoteInfo> m_pFootNoteInfo;
233
234public:
235 SwUndoFootNoteInfo( const SwFootnoteInfo &rInfo, const SwDoc& rDoc );
236
237 virtual ~SwUndoFootNoteInfo() override;
238
239 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
240 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
241};
242
243class SwUndoEndNoteInfo final : public SwUndo
244{
245 std::unique_ptr<SwEndNoteInfo> m_pEndNoteInfo;
246
247public:
248 SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo, const SwDoc& rDoc );
249
250 virtual ~SwUndoEndNoteInfo() override;
251
252 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
253 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
254};
255
256#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX
257
258/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:192
Base class for various Writer styles.
Definition: format.hxx:47
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
SfxItemSet m_AttrSet
SwNodeOffset m_nNodeIndex
void RemoveIdx(SwDoc &rDoc)
Definition: unattr.cxx:805
const std::unique_ptr< SwHistory > m_pHistory
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:766
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:715
SwUndoAttr(const SwPaM &, SfxItemSet, const SetAttrMode nFlags)
Definition: unattr.cxx:673
void SaveRedlineData(const SwPaM &rPam, bool bInsContent)
Definition: unattr.cxx:695
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unattr.cxx:752
OUString m_aChrFormatName
std::unique_ptr< SwRedlineSaveDatas > m_pRedlineSaveData
virtual ~SwUndoAttr() override
Definition: unattr.cxx:691
SwHistory & GetHistory()
std::unique_ptr< SwRedlineData > m_pRedlineData
const SetAttrMode m_nInsertFlags
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:949
const std::unique_ptr< SwHistory > m_pHistory
SwUndoChangeFootNote(const SwPaM &rRange, OUString aText, bool bIsEndNote)
Definition: unattr.cxx:935
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:961
virtual ~SwUndoChangeFootNote() override
Definition: unattr.cxx:945
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unattr.cxx:969
SwHistory & GetHistory()
const OUString m_Text
std::optional< SfxItemSet > m_oOldSet
SwUndoDefaultAttr(const SfxItemSet &rOldSet, const SwDoc &rDoc)
Definition: unattr.cxx:846
virtual ~SwUndoDefaultAttr() override
Definition: unattr.cxx:862
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:889
std::unique_ptr< SvxTabStopItem > m_pTabStop
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:866
const sal_Int32 m_nContentIndex
const SwNodeOffset m_nNodeIndex
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:1044
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:1034
SwUndoDontExpandFormat(const SwPosition &rPos)
Definition: unattr.cxx:1027
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unattr.cxx:1054
std::unique_ptr< SwEndNoteInfo > m_pEndNoteInfo
SwUndoEndNoteInfo(const SwEndNoteInfo &rInfo, const SwDoc &rDoc)
Definition: unattr.cxx:1001
virtual ~SwUndoEndNoteInfo() override
Definition: unattr.cxx:1007
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:1011
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:1019
std::unique_ptr< SwFootnoteInfo > m_pFootNoteInfo
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:993
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:985
virtual ~SwUndoFootNoteInfo() override
Definition: unattr.cxx:981
SwUndoFootNoteInfo(const SwFootnoteInfo &rInfo, const SwDoc &rDoc)
Definition: unattr.cxx:975
std::unique_ptr< SwUndoFormatAttr > m_pUndo
SwUndoFormatAttr * GetUndo() const
std::unique_ptr< SwUndoFormatAttr > ReleaseUndo()
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: unattr.cxx:66
SwUndoFormatAttrHelper(SwFormat &rFormat, bool bSaveDrawPt=true)
Definition: unattr.cxx:59
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:264
const sal_uInt16 m_nFormatWhich
SwUndoFormatAttr(SfxItemSet &&rOldSet, SwFormat &rFormat, bool bSaveDrawPt)
Definition: unattr.cxx:95
bool RestoreFlyAnchor(::sw::UndoRedoContext &rContext)
Definition: unattr.cxx:389
void SaveFlyAnchor(const SwFormat *pFormat, bool bSaveDrawPt=false)
Definition: unattr.cxx:350
void Init(const SwFormat &rFormat)
Definition: unattr.cxx:126
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unattr.cxx:271
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: unattr.cxx:327
SwFormat * GetFormat(const SwDoc &rDoc)
Definition: unattr.cxx:207
SwNodeOffset m_nNodeIndex
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:158
OUString m_sFormatName
std::optional< SfxItemSet > m_oOldSet
virtual ~SwUndoFormatAttr() override
Definition: unattr.cxx:154
const bool m_bSaveDrawPt
void PutAttr(const SfxPoolItem &rItem, const SwDoc &rDoc)
Definition: unattr.cxx:336
SwUndoFormatResetAttr(SwFormat &rChangedFormat, const sal_uInt16 nWhichId)
Definition: unattr.cxx:511
std::unique_ptr< SfxPoolItem > m_pOldItem
virtual ~SwUndoFormatResetAttr() override
Definition: unattr.cxx:523
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:527
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:535
SwFormat *const m_pChangedFormat
const sal_uInt16 m_nWhichId
virtual ~SwUndoMoveLeftMargin() override
Definition: unattr.cxx:903
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:907
const std::unique_ptr< SwHistory > m_pHistory
SwUndoMoveLeftMargin(const SwPaM &, bool bRight, bool bModulus)
Definition: unattr.cxx:894
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unattr.cxx:928
SwHistory & GetHistory()
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:918
void SetAttrs(o3tl::sorted_vector< sal_uInt16 > &&rAttrs)
Definition: unattr.cxx:648
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:563
const std::unique_ptr< SwHistory > m_pHistory
SwUndoResetAttr(const SwPaM &, sal_uInt16 nFormatId)
Definition: unattr.cxx:543
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unattr.cxx:629
SwHistory & GetHistory()
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unattr.cxx:580
virtual ~SwUndoResetAttr() override
Definition: unattr.cxx:559
o3tl::sorted_vector< sal_uInt16 > m_Ids
const sal_uInt16 m_nFormatId
Marks a position in the document model.
Definition: pam.hxx:37
SetAttrMode
Definition: swtypes.hxx:133