1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX
25 #include <rtl/ustring.hxx>
26 #include <svl/itemset.hxx>
27 #include <swtypes.hxx>
29 #include <o3tl/sorted_vector.hxx>
37 class SwUndoAttr
: public SwUndo
, private SwUndRng
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 sal_uLong m_nNodeIndex
; // Offset: for Redlining
44 const SetAttrMode m_nInsertFlags
; // insert flags
45 OUString m_aChrFormatName
;
47 void RemoveIdx( SwDoc
& rDoc
);
50 SwUndoAttr( const SwPaM
&, const SfxItemSet
&, const SetAttrMode nFlags
);
51 SwUndoAttr( const SwPaM
&, const SfxPoolItem
&, const SetAttrMode nFlags
);
53 virtual ~SwUndoAttr() override
;
55 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
56 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
57 virtual void RepeatImpl( ::sw::RepeatContext
& ) override
;
59 void SaveRedlineData( const SwPaM
& rPam
, bool bInsContent
);
61 SwHistory
& GetHistory() { return *m_pHistory
; }
64 class SwUndoResetAttr
: public SwUndo
, private SwUndRng
66 const std::unique_ptr
<SwHistory
> m_pHistory
;
67 o3tl::sorted_vector
<sal_uInt16
> m_Ids
;
68 const sal_uInt16 m_nFormatId
; // Format-Id for Redo
71 SwUndoResetAttr( const SwPaM
&, sal_uInt16 nFormatId
);
72 SwUndoResetAttr( const SwPosition
&, sal_uInt16 nFormatId
);
74 virtual ~SwUndoResetAttr() override
;
76 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
77 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
78 virtual void RepeatImpl( ::sw::RepeatContext
& ) override
;
80 void SetAttrs( const o3tl::sorted_vector
<sal_uInt16
> &rAttrs
);
82 SwHistory
& GetHistory() { return *m_pHistory
; }
85 class SwUndoFormatAttr
: public SwUndo
87 friend class SwUndoDefaultAttr
;
88 OUString m_sFormatName
;
89 std::unique_ptr
<SfxItemSet
> m_pOldSet
; // old attributes
90 sal_uLong m_nNodeIndex
;
91 const sal_uInt16 m_nFormatWhich
;
92 const bool m_bSaveDrawPt
;
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
99 // - Anchor attribute isn't restored successfully, if it contains
100 // an invalid anchor position and all other existing attributes
102 // This situation occurs for undo of styles.
103 bool RestoreFlyAnchor(::sw::UndoRedoContext
& rContext
);
104 // --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet>
105 void Init( const SwFormat
& rFormat
);
108 // register at the Format and save old attributes
109 // --> OD 2008-02-27 #refactorlists# - removed <rNewSet>
110 SwUndoFormatAttr( const SfxItemSet
& rOldSet
,
113 SwUndoFormatAttr( const SfxPoolItem
& rItem
,
117 virtual ~SwUndoFormatAttr() override
;
119 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
120 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
121 virtual void RepeatImpl( ::sw::RepeatContext
& ) override
;
123 virtual SwRewriter
GetRewriter() const override
;
125 void PutAttr( const SfxPoolItem
& rItem
, const SwDoc
& rDoc
);
126 SwFormat
* GetFormat( const SwDoc
& rDoc
); // checks if it is still in the Doc!
129 // --> OD 2008-02-12 #newlistlevelattrs#
130 class SwUndoFormatResetAttr
: public SwUndo
133 SwUndoFormatResetAttr( SwFormat
& rChangedFormat
,
134 const sal_uInt16 nWhichId
);
135 virtual ~SwUndoFormatResetAttr() override
;
137 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
138 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
141 // format at which a certain attribute is reset.
142 SwFormat
* const m_pChangedFormat
;
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
;
149 class SwUndoDontExpandFormat
: public SwUndo
151 const sal_uLong m_nNodeIndex
;
152 const sal_Int32 m_nContentIndex
;
155 SwUndoDontExpandFormat( const SwPosition
& rPos
);
157 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
158 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
159 virtual void RepeatImpl( ::sw::RepeatContext
& ) override
;
162 // helper class to receive changed attribute sets
163 class SwUndoFormatAttrHelper final
: public SwClient
166 std::unique_ptr
<SwUndoFormatAttr
> m_pUndo
;
167 const bool m_bSaveDrawPt
;
170 SwUndoFormatAttrHelper(SwFormat
& rFormat
, bool bSaveDrawPt
= true);
172 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
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
); }
179 class SwUndoMoveLeftMargin
: public SwUndo
, private SwUndRng
181 const std::unique_ptr
<SwHistory
> m_pHistory
;
182 const bool m_bModulus
;
185 SwUndoMoveLeftMargin( const SwPaM
&, bool bRight
, bool bModulus
);
187 virtual ~SwUndoMoveLeftMargin() override
;
189 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
190 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
191 virtual void RepeatImpl( ::sw::RepeatContext
& ) override
;
193 SwHistory
& GetHistory() { return *m_pHistory
; }
197 class SwUndoDefaultAttr
: public SwUndo
199 std::unique_ptr
<SfxItemSet
> m_pOldSet
; // the old attributes
200 std::unique_ptr
<SvxTabStopItem
> m_pTabStop
;
203 // registers at the format and saves old attributes
204 SwUndoDefaultAttr( const SfxItemSet
& rOldSet
, const SwDoc
& rDoc
);
206 virtual ~SwUndoDefaultAttr() override
;
208 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
209 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
212 class SwUndoChangeFootNote
: public SwUndo
, private SwUndRng
214 const std::unique_ptr
<SwHistory
> m_pHistory
;
215 const OUString m_Text
;
216 const bool m_bEndNote
;
219 SwUndoChangeFootNote( const SwPaM
& rRange
, const OUString
& rText
,
221 virtual ~SwUndoChangeFootNote() override
;
223 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
224 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
225 virtual void RepeatImpl( ::sw::RepeatContext
& ) override
;
227 SwHistory
& GetHistory() { return *m_pHistory
; }
230 class SwUndoFootNoteInfo
: public SwUndo
232 std::unique_ptr
<SwFootnoteInfo
> m_pFootNoteInfo
;
235 SwUndoFootNoteInfo( const SwFootnoteInfo
&rInfo
, const SwDoc
& rDoc
);
237 virtual ~SwUndoFootNoteInfo() override
;
239 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
240 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
243 class SwUndoEndNoteInfo
: public SwUndo
245 std::unique_ptr
<SwEndNoteInfo
> m_pEndNoteInfo
;
248 SwUndoEndNoteInfo( const SwEndNoteInfo
&rInfo
, const SwDoc
& rDoc
);
250 virtual ~SwUndoEndNoteInfo() override
;
252 virtual void UndoImpl( ::sw::UndoRedoContext
& ) override
;
253 virtual void RedoImpl( ::sw::UndoRedoContext
& ) override
;
256 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOATTRIBUTE_HXX
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */