Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _REDLINE_HXX
29 : : #define _REDLINE_HXX
30 : :
31 : : #include <tools/datetime.hxx>
32 : : #include <tools/string.hxx>
33 : :
34 : : #include <pam.hxx>
35 : :
36 : : #include <IDocumentRedlineAccess.hxx>
37 : :
38 : : #include <svl/smplhint.hxx>
39 : : #include <vector>
40 : :
41 : : class SfxItemSet;
42 : : class SwView;
43 : :
44 : : class SwRedlineExtraData
45 : : {
46 : : SwRedlineExtraData( const SwRedlineExtraData& );
47 : : SwRedlineExtraData& operator=( const SwRedlineExtraData& );
48 : :
49 : : protected:
50 : 0 : SwRedlineExtraData() {}
51 : :
52 : : public:
53 : : virtual ~SwRedlineExtraData();
54 : : virtual SwRedlineExtraData* CreateNew() const = 0;
55 : :
56 : : virtual void Accept( SwPaM& rPam ) const;
57 : : virtual void Reject( SwPaM& rPam ) const;
58 : : virtual int operator == ( const SwRedlineExtraData& ) const;
59 : : };
60 : :
61 : : class SwRedlineExtraData_FmtColl : public SwRedlineExtraData
62 : : {
63 : : String sFmtNm;
64 : : SfxItemSet* pSet;
65 : : sal_uInt16 nPoolId;
66 : : public:
67 : : SwRedlineExtraData_FmtColl( const String& rColl, sal_uInt16 nPoolFmtId,
68 : : const SfxItemSet* pSet = 0 );
69 : : virtual ~SwRedlineExtraData_FmtColl();
70 : : virtual SwRedlineExtraData* CreateNew() const;
71 : : virtual void Reject( SwPaM& rPam ) const;
72 : : virtual int operator == ( const SwRedlineExtraData& ) const;
73 : :
74 : : void SetItemSet( const SfxItemSet& rSet );
75 : : };
76 : :
77 : : class SwRedlineExtraData_Format : public SwRedlineExtraData
78 : : {
79 : : std::vector<sal_uInt16> aWhichIds;
80 : :
81 : : SwRedlineExtraData_Format( const SwRedlineExtraData_Format& rCpy );
82 : :
83 : : public:
84 : : SwRedlineExtraData_Format( const SfxItemSet& rSet );
85 : : virtual ~SwRedlineExtraData_Format();
86 : : virtual SwRedlineExtraData* CreateNew() const;
87 : : virtual void Reject( SwPaM& rPam ) const;
88 : : virtual int operator == ( const SwRedlineExtraData& ) const;
89 : : };
90 : :
91 : :
92 : : class SW_DLLPUBLIC SwRedlineData
93 : : {
94 : : friend class SwRedline;
95 : : SwRedlineData* pNext; // Points to other data.
96 : : SwRedlineExtraData* pExtraData;
97 : :
98 : : String sComment;
99 : : DateTime aStamp;
100 : : RedlineType_t eType;
101 : : sal_uInt16 nAuthor, nSeqNo;
102 : :
103 : : public:
104 : : SwRedlineData( RedlineType_t eT, sal_uInt16 nAut );
105 : : SwRedlineData( const SwRedlineData& rCpy, sal_Bool bCpyNext = sal_True );
106 : :
107 : : // For sw3io: pNext/pExtraData are taken over.
108 : : SwRedlineData( RedlineType_t eT, sal_uInt16 nAut, const DateTime& rDT,
109 : : const String& rCmnt, SwRedlineData* pNxt,
110 : : SwRedlineExtraData* pExtraData = 0 );
111 : :
112 : : ~SwRedlineData();
113 : :
114 : 0 : int operator==( const SwRedlineData& rCmp ) const
115 : : {
116 : : return nAuthor == rCmp.nAuthor &&
117 : : eType == rCmp.eType &&
118 : 0 : sComment == rCmp.sComment &&
119 : 0 : (( !pNext && !rCmp.pNext ) ||
120 : 0 : ( pNext && rCmp.pNext && *pNext == *rCmp.pNext )) &&
121 : 0 : (( !pExtraData && !rCmp.pExtraData ) ||
122 : : ( pExtraData && rCmp.pExtraData &&
123 [ # # ]: 0 : *pExtraData == *rCmp.pExtraData ));
[ # # # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
124 : : }
125 : 0 : int operator!=( const SwRedlineData& rCmp ) const
126 : 0 : { return !operator==( rCmp ); }
127 : :
128 : 0 : RedlineType_t GetType() const
129 : 0 : { return ((RedlineType_t)(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
130 : : RedlineType_t GetRealType() const { return eType; }
131 : 0 : sal_uInt16 GetAuthor() const { return nAuthor; }
132 : 0 : const String& GetComment() const { return sComment; }
133 : 874 : const DateTime& GetTimeStamp() const { return aStamp; }
134 : 0 : inline const SwRedlineData* Next() const{ return pNext; }
135 : :
136 : 0 : void SetComment( const String& rS ) { sComment = rS; }
137 : 0 : void SetTimeStamp( const DateTime& rDT ) { aStamp = rDT; }
138 : :
139 : 0 : void SetAutoFmtFlag()
140 : 0 : { eType = (RedlineType_t)(eType | nsRedlineType_t::REDLINE_FORM_AUTOFMT); }
141 : 2229 : int CanCombine( const SwRedlineData& rCmp ) const
142 : : {
143 : : return nAuthor == rCmp.nAuthor &&
144 : : eType == rCmp.eType &&
145 : 437 : sComment == rCmp.sComment &&
146 : 437 : GetTimeStamp() == rCmp.GetTimeStamp() &&
147 : 874 : (( !pNext && !rCmp.pNext ) ||
148 : : ( pNext && rCmp.pNext &&
149 : 0 : pNext->CanCombine( *rCmp.pNext ))) &&
150 : 874 : (( !pExtraData && !rCmp.pExtraData ) ||
151 : : ( pExtraData && rCmp.pExtraData &&
152 [ + + ][ + - : 3103 : *pExtraData == *rCmp.pExtraData ));
+ - + - ]
[ + - ][ - + ]
[ # # ]
[ # # # # ]
[ + - ][ - + ]
[ # # ][ # # ]
[ # # ]
153 : : }
154 : :
155 : : // ExtraData gets copied, the pointer is therefore not taken over by
156 : : // the RedlilneObject
157 : : void SetExtraData( const SwRedlineExtraData* pData );
158 : 0 : const SwRedlineExtraData* GetExtraData() const { return pExtraData; }
159 : :
160 : : // For UI-side pooling of Redline-actions.
161 : : // At the moment only used for Autoformat with Redline.
162 : : // Value != 0 means there can be others!
163 : 0 : sal_uInt16 GetSeqNo() const { return nSeqNo; }
164 : 0 : void SetSeqNo( sal_uInt16 nNo ) { nSeqNo = nNo; }
165 : :
166 : : String GetDescr() const;
167 : : };
168 : :
169 : :
170 : : class SW_DLLPUBLIC SwRedline : public SwPaM
171 : : {
172 : : SwRedlineData* pRedlineData;
173 : : SwNodeIndex* pCntntSect;
174 : : sal_Bool bDelLastPara : 1;
175 : : sal_Bool bIsLastParaDelete : 1;
176 : : sal_Bool bIsVisible : 1;
177 : :
178 : : void MoveToSection();
179 : : void CopyToSection();
180 : : void DelCopyOfSection();
181 : : void MoveFromSection();
182 : :
183 : : public:
184 : : SwRedline( RedlineType_t eType, const SwPaM& rPam );
185 : : SwRedline( const SwRedlineData& rData, const SwPaM& rPam );
186 : : SwRedline( const SwRedlineData& rData, const SwPosition& rPos );
187 : : // For sw3io: pData is taken over!
188 : 0 : SwRedline(SwRedlineData* pData, const SwPosition& rPos, sal_Bool bVsbl,
189 : : sal_Bool bDelLP, sal_Bool bIsPD) :
190 : : SwPaM( rPos ), pRedlineData( pData ), pCntntSect( 0 ),
191 : 0 : bDelLastPara( bDelLP ), bIsLastParaDelete( bIsPD ), bIsVisible( bVsbl )
192 : 0 : {}
193 : : SwRedline( const SwRedline& );
194 : : virtual ~SwRedline();
195 : :
196 : 1569 : SwNodeIndex* GetContentIdx() const { return pCntntSect; }
197 : : // For Undo.
198 : : void SetContentIdx( const SwNodeIndex* );
199 : :
200 : 4458 : sal_Bool IsVisible() const { return bIsVisible; }
201 : 0 : sal_Bool IsDelLastPara() const { return bDelLastPara; }
202 : :
203 : : // sal_Bool indicates whether after setting of Pos no range is spanned.
204 : : // -> sal-True else range and sal-False.
205 : 0 : void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = 0 )
206 : : {
207 [ # # ]: 0 : if( !pSttPtr ) pSttPtr = Start();
208 : 0 : *pSttPtr = rPos;
209 : 0 : }
210 : 437 : void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = 0 )
211 : : {
212 [ - + ]: 437 : if( !pEndPtr ) pEndPtr = End();
213 : 437 : *pEndPtr = rPos;
214 : 437 : }
215 : : // Do we have a valid selection?
216 : : sal_Bool HasValidRange() const;
217 : :
218 : : const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
219 : : int operator==( const SwRedlineData& rCmp ) const
220 : : { return *pRedlineData == rCmp; }
221 : 0 : int operator!=( const SwRedlineData& rCmp ) const
222 : 0 : { return *pRedlineData != rCmp; }
223 : 0 : void SetAutoFmtFlag() { pRedlineData->SetAutoFmtFlag(); }
224 : :
225 : : sal_uInt16 GetStackCount() const;
226 : : sal_uInt16 GetAuthor( sal_uInt16 nPos = 0) const;
227 : : const String& GetAuthorString( sal_uInt16 nPos = 0 ) const;
228 : : const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
229 : : RedlineType_t GetRealType( sal_uInt16 nPos = 0 ) const;
230 : 3937 : RedlineType_t GetType( sal_uInt16 nPos = 0) const
231 : 3937 : { return ( (RedlineType_t)(GetRealType( nPos ) & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
232 : : const String& GetComment( sal_uInt16 nPos = 0 ) const;
233 : :
234 : 0 : void SetComment( const String& rS ) { pRedlineData->SetComment( rS ); }
235 : :
236 : : // ExtraData gets copied, the pointer is therefor not taken over by
237 : : // the RedLineObject.
238 : 0 : void SetExtraData( const SwRedlineExtraData* pData )
239 : 0 : { pRedlineData->SetExtraData( pData ); }
240 : 0 : const SwRedlineExtraData* GetExtraData() const
241 : 0 : { return pRedlineData->GetExtraData(); }
242 : :
243 : : // For UI-side pooling of Redline-actions.
244 : : // At the moment only used for Autoformat with Redline.
245 : : // Value != 0 means there can be others!
246 : 0 : sal_uInt16 GetSeqNo() const { return pRedlineData->GetSeqNo(); }
247 : 0 : void SetSeqNo( sal_uInt16 nNo ) { pRedlineData->SetSeqNo( nNo ); }
248 : :
249 : : // At Hide/ShowOriginal the list is traversed two times in order to
250 : : // hide the Del-Redlines via Copy and Delete.
251 : : // Otherwise at Move the attribution would be handled incorrectly.
252 : : // All other callers must always give 0.
253 : : void CallDisplayFunc( sal_uInt16 nLoop = 0 );
254 : : void Show( sal_uInt16 nLoop = 0 );
255 : : void Hide( sal_uInt16 nLoop = 0 );
256 : : void ShowOriginal( sal_uInt16 nLoop = 0 );
257 : :
258 : : // Calculates the intersection with text node number nNdIdx.
259 : : void CalcStartEnd( sal_uLong nNdIdx, sal_uInt16& nStart, sal_uInt16& nEnd ) const;
260 : :
261 : : void InvalidateRange(); // Initiate the layout.
262 : :
263 : 1266 : sal_Bool IsOwnRedline( const SwRedline& rRedl ) const
264 : 1266 : { return GetAuthor() == rRedl.GetAuthor(); }
265 : : sal_Bool CanCombine( const SwRedline& rRedl ) const;
266 : :
267 : : void PushData( const SwRedline& rRedl, sal_Bool bOwnAsNext = sal_True );
268 : : sal_Bool PopData();
269 : :
270 : : /**
271 : : Returns textual description of this a redline data element of
272 : : this redline.
273 : :
274 : : @param nPos index of the redline data element to describe
275 : :
276 : : The textual description of the selected element contains the
277 : : kind of redline and the possibly shortened text of the redline.
278 : :
279 : : @return textual description of the selected redline data element
280 : : */
281 : : String GetDescr(sal_uInt16 nPos = 0);
282 : :
283 : : int operator==( const SwRedline& ) const;
284 : : int operator<( const SwRedline& ) const;
285 : : };
286 : :
287 [ # # ]: 0 : class SW_DLLPUBLIC SwRedlineHint : public SfxHint
288 : : {
289 : : #define SWREDLINE_INSERTED 1
290 : : #define SWREDLINE_REMOVED 2
291 : : #define SWREDLINE_FOCUS 3
292 : : #define SWREDLINE_CHANGED 4
293 : : #define SWREDLINE_LANGUAGE 5
294 : :
295 : : const SwRedline* pRedline;
296 : : sal_Int16 nWhich;
297 : : const SwView* pView;
298 : :
299 : : public:
300 : 0 : SwRedlineHint( const SwRedline* p, sal_Int16 n, const SwView* pV = 0)
301 : : : pRedline(p)
302 : : , nWhich(n)
303 : 0 : , pView(pV)
304 : 0 : {}
305 : :
306 : : TYPEINFO();
307 : : const SwRedline* GetRedline() const { return pRedline; }
308 : : sal_Int16 Which() const { return nWhich; }
309 : : const SwView* GetView() const { return pView; }
310 : : };
311 : :
312 : :
313 : : #endif
314 : :
315 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|