LibreOffice Module sw (master)  1
UndoCore.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_UNDOCORE_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNDOCORE_HXX
22 
23 #include <undobj.hxx>
24 #include <calbck.hxx>
25 #include <o3tl/deleter.hxx>
26 #include <rtl/ustring.hxx>
27 #include <redline.hxx>
28 
29 #include <memory>
30 #include <vector>
31 
32 class SfxItemSet;
33 class SwFormatColl;
34 class SwFormatAnchor;
35 class SdrMarkList;
36 class SwUndoDelete;
37 
38 namespace sw {
39  class UndoManager;
40  class IShellCursorSupplier;
41 }
42 
44 {
45 public:
47  SwComparePosition eCmpPos,
48  const SwPosition& rSttPos,
49  const SwPosition& rEndPos,
50  SwRangeRedline& rRedl,
51  bool bCopyNext );
52 
54 
55  void RedlineToDoc( SwPaM const & rPam );
56 
58  {
60  }
61 
62 #if OSL_DEBUG_LEVEL > 0
63  sal_uInt16 nRedlineCount;
64 #endif
65 };
66 
68 private:
69  std::vector<std::unique_ptr<SwRedlineSaveData, o3tl::default_delete<SwRedlineSaveData>>> m_Data;
70 
71 public:
72  SwRedlineSaveDatas() : m_Data() {}
73 
74  void clear() { m_Data.clear(); }
75  bool empty() const { return m_Data.empty(); }
76  size_t size() const { return m_Data.size(); }
77  void push_back(std::unique_ptr<SwRedlineSaveData, o3tl::default_delete<SwRedlineSaveData>> pNew) { m_Data.push_back(std::move(pNew)); }
78  const SwRedlineSaveData& operator[](size_t const nIdx) const { return *m_Data[ nIdx ]; }
79  SwRedlineSaveData& operator[](size_t const nIdx) { return *m_Data[ nIdx ]; }
80 };
81 
82 namespace sw {
84  : public SfxUndoContext
85 {
86 public:
87  UndoRedoContext(SwDoc & rDoc, IShellCursorSupplier & rCursorSupplier)
88  : m_rDoc(rDoc)
89  , m_rCursorSupplier(rCursorSupplier)
90  , m_pSelFormat(nullptr)
91  , m_pMarkList(nullptr)
92  { }
93 
94  SwDoc & GetDoc() const { return m_rDoc; }
95 
97 
98  void SetSelections(SwFrameFormat *const pSelFormat, SdrMarkList *const pMarkList)
99  {
100  m_pSelFormat = pSelFormat;
101  m_pMarkList = pMarkList;
102  }
103  void GetSelections(SwFrameFormat *& o_rpSelFormat, SdrMarkList *& o_rpMarkList)
104  {
105  o_rpSelFormat = m_pSelFormat;
106  o_rpMarkList = m_pMarkList;
107  }
108 
109 private:
114 };
115 
117  : public SfxRepeatTarget
118 {
119 public:
120  RepeatContext(SwDoc & rDoc, SwPaM & rPaM)
121  : m_rDoc(rDoc)
122  , m_pCurrentPaM(& rPaM)
123  , m_bDeleteRepeated(false)
124  { }
125 
126  SwDoc & GetDoc() const { return m_rDoc; }
127 
129  {
130  return *m_pCurrentPaM;
131  }
132 
133 private:
134  friend class ::sw::UndoManager;
135  friend class ::SwUndoDelete;
136 
140 };
141 
142 } // namespace sw
143 
144 class SwUndoFormatColl : public SwUndo, private SwUndRng
145 {
146  OUString aFormatName;
147  std::unique_ptr<SwHistory> pHistory;
148  // for correct <ReDo(..)> and <Repeat(..)>
149  // boolean, which indicates that the attributes are reset at the nodes
150  // before the format has been applied.
151  const bool mbReset;
152  // boolean, which indicates that the list attributes had been reset at
153  // the nodes before the format has been applied.
154  const bool mbResetListAttrs;
155 
156  void DoSetFormatColl(SwDoc & rDoc, SwPaM const & rPaM);
157 
158 public:
160  const bool bReset,
161  const bool bResetListAttrs );
162  virtual ~SwUndoFormatColl() override;
163 
164  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
165  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
166  virtual void RepeatImpl( ::sw::RepeatContext & ) override;
167 
181  virtual SwRewriter GetRewriter() const override;
182 
183  SwHistory* GetHistory() { return pHistory.get(); }
184 
185 };
186 
187 class SwUndoSetFlyFormat : public SwUndo, public SwClient
188 {
189  SwFrameFormat* m_pFrameFormat; // saved FlyFormat
190  const OUString m_DerivedFromFormatName;
191  const OUString m_NewFormatName;
192  std::unique_ptr<SfxItemSet> m_pItemSet; // the re-/ set attributes
197 
198  void PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem );
199  void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
200  void GetAnchor( SwFormatAnchor& rAnhor, sal_uLong nNode, sal_Int32 nContent );
201 
202 public:
203  SwUndoSetFlyFormat( SwFrameFormat& rFlyFormat, SwFrameFormat& rNewFrameFormat );
204  virtual ~SwUndoSetFlyFormat() override;
205 
206  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
207  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
208 
209  virtual SwRewriter GetRewriter() const override;
210 };
211 
212 class SwUndoOutlineLeftRight : public SwUndo, private SwUndRng
213 {
214  short const nOffset;
215 
216 public:
217  SwUndoOutlineLeftRight( const SwPaM& rPam, short nOffset );
218 
219  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
220  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
221  virtual void RepeatImpl( ::sw::RepeatContext & ) override;
222 };
223 
224 const int nUndoStringLength = 20;
225 
249 OUString
250 ShortenString(const OUString & rStr, sal_Int32 nLength, const OUString & rFillStr);
269 OUString DenoteSpecialCharacters(const OUString & rStr);
270 
271 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOCORE_HXX
272 
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetSelections(SwFrameFormat *const pSelFormat, SdrMarkList *const pMarkList)
Definition: UndoCore.hxx:98
Marks a position in the document model.
Definition: pam.hxx:35
RndStdIds m_nOldAnchorType
Definition: UndoCore.hxx:195
UndoRedoContext(SwDoc &rDoc, IShellCursorSupplier &rCursorSupplier)
Definition: UndoCore.hxx:87
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unfmco.cxx:57
size_t size() const
Definition: UndoCore.hxx:76
sal_Int32 m_nNewContent
Definition: UndoCore.hxx:194
sal_uIntPtr sal_uLong
SwPaM & GetRepeatPaM()
Definition: UndoCore.hxx:128
Definition: doc.hxx:185
SwUndoOutlineLeftRight(const SwPaM &rPam, short nOffset)
Definition: unoutl.cxx:27
SwRedlineSaveData(SwComparePosition eCmpPos, const SwPosition &rSttPos, const SwPosition &rEndPos, SwRangeRedline &rRedl, bool bCopyNext)
Definition: undobj.cxx:1296
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:38
virtual ~SwUndoFormatColl() override
Definition: unfmco.cxx:43
SwRedlineSaveData & operator[](size_t const nIdx)
Definition: UndoCore.hxx:79
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unoutl.cxx:33
const SwRedlineSaveData & operator[](size_t const nIdx) const
Definition: UndoCore.hxx:78
SwUndoFormatColl(const SwPaM &, SwFormatColl *, const bool bReset, const bool bResetListAttrs)
Definition: unfmco.cxx:28
sal_Int32 m_nOldContent
Definition: UndoCore.hxx:194
IShellCursorSupplier & GetCursorSupplier()
Definition: UndoCore.hxx:96
void push_back(std::unique_ptr< SwRedlineSaveData, o3tl::default_delete< SwRedlineSaveData >> pNew)
Definition: UndoCore.hxx:77
const OUString m_DerivedFromFormatName
Definition: UndoCore.hxx:190
SwHistory * GetHistory()
Definition: UndoCore.hxx:183
SwNodeIndex * GetMvSttIdx() const
Definition: UndoCore.hxx:57
SwDoc & GetDoc() const
Definition: UndoCore.hxx:126
SwDoc & GetDoc() const
Definition: UndoCore.hxx:94
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:605
sal_uLong m_nOldNode
Definition: UndoCore.hxx:193
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
std::unique_ptr< SwHistory > pHistory
Definition: UndoCore.hxx:147
const bool mbReset
Definition: UndoCore.hxx:151
Style of a layout element.
Definition: frmfmt.hxx:57
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this object.
Definition: undobj1.cxx:470
const bool mbResetListAttrs
Definition: UndoCore.hxx:154
sal_uLong m_nNewNode
Definition: UndoCore.hxx:193
SwFrameFormat * m_pSelFormat
Definition: UndoCore.hxx:112
std::vector< std::unique_ptr< SwRedlineSaveData, o3tl::default_delete< SwRedlineSaveData > > > m_Data
Definition: UndoCore.hxx:69
FlyAnchors.
Definition: fmtanchr.hxx:34
SdrMarkList * m_pMarkList
Definition: UndoCore.hxx:113
Marks a node in the document model.
Definition: ndindex.hxx:31
void GetAnchor(SwFormatAnchor &rAnhor, sal_uLong nNode, sal_Int32 nContent)
Definition: undobj1.cxx:483
void RedlineToDoc(SwPaM const &rPam)
Definition: undobj.cxx:1352
The Undo actions need to create new Shell cursors.
IShellCursorSupplier & m_rCursorSupplier
Definition: UndoCore.hxx:111
void PutAttr(sal_uInt16 nWhich, const SfxPoolItem *pItem)
Definition: undobj1.cxx:628
OUString aFormatName
Definition: UndoCore.hxx:146
SwFrameFormat * m_pFrameFormat
Definition: UndoCore.hxx:189
virtual ~SwUndoSetFlyFormat() override
Definition: undobj1.cxx:479
void GetSelections(SwFrameFormat *&o_rpSelFormat, SdrMarkList *&o_rpMarkList)
Definition: UndoCore.hxx:103
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unfmco.cxx:47
void DoSetFormatColl(SwDoc &rDoc, SwPaM const &rPaM)
Definition: unfmco.cxx:69
OUString ShortenString(const OUString &rStr, sal_Int32 nLength, const OUString &rFillStr)
Shortens a string to a maximum length.
Definition: undobj.cxx:1507
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unoutl.cxx:45
RndStdIds m_nNewAnchorType
Definition: UndoCore.hxx:195
SwUndoSetFlyFormat(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFrameFormat)
Definition: undobj1.cxx:458
SwNodeIndex * GetMvSttIdx() const
Definition: undobj.hxx:197
bool empty() const
Definition: UndoCore.hxx:75
sal_uInt16 nRedlineCount
Definition: UndoCore.hxx:63
RepeatContext(SwDoc &rDoc, SwPaM &rPaM)
Definition: UndoCore.hxx:120
OUString DenoteSpecialCharacters(const OUString &rStr)
Denotes special characters in a string.
Definition: undel.cxx:706
RndStdIds
SwPaM * m_pCurrentPaM
Definition: UndoCore.hxx:138
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unoutl.cxx:39
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unfmco.cxx:64
std::unique_ptr< SfxItemSet > m_pItemSet
Definition: UndoCore.hxx:192
void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: undobj1.cxx:681
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: undobj1.cxx:530
virtual SwRewriter GetRewriter() const override
Returns the rewriter for this undo object.
Definition: unfmco.cxx:80
const int nUndoStringLength
Definition: UndoCore.hxx:224
SwComparePosition
Definition: pam.hxx:64
const OUString m_NewFormatName
Definition: UndoCore.hxx:191