1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: redline.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #ifndef _DATETIME_HXX //autogen
34 #include <tools/datetime.hxx>
36 #ifndef _STRING_HXX //autogen
37 #include <tools/string.hxx>
40 #define _SVSTDARR_USHORTS
41 #include <bf_svtools/svstdarr.hxx>
47 #include <redlenum.hxx>
54 class SwRedlineExtraData
56 SwRedlineExtraData( const SwRedlineExtraData
& );
57 SwRedlineExtraData
& operator=( const SwRedlineExtraData
& );
60 SwRedlineExtraData() {}
63 virtual ~SwRedlineExtraData();
64 virtual SwRedlineExtraData
* CreateNew() const = 0;
66 virtual int operator == ( const SwRedlineExtraData
& ) const;
75 friend class SwRedline
;
76 SwRedlineData
* pNext
; // Verweis auf weitere Daten
77 SwRedlineExtraData
* pExtraData
;
82 USHORT nAuthor
, nSeqNo
;
85 SwRedlineData( const SwRedlineData
& rCpy
, BOOL bCpyNext
= TRUE
);
87 // fuer sw3io: pNext/pExtraData gehen in eigenen Besitz ueber!
88 SwRedlineData( SwRedlineType eT
, USHORT nAut
, const DateTime
& rDT
,
89 const String
& rCmnt
, SwRedlineData
* pNxt
,
90 SwRedlineExtraData
* pExtraData
= 0 );
94 int operator==( const SwRedlineData
& rCmp
) const
96 return nAuthor
== rCmp
.nAuthor
&&
97 eType
== rCmp
.eType
&&
98 sComment
== rCmp
.sComment
&&
99 (( !pNext
&& !rCmp
.pNext
) ||
100 ( pNext
&& rCmp
.pNext
&& *pNext
== *rCmp
.pNext
)) &&
101 (( !pExtraData
&& !rCmp
.pExtraData
) ||
102 ( pExtraData
&& rCmp
.pExtraData
&&
103 *pExtraData
== *rCmp
.pExtraData
));
105 int operator!=( const SwRedlineData
& rCmp
) const
106 { return !operator==( rCmp
); }
108 SwRedlineType
GetType() const
109 { return SwRedlineType( eType
& REDLINE_NO_FLAG_MASK
); }
110 SwRedlineType
GetRealType() const { return eType
; }
111 USHORT
GetAuthor() const { return nAuthor
; }
112 const String
& GetComment() const { return sComment
; }
113 const DateTime
& GetTimeStamp() const { return aStamp
; }
114 inline const SwRedlineData
* Next() const{ return pNext
; }
116 void SetTimeStamp( const DateTime
& rDT
)
117 { aStamp
= rDT
; aStamp
.SetSec( 0 ); aStamp
.Set100Sec( 0 ); }
118 void SetComment( const String
& rS
) { sComment
= rS
; }
119 void SetAutoFmtFlag()
120 { eType
= SwRedlineType( eType
| REDLINE_FORM_AUTOFMT
); }
121 int CanCombine( const SwRedlineData
& rCmp
) const
123 return nAuthor
== rCmp
.nAuthor
&&
124 eType
== rCmp
.eType
&&
125 sComment
== rCmp
.sComment
&&
126 GetTimeStamp() == rCmp
.GetTimeStamp() &&
127 (( !pNext
&& !rCmp
.pNext
) ||
128 ( pNext
&& rCmp
.pNext
&&
129 pNext
->CanCombine( *rCmp
.pNext
))) &&
130 (( !pExtraData
&& !rCmp
.pExtraData
) ||
131 ( pExtraData
&& rCmp
.pExtraData
&&
132 *pExtraData
== *rCmp
.pExtraData
));
135 // ExtraData wird kopiert, der Pointer geht also NICHT in den Besitz
136 // des RedlineObjectes!
137 const SwRedlineExtraData
* GetExtraData() const { return pExtraData
; }
139 // fuers UI-seitige zusammenfassen von Redline-Actionen. Wird z.Z. nur
140 // fuers Autoformat mit Redline benoetigt. Der Wert != 0 bedeutet dabei,
141 // das es noch weitere geben kann!
142 USHORT
GetSeqNo() const { return nSeqNo
; }
143 void SetSeqNo( USHORT nNo
) { nSeqNo
= nNo
; }
147 class SwRedline
: public SwPaM
149 SwRedlineData
* pRedlineData
;
150 SwNodeIndex
* pCntntSect
;
151 BOOL bDelLastPara
: 1;
152 BOOL bIsLastParaDelete
: 1;
157 SwRedline( const SwRedlineData
& rData
, const SwPosition
& rPos
);
158 // fuer sw3io: pData geht in eigenen Besitz ueber!
159 SwRedline(SwRedlineData
* pData
, const SwPosition
& rPos
, BOOL bVsbl
,
160 BOOL bDelLP
, BOOL bIsPD
) :
161 SwPaM( rPos
), pRedlineData( pData
), pCntntSect( 0 ),
162 bDelLastPara( bDelLP
), bIsLastParaDelete( bIsPD
), bIsVisible( bVsbl
)
164 SwRedline( const SwRedline
& );
165 virtual ~SwRedline();
167 SwNodeIndex
* GetContentIdx() const { return pCntntSect
; }
169 void SetContentIdx( const SwNodeIndex
* );
171 BOOL
IsVisible() const { return bIsVisible
; }
172 BOOL
IsDelLastPara() const { return bDelLastPara
; }
173 BOOL
IsLastParaDelete() const { return bIsLastParaDelete
; }
175 // das BOOL besagt, ob nach dem setzen der Pos kein Bereich mehr
176 // aufgespannt ist. -> TRUE, ansonten Bereich und FALSE
177 void SetStart( const SwPosition
& rPos
, SwPosition
* pSttPtr
= 0 )
179 if( !pSttPtr
) pSttPtr
= Start();
182 void SetEnd( const SwPosition
& rPos
, SwPosition
* pEndPtr
= 0 )
184 if( !pEndPtr
) pEndPtr
= End();
187 // liegt eine gueltige Selektion vor?
188 /*N*/ BOOL
HasValidRange() const; //SW50.SDW
190 USHORT
GetAuthor() const { return pRedlineData
->GetAuthor(); }
191 const DateTime
& GetTimeStamp() const { return pRedlineData
->GetTimeStamp(); }
192 SwRedlineType
GetType() const { return pRedlineData
->GetType(); }
193 SwRedlineType
GetRealType() const { return pRedlineData
->GetRealType(); }
194 const SwRedlineData
& GetRedlineData() const { return *pRedlineData
; }
195 int operator==( const SwRedlineData
& rCmp
) const
196 { return *pRedlineData
== rCmp
; }
197 int operator!=( const SwRedlineData
& rCmp
) const
198 { return *pRedlineData
!= rCmp
; }
199 void SetAutoFmtFlag() { pRedlineData
->SetAutoFmtFlag(); }
201 USHORT
GetStackCount() const;
202 const String
& GetAuthorString( USHORT nPos
= 0 ) const;
203 const DateTime
& GetTimeStamp( USHORT nPos
) const;
204 SwRedlineType
GetRealType( USHORT nPos
) const;
205 SwRedlineType
GetType( USHORT nPos
) const
206 { return SwRedlineType( GetRealType( nPos
) & REDLINE_NO_FLAG_MASK
); }
207 const String
& GetComment( USHORT nPos
) const;
209 const String
& GetComment() const { return pRedlineData
->GetComment(); }
210 void SetComment( const String
& rS
) { pRedlineData
->SetComment( rS
); }
212 // ExtraData wird kopiert, der Pointer geht also NICHT in den Besitz
213 // des RedlineObjectes!
214 const SwRedlineExtraData
* GetExtraData() const
215 { return pRedlineData
->GetExtraData(); }
217 // fuers UI-seitige zusammenfassen von Redline-Actionen. Wird z.Z. nur
218 // fuers Autoformat mit Redline benoetigt. Der Wert != 0 bedeutet dabei,
219 // das es noch weitere geben kann!
220 USHORT
GetSeqNo() const { return pRedlineData
->GetSeqNo(); }
221 void SetSeqNo( USHORT nNo
) { pRedlineData
->SetSeqNo( nNo
); }
223 // Beim Hide/ShowOriginal wird 2 mal ueber die Liste gelaufen, damit
224 // die Del-Redlines per Copy und Delete versteckt werden. Beim Move
225 // wird sonst die Attributierung falsch behandelt.
226 // Alle anderen Aufrufer muessen immer 0 angeben.
227 void Show( USHORT nLoop
= 0 );
228 void Hide( USHORT nLoop
= 0 );
230 // calculates the intersection with text node number nNdIdx
233 BOOL
IsOwnRedline( const SwRedline
& rRedl
) const
234 { return GetAuthor() == rRedl
.GetAuthor(); }
235 BOOL
CanCombine( const SwRedline
& rRedl
) const;
238 int operator==( const SwRedline
& ) const;
239 int operator<( const SwRedline
& ) const;
242 } //namespace binfilter