LibreOffice Module sw (master) 1
UndoInsert.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_UNDOINSERT_HXX
21#define INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX
22
23#include <memory>
24
25#include <undobj.hxx>
26#include <svx/svdtypes.hxx>
27#include <rtl/ustring.hxx>
28#include <vcl/graph.hxx>
29#include <swtypes.hxx>
30#include <ndindex.hxx>
32#include <optional>
33
34class SwGrfNode;
35class SwUndoDelete;
37class SwDoc;
38namespace sw { class DocumentContentOperationsManager; }
39enum class MirrorGraph;
40
42class SwUndoInsert final : public SwUndo, private SwUndoSaveContent
43{
45 std::optional<SwNodeIndex> m_oUndoNodeIndex;
46 std::optional<OUString> maText;
47 std::optional<OUString> maUndoText;
48 std::unique_ptr<SwRedlineData> m_pRedlData;
50 sal_Int32 m_nContent, m_nLen;
52 bool m_bIsAppend : 1;
53 bool m_bWithRsid : 1;
54
56
57 friend class ::sw::DocumentContentOperationsManager; // actually only DocumentContentOperationsManager::InsertString, because it uses CanGrouping
58 bool CanGrouping( sal_Unicode cIns );
59 bool CanGrouping( const SwPosition& rPos );
60
62
63 void Init(const SwNode & rNode);
64 std::optional<OUString> GetTextFromDoc() const;
65
66public:
67 SwUndoInsert( const SwNode& rNode, sal_Int32 nContent, sal_Int32 nLen,
68 const SwInsertFlags nInsertFlags,
69 bool bWDelim = true );
70 SwUndoInsert( const SwNode& rNode );
71 virtual ~SwUndoInsert() override;
72
73 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
74 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
75 virtual void RepeatImpl( ::sw::RepeatContext & ) override;
76
88 virtual SwRewriter GetRewriter() const override;
89
90 void SetWithRsid() { m_bWithRsid = true; }
91
92 bool IsIndependent(const SwUndoInsert& rOther) const;
93};
94
96MakeUndoReplaceRewriter(sal_uLong const occurrences,
97 OUString const& sOld, OUString const& sNew);
98
99class SwUndoReplace final
100 : public SwUndo
101{
102public:
103 SwUndoReplace(SwPaM const& rPam,
104 OUString const& rInsert, bool const bRegExp);
105
106 virtual ~SwUndoReplace() override;
107
108 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
109 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
110
130 virtual SwRewriter GetRewriter() const override;
131
132 void SetEnd( const SwPaM& rPam );
133
134private:
135 class Impl;
136 std::unique_ptr<Impl> m_pImpl;
137};
138
140class SwUndoReRead final : public SwUndo
141{
142 std::optional<Graphic> moGraphic;
143 std::optional<OUString> maNm;
144 std::optional<OUString> maFltr;
147
148 void SaveGraphicData( const SwGrfNode& );
150
151public:
152 SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd );
153
154 virtual ~SwUndoReRead() override;
155
156 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
157 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
158};
159
160class SwUndoInsertLabel final : public SwUndo
161{
162 union {
163 struct {
164 // for NoTextFrames
168 struct {
169 // for tables or TextFrames
173 };
174
175 OUString m_sText;
176 // #i39983# the separator is drawn with a character style
177 OUString m_sSeparator;
180 // #i26791# - re-store of drawing object position no longer needed
181 sal_uInt16 m_nFieldId;
183 SdrLayerID m_nLayerId; // for character objects
184 bool m_bBefore :1;
185 bool m_bUndoKeep :1;
187
188public:
189 SwUndoInsertLabel( const SwLabelType eTyp, OUString rText,
190 // #i39983# the separator is drawn with a character style
191 OUString aSeparator,
192 OUString aNumberSeparator, //#i61007# order of captions
193 const bool bBefore, const sal_uInt16 nId,
194 OUString aCharacterStyle,
195 const bool bCpyBrd,
196 const SwDoc* pDoc );
197 virtual ~SwUndoInsertLabel() override;
198
199 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
200 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
201 virtual void RepeatImpl( ::sw::RepeatContext & ) override;
202
215 virtual SwRewriter GetRewriter() const override;
216 static SwRewriter CreateRewriter(const OUString &rStr);
217
219 { if( SwLabelType::Object != m_eType ) NODE.nNode = nNd; }
220
221 void SetUndoKeep() { m_bUndoKeep = true; }
222 void SetFlys( SwFrameFormat& rOldFly, SfxItemSet const & rChgSet, SwFrameFormat& rNewFly );
223 void SetDrawObj( SdrLayerID nLayerId );
224};
225
226#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX
227
228/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwRewriter MakeUndoReplaceRewriter(sal_uLong const occurrences, OUString const &sOld, OUString const &sNew)
Definition: unins.cxx:528
Definition: doc.hxx:197
Style of a layout element.
Definition: frmfmt.hxx:72
Base class of the Writer document model elements.
Definition: node.hxx:98
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
struct SwUndoInsertLabel::@5::@8 NODE
SwLabelType m_eType
Definition: UndoInsert.hxx:182
OUString m_sNumberSeparator
Definition: UndoInsert.hxx:178
virtual ~SwUndoInsertLabel() override
Definition: unins.cxx:857
SwUndoDelete * pUndoInsNd
Definition: UndoInsert.hxx:170
sal_uInt16 m_nFieldId
Definition: UndoInsert.hxx:181
void SetFlys(SwFrameFormat &rOldFly, SfxItemSet const &rChgSet, SwFrameFormat &rNewFly)
Definition: unins.cxx:1012
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:907
static SwRewriter CreateRewriter(const OUString &rStr)
Definition: unins.cxx:993
virtual SwRewriter GetRewriter() const override
Returns the rewriter of this undo object.
Definition: unins.cxx:988
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:868
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unins.cxx:949
SdrLayerID m_nLayerId
Definition: UndoInsert.hxx:183
SwUndoInsertLabel(const SwLabelType eTyp, OUString rText, OUString aSeparator, OUString aNumberSeparator, const bool bBefore, const sal_uInt16 nId, OUString aCharacterStyle, const bool bCpyBrd, const SwDoc *pDoc)
Definition: unins.cxx:832
SwUndoInsLayFormat * pUndoFly
Definition: UndoInsert.hxx:165
void SetDrawObj(SdrLayerID nLayerId)
Definition: unins.cxx:1027
struct SwUndoInsertLabel::@5::@7 OBJECT
void SetNodePos(SwNodeOffset nNd)
Definition: UndoInsert.hxx:218
OUString m_sCharacterStyle
Definition: UndoInsert.hxx:179
SwNodeOffset nNode
Definition: UndoInsert.hxx:171
SwUndoFormatAttr * pUndoAttr
Definition: UndoInsert.hxx:166
OUString m_sSeparator
Definition: UndoInsert.hxx:177
Typing one or more characters to a single paragraph.
Definition: UndoInsert.hxx:43
bool m_bWithRsid
Definition: UndoInsert.hxx:53
std::optional< OUString > maText
Definition: UndoInsert.hxx:46
const SwInsertFlags m_nInsertFlags
Definition: UndoInsert.hxx:55
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:287
virtual SwRewriter GetRewriter() const override
Returns rewriter for this undo object.
Definition: unins.cxx:446
virtual ~SwUndoInsert() override
Definition: unins.cxx:187
bool m_bIsWordDelim
Definition: UndoInsert.hxx:51
std::optional< OUString > maUndoText
Definition: UndoInsert.hxx:47
SwNodeOffset m_nNode
Definition: UndoInsert.hxx:49
std::optional< SwNodeIndex > m_oUndoNodeIndex
start of Content in UndoNodes for Redo
Definition: UndoInsert.hxx:45
sal_Int32 m_nContent
Definition: UndoInsert.hxx:50
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:204
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unins.cxx:370
sal_Int32 m_nLen
Definition: UndoInsert.hxx:50
bool IsIndependent(const SwUndoInsert &rOther) const
Definition: unins.cxx:476
SwDoc * m_pDoc
Definition: UndoInsert.hxx:61
bool CanGrouping(sal_Unicode cIns)
Definition: unins.cxx:130
void Init(const SwNode &rNode)
Definition: unins.cxx:87
bool m_bIsAppend
Definition: UndoInsert.hxx:52
void SetWithRsid()
Definition: UndoInsert.hxx:90
SwUndoInsert(const SwNode &rNode, sal_Int32 nContent, sal_Int32 nLen, const SwInsertFlags nInsertFlags, bool bWDelim=true)
Definition: unins.cxx:103
std::optional< OUString > GetTextFromDoc() const
Definition: unins.cxx:61
std::unique_ptr< SwRedlineData > m_pRedlData
Definition: UndoInsert.hxx:48
Handles the undo/redo of the 'Replace...' context menu item for an image.
Definition: UndoInsert.hxx:141
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:804
void SaveGraphicData(const SwGrfNode &)
Definition: unins.cxx:814
std::optional< Graphic > moGraphic
Definition: UndoInsert.hxx:142
virtual ~SwUndoReRead() override
Definition: unins.cxx:770
SwNodeOffset mnPosition
Definition: UndoInsert.hxx:145
std::optional< OUString > maFltr
Definition: UndoInsert.hxx:144
void SetAndSave(::sw::UndoRedoContext &)
Definition: unins.cxx:774
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:809
MirrorGraph mnMirror
Definition: UndoInsert.hxx:146
std::optional< OUString > maNm
Definition: UndoInsert.hxx:143
SwUndoReRead(const SwPaM &rPam, const SwGrfNode &pGrfNd)
Definition: unins.cxx:764
virtual SwRewriter GetRewriter() const override
Returns the rewriter of this undo object.
Definition: unins.cxx:570
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:522
SwUndoReplace(SwPaM const &rPam, OUString const &rInsert, bool const bRegExp)
Definition: unins.cxx:506
std::unique_ptr< Impl > m_pImpl
Definition: UndoInsert.hxx:135
virtual ~SwUndoReplace() override
Definition: unins.cxx:513
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:517
void SetEnd(const SwPaM &rPam)
Definition: unins.cxx:575
MirrorGraph
Definition: grfatr.hxx:32
Dialog to specify the properties of date form field.
sal_uIntPtr sal_uLong
Marks a position in the document model.
Definition: pam.hxx:38
SwLabelType
Definition: swtypes.hxx:85
sal_uInt16 sal_Unicode