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 public:
59  SwRedlineExtraData_FormatColl( const OUString& rColl, sal_uInt16 nPoolFormatId,
60  const SfxItemSet* pSet = nullptr );
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 };
70 
72 {
73  std::vector<sal_uInt16> m_aWhichIds;
74 
76 
77 public:
79  virtual ~SwRedlineExtraData_Format() override;
80  virtual SwRedlineExtraData* CreateNew() const override;
81  virtual void Reject( SwPaM& rPam ) const override;
82  virtual bool operator == ( const SwRedlineExtraData& ) const override;
83 };
84 
86 {
87  friend class SwRangeRedline;
88  SwRedlineData* m_pNext; // Points to other data.
90 
91  OUString m_sComment;
95  std::size_t const m_nAuthor;
96  sal_uInt16 m_nSeqNo;
97 
98 public:
99  SwRedlineData( RedlineType eT, std::size_t nAut );
100  SwRedlineData( const SwRedlineData& rCpy, bool bCpyNext = true );
101 
102  // For sw3io: pNext/pExtraData are taken over.
103  SwRedlineData( RedlineType eT, std::size_t nAut, const DateTime& rDT,
104  const OUString& rCmnt, SwRedlineData* pNxt );
105 
106  ~SwRedlineData();
107 
108  bool operator==( const SwRedlineData& rCmp ) const
109  {
110  return m_nAuthor == rCmp.m_nAuthor &&
111  m_eType == rCmp.m_eType &&
112  m_bAutoFormat == rCmp.m_bAutoFormat &&
113  m_sComment == rCmp.m_sComment &&
114  (( !m_pNext && !rCmp.m_pNext ) ||
115  ( m_pNext && rCmp.m_pNext && *m_pNext == *rCmp.m_pNext )) &&
116  (( !m_pExtraData && !rCmp.m_pExtraData ) ||
117  ( m_pExtraData && rCmp.m_pExtraData &&
118  *m_pExtraData == *rCmp.m_pExtraData ));
119  }
120  bool operator!=( const SwRedlineData& rCmp ) const
121  { return !operator==( rCmp ); }
122 
123  RedlineType GetType() const { return m_eType; }
124 
125  std::size_t GetAuthor() const { return m_nAuthor; }
126  const OUString& GetComment() const { return m_sComment; }
127  const DateTime& GetTimeStamp() const { return m_aStamp; }
128  const SwRedlineData* Next() const{ return m_pNext; }
129 
130  void SetComment( const OUString& rS ) { m_sComment = rS; }
131  void SetTimeStamp( const DateTime& rDT ) { m_aStamp = rDT; }
132 
133  void SetAutoFormat() { m_bAutoFormat = true; }
134  bool IsAutoFormat() const { return m_bAutoFormat; }
135  bool CanCombine( const SwRedlineData& rCmp ) const;
136 
137  // ExtraData gets copied, the pointer is therefore not taken over by
138  // the RedlineObject
139  void SetExtraData( const SwRedlineExtraData* pData );
140  const SwRedlineExtraData* GetExtraData() const { return m_pExtraData; }
141 
142  // For UI-side pooling of Redline-actions.
143  // At the moment only used for Autoformat with Redline.
144  // Value != 0 means there can be others!
145  sal_uInt16 GetSeqNo() const { return m_nSeqNo; }
146  void SetSeqNo( sal_uInt16 nNo ) { m_nSeqNo = nNo; }
147 
148  OUString GetDescr() const;
149 };
150 
152 {
155  bool m_bDelLastPara : 1;
156  bool m_bIsVisible : 1;
157  sal_uInt32 const m_nId;
158 
160 
161  void MoveToSection();
162  void CopyToSection();
163  void DelCopyOfSection(size_t nMyPos);
164  void MoveFromSection(size_t nMyPos);
165 
166 public:
167  static sal_uInt32 m_nLastId;
168 
169  SwRangeRedline( RedlineType eType, const SwPaM& rPam );
170  SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam );
171  SwRangeRedline( const SwRedlineData& rData, const SwPosition& rPos );
172  // For sw3io: pData is taken over!
174  bool bDelLP) :
175  SwPaM( rPos ), m_pRedlineData( pData ), m_pContentSect( nullptr ),
176  m_bDelLastPara( bDelLP ), m_bIsVisible( true ), m_nId( m_nLastId++ )
177  {}
178  SwRangeRedline( const SwRangeRedline& );
179  virtual ~SwRangeRedline() override;
180 
181  sal_uInt32 GetId() const { return m_nId; }
182  SwNodeIndex* GetContentIdx() const { return m_pContentSect; }
183  // For Undo.
184  void SetContentIdx( const SwNodeIndex* );
185 
186  bool IsVisible() const { return m_bIsVisible; }
187  bool IsDelLastPara() const { return m_bDelLastPara; }
188 
189  void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = nullptr );
190  void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = nullptr );
191 
193  bool HasValidRange() const;
194 
195  const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
196  bool operator!=( const SwRedlineData& rCmp ) const
197  { return *m_pRedlineData != rCmp; }
198  void SetAutoFormat() { m_pRedlineData->SetAutoFormat(); }
199  bool IsAutoFormat() const { return m_pRedlineData->IsAutoFormat(); }
200 
201  sal_uInt16 GetStackCount() const;
202  std::size_t GetAuthor( sal_uInt16 nPos = 0) const;
203  OUString const & GetAuthorString( sal_uInt16 nPos = 0 ) const;
204  const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
205  RedlineType GetType( sal_uInt16 nPos = 0 ) const;
206  const OUString& GetComment( sal_uInt16 nPos = 0 ) const;
207 
208  void SetComment( const OUString& rS ) { m_pRedlineData->SetComment( rS ); }
209 
212  void SetExtraData( const SwRedlineExtraData* pData )
213  { m_pRedlineData->SetExtraData( pData ); }
215  { return m_pRedlineData->GetExtraData(); }
216 
217  // For UI-side pooling of Redline-actions.
218  // At the moment only used for Autoformat with Redline.
219  // Value != 0 means there can be others!
220  sal_uInt16 GetSeqNo() const { return m_pRedlineData->GetSeqNo(); }
221  void SetSeqNo( sal_uInt16 nNo ) { m_pRedlineData->SetSeqNo( nNo ); }
222 
223  // At Hide/ShowOriginal the list is traversed two times in order to
224  // hide the Del-Redlines via Copy and Delete.
225  // Otherwise at Move the attribution would be handled incorrectly.
226  // All other callers must always give 0.
227  void CallDisplayFunc(size_t nMyPos);
228  void Show(sal_uInt16 nLoop , size_t nMyPos);
229  void Hide(sal_uInt16 nLoop , size_t nMyPos);
230  void ShowOriginal(sal_uInt16 nLoop, size_t nMyPos);
231 
233  void CalcStartEnd(sal_uLong nNdIdx, sal_Int32& rStart, sal_Int32& rEnd) const;
234 
235  enum class Invalidation { Add, Remove };
237  void InvalidateRange(Invalidation);
238 
239  bool IsOwnRedline( const SwRangeRedline& rRedl ) const
240  { return GetAuthor() == rRedl.GetAuthor(); }
241  bool CanCombine( const SwRangeRedline& rRedl ) const;
242 
243  void PushData( const SwRangeRedline& rRedl, bool bOwnAsNext = true );
244  bool PopData();
245 
255  OUString GetDescr();
256 
257  bool operator<( const SwRangeRedline& ) const;
258  void dumpAsXml(xmlTextWriterPtr pWriter) const;
259 
260  void MaybeNotifyRedlinePositionModification(long nTop);
261 };
262 
264 
267 {
268 private:
269  SwExtraRedline(SwExtraRedline const&) = delete;
270  SwExtraRedline& operator=(SwExtraRedline const&) = delete;
271 public:
272  SwExtraRedline() = default;
273  virtual ~SwExtraRedline();
274 };
275 
278 {
279 private:
282 
283 public:
284  SwTableRowRedline(const SwRedlineData& rData, const SwTableLine& rTableLine);
285  virtual ~SwTableRowRedline() override;
286 
289  void SetExtraData( const SwRedlineExtraData* pData )
290  { m_aRedlineData.SetExtraData( pData ); }
291  const SwTableLine& GetTableLine() const
292  { return m_rTableLine; }
294  { return m_aRedlineData; }
295 };
296 
299 {
300 private:
303 
304 public:
305  SwTableCellRedline(const SwRedlineData& rData, const SwTableBox& rTableBox);
306  virtual ~SwTableCellRedline() override;
307 
310  void SetExtraData( const SwRedlineExtraData* pData )
311  { m_aRedlineData.SetExtraData( pData ); }
312  const SwTableBox& GetTableBox() const
313  { return m_rTableBox; }
315  { return m_aRedlineData; }
316 };
317 
319 {
320 };
321 
322 
323 namespace sw {
324 
325 std::vector<SwRangeRedline*> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p);
326 
327 } // namespace sw
328 
329 #endif
330 
331 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SW_DLLPUBLIC void MaybeNotifyRedlineModification(SwRangeRedline *pRedline, SwDoc *pDoc)
Definition: docredln.cxx:1017
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:145
bool CanCombine(const SwRangeRedline &rRedl) const
Definition: docredln.cxx:1659
bool operator<(const SwTextGlyphsKey &l, const SwTextGlyphsKey &r)
Definition: fntcache.cxx:133
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:214
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:220
Marks a position in the document model.
Definition: pam.hxx:35
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:120
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:310
SwNodeIndex * m_pContentSect
Definition: redline.hxx:154
SwRedlineData * m_pNext
Definition: redline.hxx:88
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:146
const SwRedlineData * Next() const
Definition: redline.hxx:128
void SetTimeStamp(const DateTime &rDT)
Definition: redline.hxx:131
std::size_t GetAuthor() const
Definition: redline.hxx:125
sal_uIntPtr sal_uLong
const SwTableBox & m_rTableBox
Definition: redline.hxx:302
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:221
Definition: doc.hxx:185
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:140
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:314
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:293
const SwTableBox & GetTableBox() const
Definition: redline.hxx:312
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
static sal_uInt32 m_nLastId
Definition: redline.hxx:167
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: pam.cxx:1072
virtual SwRedlineExtraData * CreateNew() const override
Definition: docredln.cxx:833
bool IsOwnRedline(const SwRangeRedline &rRedl) const
Definition: redline.hxx:239
RedlineType GetType() const
Definition: redline.hxx:123
virtual void Reject(SwPaM &rPam) const
Definition: docredln.cxx:745
sal_uInt16 m_nSeqNo
Definition: redline.hxx:96
void SetComment(const OUString &rS)
Definition: redline.hxx:130
bool IsAutoFormat() const
Definition: redline.hxx:134
bool m_bAutoFormat
Definition: redline.hxx:94
boost::optional< long > m_oLOKLastNodeTop
Definition: redline.hxx:159
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:212
std::vector< sal_uInt16 > m_aWhichIds
Definition: redline.hxx:73
Redline that holds information about a table-cell that had some change.
Definition: redline.hxx:298
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:838
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:927
bool IsAutoFormat() const
Definition: redline.hxx:199
std::size_t const m_nAuthor
Definition: redline.hxx:95
std::vector< SwRangeRedline * > GetAllValidRanges(std::unique_ptr< SwRangeRedline > p)
Definition: docredln.cxx:452
virtual ~SwRedlineExtraData_Format() override
Definition: docredln.cxx:829
const DateTime & GetTimeStamp() const
Definition: redline.hxx:127
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:266
sal_uInt32 GetId() const
Definition: redline.hxx:181
Redline that holds information about a table-row that had some change.
Definition: redline.hxx:277
bool IsVisible() const
Definition: redline.hxx:186
SwRangeRedline(SwRedlineData *pData, const SwPosition &rPos, bool bDelLP)
Definition: redline.hxx:173
void SetComment(const OUString &rS)
Definition: redline.hxx:208
const OUString & GetFormatName() const
Definition: redline.hxx:66
const SwTableLine & GetTableLine() const
Definition: redline.hxx:291
const OUString & GetComment() const
Definition: redline.hxx:126
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:289
OUString m_sComment
Definition: redline.hxx:91
SwRedlineExtraData * m_pExtraData
Definition: redline.hxx:89
virtual SwRedlineExtraData * CreateNew() const =0
std::size_t GetAuthor(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1699
RedlineType m_eType
Definition: redline.hxx:93
virtual bool operator==(const SwRedlineExtraData &) const override
Definition: docredln.cxx:855
void SetAutoFormat()
Definition: redline.hxx:133
void SetAutoFormat()
Definition: redline.hxx:198
bool operator==(const SwRedlineData &rCmp) const
Definition: redline.hxx:108
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
SfxItemSet * GetItemSet() const
Definition: redline.hxx:68
SwRedlineData m_aRedlineData
Definition: redline.hxx:280
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:196
OUString GetDescr()
Returns textual description of a redline data element of this redline.
Definition: docredln.cxx:1750
bool IsDelLastPara() const
Definition: redline.hxx:187
SwRedlineData * m_pRedlineData
Definition: redline.hxx:153
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
SwRedlineData m_aRedlineData
Definition: redline.hxx:301
SwNodeIndex * GetContentIdx() const
Definition: redline.hxx:182
const SwTableLine & m_rTableLine
Definition: redline.hxx:281
DateTime m_aStamp
Definition: redline.hxx:92
SwRedlineExtraData_Format(const SwRedlineExtraData_Format &rCpy)
Definition: docredln.cxx:822
sal_uInt32 const m_nId
Definition: redline.hxx:157