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 <tools/datetime.hxx>
23 #include <rtl/ustring.hxx>
24 
25 #include "pam.hxx"
26 
28 
29 #include <cstddef>
30 #include <memory>
31 #include <vector>
32 #include <boost/optional.hpp>
33 
34 
35 class SfxItemSet;
36 
38 {
39  SwRedlineExtraData( const SwRedlineExtraData& ) = delete;
40  SwRedlineExtraData& operator=( const SwRedlineExtraData& ) = delete;
41 
42 protected:
44 
45 public:
46  virtual ~SwRedlineExtraData();
47  virtual SwRedlineExtraData* CreateNew() const = 0;
48 
49  virtual void Reject( SwPaM& rPam ) const;
50  virtual bool operator == ( const SwRedlineExtraData& ) const;
51 };
52 
54 {
55  OUString m_sFormatNm;
56  std::unique_ptr<SfxItemSet> m_pSet;
57  sal_uInt16 m_nPoolId;
58  bool m_bFormatAll; // don't strip the last paragraph mark
59 public:
60  SwRedlineExtraData_FormatColl( const OUString& rColl, sal_uInt16 nPoolFormatId,
61  const SfxItemSet* pSet = nullptr, bool bFormatAll = true );
62  virtual ~SwRedlineExtraData_FormatColl() override;
63  virtual SwRedlineExtraData* CreateNew() const override;
64  virtual void Reject( SwPaM& rPam ) const override;
65  virtual bool operator == ( const SwRedlineExtraData& ) const override;
66 
67  const OUString& GetFormatName() const { return m_sFormatNm; }
68  void SetItemSet( const SfxItemSet& rSet );
69  SfxItemSet* GetItemSet( ) const { return m_pSet.get(); }
70  void SetFormatAll( bool bAll ) { m_bFormatAll = bAll; }
71 };
72 
74 {
75  std::vector<sal_uInt16> m_aWhichIds;
76 
78 
79 public:
81  virtual ~SwRedlineExtraData_Format() override;
82  virtual SwRedlineExtraData* CreateNew() const override;
83  virtual void Reject( SwPaM& rPam ) const override;
84  virtual bool operator == ( const SwRedlineExtraData& ) const override;
85 };
86 
88 {
89  friend class SwRangeRedline;
90  SwRedlineData* m_pNext; // Points to other data.
92 
93  OUString m_sComment;
97  std::size_t const m_nAuthor;
98  sal_uInt16 m_nSeqNo;
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_sComment == rCmp.m_sComment &&
116  (( !m_pNext && !rCmp.m_pNext ) ||
117  ( m_pNext && rCmp.m_pNext && *m_pNext == *rCmp.m_pNext )) &&
118  (( !m_pExtraData && !rCmp.m_pExtraData ) ||
119  ( m_pExtraData && rCmp.m_pExtraData &&
120  *m_pExtraData == *rCmp.m_pExtraData ));
121  }
122  bool operator!=( const SwRedlineData& rCmp ) const
123  { return !operator==( rCmp ); }
124 
125  RedlineType GetType() const { return m_eType; }
126 
127  std::size_t GetAuthor() const { return m_nAuthor; }
128  const OUString& GetComment() const { return m_sComment; }
129  const DateTime& GetTimeStamp() const { return m_aStamp; }
130  const SwRedlineData* Next() const{ return m_pNext; }
131 
132  void SetComment( const OUString& rS ) { m_sComment = rS; }
133  void SetTimeStamp( const DateTime& rDT ) { m_aStamp = rDT; }
134 
135  void SetAutoFormat() { m_bAutoFormat = true; }
136  bool IsAutoFormat() const { return m_bAutoFormat; }
137  bool CanCombine( const SwRedlineData& rCmp ) const;
138 
139  // ExtraData gets copied, the pointer is therefore not taken over by
140  // the RedlineObject
141  void SetExtraData( const SwRedlineExtraData* pData );
142  const SwRedlineExtraData* GetExtraData() const { return m_pExtraData; }
143 
144  // For UI-side pooling of Redline-actions.
145  // At the moment only used for Autoformat with Redline.
146  // Value != 0 means there can be others!
147  sal_uInt16 GetSeqNo() const { return m_nSeqNo; }
148  void SetSeqNo( sal_uInt16 nNo ) { m_nSeqNo = nNo; }
149 
150  OUString GetDescr() const;
151 };
152 
154 {
157  bool m_bDelLastPara : 1;
158  bool m_bIsVisible : 1;
159  sal_uInt32 const m_nId;
160 
162 
163  void MoveToSection();
164  void CopyToSection();
165  void DelCopyOfSection(size_t nMyPos);
166  void MoveFromSection(size_t nMyPos);
167 
168 public:
169  static sal_uInt32 m_nLastId;
170 
171  SwRangeRedline( RedlineType eType, const SwPaM& rPam );
172  SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam );
173  SwRangeRedline( const SwRedlineData& rData, const SwPosition& rPos );
174  // For sw3io: pData is taken over!
176  bool bDelLP) :
177  SwPaM( rPos ), m_pRedlineData( pData ), m_pContentSect( nullptr ),
178  m_bDelLastPara( bDelLP ), m_bIsVisible( true ), m_nId( m_nLastId++ )
179  {}
180  SwRangeRedline( const SwRangeRedline& );
181  virtual ~SwRangeRedline() override;
182 
183  sal_uInt32 GetId() const { return m_nId; }
184  SwNodeIndex* GetContentIdx() const { return m_pContentSect; }
185  // For Undo.
186  void SetContentIdx( const SwNodeIndex* );
187 
188  bool IsVisible() const { return m_bIsVisible; }
189  bool IsDelLastPara() const { return m_bDelLastPara; }
190 
191  void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = nullptr );
192  void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = nullptr );
193 
195  bool HasValidRange() const;
196 
197  const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
198  bool operator!=( const SwRedlineData& rCmp ) const
199  { return *m_pRedlineData != rCmp; }
200  void SetAutoFormat() { m_pRedlineData->SetAutoFormat(); }
201  bool IsAutoFormat() const { return m_pRedlineData->IsAutoFormat(); }
202 
203  sal_uInt16 GetStackCount() const;
204  std::size_t GetAuthor( sal_uInt16 nPos = 0) const;
205  OUString const & GetAuthorString( sal_uInt16 nPos = 0 ) const;
206  const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
207  RedlineType GetType( sal_uInt16 nPos = 0 ) const;
208  const OUString& GetComment( sal_uInt16 nPos = 0 ) const;
209 
210  void SetComment( const OUString& rS ) { m_pRedlineData->SetComment( rS ); }
211 
214  void SetExtraData( const SwRedlineExtraData* pData )
215  { m_pRedlineData->SetExtraData( pData ); }
217  { return m_pRedlineData->GetExtraData(); }
218 
219  // For UI-side pooling of Redline-actions.
220  // At the moment only used for Autoformat with Redline.
221  // Value != 0 means there can be others!
222  sal_uInt16 GetSeqNo() const { return m_pRedlineData->GetSeqNo(); }
223  void SetSeqNo( sal_uInt16 nNo ) { m_pRedlineData->SetSeqNo( nNo ); }
224 
225  // At Hide/ShowOriginal the list is traversed two times in order to
226  // hide the Del-Redlines via Copy and Delete.
227  // Otherwise at Move the attribution would be handled incorrectly.
228  // All other callers must always give 0.
229  void CallDisplayFunc(size_t nMyPos);
230  void Show(sal_uInt16 nLoop , size_t nMyPos);
231  void Hide(sal_uInt16 nLoop , size_t nMyPos);
232  void ShowOriginal(sal_uInt16 nLoop, size_t nMyPos);
233 
235  void CalcStartEnd(sal_uLong nNdIdx, sal_Int32& rStart, sal_Int32& rEnd) const;
236 
237  enum class Invalidation { Add, Remove };
239  void InvalidateRange(Invalidation);
240 
241  bool IsOwnRedline( const SwRangeRedline& rRedl ) const
242  { return GetAuthor() == rRedl.GetAuthor(); }
243  bool CanCombine( const SwRangeRedline& rRedl ) const;
244 
245  void PushData( const SwRangeRedline& rRedl, bool bOwnAsNext = true );
246  bool PopData();
247 
257  OUString GetDescr();
258 
259  bool operator<( const SwRangeRedline& ) const;
260  void dumpAsXml(xmlTextWriterPtr pWriter) const;
261 
262  void MaybeNotifyRedlinePositionModification(long nTop);
263 };
264 
266 
269 {
270 private:
271  SwExtraRedline(SwExtraRedline const&) = delete;
272  SwExtraRedline& operator=(SwExtraRedline const&) = delete;
273 public:
274  SwExtraRedline() = default;
275  virtual ~SwExtraRedline();
276 };
277 
280 {
281 private:
284 
285 public:
286  SwTableRowRedline(const SwRedlineData& rData, const SwTableLine& rTableLine);
287  virtual ~SwTableRowRedline() override;
288 
291  void SetExtraData( const SwRedlineExtraData* pData )
292  { m_aRedlineData.SetExtraData( pData ); }
293  const SwTableLine& GetTableLine() const
294  { return m_rTableLine; }
296  { return m_aRedlineData; }
297 };
298 
301 {
302 private:
305 
306 public:
307  SwTableCellRedline(const SwRedlineData& rData, const SwTableBox& rTableBox);
308  virtual ~SwTableCellRedline() override;
309 
312  void SetExtraData( const SwRedlineExtraData* pData )
313  { m_aRedlineData.SetExtraData( pData ); }
314  const SwTableBox& GetTableBox() const
315  { return m_rTableBox; }
317  { return m_aRedlineData; }
318 };
319 
321 {
322 };
323 
324 
325 namespace sw {
326 
327 std::vector<SwRangeRedline*> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p);
328 
329 } // namespace sw
330 
331 #endif
332 
333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SW_DLLPUBLIC void MaybeNotifyRedlineModification(SwRangeRedline *pRedline, SwDoc *pDoc)
Definition: docredln.cxx:1038
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:147
bool CanCombine(const SwRangeRedline &rRedl) const
Definition: docredln.cxx:1680
bool operator<(const SwTextGlyphsKey &l, const SwTextGlyphsKey &r)
Definition: fntcache.cxx:132
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:216
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:222
Marks a position in the document model.
Definition: pam.hxx:35
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:122
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:312
SwNodeIndex * m_pContentSect
Definition: redline.hxx:156
SwRedlineData * m_pNext
Definition: redline.hxx:90
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:148
const SwRedlineData * Next() const
Definition: redline.hxx:130
void SetTimeStamp(const DateTime &rDT)
Definition: redline.hxx:133
std::size_t GetAuthor() const
Definition: redline.hxx:127
sal_uIntPtr sal_uLong
const SwTableBox & m_rTableBox
Definition: redline.hxx:304
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:223
Definition: doc.hxx:185
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:142
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:316
virtual bool operator==(const SwRedlineExtraData &) const
Definition: docredln.cxx:749
SwTableLine is one table row in the document model.
Definition: swtable.hxx:344
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:295
const SwTableBox & GetTableBox() const
Definition: redline.hxx:314
Dialog to specify the properties of date form field.
static sal_uInt32 m_nLastId
Definition: redline.hxx:169
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: pam.cxx:1070
virtual SwRedlineExtraData * CreateNew() const override
Definition: docredln.cxx:854
bool IsOwnRedline(const SwRangeRedline &rRedl) const
Definition: redline.hxx:241
RedlineType GetType() const
Definition: redline.hxx:125
virtual void Reject(SwPaM &rPam) const
Definition: docredln.cxx:745
sal_uInt16 m_nSeqNo
Definition: redline.hxx:98
void SetComment(const OUString &rS)
Definition: redline.hxx:132
bool IsAutoFormat() const
Definition: redline.hxx:136
bool m_bAutoFormat
Definition: redline.hxx:96
boost::optional< long > m_oLOKLastNodeTop
Definition: redline.hxx:161
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:214
std::vector< sal_uInt16 > m_aWhichIds
Definition: redline.hxx:75
Redline that holds information about a table-cell that had some change.
Definition: redline.hxx:300
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:859
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:948
bool IsAutoFormat() const
Definition: redline.hxx:201
std::size_t const m_nAuthor
Definition: redline.hxx:97
std::vector< SwRangeRedline * > GetAllValidRanges(std::unique_ptr< SwRangeRedline > p)
Definition: docredln.cxx:452
void SetFormatAll(bool bAll)
Definition: redline.hxx:70
virtual ~SwRedlineExtraData_Format() override
Definition: docredln.cxx:850
const DateTime & GetTimeStamp() const
Definition: redline.hxx:129
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:268
sal_uInt32 GetId() const
Definition: redline.hxx:183
Redline that holds information about a table-row that had some change.
Definition: redline.hxx:279
bool IsVisible() const
Definition: redline.hxx:188
SwRangeRedline(SwRedlineData *pData, const SwPosition &rPos, bool bDelLP)
Definition: redline.hxx:175
void SetComment(const OUString &rS)
Definition: redline.hxx:210
const OUString & GetFormatName() const
Definition: redline.hxx:67
const SwTableLine & GetTableLine() const
Definition: redline.hxx:293
const OUString & GetComment() const
Definition: redline.hxx:128
std::unique_ptr< SfxItemSet > m_pSet
Definition: redline.hxx:56
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:291
OUString m_sComment
Definition: redline.hxx:93
SwRedlineExtraData * m_pExtraData
Definition: redline.hxx:91
virtual SwRedlineExtraData * CreateNew() const =0
std::size_t GetAuthor(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1720
RedlineType m_eType
Definition: redline.hxx:95
virtual bool operator==(const SwRedlineExtraData &) const override
Definition: docredln.cxx:876
void SetAutoFormat()
Definition: redline.hxx:135
void SetAutoFormat()
Definition: redline.hxx:200
bool operator==(const SwRedlineData &rCmp) const
Definition: redline.hxx:110
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
SfxItemSet * GetItemSet() const
Definition: redline.hxx:69
SwRedlineData m_aRedlineData
Definition: redline.hxx:282
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:198
OUString GetDescr()
Returns textual description of a redline data element of this redline.
Definition: docredln.cxx:1771
bool IsDelLastPara() const
Definition: redline.hxx:189
SwRedlineData * m_pRedlineData
Definition: redline.hxx:155
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
SwRedlineData m_aRedlineData
Definition: redline.hxx:303
SwNodeIndex * GetContentIdx() const
Definition: redline.hxx:184
const SwTableLine & m_rTableLine
Definition: redline.hxx:283
DateTime m_aStamp
Definition: redline.hxx:94
SwRedlineExtraData_Format(const SwRedlineExtraData_Format &rCpy)
Definition: docredln.cxx:843
sal_uInt32 const m_nId
Definition: redline.hxx:159