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