LibreOffice Module sw (master)  1
redline.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 #ifndef INCLUDED_SW_INC_REDLINE_HXX
20 #define INCLUDED_SW_INC_REDLINE_HXX
21 
22 #include <svx/ctredlin.hxx>
23 #include <tools/datetime.hxx>
24 #include <rtl/ustring.hxx>
25 
26 #include "pam.hxx"
27 
28 #include <cstddef>
29 #include <memory>
30 #include <vector>
31 #include <optional>
32 
33 
34 class SfxItemSet;
35 
37 {
38  SwRedlineExtraData( const SwRedlineExtraData& ) = delete;
39  SwRedlineExtraData& operator=( const SwRedlineExtraData& ) = delete;
40 
41 protected:
43 
44 public:
45  virtual ~SwRedlineExtraData();
46  virtual SwRedlineExtraData* CreateNew() const = 0;
47 
48  virtual void Reject( SwPaM& rPam ) const;
49  virtual bool operator == ( const SwRedlineExtraData& ) const;
50 };
51 
53 {
54  OUString m_sFormatNm;
55  std::unique_ptr<SfxItemSet> m_pSet;
56  sal_uInt16 m_nPoolId;
57  bool m_bFormatAll; // don't strip the last paragraph mark
58 public:
59  SwRedlineExtraData_FormatColl( const OUString& rColl, sal_uInt16 nPoolFormatId,
60  const SfxItemSet* pSet = nullptr, bool bFormatAll = true );
61  virtual ~SwRedlineExtraData_FormatColl() override;
62  virtual SwRedlineExtraData* CreateNew() const override;
63  virtual void Reject( SwPaM& rPam ) const override;
64  virtual bool operator == ( const SwRedlineExtraData& ) const override;
65 
66  const OUString& GetFormatName() const { return m_sFormatNm; }
67  void SetItemSet( const SfxItemSet& rSet );
68  SfxItemSet* GetItemSet( ) const { return m_pSet.get(); }
69  void SetFormatAll( bool bAll ) { m_bFormatAll = bAll; }
70 };
71 
73 {
74  std::vector<sal_uInt16> m_aWhichIds;
75 
77 
78 public:
80  virtual ~SwRedlineExtraData_Format() override;
81  virtual SwRedlineExtraData* CreateNew() const override;
82  virtual void Reject( SwPaM& rPam ) const override;
83  virtual bool operator == ( const SwRedlineExtraData& ) const override;
84 };
85 
87 {
88  friend class SwRangeRedline;
89  SwRedlineData* m_pNext; // Points to other data.
91 
92  OUString m_sComment;
94  std::size_t m_nAuthor;
96  sal_uInt16 m_nSeqNo;
98  bool m_bMoved;
99 
100 public:
101  SwRedlineData( RedlineType eT, std::size_t nAut );
102  SwRedlineData( const SwRedlineData& rCpy, bool bCpyNext = true );
103 
104  // For sw3io: pNext/pExtraData are taken over.
105  SwRedlineData( RedlineType eT, std::size_t nAut, const DateTime& rDT,
106  const OUString& rCmnt, SwRedlineData* pNxt );
107 
108  ~SwRedlineData();
109 
110  bool operator==( const SwRedlineData& rCmp ) const
111  {
112  return m_nAuthor == rCmp.m_nAuthor &&
113  m_eType == rCmp.m_eType &&
114  m_bAutoFormat == rCmp.m_bAutoFormat &&
115  m_bMoved == rCmp.m_bMoved &&
116  m_sComment == rCmp.m_sComment &&
117  (( !m_pNext && !rCmp.m_pNext ) ||
118  ( m_pNext && rCmp.m_pNext && *m_pNext == *rCmp.m_pNext )) &&
119  (( !m_pExtraData && !rCmp.m_pExtraData ) ||
120  ( m_pExtraData && rCmp.m_pExtraData &&
121  *m_pExtraData == *rCmp.m_pExtraData ));
122  }
123  bool operator!=( const SwRedlineData& rCmp ) const
124  { return !operator==( rCmp ); }
125 
126  RedlineType GetType() const { return m_eType; }
127 
128  std::size_t GetAuthor() const { return m_nAuthor; }
129  const OUString& GetComment() const { return m_sComment; }
130  const DateTime& GetTimeStamp() const { return m_aStamp; }
131  const SwRedlineData* Next() const{ return m_pNext; }
132 
133  void SetComment( const OUString& rS ) { m_sComment = rS; }
134  void SetTimeStamp( const DateTime& rDT ) { m_aStamp = rDT; }
135 
136  void SetAutoFormat() { m_bAutoFormat = true; }
137  bool IsAutoFormat() const { return m_bAutoFormat; }
138  void SetMoved() { m_bMoved = true; }
139  bool IsMoved() const { return m_bMoved; }
140  bool CanCombine( const SwRedlineData& rCmp ) const;
141 
142  // ExtraData gets copied, the pointer is therefore not taken over by
143  // the RedlineObject
144  void SetExtraData( const SwRedlineExtraData* pData );
145  const SwRedlineExtraData* GetExtraData() const { return m_pExtraData; }
146 
147  // For UI-side pooling of Redline-actions.
148  // At the moment only used for Autoformat with Redline.
149  // Value != 0 means there can be others!
150  sal_uInt16 GetSeqNo() const { return m_nSeqNo; }
151  void SetSeqNo( sal_uInt16 nNo ) { m_nSeqNo = nNo; }
152 
153  OUString GetDescr() const;
154 };
155 
156 class SW_DLLPUBLIC SwRangeRedline final : public SwPaM
157 {
160  bool m_bDelLastPara : 1;
161  bool m_bIsVisible : 1;
162  sal_uInt32 m_nId;
163 
164  std::optional<tools::Long> m_oLOKLastNodeTop;
165 
166  void MoveToSection();
167  void CopyToSection();
168  void DelCopyOfSection(size_t nMyPos);
169  void MoveFromSection(size_t nMyPos);
170 
171 public:
172  static sal_uInt32 s_nLastId;
173 
174  SwRangeRedline( RedlineType eType, const SwPaM& rPam );
175  SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam );
176  SwRangeRedline( const SwRedlineData& rData, const SwPosition& rPos );
177  // For sw3io: pData is taken over!
179  bool bDelLP) :
180  SwPaM( rPos ), m_pRedlineData( pData ), m_pContentSect( nullptr ),
181  m_bDelLastPara( bDelLP ), m_bIsVisible( true ), m_nId( s_nLastId++ )
182  {}
183  SwRangeRedline( const SwRangeRedline& );
184  virtual ~SwRangeRedline() override;
185 
186  sal_uInt32 GetId() const { return m_nId; }
187  SwNodeIndex* GetContentIdx() const { return m_pContentSect; }
188  // For Undo.
189  void SetContentIdx( const SwNodeIndex* );
190 
191  bool IsVisible() const { return m_bIsVisible; }
192  bool IsDelLastPara() const { return m_bDelLastPara; }
193 
194  void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = nullptr );
195  void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = nullptr );
196 
198  bool HasValidRange() const;
199 
200  const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
201  bool operator!=( const SwRedlineData& rCmp ) const
202  { return *m_pRedlineData != rCmp; }
203  void SetAutoFormat() { m_pRedlineData->SetAutoFormat(); }
204  bool IsAutoFormat() const { return m_pRedlineData->IsAutoFormat(); }
205 
206  sal_uInt16 GetStackCount() const;
207  std::size_t GetAuthor( sal_uInt16 nPos = 0) const;
208  OUString const & GetAuthorString( sal_uInt16 nPos = 0 ) const;
209  const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
210  RedlineType GetType( sal_uInt16 nPos = 0 ) const;
211  const OUString& GetComment( sal_uInt16 nPos = 0 ) const;
212 
213  void SetComment( const OUString& rS ) { m_pRedlineData->SetComment( rS ); }
214 
217  void SetExtraData( const SwRedlineExtraData* pData )
218  { m_pRedlineData->SetExtraData( pData ); }
220  { return m_pRedlineData->GetExtraData(); }
221 
222  // For UI-side pooling of Redline-actions.
223  // At the moment only used for Autoformat with Redline.
224  // Value != 0 means there can be others!
225  sal_uInt16 GetSeqNo() const { return m_pRedlineData->GetSeqNo(); }
226  void SetSeqNo( sal_uInt16 nNo ) { m_pRedlineData->SetSeqNo( nNo ); }
227 
228  // At Hide/ShowOriginal the list is traversed two times in order to
229  // hide the Del-Redlines via Copy and Delete.
230  // Otherwise at Move the attribution would be handled incorrectly.
231  // All other callers must always give 0.
232  void CallDisplayFunc(size_t nMyPos);
233  void Show(sal_uInt16 nLoop , size_t nMyPos, bool bForced = false);
234  void Hide(sal_uInt16 nLoop , size_t nMyPos, bool bForced = false);
235  void ShowOriginal(sal_uInt16 nLoop, size_t nMyPos, bool bForced = false);
236 
238  void CalcStartEnd(SwNodeOffset nNdIdx, sal_Int32& rStart, sal_Int32& rEnd) const;
239 
240  enum class Invalidation { Add, Remove };
242  void InvalidateRange(Invalidation);
243 
244  bool IsOwnRedline( const SwRangeRedline& rRedl ) const
245  { return GetAuthor() == rRedl.GetAuthor(); }
246  bool CanCombine( const SwRangeRedline& rRedl ) const;
247 
248  void PushData( const SwRangeRedline& rRedl, bool bOwnAsNext = true );
249  bool PopData();
250 
262  OUString GetDescr(bool bSimplified = false);
263 
264  bool operator<( const SwRangeRedline& ) const;
265  void dumpAsXml(xmlTextWriterPtr pWriter) const;
266 
267  void MaybeNotifyRedlinePositionModification(tools::Long nTop);
268 
269  void SetMoved() { m_pRedlineData->SetMoved(); }
270  bool IsMoved() const { return m_pRedlineData->IsMoved(); }
271 };
272 
274 
277 {
278 private:
279  SwExtraRedline(SwExtraRedline const&) = delete;
280  SwExtraRedline& operator=(SwExtraRedline const&) = delete;
281 public:
282  SwExtraRedline() = default;
283  virtual ~SwExtraRedline();
284 };
285 
288 {
289 private:
292 
293 public:
294  SwTableRowRedline(const SwRedlineData& rData, const SwTableLine& rTableLine);
295  virtual ~SwTableRowRedline() override;
296 
299  void SetExtraData( const SwRedlineExtraData* pData )
300  { m_aRedlineData.SetExtraData( pData ); }
301  const SwTableLine& GetTableLine() const
302  { return m_rTableLine; }
304  { return m_aRedlineData; }
305 };
306 
309 {
310 private:
313 
314 public:
315  SwTableCellRedline(const SwRedlineData& rData, const SwTableBox& rTableBox);
316  virtual ~SwTableCellRedline() override;
317 
320  void SetExtraData( const SwRedlineExtraData* pData )
321  { m_aRedlineData.SetExtraData( pData ); }
322  const SwTableBox& GetTableBox() const
323  { return m_rTableBox; }
325  { return m_aRedlineData; }
326 };
327 
328 class SW_DLLPUBLIC SwRedlineHint final : public SfxHint
329 {
330 };
331 
332 
333 namespace sw {
334 
335 std::vector<SwRangeRedline*> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p);
336 
337 } // namespace sw
338 
339 #endif
340 
341 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:150
bool CanCombine(const SwRangeRedline &rRedl) const
Definition: docredln.cxx:1848
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:219
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:225
void MaybeNotifyRedlineModification(SwRangeRedline &rRedline, SwDoc &rDoc)
Definition: docredln.cxx:1147
Marks a position in the document model.
Definition: pam.hxx:36
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:123
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:320
SwNodeIndex * m_pContentSect
Definition: redline.hxx:159
SwRedlineData * m_pNext
Definition: redline.hxx:89
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:151
const SwRedlineData * Next() const
Definition: redline.hxx:131
void SetTimeStamp(const DateTime &rDT)
Definition: redline.hxx:134
std::size_t GetAuthor() const
Definition: redline.hxx:128
long Long
const SwTableBox & m_rTableBox
Definition: redline.hxx:312
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:226
Definition: doc.hxx:188
void SetMoved()
Definition: redline.hxx:138
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:145
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:324
virtual bool operator==(const SwRedlineExtraData &) const
Definition: docredln.cxx:858
SwTableLine is one table row in the document model.
Definition: swtable.hxx:358
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:303
const SwTableBox & GetTableBox() const
Definition: redline.hxx:322
Dialog to specify the properties of date form field.
bool m_bMoved
Definition: redline.hxx:98
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: pam.cxx:1151
virtual SwRedlineExtraData * CreateNew() const override
Definition: docredln.cxx:961
static sal_uInt32 s_nLastId
Definition: redline.hxx:172
bool IsOwnRedline(const SwRangeRedline &rRedl) const
Definition: redline.hxx:244
RedlineType GetType() const
Definition: redline.hxx:126
bool IsMoved() const
Definition: redline.hxx:139
virtual void Reject(SwPaM &rPam) const
Definition: docredln.cxx:854
sal_uInt16 m_nSeqNo
Definition: redline.hxx:96
void SetComment(const OUString &rS)
Definition: redline.hxx:133
bool IsAutoFormat() const
Definition: redline.hxx:137
bool m_bAutoFormat
Definition: redline.hxx:97
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:217
std::vector< sal_uInt16 > m_aWhichIds
Definition: redline.hxx:74
Redline that holds information about a table-cell that had some change.
Definition: redline.hxx:308
OUString GetDescr(bool bSimplified=false)
Returns textual description of a redline data element of this redline.
Definition: docredln.cxx:1939
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:966
Ring * m_pNext
Definition: ring.hxx:119
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData is copied.
Definition: docredln.cxx:1057
bool IsAutoFormat() const
Definition: redline.hxx:204
std::vector< SwRangeRedline * > GetAllValidRanges(std::unique_ptr< SwRangeRedline > p)
Definition: docredln.cxx:466
void SetFormatAll(bool bAll)
Definition: redline.hxx:69
virtual ~SwRedlineExtraData_Format() override
Definition: docredln.cxx:957
std::optional< tools::Long > m_oLOKLastNodeTop
Definition: redline.hxx:164
const DateTime & GetTimeStamp() const
Definition: redline.hxx:130
bool operator<(const wwFont &r1, const wwFont &r2)
Definition: wrtw8sty.cxx:849
Marks a node in the document model.
Definition: ndindex.hxx:32
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
Base object for 'Redlines' that are not of 'Ranged' type (like table row insert)
Definition: redline.hxx:276
sal_uInt32 GetId() const
Definition: redline.hxx:186
Redline that holds information about a table-row that had some change.
Definition: redline.hxx:287
bool IsVisible() const
Definition: redline.hxx:191
SwRangeRedline(SwRedlineData *pData, const SwPosition &rPos, bool bDelLP)
Definition: redline.hxx:178
void SetComment(const OUString &rS)
Definition: redline.hxx:213
const OUString & GetFormatName() const
Definition: redline.hxx:66
const SwTableLine & GetTableLine() const
Definition: redline.hxx:301
const OUString & GetComment() const
Definition: redline.hxx:129
std::unique_ptr< SfxItemSet > m_pSet
Definition: redline.hxx:55
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:299
OUString m_sComment
Definition: redline.hxx:92
SwRedlineExtraData * m_pExtraData
Definition: redline.hxx:90
bool IsMoved() const
Definition: redline.hxx:270
virtual SwRedlineExtraData * CreateNew() const =0
std::size_t GetAuthor(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1888
RedlineType m_eType
Definition: redline.hxx:95
virtual bool operator==(const SwRedlineExtraData &) const override
Definition: docredln.cxx:983
void SetAutoFormat()
Definition: redline.hxx:136
void SetMoved()
Definition: redline.hxx:269
void SetAutoFormat()
Definition: redline.hxx:203
bool operator==(const SwRedlineData &rCmp) const
Definition: redline.hxx:110
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:419
SfxItemSet * GetItemSet() const
Definition: redline.hxx:68
SwRedlineData m_aRedlineData
Definition: redline.hxx:290
struct _xmlTextWriter * xmlTextWriterPtr
RedlineType
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:201
bool IsDelLastPara() const
Definition: redline.hxx:192
SwRedlineData * m_pRedlineData
Definition: redline.hxx:158
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
SwRedlineData m_aRedlineData
Definition: redline.hxx:311
SwNodeIndex * GetContentIdx() const
Definition: redline.hxx:187
const SwTableLine & m_rTableLine
Definition: redline.hxx:291
sal_uInt32 m_nId
Definition: redline.hxx:162
DateTime m_aStamp
Definition: redline.hxx:93
SwRedlineExtraData_Format(const SwRedlineExtraData_Format &rCpy)
Definition: docredln.cxx:950
std::size_t m_nAuthor
Definition: redline.hxx:94