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
34class SfxItemSet;
35
37{
40
41protected:
43
44public:
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
58public:
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
78public:
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;
99
100public:
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
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
157{
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
171public:
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 {}
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 // text content of the redline is only an annotation placeholder
212 // (i.e. a comment, but don't confuse it with comment of the redline)
213 bool IsAnnotation() const;
214 const OUString& GetComment( sal_uInt16 nPos = 0 ) const;
215
216 void SetComment( const OUString& rS ) { m_pRedlineData->SetComment( rS ); }
217
220 void SetExtraData( const SwRedlineExtraData* pData )
221 { m_pRedlineData->SetExtraData( pData ); }
223 { return m_pRedlineData->GetExtraData(); }
224
225 // For UI-side pooling of Redline-actions.
226 // At the moment only used for Autoformat with Redline.
227 // Value != 0 means there can be others!
228 sal_uInt16 GetSeqNo() const { return m_pRedlineData->GetSeqNo(); }
229 void SetSeqNo( sal_uInt16 nNo ) { m_pRedlineData->SetSeqNo( nNo ); }
230
231 // At Hide/ShowOriginal the list is traversed two times in order to
232 // hide the Del-Redlines via Copy and Delete.
233 // Otherwise at Move the attribution would be handled incorrectly.
234 // All other callers must always give 0.
235 void CallDisplayFunc(size_t nMyPos);
236 void Show(sal_uInt16 nLoop , size_t nMyPos, bool bForced = false);
237 void Hide(sal_uInt16 nLoop , size_t nMyPos, bool bForced = false);
238 void ShowOriginal(sal_uInt16 nLoop, size_t nMyPos, bool bForced = false);
239
241 void CalcStartEnd(SwNodeOffset nNdIdx, sal_Int32& rStart, sal_Int32& rEnd) const;
242
243 enum class Invalidation { Add, Remove };
245 void InvalidateRange(Invalidation);
246
247 bool IsOwnRedline( const SwRangeRedline& rRedl ) const
248 { return GetAuthor() == rRedl.GetAuthor(); }
249 bool CanCombine( const SwRangeRedline& rRedl ) const;
250
251 void PushData( const SwRangeRedline& rRedl, bool bOwnAsNext = true );
252 bool PopData();
253
265 OUString GetDescr(bool bSimplified = false);
266
267 bool operator<( const SwRangeRedline& ) const;
268 void dumpAsXml(xmlTextWriterPtr pWriter) const;
269
270 void MaybeNotifyRedlinePositionModification(tools::Long nTop);
271
272 void SetMoved() { m_pRedlineData->SetMoved(); }
273 bool IsMoved() const { return m_pRedlineData->IsMoved(); }
274};
275
277
280{
281private:
284public:
285 SwExtraRedline() = default;
286 virtual ~SwExtraRedline();
287};
288
291{
292private:
295
296public:
297 SwTableRowRedline(const SwRedlineData& rData, const SwTableLine& rTableLine);
298 virtual ~SwTableRowRedline() override;
299
302 void SetExtraData( const SwRedlineExtraData* pData )
303 { m_aRedlineData.SetExtraData( pData ); }
305 { return m_rTableLine; }
307 { return m_aRedlineData; }
308};
309
312{
313private:
316
317public:
318 SwTableCellRedline(const SwRedlineData& rData, const SwTableBox& rTableBox);
319 virtual ~SwTableCellRedline() override;
320
323 void SetExtraData( const SwRedlineExtraData* pData )
324 { m_aRedlineData.SetExtraData( pData ); }
325 const SwTableBox& GetTableBox() const
326 { return m_rTableBox; }
328 { return m_aRedlineData; }
329};
330
332{
333};
334
335
336namespace sw {
337
338std::vector<SwRangeRedline*> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p);
339
340} // namespace sw
341
342#endif
343
344/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
Definition: doc.hxx:188
Base object for 'Redlines' that are not of 'Ranged' type (like table row insert\delete)
Definition: redline.hxx:280
SwExtraRedline(SwExtraRedline const &)=delete
SwExtraRedline & operator=(SwExtraRedline const &)=delete
SwExtraRedline()=default
Marks a node in the document model.
Definition: ndindex.hxx:31
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:138
sal_uInt32 m_nId
Definition: redline.hxx:162
sal_uInt32 GetId() const
Definition: redline.hxx:186
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:220
bool IsAutoFormat() const
Definition: redline.hxx:204
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:229
static sal_uInt32 s_nLastId
Definition: redline.hxx:172
std::size_t GetAuthor(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1914
SwRangeRedline(SwRedlineData *pData, const SwPosition &rPos, bool bDelLP)
Definition: redline.hxx:178
bool IsVisible() const
Definition: redline.hxx:191
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:201
bool m_bDelLastPara
Definition: redline.hxx:160
bool IsOwnRedline(const SwRangeRedline &rRedl) const
Definition: redline.hxx:247
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:222
SwNodeIndex * GetContentIdx() const
Definition: redline.hxx:187
void SetAutoFormat()
Definition: redline.hxx:203
OUString GetDescr(bool bSimplified=false)
Returns textual description of a redline data element of this redline.
Definition: docredln.cxx:1970
bool IsMoved() const
Definition: redline.hxx:273
void SetMoved()
Definition: redline.hxx:272
std::optional< tools::Long > m_oLOKLastNodeTop
Definition: redline.hxx:164
void SetComment(const OUString &rS)
Definition: redline.hxx:216
SwRedlineData * m_pRedlineData
Definition: redline.hxx:158
bool IsDelLastPara() const
Definition: redline.hxx:192
bool CanCombine(const SwRangeRedline &rRedl) const
Definition: docredln.cxx:1874
bool m_bIsVisible
Definition: redline.hxx:161
SwNodeIndex * m_pContentSect
Definition: redline.hxx:159
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:228
std::size_t m_nAuthor
Definition: redline.hxx:94
SwRedlineData * m_pNext
Definition: redline.hxx:89
void SetMoved()
Definition: redline.hxx:138
DateTime m_aStamp
Definition: redline.hxx:93
bool IsAutoFormat() const
Definition: redline.hxx:137
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:150
SwRedlineExtraData * m_pExtraData
Definition: redline.hxx:90
bool IsMoved() const
Definition: redline.hxx:139
bool operator==(const SwRedlineData &rCmp) const
Definition: redline.hxx:110
std::size_t GetAuthor() const
Definition: redline.hxx:128
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:123
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:145
const SwRedlineData * Next() const
Definition: redline.hxx:131
void SetTimeStamp(const DateTime &rDT)
Definition: redline.hxx:134
void SetAutoFormat()
Definition: redline.hxx:136
RedlineType m_eType
Definition: redline.hxx:95
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:151
void SetComment(const OUString &rS)
Definition: redline.hxx:133
OUString m_sComment
Definition: redline.hxx:92
bool m_bMoved
Definition: redline.hxx:98
bool m_bAutoFormat
Definition: redline.hxx:97
const OUString & GetComment() const
Definition: redline.hxx:129
sal_uInt16 m_nSeqNo
Definition: redline.hxx:96
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData is copied.
Definition: docredln.cxx:1075
const DateTime & GetTimeStamp() const
Definition: redline.hxx:130
RedlineType GetType() const
Definition: redline.hxx:126
SfxItemSet * GetItemSet() const
Definition: redline.hxx:68
const OUString & GetFormatName() const
Definition: redline.hxx:66
std::unique_ptr< SfxItemSet > m_pSet
Definition: redline.hxx:55
void SetFormatAll(bool bAll)
Definition: redline.hxx:69
virtual ~SwRedlineExtraData_Format() override
Definition: docredln.cxx:975
virtual SwRedlineExtraData * CreateNew() const override
Definition: docredln.cxx:979
virtual bool operator==(const SwRedlineExtraData &) const override
Definition: docredln.cxx:1001
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:984
std::vector< sal_uInt16 > m_aWhichIds
Definition: redline.hxx:74
SwRedlineExtraData_Format(const SwRedlineExtraData_Format &rCpy)
Definition: docredln.cxx:968
virtual SwRedlineExtraData * CreateNew() const =0
SwRedlineExtraData & operator=(const SwRedlineExtraData &)=delete
SwRedlineExtraData(const SwRedlineExtraData &)=delete
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:419
Redline that holds information about a table-cell that had some change.
Definition: redline.hxx:312
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:323
SwRedlineData m_aRedlineData
Definition: redline.hxx:314
const SwTableBox & m_rTableBox
Definition: redline.hxx:315
const SwTableBox & GetTableBox() const
Definition: redline.hxx:325
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:327
SwTableLine is one table row in the document model.
Definition: swtable.hxx:358
Redline that holds information about a table-row that had some change.
Definition: redline.hxx:291
const SwTableLine & m_rTableLine
Definition: redline.hxx:294
const SwTableLine & GetTableLine() const
Definition: redline.hxx:304
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:306
SwRedlineData m_aRedlineData
Definition: redline.hxx:293
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:302
Ring * m_pNext
Definition: ring.hxx:119
RedlineType
const EnumerationType m_eType
std::unique_ptr< sal_Int32[]> pData
Dialog to specify the properties of date form field.
std::vector< SwRangeRedline * > GetAllValidRanges(std::unique_ptr< SwRangeRedline > p)
Definition: docredln.cxx:484
long Long
void MaybeNotifyRedlineModification(SwRangeRedline &rRedline, SwDoc &rDoc)
Definition: docredln.cxx:1173
Marks a position in the document model.
Definition: pam.hxx:37
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool operator<(const wwFont &r1, const wwFont &r2)
Definition: wrtw8sty.cxx:841
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)