1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_REDLINE_HXX
20 #define INCLUDED_SW_INC_REDLINE_HXX
22 #include <tools/datetime.hxx>
23 #include <rtl/ustring.hxx>
26 #include <swtable.hxx>
28 #include <IDocumentRedlineAccess.hxx>
30 #include <svl/smplhint.hxx>
36 class SW_DLLPUBLIC SwRedlineExtraData
38 SwRedlineExtraData( const SwRedlineExtraData
& ) SAL_DELETED_FUNCTION
;
39 SwRedlineExtraData
& operator=( const SwRedlineExtraData
& ) SAL_DELETED_FUNCTION
;
42 SwRedlineExtraData() {}
45 virtual ~SwRedlineExtraData();
46 virtual SwRedlineExtraData
* CreateNew() const = 0;
48 virtual void Reject( SwPaM
& rPam
) const;
49 virtual bool operator == ( const SwRedlineExtraData
& ) const;
52 class SwRedlineExtraData_FormatColl
: public SwRedlineExtraData
58 SwRedlineExtraData_FormatColl( const OUString
& rColl
, sal_uInt16 nPoolFormatId
,
59 const SfxItemSet
* pSet
= 0 );
60 virtual ~SwRedlineExtraData_FormatColl();
61 virtual SwRedlineExtraData
* CreateNew() const SAL_OVERRIDE
;
62 virtual void Reject( SwPaM
& rPam
) const SAL_OVERRIDE
;
63 virtual bool operator == ( const SwRedlineExtraData
& ) const SAL_OVERRIDE
;
65 void SetItemSet( const SfxItemSet
& rSet
);
68 class SwRedlineExtraData_Format
: public SwRedlineExtraData
70 std::vector
<sal_uInt16
> aWhichIds
;
72 SwRedlineExtraData_Format( const SwRedlineExtraData_Format
& rCpy
);
75 SwRedlineExtraData_Format( const SfxItemSet
& rSet
);
76 virtual ~SwRedlineExtraData_Format();
77 virtual SwRedlineExtraData
* CreateNew() const SAL_OVERRIDE
;
78 virtual void Reject( SwPaM
& rPam
) const SAL_OVERRIDE
;
79 virtual bool operator == ( const SwRedlineExtraData
& ) const SAL_OVERRIDE
;
83 * This class is used to store 'redline' data regarding formatting changes,
84 * e.g. - a text portion *was* italic and now is not italic,
85 * e.g. - a text portion got a hightlight to it
87 * The way the information is stored is in an 'SfxItemSet' that holds all
88 * the WhichIds with their values.
90 class SW_DLLPUBLIC SwRedlineExtraData_FormattingChanges
: public SwRedlineExtraData
94 SwRedlineExtraData_FormattingChanges( const SwRedlineExtraData_FormattingChanges
& rCpy
);
97 SwRedlineExtraData_FormattingChanges( const SfxItemSet
* pItemSet
);
98 virtual ~SwRedlineExtraData_FormattingChanges();
99 virtual SwRedlineExtraData
* CreateNew() const SAL_OVERRIDE
;
100 virtual void Reject( SwPaM
& rPam
) const SAL_OVERRIDE
;
101 virtual bool operator == ( const SwRedlineExtraData
& ) const SAL_OVERRIDE
;
102 SfxItemSet
* GetItemSet( ) const { return pSet
; }
105 class SW_DLLPUBLIC SwRedlineData
107 friend class SwRangeRedline
;
108 SwRedlineData
* pNext
; // Points to other data.
109 SwRedlineExtraData
* pExtraData
;
114 sal_uInt16 nAuthor
, nSeqNo
;
117 SwRedlineData( RedlineType_t eT
, sal_uInt16 nAut
);
118 SwRedlineData( const SwRedlineData
& rCpy
, bool bCpyNext
= true );
120 // For sw3io: pNext/pExtraData are taken over.
121 SwRedlineData( RedlineType_t eT
, sal_uInt16 nAut
, const DateTime
& rDT
,
122 const OUString
& rCmnt
, SwRedlineData
* pNxt
,
123 SwRedlineExtraData
* pExtraData
= 0 );
127 bool operator==( const SwRedlineData
& rCmp
) const
129 return nAuthor
== rCmp
.nAuthor
&&
130 eType
== rCmp
.eType
&&
131 sComment
== rCmp
.sComment
&&
132 (( !pNext
&& !rCmp
.pNext
) ||
133 ( pNext
&& rCmp
.pNext
&& *pNext
== *rCmp
.pNext
)) &&
134 (( !pExtraData
&& !rCmp
.pExtraData
) ||
135 ( pExtraData
&& rCmp
.pExtraData
&&
136 *pExtraData
== *rCmp
.pExtraData
));
138 bool operator!=( const SwRedlineData
& rCmp
) const
139 { return !operator==( rCmp
); }
141 RedlineType_t
GetType() const
142 { return ((RedlineType_t
)(eType
& nsRedlineType_t::REDLINE_NO_FLAG_MASK
)); }
143 RedlineType_t
GetRealType() const { return eType
; }
144 sal_uInt16
GetAuthor() const { return nAuthor
; }
145 const OUString
& GetComment() const { return sComment
; }
146 const DateTime
& GetTimeStamp() const { return aStamp
; }
147 inline const SwRedlineData
* Next() const{ return pNext
; }
149 void SetComment( const OUString
& rS
) { sComment
= rS
; }
150 void SetTimeStamp( const DateTime
& rDT
) { aStamp
= rDT
; }
152 void SetAutoFormatFlag()
153 { eType
= (RedlineType_t
)(eType
| nsRedlineType_t::REDLINE_FORM_AUTOFMT
); }
154 bool CanCombine( const SwRedlineData
& rCmp
) const
156 return nAuthor
== rCmp
.nAuthor
&&
157 eType
== rCmp
.eType
&&
158 sComment
== rCmp
.sComment
&&
159 GetTimeStamp() == rCmp
.GetTimeStamp() &&
160 (( !pNext
&& !rCmp
.pNext
) ||
161 ( pNext
&& rCmp
.pNext
&&
162 pNext
->CanCombine( *rCmp
.pNext
))) &&
163 (( !pExtraData
&& !rCmp
.pExtraData
) ||
164 ( pExtraData
&& rCmp
.pExtraData
&&
165 *pExtraData
== *rCmp
.pExtraData
));
168 // ExtraData gets copied, the pointer is therefore not taken over by
169 // the RedlilneObject
170 void SetExtraData( const SwRedlineExtraData
* pData
);
171 const SwRedlineExtraData
* GetExtraData() const { return pExtraData
; }
173 // For UI-side pooling of Redline-actions.
174 // At the moment only used for Autoformat with Redline.
175 // Value != 0 means there can be others!
176 sal_uInt16
GetSeqNo() const { return nSeqNo
; }
177 void SetSeqNo( sal_uInt16 nNo
) { nSeqNo
= nNo
; }
179 OUString
GetDescr() const;
182 class SW_DLLPUBLIC SwRangeRedline
: public SwPaM
184 SwRedlineData
* pRedlineData
;
185 SwNodeIndex
* pContentSect
;
186 bool bDelLastPara
: 1;
187 bool bIsLastParaDelete
: 1;
190 void MoveToSection();
191 void CopyToSection();
192 void DelCopyOfSection(size_t nMyPos
);
193 void MoveFromSection(size_t nMyPos
);
196 SwRangeRedline( RedlineType_t eType
, const SwPaM
& rPam
);
197 SwRangeRedline( const SwRedlineData
& rData
, const SwPaM
& rPam
);
198 SwRangeRedline( const SwRedlineData
& rData
, const SwPosition
& rPos
);
199 // For sw3io: pData is taken over!
200 SwRangeRedline(SwRedlineData
* pData
, const SwPosition
& rPos
, bool bVsbl
,
201 bool bDelLP
, bool bIsPD
) :
202 SwPaM( rPos
), pRedlineData( pData
), pContentSect( 0 ),
203 bDelLastPara( bDelLP
), bIsLastParaDelete( bIsPD
), bIsVisible( bVsbl
)
205 SwRangeRedline( const SwRangeRedline
& );
206 virtual ~SwRangeRedline();
208 SwNodeIndex
* GetContentIdx() const { return pContentSect
; }
210 void SetContentIdx( const SwNodeIndex
* );
212 bool IsVisible() const { return bIsVisible
; }
213 bool IsDelLastPara() const { return bDelLastPara
; }
215 void SetStart( const SwPosition
& rPos
, SwPosition
* pSttPtr
= 0 )
217 if( !pSttPtr
) pSttPtr
= Start();
220 void SetEnd( const SwPosition
& rPos
, SwPosition
* pEndPtr
= 0 )
222 if( !pEndPtr
) pEndPtr
= End();
225 /// Do we have a valid selection?
226 bool HasValidRange() const;
228 const SwRedlineData
& GetRedlineData(sal_uInt16 nPos
= 0) const;
229 bool operator==( const SwRedlineData
& rCmp
) const
230 { return *pRedlineData
== rCmp
; }
231 bool operator!=( const SwRedlineData
& rCmp
) const
232 { return *pRedlineData
!= rCmp
; }
233 void SetAutoFormatFlag() { pRedlineData
->SetAutoFormatFlag(); }
235 sal_uInt16
GetStackCount() const;
236 sal_uInt16
GetAuthor( sal_uInt16 nPos
= 0) const;
237 OUString
GetAuthorString( sal_uInt16 nPos
= 0 ) const;
238 const DateTime
& GetTimeStamp( sal_uInt16 nPos
= 0) const;
239 RedlineType_t
GetRealType( sal_uInt16 nPos
= 0 ) const;
240 RedlineType_t
GetType( sal_uInt16 nPos
= 0) const
241 { return ( (RedlineType_t
)(GetRealType( nPos
) & nsRedlineType_t::REDLINE_NO_FLAG_MASK
)); }
242 const OUString
& GetComment( sal_uInt16 nPos
= 0 ) const;
244 void SetComment( const OUString
& rS
) { pRedlineData
->SetComment( rS
); }
246 /** ExtraData gets copied, the pointer is therefore not taken over by
247 * the RedLineObject.*/
248 void SetExtraData( const SwRedlineExtraData
* pData
)
249 { pRedlineData
->SetExtraData( pData
); }
250 const SwRedlineExtraData
* GetExtraData() const
251 { return pRedlineData
->GetExtraData(); }
253 // For UI-side pooling of Redline-actions.
254 // At the moment only used for Autoformat with Redline.
255 // Value != 0 means there can be others!
256 sal_uInt16
GetSeqNo() const { return pRedlineData
->GetSeqNo(); }
257 void SetSeqNo( sal_uInt16 nNo
) { pRedlineData
->SetSeqNo( nNo
); }
259 // At Hide/ShowOriginal the list is traversed two times in order to
260 // hide the Del-Redlines via Copy and Delete.
261 // Otherwise at Move the attribution would be handled incorrectly.
262 // All other callers must always give 0.
263 void CallDisplayFunc(sal_uInt16 nLoop
, size_t nMyPos
);
264 void Show(sal_uInt16 nLoop
, size_t nMyPos
);
265 void Hide(sal_uInt16 nLoop
, size_t nMyPos
);
266 void ShowOriginal(sal_uInt16 nLoop
, size_t nMyPos
);
268 /// Calculates the intersection with text node number nNdIdx.
269 void CalcStartEnd(sal_uLong nNdIdx
, sal_Int32
& rStart
, sal_Int32
& rEnd
) const;
271 /// Initiate the layout.
272 void InvalidateRange();
274 bool IsOwnRedline( const SwRangeRedline
& rRedl
) const
275 { return GetAuthor() == rRedl
.GetAuthor(); }
276 bool CanCombine( const SwRangeRedline
& rRedl
) const;
278 void PushData( const SwRangeRedline
& rRedl
, bool bOwnAsNext
= true );
282 Returns textual description of this a redline data element of
285 @param nPos index of the redline data element to describe
287 The textual description of the selected element contains the
288 kind of redline and the possibly shortened text of the redline.
290 @return textual description of the selected redline data element
292 OUString
GetDescr(sal_uInt16 nPos
= 0);
294 bool operator==( const SwRangeRedline
& ) const;
295 bool operator<( const SwRangeRedline
& ) const;
296 void dumpAsXml(struct _xmlTextWriter
* pWriter
) const;
299 /// Base object for 'Redlines' that are not of 'Ranged' type (like table row insert\delete)
300 class SW_DLLPUBLIC SwExtraRedline
: private boost::noncopyable
303 virtual ~SwExtraRedline();
306 /// Redline that holds information about a table-row that had some change
307 class SW_DLLPUBLIC SwTableRowRedline
: public SwExtraRedline
310 SwRedlineData m_aRedlineData
;
311 const SwTableLine
& m_rTableLine
;
314 SwTableRowRedline(const SwRedlineData
& rData
, const SwTableLine
& rTableLine
);
315 virtual ~SwTableRowRedline();
317 /** ExtraData gets copied, the pointer is therefore not taken over by
318 * the RedLineObject.*/
319 void SetExtraData( const SwRedlineExtraData
* pData
)
320 { m_aRedlineData
.SetExtraData( pData
); }
321 const SwRedlineExtraData
* GetExtraData() const
322 { return m_aRedlineData
.GetExtraData(); }
323 const SwTableLine
& GetTableLine() const
324 { return m_rTableLine
; }
325 const SwRedlineData
& GetRedlineData() const
326 { return m_aRedlineData
; }
329 /// Redline that holds information about a table-cell that had some change
330 class SW_DLLPUBLIC SwTableCellRedline
: public SwExtraRedline
333 SwRedlineData m_aRedlineData
;
334 const SwTableBox
& m_rTableBox
;
337 SwTableCellRedline(const SwRedlineData
& rData
, const SwTableBox
& rTableBox
);
338 virtual ~SwTableCellRedline();
340 /** ExtraData gets copied, the pointer is therefore not taken over by
341 * the RedLineObject.*/
342 void SetExtraData( const SwRedlineExtraData
* pData
)
343 { m_aRedlineData
.SetExtraData( pData
); }
344 const SwRedlineExtraData
* GetExtraData() const
345 { return m_aRedlineData
.GetExtraData(); }
346 const SwTableBox
& GetTableBox() const
347 { return m_rTableBox
; }
348 const SwRedlineData
& GetRedlineData() const
349 { return m_aRedlineData
; }
352 class SW_DLLPUBLIC SwRedlineHint
: public SfxHint
354 #define SWREDLINE_INSERTED 1
355 #define SWREDLINE_FOCUS 3
357 const SwRangeRedline
* pRedline
;
362 SwRedlineHint( const SwRangeRedline
* p
, sal_Int16 n
, const SwView
* pV
= 0)
368 const SwRangeRedline
* GetRedline() const { return pRedline
; }
369 sal_Int16
Which() const { return nWhich
; }
370 const SwView
* GetView() const { return pView
; }
375 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */