bump product version to 4.1.6.2
[LibreOffice.git] / sw / inc / redline.hxx
blob2c54a2ea61a4bb88aa41032d3da168255aabd756
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _REDLINE_HXX
20 #define _REDLINE_HXX
22 #include <tools/datetime.hxx>
23 #include <tools/string.hxx>
25 #include <pam.hxx>
27 #include <IDocumentRedlineAccess.hxx>
29 #include <svl/smplhint.hxx>
30 #include <vector>
32 class SfxItemSet;
33 class SwView;
35 class SwRedlineExtraData
37 SwRedlineExtraData( const SwRedlineExtraData& );
38 SwRedlineExtraData& operator=( const SwRedlineExtraData& );
40 protected:
41 SwRedlineExtraData() {}
43 public:
44 virtual ~SwRedlineExtraData();
45 virtual SwRedlineExtraData* CreateNew() const = 0;
47 virtual void Accept( SwPaM& rPam ) const;
48 virtual void Reject( SwPaM& rPam ) const;
49 virtual int operator == ( const SwRedlineExtraData& ) const;
52 class SwRedlineExtraData_FmtColl : public SwRedlineExtraData
54 String sFmtNm;
55 SfxItemSet* pSet;
56 sal_uInt16 nPoolId;
57 public:
58 SwRedlineExtraData_FmtColl( const String& rColl, sal_uInt16 nPoolFmtId,
59 const SfxItemSet* pSet = 0 );
60 virtual ~SwRedlineExtraData_FmtColl();
61 virtual SwRedlineExtraData* CreateNew() const;
62 virtual void Reject( SwPaM& rPam ) const;
63 virtual int operator == ( const SwRedlineExtraData& ) const;
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 );
74 public:
75 SwRedlineExtraData_Format( const SfxItemSet& rSet );
76 virtual ~SwRedlineExtraData_Format();
77 virtual SwRedlineExtraData* CreateNew() const;
78 virtual void Reject( SwPaM& rPam ) const;
79 virtual int operator == ( const SwRedlineExtraData& ) const;
83 class SW_DLLPUBLIC SwRedlineData
85 friend class SwRedline;
86 SwRedlineData* pNext; // Points to other data.
87 SwRedlineExtraData* pExtraData;
89 String sComment;
90 DateTime aStamp;
91 RedlineType_t eType;
92 sal_uInt16 nAuthor, nSeqNo;
94 public:
95 SwRedlineData( RedlineType_t eT, sal_uInt16 nAut );
96 SwRedlineData( const SwRedlineData& rCpy, sal_Bool bCpyNext = sal_True );
98 // For sw3io: pNext/pExtraData are taken over.
99 SwRedlineData( RedlineType_t eT, sal_uInt16 nAut, const DateTime& rDT,
100 const String& rCmnt, SwRedlineData* pNxt,
101 SwRedlineExtraData* pExtraData = 0 );
103 ~SwRedlineData();
105 int operator==( const SwRedlineData& rCmp ) const
107 return nAuthor == rCmp.nAuthor &&
108 eType == rCmp.eType &&
109 sComment == rCmp.sComment &&
110 (( !pNext && !rCmp.pNext ) ||
111 ( pNext && rCmp.pNext && *pNext == *rCmp.pNext )) &&
112 (( !pExtraData && !rCmp.pExtraData ) ||
113 ( pExtraData && rCmp.pExtraData &&
114 *pExtraData == *rCmp.pExtraData ));
116 int operator!=( const SwRedlineData& rCmp ) const
117 { return !operator==( rCmp ); }
119 RedlineType_t GetType() const
120 { return ((RedlineType_t)(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
121 RedlineType_t GetRealType() const { return eType; }
122 sal_uInt16 GetAuthor() const { return nAuthor; }
123 const String& GetComment() const { return sComment; }
124 const DateTime& GetTimeStamp() const { return aStamp; }
125 inline const SwRedlineData* Next() const{ return pNext; }
127 void SetComment( const String& rS ) { sComment = rS; }
128 void SetTimeStamp( const DateTime& rDT ) { aStamp = rDT; }
130 void SetAutoFmtFlag()
131 { eType = (RedlineType_t)(eType | nsRedlineType_t::REDLINE_FORM_AUTOFMT); }
132 int CanCombine( const SwRedlineData& rCmp ) const
134 return nAuthor == rCmp.nAuthor &&
135 eType == rCmp.eType &&
136 sComment == rCmp.sComment &&
137 GetTimeStamp() == rCmp.GetTimeStamp() &&
138 (( !pNext && !rCmp.pNext ) ||
139 ( pNext && rCmp.pNext &&
140 pNext->CanCombine( *rCmp.pNext ))) &&
141 (( !pExtraData && !rCmp.pExtraData ) ||
142 ( pExtraData && rCmp.pExtraData &&
143 *pExtraData == *rCmp.pExtraData ));
146 // ExtraData gets copied, the pointer is therefore not taken over by
147 // the RedlilneObject
148 void SetExtraData( const SwRedlineExtraData* pData );
149 const SwRedlineExtraData* GetExtraData() const { return pExtraData; }
151 // For UI-side pooling of Redline-actions.
152 // At the moment only used for Autoformat with Redline.
153 // Value != 0 means there can be others!
154 sal_uInt16 GetSeqNo() const { return nSeqNo; }
155 void SetSeqNo( sal_uInt16 nNo ) { nSeqNo = nNo; }
157 String GetDescr() const;
161 class SW_DLLPUBLIC SwRedline : public SwPaM
163 SwRedlineData* pRedlineData;
164 SwNodeIndex* pCntntSect;
165 sal_Bool bDelLastPara : 1;
166 sal_Bool bIsLastParaDelete : 1;
167 sal_Bool bIsVisible : 1;
169 void MoveToSection();
170 void CopyToSection();
171 void DelCopyOfSection();
172 void MoveFromSection();
174 public:
175 SwRedline( RedlineType_t eType, const SwPaM& rPam );
176 SwRedline( const SwRedlineData& rData, const SwPaM& rPam );
177 SwRedline( const SwRedlineData& rData, const SwPosition& rPos );
178 // For sw3io: pData is taken over!
179 SwRedline(SwRedlineData* pData, const SwPosition& rPos, sal_Bool bVsbl,
180 sal_Bool bDelLP, sal_Bool bIsPD) :
181 SwPaM( rPos ), pRedlineData( pData ), pCntntSect( 0 ),
182 bDelLastPara( bDelLP ), bIsLastParaDelete( bIsPD ), bIsVisible( bVsbl )
184 SwRedline( const SwRedline& );
185 virtual ~SwRedline();
187 SwNodeIndex* GetContentIdx() const { return pCntntSect; }
188 // For Undo.
189 void SetContentIdx( const SwNodeIndex* );
191 sal_Bool IsVisible() const { return bIsVisible; }
192 sal_Bool IsDelLastPara() const { return bDelLastPara; }
194 // sal_Bool indicates whether after setting of Pos no range is spanned.
195 // -> sal-True else range and sal-False.
196 void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = 0 )
198 if( !pSttPtr ) pSttPtr = Start();
199 *pSttPtr = rPos;
201 void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = 0 )
203 if( !pEndPtr ) pEndPtr = End();
204 *pEndPtr = rPos;
206 /// Do we have a valid selection?
207 sal_Bool HasValidRange() const;
209 const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
210 int operator==( const SwRedlineData& rCmp ) const
211 { return *pRedlineData == rCmp; }
212 int operator!=( const SwRedlineData& rCmp ) const
213 { return *pRedlineData != rCmp; }
214 void SetAutoFmtFlag() { pRedlineData->SetAutoFmtFlag(); }
216 sal_uInt16 GetStackCount() const;
217 sal_uInt16 GetAuthor( sal_uInt16 nPos = 0) const;
218 const String& GetAuthorString( sal_uInt16 nPos = 0 ) const;
219 const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
220 RedlineType_t GetRealType( sal_uInt16 nPos = 0 ) const;
221 RedlineType_t GetType( sal_uInt16 nPos = 0) const
222 { return ( (RedlineType_t)(GetRealType( nPos ) & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
223 const String& GetComment( sal_uInt16 nPos = 0 ) const;
225 void SetComment( const String& rS ) { pRedlineData->SetComment( rS ); }
227 /** ExtraData gets copied, the pointer is therefor not taken over by
228 * the RedLineObject.*/
229 void SetExtraData( const SwRedlineExtraData* pData )
230 { pRedlineData->SetExtraData( pData ); }
231 const SwRedlineExtraData* GetExtraData() const
232 { return pRedlineData->GetExtraData(); }
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 pRedlineData->GetSeqNo(); }
238 void SetSeqNo( sal_uInt16 nNo ) { pRedlineData->SetSeqNo( nNo ); }
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( sal_uInt16 nLoop = 0 );
245 void Show( sal_uInt16 nLoop = 0 );
246 void Hide( sal_uInt16 nLoop = 0 );
247 void ShowOriginal( sal_uInt16 nLoop = 0 );
249 /// Calculates the intersection with text node number nNdIdx.
250 void CalcStartEnd( sal_uLong nNdIdx, sal_uInt16& nStart, sal_uInt16& nEnd ) const;
252 /// Initiate the layout.
253 void InvalidateRange();
255 sal_Bool IsOwnRedline( const SwRedline& rRedl ) const
256 { return GetAuthor() == rRedl.GetAuthor(); }
257 sal_Bool CanCombine( const SwRedline& rRedl ) const;
259 void PushData( const SwRedline& rRedl, sal_Bool bOwnAsNext = sal_True );
260 sal_Bool PopData();
263 Returns textual description of this a redline data element of
264 this redline.
266 @param nPos index of the redline data element to describe
268 The textual description of the selected element contains the
269 kind of redline and the possibly shortened text of the redline.
271 @return textual description of the selected redline data element
273 String GetDescr(sal_uInt16 nPos = 0);
275 int operator==( const SwRedline& ) const;
276 int operator<( const SwRedline& ) const;
279 class SW_DLLPUBLIC SwRedlineHint : public SfxHint
281 #define SWREDLINE_INSERTED 1
282 #define SWREDLINE_REMOVED 2
283 #define SWREDLINE_FOCUS 3
284 #define SWREDLINE_CHANGED 4
285 #define SWREDLINE_LANGUAGE 5
287 const SwRedline* pRedline;
288 sal_Int16 nWhich;
289 const SwView* pView;
291 public:
292 SwRedlineHint( const SwRedline* p, sal_Int16 n, const SwView* pV = 0)
293 : pRedline(p)
294 , nWhich(n)
295 , pView(pV)
298 TYPEINFO();
299 const SwRedline* GetRedline() const { return pRedline; }
300 sal_Int16 Which() const { return nWhich; }
301 const SwView* GetView() const { return pView; }
305 #endif
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */