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 <swtypes.hxx>
30 #include <optional>
31 
32 class Graphic;
33 class SwGrfNode;
34 class SwUndoDelete;
35 class SwUndoFormatAttr;
36 class SwDoc;
37 namespace sw { class DocumentContentOperationsManager; }
38 enum class MirrorGraph;
39 
41 class SwUndoInsert final : public SwUndo, private SwUndoSaveContent
42 {
44  std::unique_ptr<SwNodeIndex> m_pUndoNodeIndex;
45  std::optional<OUString> maText;
46  std::optional<OUString> maUndoText;
47  std::unique_ptr<SwRedlineData> m_pRedlData;
49  sal_Int32 m_nContent, m_nLen;
50  bool m_bIsWordDelim : 1;
51  bool m_bIsAppend : 1;
52  bool m_bWithRsid : 1;
53 
55 
56  friend class ::sw::DocumentContentOperationsManager; // actually only DocumentContentOperationsManager::InsertString, because it uses CanGrouping
57  bool CanGrouping( sal_Unicode cIns );
58  bool CanGrouping( const SwPosition& rPos );
59 
61 
62  void Init(const SwNodeIndex & rNode);
63  std::optional<OUString> GetTextFromDoc() const;
64 
65 public:
66  SwUndoInsert( const SwNodeIndex& rNode, sal_Int32 nContent, sal_Int32 nLen,
67  const SwInsertFlags nInsertFlags,
68  bool bWDelim = true );
69  SwUndoInsert( const SwNodeIndex& rNode );
70  virtual ~SwUndoInsert() override;
71 
72  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
73  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
74  virtual void RepeatImpl( ::sw::RepeatContext & ) override;
75 
87  virtual SwRewriter GetRewriter() const override;
88 
89  void SetWithRsid() { m_bWithRsid = true; }
90 
91  bool IsIndependent(const SwUndoInsert& rOther) const;
92 };
93 
95 MakeUndoReplaceRewriter(sal_uLong const occurrences,
96  OUString const& sOld, OUString const& sNew);
97 
98 class SwUndoReplace final
99  : public SwUndo
100 {
101 public:
102  SwUndoReplace(SwPaM const& rPam,
103  OUString const& rInsert, bool const bRegExp);
104 
105  virtual ~SwUndoReplace() override;
106 
107  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
108  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
109 
129  virtual SwRewriter GetRewriter() const override;
130 
131  void SetEnd( const SwPaM& rPam );
132 
133 private:
134  class Impl;
135  std::unique_ptr<Impl> m_pImpl;
136 };
137 
138 class SwUndoReRead final : public SwUndo
139 {
140  std::unique_ptr<Graphic> mpGraphic;
141  std::optional<OUString> maNm;
142  std::optional<OUString> maFltr;
145 
146  void SaveGraphicData( const SwGrfNode& );
147  void SetAndSave( ::sw::UndoRedoContext & );
148 
149 public:
150  SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd );
151 
152  virtual ~SwUndoReRead() override;
153 
154  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
155  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
156 };
157 
158 class SwUndoInsertLabel final : public SwUndo
159 {
160  union {
161  struct {
162  // for NoTextFrames
165  } OBJECT;
166  struct {
167  // for tables or TextFrames
170  } NODE;
171  };
172 
173  OUString m_sText;
174  // #i39983# the separator is drawn with a character style
175  OUString m_sSeparator;
178  // #i26791# - re-store of drawing object position no longer needed
179  sal_uInt16 m_nFieldId;
181  SdrLayerID m_nLayerId; // for character objects
182  bool m_bBefore :1;
183  bool m_bUndoKeep :1;
184  bool m_bCopyBorder :1;
185 
186 public:
187  SwUndoInsertLabel( const SwLabelType eTyp, const OUString &rText,
188  // #i39983# the separator is drawn with a character style
189  const OUString& rSeparator,
190  const OUString& rNumberSeparator, //#i61007# order of captions
191  const bool bBefore, const sal_uInt16 nId,
192  const OUString& rCharacterStyle,
193  const bool bCpyBrd,
194  const SwDoc* pDoc );
195  virtual ~SwUndoInsertLabel() override;
196 
197  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
198  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
199  virtual void RepeatImpl( ::sw::RepeatContext & ) override;
200 
213  virtual SwRewriter GetRewriter() const override;
214  static SwRewriter CreateRewriter(const OUString &rStr);
215 
217  { if( SwLabelType::Object != m_eType ) NODE.nNode = nNd; }
218 
219  void SetUndoKeep() { m_bUndoKeep = true; }
220  void SetFlys( SwFrameFormat& rOldFly, SfxItemSet const & rChgSet, SwFrameFormat& rNewFly );
221  void SetDrawObj( SdrLayerID nLayerId );
222 };
223 
224 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX
225 
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::optional< OUString > maFltr
Definition: UndoInsert.hxx:142
std::unique_ptr< SwNodeIndex > m_pUndoNodeIndex
start of Content in UndoNodes for Redo
Definition: UndoInsert.hxx:44
std::optional< OUString > maUndoText
Definition: UndoInsert.hxx:46
SwRewriter MakeUndoReplaceRewriter(sal_uLong const occurrences, OUString const &sOld, OUString const &sNew)
Definition: unins.cxx:531
SwLabelType
Definition: swtypes.hxx:84
Marks a position in the document model.
Definition: pam.hxx:36
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:822
bool m_bIsAppend
Definition: UndoInsert.hxx:51
void SetNodePos(SwNodeOffset nNd)
Definition: UndoInsert.hxx:216
sal_uIntPtr sal_uLong
Definition: doc.hxx:187
OUString m_sCharacterStyle
Definition: UndoInsert.hxx:177
SwUndoFormatAttr * pUndoAttr
Definition: UndoInsert.hxx:164
MirrorGraph
Definition: grfatr.hxx:31
bool m_bWithRsid
Definition: UndoInsert.hxx:52
bool m_bIsWordDelim
Definition: UndoInsert.hxx:50
bool IsIndependent(const SwUndoInsert &rOther) const
Definition: unins.cxx:479
void SetEnd(const SwPaM &rPam)
Definition: unins.cxx:578
Dialog to specify the properties of date form field.
SwUndoInsertLabel(const SwLabelType eTyp, const OUString &rText, const OUString &rSeparator, const OUString &rNumberSeparator, const bool bBefore, const sal_uInt16 nId, const OUString &rCharacterStyle, const bool bCpyBrd, const SwDoc *pDoc)
Definition: unins.cxx:845
const SwInsertFlags m_nInsertFlags
Definition: UndoInsert.hxx:54
SwNodeOffset mnPosition
Definition: UndoInsert.hxx:143
std::optional< OUString > maNm
Definition: UndoInsert.hxx:141
sal_uInt16 sal_Unicode
void SetWithRsid()
Definition: UndoInsert.hxx:89
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unins.cxx:373
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unins.cxx:962
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:817
void SetDrawObj(SdrLayerID nLayerId)
Definition: unins.cxx:1040
std::unique_ptr< SwRedlineData > m_pRedlData
Definition: UndoInsert.hxx:47
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:290
std::optional< OUString > GetTextFromDoc() const
Definition: unins.cxx:60
OUString m_sNumberSeparator
Definition: UndoInsert.hxx:176
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
Typing one or more characters to a single paragraph.
Definition: UndoInsert.hxx:41
Style of a layout element.
Definition: frmfmt.hxx:59
SwUndoReplace(SwPaM const &rPam, OUString const &rInsert, bool const bRegExp)
Definition: unins.cxx:509
virtual SwRewriter GetRewriter() const override
Returns rewriter for this undo object.
Definition: unins.cxx:449
SwNodeOffset m_nNode
Definition: UndoInsert.hxx:48
Marks a node in the document model.
Definition: ndindex.hxx:30
OUString m_sSeparator
Definition: UndoInsert.hxx:175
void SetFlys(SwFrameFormat &rOldFly, SfxItemSet const &rChgSet, SwFrameFormat &rNewFly)
Definition: unins.cxx:1025
virtual SwRewriter GetRewriter() const override
Returns the rewriter of this undo object.
Definition: unins.cxx:1001
SwUndoReRead(const SwPaM &rPam, const SwGrfNode &pGrfNd)
Definition: unins.cxx:777
std::unique_ptr< Impl > m_pImpl
Definition: UndoInsert.hxx:134
void SaveGraphicData(const SwGrfNode &)
Definition: unins.cxx:827
sal_Int32 m_nLen
Definition: UndoInsert.hxx:49
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:203
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:881
void SetAndSave(::sw::UndoRedoContext &)
Definition: unins.cxx:787
SwUndoDelete * pUndoInsNd
Definition: UndoInsert.hxx:168
std::unique_ptr< Graphic > mpGraphic
Definition: UndoInsert.hxx:140
virtual ~SwUndoReplace() override
Definition: unins.cxx:516
SwDoc * m_pDoc
Definition: UndoInsert.hxx:60
virtual ~SwUndoInsert() override
Definition: unins.cxx:186
sal_uInt16 m_nFieldId
Definition: UndoInsert.hxx:179
SwUndoInsLayFormat * pUndoFly
Definition: UndoInsert.hxx:163
static SwRewriter CreateRewriter(const OUString &rStr)
Definition: unins.cxx:1006
virtual ~SwUndoReRead() override
Definition: unins.cxx:783
MirrorGraph mnMirror
Definition: UndoInsert.hxx:144
SwUndoInsert(const SwNodeIndex &rNode, sal_Int32 nContent, sal_Int32 nLen, const SwInsertFlags nInsertFlags, bool bWDelim=true)
Definition: unins.cxx:102
bool CanGrouping(sal_Unicode cIns)
Definition: unins.cxx:129
SwLabelType m_eType
Definition: UndoInsert.hxx:180
struct SwUndoInsertLabel::@5::@7 OBJECT
void Init(const SwNodeIndex &rNode)
Definition: unins.cxx:86
sal_Int32 m_nContent
Definition: UndoInsert.hxx:49
struct SwUndoInsertLabel::@5::@8 NODE
SdrLayerID m_nLayerId
Definition: UndoInsert.hxx:181
SwNodeOffset nNode
Definition: UndoInsert.hxx:169
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:525
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:520
std::optional< OUString > maText
Definition: UndoInsert.hxx:45
virtual ~SwUndoInsertLabel() override
Definition: unins.cxx:870
virtual SwRewriter GetRewriter() const override
Returns the rewriter of this undo object.
Definition: unins.cxx:573
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:920