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 <boost/optional.hpp>
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 
40 class SwUndoInsert: public SwUndo, private SwUndoSaveContent
41 {
43  std::unique_ptr<SwNodeIndex> m_pUndoNodeIndex;
46  std::unique_ptr<SwRedlineData> pRedlData;
48  sal_Int32 nContent, nLen;
49  bool const bIsWordDelim : 1;
50  bool const bIsAppend : 1;
51  bool m_bWithRsid : 1;
52 
54 
55  friend class ::sw::DocumentContentOperationsManager; // actually only DocumentContentOperationsManager::InsertString, because it uses CanGrouping
56  bool CanGrouping( sal_Unicode cIns );
57  bool CanGrouping( const SwPosition& rPos );
58 
60 
61  void Init(const SwNodeIndex & rNode);
63 
64 public:
65  SwUndoInsert( const SwNodeIndex& rNode, sal_Int32 nContent, sal_Int32 nLen,
66  const SwInsertFlags nInsertFlags,
67  bool bWDelim = true );
68  SwUndoInsert( const SwNodeIndex& rNode );
69  virtual ~SwUndoInsert() override;
70 
71  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
72  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
73  virtual void RepeatImpl( ::sw::RepeatContext & ) override;
74 
86  virtual SwRewriter GetRewriter() const override;
87 
88  void SetWithRsid() { m_bWithRsid = true; }
89 };
90 
92 MakeUndoReplaceRewriter(sal_uLong const occurrences,
93  OUString const& sOld, OUString const& sNew);
94 
96  : public SwUndo
97 {
98 public:
99  SwUndoReplace(SwPaM const& rPam,
100  OUString const& rInsert, bool const bRegExp);
101 
102  virtual ~SwUndoReplace() override;
103 
104  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
105  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
106 
126  virtual SwRewriter GetRewriter() const override;
127 
128  void SetEnd( const SwPaM& rPam );
129 
130 private:
131  class Impl;
132  std::unique_ptr<Impl> m_pImpl;
133 };
134 
135 class SwUndoReRead : public SwUndo
136 {
137  std::unique_ptr<Graphic> pGrf;
142 
143  void SaveGraphicData( const SwGrfNode& );
144  void SetAndSave( ::sw::UndoRedoContext & );
145 
146 public:
147  SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd );
148 
149  virtual ~SwUndoReRead() override;
150 
151  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
152  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
153 };
154 
155 class SwUndoInsertLabel : public SwUndo
156 {
157  union {
158  struct {
159  // for NoTextFrames
162  } OBJECT;
163  struct {
164  // for tables or TextFrames
167  } NODE;
168  };
169 
170  OUString const sText;
171  // #i39983# the separator is drawn with a character style
172  OUString const sSeparator;
173  OUString const sNumberSeparator;
174  OUString const sCharacterStyle;
175  // #i26791# - re-store of drawing object position no longer needed
176  sal_uInt16 const nFieldId;
178  SdrLayerID nLayerId; // for character objects
179  bool const bBefore :1;
180  bool bUndoKeep :1;
181  bool const bCpyBrd :1;
182 
183 public:
184  SwUndoInsertLabel( const SwLabelType eTyp, const OUString &rText,
185  // #i39983# the separator is drawn with a character style
186  const OUString& rSeparator,
187  const OUString& rNumberSeparator, //#i61007# order of captions
188  const bool bBefore, const sal_uInt16 nId,
189  const OUString& rCharacterStyle,
190  const bool bCpyBrd,
191  const SwDoc* pDoc );
192  virtual ~SwUndoInsertLabel() override;
193 
194  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
195  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
196  virtual void RepeatImpl( ::sw::RepeatContext & ) override;
197 
210  virtual SwRewriter GetRewriter() const override;
211  static SwRewriter CreateRewriter(const OUString &rStr);
212 
213  void SetNodePos( sal_uLong nNd )
214  { if( LTYPE_OBJECT != eType ) NODE.nNode = nNd; }
215 
216  void SetUndoKeep() { bUndoKeep = true; }
217  void SetFlys( SwFrameFormat& rOldFly, SfxItemSet const & rChgSet, SwFrameFormat& rNewFly );
218  void SetDrawObj( SdrLayerID nLayerId );
219 };
220 
221 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX
222 
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< SwNodeIndex > m_pUndoNodeIndex
start of Content in UndoNodes for Redo
Definition: UndoInsert.hxx:43
bool const bCpyBrd
Definition: UndoInsert.hxx:181
boost::optional< OUString > maFltr
Definition: UndoInsert.hxx:139
struct SwUndoInsertLabel::@6::@9 NODE
SwRewriter MakeUndoReplaceRewriter(sal_uLong const occurrences, OUString const &sOld, OUString const &sNew)
Definition: unins.cxx:534
SwLabelType
Definition: swtypes.hxx:87
Marks a position in the document model.
Definition: pam.hxx:35
OUString const sText
Definition: UndoInsert.hxx:170
boost::optional< OUString > maUndoText
Definition: UndoInsert.hxx:45
void SetNodePos(sal_uLong nNd)
Definition: UndoInsert.hxx:213
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:834
OUString const sCharacterStyle
Definition: UndoInsert.hxx:174
MirrorGraph nMirr
Definition: UndoInsert.hxx:141
sal_uIntPtr sal_uLong
Definition: doc.hxx:185
std::unique_ptr< SwRedlineData > pRedlData
Definition: UndoInsert.hxx:46
SwUndoFormatAttr * pUndoAttr
Definition: UndoInsert.hxx:161
MirrorGraph
Definition: grfatr.hxx:31
bool m_bWithRsid
Definition: UndoInsert.hxx:51
OUString const sSeparator
Definition: UndoInsert.hxx:172
void SetEnd(const SwPaM &rPam)
Definition: unins.cxx:586
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:38
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:857
const SwInsertFlags m_nInsertFlags
Definition: UndoInsert.hxx:53
bool const bIsWordDelim
Definition: UndoInsert.hxx:49
struct SwUndoInsertLabel::@6::@8 OBJECT
bool const bIsAppend
Definition: UndoInsert.hxx:50
sal_uInt16 sal_Unicode
void SetWithRsid()
Definition: UndoInsert.hxx:88
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unins.cxx:377
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unins.cxx:974
sal_Int32 nLen
Definition: UndoInsert.hxx:48
sal_uInt16 const nFieldId
Definition: UndoInsert.hxx:176
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:829
void SetDrawObj(SdrLayerID nLayerId)
Definition: unins.cxx:1052
SdrLayerID nLayerId
Definition: UndoInsert.hxx:178
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:294
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SwDoc * pDoc
Definition: UndoInsert.hxx:59
Style of a layout element.
Definition: frmfmt.hxx:57
SwUndoReplace(SwPaM const &rPam, OUString const &rInsert, bool const bRegExp)
Definition: unins.cxx:512
virtual SwRewriter GetRewriter() const override
Returns rewriter for this undo object.
Definition: unins.cxx:454
OUString const sNumberSeparator
Definition: UndoInsert.hxx:173
Marks a node in the document model.
Definition: ndindex.hxx:31
void SetFlys(SwFrameFormat &rOldFly, SfxItemSet const &rChgSet, SwFrameFormat &rNewFly)
Definition: unins.cxx:1037
virtual SwRewriter GetRewriter() const override
Returns the rewriter of this undo object.
Definition: unins.cxx:1013
SwUndoReRead(const SwPaM &rPam, const SwGrfNode &pGrfNd)
Definition: unins.cxx:788
std::unique_ptr< Impl > m_pImpl
Definition: UndoInsert.hxx:131
void SaveGraphicData(const SwGrfNode &)
Definition: unins.cxx:839
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:207
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:893
sal_uLong nNode
Definition: UndoInsert.hxx:47
void SetAndSave(::sw::UndoRedoContext &)
Definition: unins.cxx:798
sal_Int32 nContent
Definition: UndoInsert.hxx:48
SwUndoDelete * pUndoInsNd
Definition: UndoInsert.hxx:165
virtual ~SwUndoReplace() override
Definition: unins.cxx:519
virtual ~SwUndoInsert() override
Definition: unins.cxx:190
std::unique_ptr< Graphic > pGrf
Definition: UndoInsert.hxx:137
SwUndoInsLayFormat * pUndoFly
Definition: UndoInsert.hxx:160
boost::optional< OUString > maNm
Definition: UndoInsert.hxx:138
static SwRewriter CreateRewriter(const OUString &rStr)
Definition: unins.cxx:1018
SwLabelType const eType
Definition: UndoInsert.hxx:177
boost::optional< OUString > GetTextFromDoc() const
Definition: unins.cxx:64
virtual ~SwUndoReRead() override
Definition: unins.cxx:794
SwUndoInsert(const SwNodeIndex &rNode, sal_Int32 nContent, sal_Int32 nLen, const SwInsertFlags nInsertFlags, bool bWDelim=true)
Definition: unins.cxx:106
bool CanGrouping(sal_Unicode cIns)
Definition: unins.cxx:133
sal_uLong nPos
Definition: UndoInsert.hxx:140
boost::optional< OUString > maText
Definition: UndoInsert.hxx:44
void Init(const SwNodeIndex &rNode)
Definition: unins.cxx:90
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:528
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:523
virtual ~SwUndoInsertLabel() override
Definition: unins.cxx:882
virtual SwRewriter GetRewriter() const override
Returns the rewriter of this undo object.
Definition: unins.cxx:581
bool const bBefore
Definition: UndoInsert.hxx:179
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unins.cxx:932