Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/editeng/source/editeng/editundo.hxx
Line
Count
Source
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 <editdoc.hxx>
23
#include <editeng/editund2.hxx>
24
#include <editeng/EPaM.hxx>
25
#include <editeng/ESelection.hxx>
26
#include <editeng/editobj.hxx>
27
#include <vector>
28
#include <memory>
29
30
class EditEngine;
31
enum class SetAttribsMode;
32
enum class TransliterationFlags;
33
34
// EditUndoDelContent
35
36
class EditUndoDelContent : public EditUndo
37
{
38
private:
39
    sal_Int32 nNode;
40
    std::unique_ptr<ContentNode> mpContentNode;   // Points to the valid, undestroyed object!
41
public:
42
    EditUndoDelContent(EditEngine* pEE, std::unique_ptr<ContentNode> pNode, sal_Int32 nPortion);
43
    virtual ~EditUndoDelContent() override;
44
45
    virtual void    Undo() override;
46
    virtual void    Redo() override;
47
};
48
49
50
// EditUndoConnectParas
51
52
class EditUndoConnectParas : public EditUndo
53
{
54
private:
55
    sal_Int32       nNode;
56
    sal_uInt16      nSepPos;
57
    SfxItemSet      aLeftParaAttribs;
58
    SfxItemSet      aRightParaAttribs;
59
60
    // 2 Pointers would be nicer but then it would have to be a SfxListener.
61
    OUString        aLeftStyleName;
62
    OUString        aRightStyleName;
63
    SfxStyleFamily  eLeftStyleFamily;
64
    SfxStyleFamily  eRightStyleFamily;
65
66
    bool            bBackward;
67
68
public:
69
    EditUndoConnectParas(EditEngine* pEE, sal_Int32 nNode, sal_uInt16 nSepPos,
70
                         SfxItemSet aLeftParaAttribs, SfxItemSet aRightParaAttribs,
71
                         const SfxStyleSheet* pLeftStyle, const SfxStyleSheet* pRightStyle, bool bBackward);
72
    virtual ~EditUndoConnectParas() override;
73
74
    virtual void    Undo() override;
75
    virtual void    Redo() override;
76
};
77
78
79
// EditUndoSplitPara
80
81
class EditUndoSplitPara : public EditUndo
82
{
83
private:
84
    sal_Int32           nNode;
85
    sal_uInt16          nSepPos;
86
87
public:
88
    EditUndoSplitPara(EditEngine* pEE, sal_Int32 nNode, sal_uInt16 nSepPos);
89
    virtual ~EditUndoSplitPara() override;
90
91
    virtual void    Undo() override;
92
    virtual void    Redo() override;
93
};
94
95
96
// EditUndoInsertChars
97
98
class EditUndoInsertChars : public EditUndo
99
{
100
private:
101
    EPaM            aEPaM;
102
    OUString        aText;
103
104
public:
105
    EditUndoInsertChars(EditEngine* pEE, const EPaM& rEPaM, OUString aStr);
106
107
    virtual void    Undo() override;
108
    virtual void    Redo() override;
109
110
    virtual bool    Merge( SfxUndoAction *pNextAction ) override;
111
};
112
113
114
// EditUndoRemoveChars
115
116
class EditUndoRemoveChars : public EditUndo
117
{
118
private:
119
    EPaM            aEPaM;
120
    OUString        aText;
121
122
public:
123
    EditUndoRemoveChars(EditEngine* pEE, const EPaM& rEPaM, OUString aStr);
124
125
    virtual void    Undo() override;
126
    virtual void    Redo() override;
127
};
128
129
130
// EditUndoInsertFeature
131
132
class EditUndoInsertFeature : public EditUndo
133
{
134
private:
135
    EPaM                           aEPaM;
136
    std::unique_ptr<SfxPoolItem>   pFeature;
137
138
public:
139
    EditUndoInsertFeature(EditEngine* pEE, const EPaM& rEPaM, const SfxPoolItem& rFeature);
140
    virtual ~EditUndoInsertFeature() override;
141
142
    virtual void    Undo() override;
143
    virtual void    Redo() override;
144
};
145
146
147
// EditUndoMoveParagraphs
148
149
class EditUndoMoveParagraphs: public EditUndo
150
{
151
private:
152
    Range           nParagraphs;
153
    sal_Int32       nDest;
154
155
public:
156
    EditUndoMoveParagraphs(EditEngine* pEE, const Range& rParas, sal_Int32 nDest);
157
    virtual ~EditUndoMoveParagraphs() override;
158
159
    virtual void    Undo() override;
160
    virtual void    Redo() override;
161
};
162
163
164
// EditUndoSetStyleSheet
165
166
class EditUndoSetStyleSheet: public EditUndo
167
{
168
private:
169
    sal_Int32       nPara;
170
    OUString        aPrevName;
171
    OUString        aNewName;
172
    SfxStyleFamily  ePrevFamily;
173
    SfxStyleFamily  eNewFamily;
174
    SfxItemSet      aPrevParaAttribs;
175
176
public:
177
    EditUndoSetStyleSheet(EditEngine* pEE, sal_Int32 nPara,
178
        OUString aPrevName, SfxStyleFamily ePrevFamily,
179
        OUString aNewName, SfxStyleFamily eNewFamily,
180
        SfxItemSet aPrevParaAttribs);
181
    virtual ~EditUndoSetStyleSheet() override;
182
183
    virtual void    Undo() override;
184
    virtual void    Redo() override;
185
};
186
187
188
// EditUndoSetParaAttribs
189
190
class EditUndoSetParaAttribs: public EditUndo
191
{
192
private:
193
    sal_Int32       nPara;
194
    SfxItemSet      aPrevItems;
195
    SfxItemSet      aNewItems;
196
197
public:
198
    EditUndoSetParaAttribs(EditEngine* pEE, sal_Int32 nPara, SfxItemSet aPrevItems, SfxItemSet aNewItems);
199
    virtual ~EditUndoSetParaAttribs() override;
200
201
    virtual void    Undo() override;
202
    virtual void    Redo() override;
203
};
204
205
206
// EditUndoSetAttribs
207
208
class EditUndoSetAttribs: public EditUndo
209
{
210
private:
211
    typedef std::vector<std::unique_ptr<ContentAttribsInfo> > InfoArrayType;
212
213
    ESelection          aESel;
214
    SfxItemSet          aNewAttribs;
215
    InfoArrayType       aPrevAttribs;
216
217
    SetAttribsMode      nSpecial;
218
    /// Once the attributes are set / unset, set the selection to the end of the formatted range?
219
    bool m_bSetSelection;
220
    bool                bSetIsRemove;
221
    bool                bRemoveParaAttribs;
222
    sal_uInt16          nRemoveWhich;
223
224
    void                ImpSetSelection();
225
226
227
public:
228
    EditUndoSetAttribs(EditEngine* pEE, const ESelection& rESel, SfxItemSet aNewItems);
229
    virtual ~EditUndoSetAttribs() override;
230
231
99.9k
    SfxItemSet&         GetNewAttribs()     { return aNewAttribs; }
232
233
89.5k
    void                SetSpecial( SetAttribsMode n )  { nSpecial = n; }
234
89.5k
    void                SetUpdateSelection( bool bSetSelection )  { m_bSetSelection = bSetSelection; }
235
4.68k
    void                SetRemoveAttribs( bool b )      { bSetIsRemove = b; }
236
4.68k
    void                SetRemoveParaAttribs( bool b )  { bRemoveParaAttribs = b; }
237
4.68k
    void                SetRemoveWhich( sal_uInt16 n )  { nRemoveWhich = n; }
238
239
    virtual void        Undo() override;
240
    virtual void        Redo() override;
241
242
    void AppendContentInfo(ContentAttribsInfo* pNew);
243
};
244
245
246
// EditUndoTransliteration
247
248
class EditUndoTransliteration: public EditUndo
249
{
250
private:
251
    ESelection          aOldESel;
252
    ESelection          aNewESel;
253
254
    TransliterationFlags
255
                        nMode;
256
    std::optional<EditTextObject>
257
                        moTxtObj;
258
    OUString            aText;
259
260
public:
261
    EditUndoTransliteration(EditEngine* pEE, const ESelection& rESel, TransliterationFlags nMode);
262
    virtual ~EditUndoTransliteration() override;
263
264
0
    void                SetText( const OUString& rText ) { aText = rText; }
265
0
    void                SetText( EditTextObject&& aObj ) { moTxtObj.emplace( std::move( aObj ) ); }
266
0
    void                SetNewSelection( const ESelection& rSel ) { aNewESel = rSel; }
267
268
    virtual void        Undo() override;
269
    virtual void        Redo() override;
270
};
271
272
273
// EditUndoMarkSelection
274
275
class EditUndoMarkSelection: public EditUndo
276
{
277
private:
278
    ESelection      aSelection;
279
280
public:
281
    EditUndoMarkSelection(EditEngine* pEE, const ESelection& rSel);
282
    virtual ~EditUndoMarkSelection() override;
283
284
    virtual void    Undo() override;
285
    virtual void    Redo() override;
286
};
287
288
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */