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
139class SwUndoReRead final : public SwUndo
140{
141 std::optional<Graphic> moGraphic;
142 std::optional<OUString> maNm;
143 std::optional<OUString> maFltr;
146
147 void SaveGraphicData( const SwGrfNode& );
149
150public:
151 SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd );
152
153 virtual ~SwUndoReRead() override;
154
155 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
156 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
157};
158
159class SwUndoInsertLabel final : public SwUndo
160{
161 union {
162 struct {
163 // for NoTextFrames
167 struct {
168 // for tables or TextFrames
172 };
173
174 OUString m_sText;
175 // #i39983# the separator is drawn with a character style
176 OUString m_sSeparator;
179 // #i26791# - re-store of drawing object position no longer needed
180 sal_uInt16 m_nFieldId;
182 SdrLayerID m_nLayerId; // for character objects
183 bool m_bBefore :1;
184 bool m_bUndoKeep :1;
186
187public:
188 SwUndoInsertLabel( const SwLabelType eTyp, OUString rText,
189 // #i39983# the separator is drawn with a character style
190 OUString aSeparator,
191 OUString aNumberSeparator, //#i61007# order of captions
192 const bool bBefore, const sal_uInt16 nId,
193 OUString aCharacterStyle,
194 const bool bCpyBrd,
195 const SwDoc* pDoc );
196 virtual ~SwUndoInsertLabel() override;
197
198 virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
199 virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
200 virtual void RepeatImpl( ::sw::RepeatContext & ) override;
201
214 virtual SwRewriter GetRewriter() const override;
215 static SwRewriter CreateRewriter(const OUString &rStr);
216
218 { if( SwLabelType::Object != m_eType ) NODE.nNode = nNd; }
219
220 void SetUndoKeep() { m_bUndoKeep = true; }
221 void SetFlys( SwFrameFormat& rOldFly, SfxItemSet const & rChgSet, SwFrameFormat& rNewFly );
222 void SetDrawObj( SdrLayerID nLayerId );
223};
224
225#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX
226
227/* 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:192
Style of a layout element.
Definition: frmfmt.hxx:62
Base class of the Writer document model elements.
Definition: node.hxx:84
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
struct SwUndoInsertLabel::@5::@8 NODE
SwLabelType m_eType
Definition: UndoInsert.hxx:181
OUString m_sNumberSeparator
Definition: UndoInsert.hxx:177
virtual ~SwUndoInsertLabel() override
Definition: unins.cxx:857
SwUndoDelete * pUndoInsNd
Definition: UndoInsert.hxx:169
sal_uInt16 m_nFieldId
Definition: UndoInsert.hxx:180
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:182
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:164
void SetDrawObj(SdrLayerID nLayerId)
Definition: unins.cxx:1027
struct SwUndoInsertLabel::@5::@7 OBJECT
void SetNodePos(SwNodeOffset nNd)
Definition: UndoInsert.hxx:217
OUString m_sCharacterStyle
Definition: UndoInsert.hxx:178
SwNodeOffset nNode
Definition: UndoInsert.hxx:170
SwUndoFormatAttr * pUndoAttr
Definition: UndoInsert.hxx:165
OUString m_sSeparator
Definition: UndoInsert.hxx:176
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
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:141
virtual ~SwUndoReRead() override
Definition: unins.cxx:770
SwNodeOffset mnPosition
Definition: UndoInsert.hxx:144
std::optional< OUString > maFltr
Definition: UndoInsert.hxx:143
void SetAndSave(::sw::UndoRedoContext &)
Definition: unins.cxx:774
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:809
MirrorGraph mnMirror
Definition: UndoInsert.hxx:145
std::optional< OUString > maNm
Definition: UndoInsert.hxx:142
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:37
SwLabelType
Definition: swtypes.hxx:85
sal_uInt16 sal_Unicode