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( OUString aColl, 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 OUString aCmnt, 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 bool IsAnonymized() const
132 {
133 return m_aStamp.GetYear() == 1970 &&
134 m_aStamp.GetMonth() == 1 && m_aStamp.GetDay() == 1;
135 }
136
137 const SwRedlineData* Next() const{ return m_pNext; }
138
139 void SetComment( const OUString& rS ) { m_sComment = rS; }
140 void SetTimeStamp( const DateTime& rDT ) { m_aStamp = rDT; }
141
142 void SetAutoFormat() { m_bAutoFormat = true; }
143 bool IsAutoFormat() const { return m_bAutoFormat; }
144 void SetMoved() { m_bMoved = true; }
145 bool IsMoved() const { return m_bMoved; }
146 bool CanCombine( const SwRedlineData& rCmp ) const;
147
148 // ExtraData gets copied, the pointer is therefore not taken over by
149 // the RedlineObject
150 void SetExtraData( const SwRedlineExtraData* pData );
151 const SwRedlineExtraData* GetExtraData() const { return m_pExtraData; }
152
153 // For UI-side pooling of Redline-actions.
154 // At the moment only used for Autoformat with Redline.
155 // Value != 0 means there can be others!
156 sal_uInt16 GetSeqNo() const { return m_nSeqNo; }
157 void SetSeqNo( sal_uInt16 nNo ) { m_nSeqNo = nNo; }
158
159 OUString GetDescr() const;
160};
161
163{
165 std::optional<SwNodeIndex> m_oContentSect;
166 std::optional<tools::Long> m_oLOKLastNodeTop;
167 sal_uInt32 m_nId;
169 bool m_bIsVisible : 1;
170
171 void MoveToSection();
172 void CopyToSection();
173 void DelCopyOfSection(size_t nMyPos);
174 void MoveFromSection(size_t nMyPos);
175
176public:
177 static sal_uInt32 s_nLastId;
178
179 SwRangeRedline( RedlineType eType, const SwPaM& rPam );
180 SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam );
181 SwRangeRedline( const SwRedlineData& rData, const SwPosition& rPos );
182 // For sw3io: pData is taken over!
184 bool bDelLP) :
185 SwPaM( rPos ), m_pRedlineData( pData ),
186 m_nId( s_nLastId++ ), m_bDelLastPara( bDelLP ), m_bIsVisible( true )
187 {
188 GetBound().SetRedline(this);
189 GetBound(false).SetRedline(this);
190 }
192 virtual ~SwRangeRedline() override;
193
194 sal_uInt32 GetId() const { return m_nId; }
195 const SwNodeIndex* GetContentIdx() const { return m_oContentSect ? &*m_oContentSect : nullptr; }
196 // For Undo.
197 void SetContentIdx( const SwNodeIndex& );
198 void ClearContentIdx();
199
200 bool IsVisible() const { return m_bIsVisible; }
201 bool IsDelLastPara() const { return m_bDelLastPara; }
202
203 void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = nullptr );
204 void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = nullptr );
205
207 bool HasValidRange() const;
208
209 const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
210 bool operator!=( const SwRedlineData& rCmp ) const
211 { return *m_pRedlineData != rCmp; }
212 void SetAutoFormat() { m_pRedlineData->SetAutoFormat(); }
213 bool IsAutoFormat() const { return m_pRedlineData->IsAutoFormat(); }
214
215 sal_uInt16 GetStackCount() const;
216 std::size_t GetAuthor( sal_uInt16 nPos = 0) const;
217 OUString const & GetAuthorString( sal_uInt16 nPos = 0 ) const;
218 const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
219 RedlineType GetType( sal_uInt16 nPos = 0 ) const;
220 // text content of the redline is only an annotation placeholder
221 // (i.e. a comment, but don't confuse it with comment of the redline)
222 bool IsAnnotation() const;
223 const OUString& GetComment( sal_uInt16 nPos = 0 ) const;
224
225 void SetComment( const OUString& rS ) { m_pRedlineData->SetComment( rS ); }
226
229 void SetExtraData( const SwRedlineExtraData* pData )
230 { m_pRedlineData->SetExtraData( pData ); }
232 { return m_pRedlineData->GetExtraData(); }
233
234 // For UI-side pooling of Redline-actions.
235 // At the moment only used for Autoformat with Redline.
236 // Value != 0 means there can be others!
237 sal_uInt16 GetSeqNo() const { return m_pRedlineData->GetSeqNo(); }
238 void SetSeqNo( sal_uInt16 nNo ) { m_pRedlineData->SetSeqNo( nNo ); }
239
240 // At Hide/ShowOriginal the list is traversed two times in order to
241 // hide the Del-Redlines via Copy and Delete.
242 // Otherwise at Move the attribution would be handled incorrectly.
243 // All other callers must always give 0.
244 void CallDisplayFunc(size_t nMyPos);
245 void Show(sal_uInt16 nLoop , size_t nMyPos, bool bForced = false);
246 void Hide(sal_uInt16 nLoop , size_t nMyPos, bool bForced = false);
247 void ShowOriginal(sal_uInt16 nLoop, size_t nMyPos, bool bForced = false);
248
250 void CalcStartEnd(SwNodeOffset nNdIdx, sal_Int32& rStart, sal_Int32& rEnd) const;
251
252 enum class Invalidation { Add, Remove };
254 void InvalidateRange(Invalidation);
255
256 bool IsOwnRedline( const SwRangeRedline& rRedl ) const
257 { return GetAuthor() == rRedl.GetAuthor(); }
258 bool CanCombine( const SwRangeRedline& rRedl ) const;
259
260 void PushData( const SwRangeRedline& rRedl, bool bOwnAsNext = true );
261 bool PopData();
262
274 OUString GetDescr(bool bSimplified = false);
275
276 bool operator<( const SwRangeRedline& ) const;
277 void dumpAsXml(xmlTextWriterPtr pWriter) const;
278
279 void MaybeNotifyRedlinePositionModification(tools::Long nTop);
280
281 void SetMoved() { m_pRedlineData->SetMoved(); }
282 bool IsMoved() const { return m_pRedlineData->IsMoved(); }
283};
284
286
289{
290private:
293public:
294 SwExtraRedline() = default;
295 virtual ~SwExtraRedline();
296};
297
300{
301private:
304
305public:
306 SwTableRowRedline(const SwRedlineData& rData, const SwTableLine& rTableLine);
307 virtual ~SwTableRowRedline() override;
308
311 void SetExtraData( const SwRedlineExtraData* pData )
312 { m_aRedlineData.SetExtraData( pData ); }
314 { return m_rTableLine; }
316 { return m_aRedlineData; }
317};
318
321{
322private:
325
326public:
327 SwTableCellRedline(const SwRedlineData& rData, const SwTableBox& rTableBox);
328 virtual ~SwTableCellRedline() override;
329
332 void SetExtraData( const SwRedlineExtraData* pData )
333 { m_aRedlineData.SetExtraData( pData ); }
334 const SwTableBox& GetTableBox() const
335 { return m_rTableBox; }
337 { return m_aRedlineData; }
338};
339
341{
342};
343
344
345namespace sw {
346
347std::vector<std::unique_ptr<SwRangeRedline>> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p);
348
349} // namespace sw
350
351#endif
352
353/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
sal_uInt16 GetMonth() const
Definition: doc.hxx:197
Base object for 'Redlines' that are not of 'Ranged' type (like table row insert\delete)
Definition: redline.hxx:289
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:188
sal_uInt32 m_nId
Definition: redline.hxx:167
sal_uInt32 GetId() const
Definition: redline.hxx:194
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:229
bool IsAutoFormat() const
Definition: redline.hxx:213
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:238
static sal_uInt32 s_nLastId
Definition: redline.hxx:177
std::size_t GetAuthor(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1960
const SwNodeIndex * GetContentIdx() const
Definition: redline.hxx:195
SwRangeRedline(SwRedlineData *pData, const SwPosition &rPos, bool bDelLP)
Definition: redline.hxx:183
bool IsVisible() const
Definition: redline.hxx:200
bool operator!=(const SwRedlineData &rCmp) const
Definition: redline.hxx:210
bool m_bDelLastPara
Definition: redline.hxx:168
std::optional< SwNodeIndex > m_oContentSect
Definition: redline.hxx:165
bool IsOwnRedline(const SwRangeRedline &rRedl) const
Definition: redline.hxx:256
const SwRedlineExtraData * GetExtraData() const
Definition: redline.hxx:231
void SetAutoFormat()
Definition: redline.hxx:212
OUString GetDescr(bool bSimplified=false)
Returns textual description of a redline data element of this redline.
Definition: docredln.cxx:2016
bool IsMoved() const
Definition: redline.hxx:282
void SetMoved()
Definition: redline.hxx:281
std::optional< tools::Long > m_oLOKLastNodeTop
Definition: redline.hxx:166
void SetComment(const OUString &rS)
Definition: redline.hxx:225
SwRedlineData * m_pRedlineData
Definition: redline.hxx:164
bool IsDelLastPara() const
Definition: redline.hxx:201
bool CanCombine(const SwRangeRedline &rRedl) const
Definition: docredln.cxx:1920
bool m_bIsVisible
Definition: redline.hxx:169
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:237
std::size_t m_nAuthor
Definition: redline.hxx:94
SwRedlineData * m_pNext
Definition: redline.hxx:89
void SetMoved()
Definition: redline.hxx:144
DateTime m_aStamp
Definition: redline.hxx:93
bool IsAutoFormat() const
Definition: redline.hxx:143
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:156
SwRedlineExtraData * m_pExtraData
Definition: redline.hxx:90
bool IsMoved() const
Definition: redline.hxx:145
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:151
const SwRedlineData * Next() const
Definition: redline.hxx:137
void SetTimeStamp(const DateTime &rDT)
Definition: redline.hxx:140
void SetAutoFormat()
Definition: redline.hxx:142
RedlineType m_eType
Definition: redline.hxx:95
void SetSeqNo(sal_uInt16 nNo)
Definition: redline.hxx:157
void SetComment(const OUString &rS)
Definition: redline.hxx:139
OUString m_sComment
Definition: redline.hxx:92
bool IsAnonymized() const
Definition: redline.hxx:131
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:1114
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:1006
virtual SwRedlineExtraData * CreateNew() const override
Definition: docredln.cxx:1010
virtual bool operator==(const SwRedlineExtraData &) const override
Definition: docredln.cxx:1032
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:1015
std::vector< sal_uInt16 > m_aWhichIds
Definition: redline.hxx:74
SwRedlineExtraData_Format(const SwRedlineExtraData_Format &rCpy)
Definition: docredln.cxx:999
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:443
Redline that holds information about a table-cell that had some change.
Definition: redline.hxx:321
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:332
SwRedlineData m_aRedlineData
Definition: redline.hxx:323
const SwTableBox & m_rTableBox
Definition: redline.hxx:324
const SwTableBox & GetTableBox() const
Definition: redline.hxx:334
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:336
SwTableLine is one table row in the document model.
Definition: swtable.hxx:376
Redline that holds information about a table-row that had some change.
Definition: redline.hxx:300
const SwTableLine & m_rTableLine
Definition: redline.hxx:303
const SwTableLine & GetTableLine() const
Definition: redline.hxx:313
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:315
SwRedlineData m_aRedlineData
Definition: redline.hxx:302
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:311
Ring * m_pNext
Definition: ring.hxx:119
RedlineType
struct _xmlTextWriter * xmlTextWriterPtr
const EnumerationType m_eType
std::unique_ptr< sal_Int32[]> pData
Dialog to specify the properties of date form field.
std::vector< std::unique_ptr< SwRangeRedline > > GetAllValidRanges(std::unique_ptr< SwRangeRedline > p)
Definition: docredln.cxx:483
long Long
void MaybeNotifyRedlineModification(SwRangeRedline &rRedline, SwDoc &rDoc)
Definition: docredln.cxx:1220
Marks a position in the document model.
Definition: pam.hxx:38
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool operator<(const wwFont &r1, const wwFont &r2)
Definition: wrtw8sty.cxx:885
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)