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 
99 public:
100  SwRedlineData( RedlineType eT, std::size_t nAut );
101  SwRedlineData( const SwRedlineData& rCpy, bool bCpyNext = true );
102 
103  // For sw3io: pNext/pExtraData are taken over.
104  SwRedlineData( RedlineType eT, std::size_t nAut, const DateTime& rDT,
105  const OUString& rCmnt, SwRedlineData* pNxt );
106 
107  ~SwRedlineData();
108 
109  bool operator==( const SwRedlineData& rCmp ) const
110  {
111  return m_nAuthor == rCmp.m_nAuthor &&
112  m_eType == rCmp.m_eType &&
113  m_bAutoFormat == rCmp.m_bAutoFormat &&
114  m_sComment == rCmp.m_sComment &&
115  (( !m_pNext && !rCmp.m_pNext ) ||
116  ( m_pNext && rCmp.m_pNext && *m_pNext == *rCmp.m_pNext )) &&
117  (( !m_pExtraData && !rCmp.m_pExtraData ) ||
118  ( m_pExtraData && rCmp.m_pExtraData &&
119  *m_pExtraData == *rCmp.m_pExtraData ));
120  }
121  bool operator!=( const SwRedlineData& rCmp ) const
122  { return !operator==( rCmp ); }
123 
124  RedlineType GetType() const { return m_eType; }
125 
126  std::size_t GetAuthor() const { return m_nAuthor; }
127  const OUString& GetComment() const { return m_sComment; }
128  const DateTime& GetTimeStamp() const { return m_aStamp; }
129  const SwRedlineData* Next() const{ return m_pNext; }
130 
131  void SetComment( const OUString& rS ) { m_sComment = rS; }
132  void SetTimeStamp( const DateTime& rDT ) { m_aStamp = rDT; }
133 
134  void SetAutoFormat() { m_bAutoFormat = true; }
135  bool IsAutoFormat() const { return m_bAutoFormat; }
136  bool CanCombine( const SwRedlineData& rCmp ) const;
137 
138  // ExtraData gets copied, the pointer is therefore not taken over by
139  // the RedlineObject
140  void SetExtraData( const SwRedlineExtraData* pData );
141  const SwRedlineExtraData* GetExtraData() const { return m_pExtraData; }
142 
143  // For UI-side pooling of Redline-actions.
144  // At the moment only used for Autoformat with Redline.
145  // Value != 0 means there can be others!
146  sal_uInt16 GetSeqNo() const { return m_nSeqNo; }
147  void SetSeqNo( sal_uInt16 nNo ) { m_nSeqNo = nNo; }
148 
149  OUString GetDescr() const;
150 };
151 
152 class SW_DLLPUBLIC SwRangeRedline final : public SwPaM
153 {
156  bool m_bDelLastPara : 1;
157  bool m_bIsVisible : 1;
158  sal_uInt32 m_nId;
159 
160  std::optional<tools::Long> m_oLOKLastNodeTop;
161 
162  void MoveToSection();
163  void CopyToSection();
164  void DelCopyOfSection(size_t nMyPos);
165  void MoveFromSection(size_t nMyPos);
166 
167 public:
168  static sal_uInt32 s_nLastId;
169 
170  SwRangeRedline( RedlineType eType, const SwPaM& rPam );
171  SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam );
172  SwRangeRedline( const SwRedlineData& rData, const SwPosition& rPos );
173  // For sw3io: pData is taken over!
175  bool bDelLP) :
176  SwPaM( rPos ), m_pRedlineData( pData ), m_pContentSect( nullptr ),
177  m_bDelLastPara( bDelLP ), m_bIsVisible( true ), m_nId( s_nLastId++ )
178  {}
179  SwRangeRedline( const SwRangeRedline& );
180  virtual ~SwRangeRedline() override;
181 
182  sal_uInt32 GetId() const { return m_nId; }
183  SwNodeIndex* GetContentIdx() const { return m_pContentSect; }
184  // For Undo.
185  void SetContentIdx( const SwNodeIndex* );
186 
187  bool IsVisible() const { return m_bIsVisible; }
188  bool IsDelLastPara() const { return m_bDelLastPara; }
189 
190  void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = nullptr );
191  void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = nullptr );
192 
194  bool HasValidRange() const;
195 
196  const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
197  bool operator!=( const SwRedlineData& rCmp ) const
198  { return *m_pRedlineData != rCmp; }
199  void SetAutoFormat() { m_pRedlineData->SetAutoFormat(); }
200  bool IsAutoFormat() const { return m_pRedlineData->IsAutoFormat(); }
201 
202  sal_uInt16 GetStackCount() const;
203  std::size_t GetAuthor( sal_uInt16 nPos = 0) const;
204  OUString const & GetAuthorString( sal_uInt16 nPos = 0 ) const;
205  const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
206  RedlineType GetType( sal_uInt16 nPos = 0 ) const;
207  const OUString& GetComment( sal_uInt16 nPos = 0 ) const;
208 
209  void SetComment( const OUString& rS ) { m_pRedlineData->SetComment( rS ); }
210 
213  void SetExtraData( const SwRedlineExtraData* pData )
214  { m_pRedlineData->SetExtraData( pData ); }
216  { return m_pRedlineData->GetExtraData(); }
217 
218  // For UI-side pooling of Redline-actions.
219  // At the moment only used for Autoformat with Redline.
220  // Value != 0 means there can be others!
221  sal_uInt16 GetSeqNo() const { return m_pRedlineData->GetSeqNo(); }
222  void SetSeqNo( sal_uInt16 nNo ) { m_pRedlineData->SetSeqNo( nNo ); }
223 
224  // At Hide/ShowOriginal the list is traversed two times in order to
225  // hide the Del-Redlines via Copy and Delete.
226  // Otherwise at Move the attribution would be handled incorrectly.
227  // All other callers must always give 0.
228  void CallDisplayFunc(size_t nMyPos);
229  void Show(sal_uInt16 nLoop , size_t nMyPos, bool bForced = false);
230  void Hide(sal_uInt16 nLoop , size_t nMyPos, bool bForced = false);
231  void ShowOriginal(sal_uInt16 nLoop, size_t nMyPos, bool bForced = false);
232 
234  void CalcStartEnd(sal_uLong nNdIdx, sal_Int32& rStart, sal_Int32& rEnd) const;
235 
236  enum class Invalidation { Add, Remove };
238  void InvalidateRange(Invalidation);
239 
240  bool IsOwnRedline( const SwRangeRedline& rRedl ) const
241  { return GetAuthor() == rRedl.GetAuthor(); }
242  bool CanCombine( const SwRangeRedline& rRedl ) const;
243 
244  void PushData( const SwRangeRedline& rRedl, bool bOwnAsNext = true );
245  bool PopData();
246 
258  OUString GetDescr(bool bSimplified = false);
259 
260  bool operator<( const SwRangeRedline& ) const;
261  void dumpAsXml(xmlTextWriterPtr pWriter) const;
262 
263  void MaybeNotifyRedlinePositionModification(tools::Long nTop);
264 };
265 
267 
270 {
271 private:
272  SwExtraRedline(SwExtraRedline const&) = delete;
273  SwExtraRedline& operator=(SwExtraRedline const&) = delete;
274 public:
275  SwExtraRedline() = default;
276  virtual ~SwExtraRedline();
277 };
278 
281 {
282 private:
285 
286 public:
287  SwTableRowRedline(const SwRedlineData& rData, const SwTableLine& rTableLine);
288  virtual ~SwTableRowRedline() override;
289 
292  void SetExtraData( const SwRedlineExtraData* pData )
293  { m_aRedlineData.SetExtraData( pData ); }
294  const SwTableLine& GetTableLine() const
295  { return m_rTableLine; }
297  { return m_aRedlineData; }
298 };
299 
302 {
303 private:
306 
307 public:
308  SwTableCellRedline(const SwRedlineData& rData, const SwTableBox& rTableBox);
309  virtual ~SwTableCellRedline() override;
310 
313  void SetExtraData( const SwRedlineExtraData* pData )
314  { m_aRedlineData.SetExtraData( pData ); }
315  const SwTableBox& GetTableBox() const
316  { return m_rTableBox; }
318  { return m_aRedlineData; }
319 };
320 
321 class SW_DLLPUBLIC SwRedlineHint final : public SfxHint
322 {
323 };
324 
325 
326 namespace sw {
327 
328 std::vector<SwRangeRedline*> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p);
329 
330 } // namespace sw
331 
332 #endif
333 
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:146
bool CanCombine(const SwRangeRedline &rRedl) const
Definition: docredln.cxx:1755
bool operator<(const SwTextGlyphsKey &l, const SwTextGlyphsKey &r)
Definition: fntcache.cxx:121
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:215
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:221
void MaybeNotifyRedlineModification(SwRangeRedline &rRedline, SwDoc &rDoc)
Definition: docredln.cxx:1048
Marks a position in the document model.
Definition: pam.hxx:35
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:121
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:313
SwNodeIndex * m_pContentSect
Definition: redline.hxx:155
SwRedlineData * m_pNext
Definition: redline.hxx:89
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:147
const SwRedlineData * Next() const
Definition: redline.hxx:129
void SetTimeStamp(const DateTime &rDT)
Definition: redline.hxx:132
std::size_t GetAuthor() const
Definition: redline.hxx:126
sal_uIntPtr sal_uLong
long Long
const SwTableBox & m_rTableBox
Definition: redline.hxx:305
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:222
Definition: doc.hxx:188
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:141
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:317
virtual bool operator==(const SwRedlineExtraData &) const
Definition: docredln.cxx:759
SwTableLine is one table row in the document model.
Definition: swtable.hxx:351
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:296
const SwTableBox & GetTableBox() const
Definition: redline.hxx:315
Dialog to specify the properties of date form field.
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: pam.cxx:1151
virtual SwRedlineExtraData * CreateNew() const override
Definition: docredln.cxx:864
static sal_uInt32 s_nLastId
Definition: redline.hxx:168
bool IsOwnRedline(const SwRangeRedline &rRedl) const
Definition: redline.hxx:240
RedlineType GetType() const
Definition: redline.hxx:124
virtual void Reject(SwPaM &rPam) const
Definition: docredln.cxx:755
sal_uInt16 m_nSeqNo
Definition: redline.hxx:96
void SetComment(const OUString &rS)
Definition: redline.hxx:131
bool IsAutoFormat() const
Definition: redline.hxx:135
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:213
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:301
OUString GetDescr(bool bSimplified=false)
Returns textual description of a redline data element of this redline.
Definition: docredln.cxx:1846
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:869
Ring * m_pNext
Definition: ring.hxx:119
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
struct _xmlTextWriter * xmlTextWriterPtr
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData is copied.
Definition: docredln.cxx:958
bool IsAutoFormat() const
Definition: redline.hxx:200
std::vector< SwRangeRedline * > GetAllValidRanges(std::unique_ptr< SwRangeRedline > p)
Definition: docredln.cxx:458
void SetFormatAll(bool bAll)
Definition: redline.hxx:69
virtual ~SwRedlineExtraData_Format() override
Definition: docredln.cxx:860
std::optional< tools::Long > m_oLOKLastNodeTop
Definition: redline.hxx:160
const DateTime & GetTimeStamp() const
Definition: redline.hxx:128
Marks a node in the document model.
Definition: ndindex.hxx:31
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
Base object for 'Redlines' that are not of 'Ranged' type (like table row insert)
Definition: redline.hxx:269
sal_uInt32 GetId() const
Definition: redline.hxx:182
Redline that holds information about a table-row that had some change.
Definition: redline.hxx:280
bool IsVisible() const
Definition: redline.hxx:187
SwRangeRedline(SwRedlineData *pData, const SwPosition &rPos, bool bDelLP)
Definition: redline.hxx:174
void SetComment(const OUString &rS)
Definition: redline.hxx:209
const OUString & GetFormatName() const
Definition: redline.hxx:66
const SwTableLine & GetTableLine() const
Definition: redline.hxx:294
const OUString & GetComment() const
Definition: redline.hxx:127
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:292
OUString m_sComment
Definition: redline.hxx:92
SwRedlineExtraData * m_pExtraData
Definition: redline.hxx:90
virtual SwRedlineExtraData * CreateNew() const =0
std::size_t GetAuthor(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1795
RedlineType m_eType
Definition: redline.hxx:95
virtual bool operator==(const SwRedlineExtraData &) const override
Definition: docredln.cxx:886
void SetAutoFormat()
Definition: redline.hxx:134
void SetAutoFormat()
Definition: redline.hxx:199
bool operator==(const SwRedlineData &rCmp) const
Definition: redline.hxx:109
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:395
SfxItemSet * GetItemSet() const
Definition: redline.hxx:68
SwRedlineData m_aRedlineData
Definition: redline.hxx:283
RedlineType
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:197
bool IsDelLastPara() const
Definition: redline.hxx:188
SwRedlineData * m_pRedlineData
Definition: redline.hxx:154
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
SwRedlineData m_aRedlineData
Definition: redline.hxx:304
SwNodeIndex * GetContentIdx() const
Definition: redline.hxx:183
const SwTableLine & m_rTableLine
Definition: redline.hxx:284
sal_uInt32 m_nId
Definition: redline.hxx:158
DateTime m_aStamp
Definition: redline.hxx:93
SwRedlineExtraData_Format(const SwRedlineExtraData_Format &rCpy)
Definition: docredln.cxx:853
std::size_t m_nAuthor
Definition: redline.hxx:94