update dev300-m58
[ooovba.git] / sw / inc / redline.hxx
blobf3d714e94fc059cc3c85974056d861284696bffa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: redline.hxx,v $
10 * $Revision: 1.14.180.1 $
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 ************************************************************************/
30 #ifndef _REDLINE_HXX
31 #define _REDLINE_HXX
33 #include <tools/datetime.hxx>
34 #include <tools/string.hxx>
36 #define _SVSTDARR_USHORTS
37 #include <svtools/svstdarr.hxx>
38 #include <pam.hxx>
40 #include <IDocumentRedlineAccess.hxx>
42 #include <svtools/smplhint.hxx>
44 class SfxItemSet;
46 class SwRedlineExtraData
48 SwRedlineExtraData( const SwRedlineExtraData& );
49 SwRedlineExtraData& operator=( const SwRedlineExtraData& );
51 protected:
52 SwRedlineExtraData() {}
54 public:
55 virtual ~SwRedlineExtraData();
56 virtual SwRedlineExtraData* CreateNew() const = 0;
58 virtual void Accept( SwPaM& rPam ) const;
59 virtual void Reject( SwPaM& rPam ) const;
60 virtual int operator == ( const SwRedlineExtraData& ) const;
63 class SwRedlineExtraData_FmtColl : public SwRedlineExtraData
65 String sFmtNm;
66 SfxItemSet* pSet;
67 USHORT nPoolId;
68 public:
69 SwRedlineExtraData_FmtColl( const String& rColl, USHORT nPoolFmtId,
70 const SfxItemSet* pSet = 0 );
71 virtual ~SwRedlineExtraData_FmtColl();
72 virtual SwRedlineExtraData* CreateNew() const;
73 virtual void Reject( SwPaM& rPam ) const;
74 virtual int operator == ( const SwRedlineExtraData& ) const;
76 void SetItemSet( const SfxItemSet& rSet );
79 class SwRedlineExtraData_Format : public SwRedlineExtraData
81 SvUShorts aWhichIds;
83 SwRedlineExtraData_Format( const SwRedlineExtraData_Format& rCpy );
85 public:
86 SwRedlineExtraData_Format( const SfxItemSet& rSet );
87 virtual ~SwRedlineExtraData_Format();
88 virtual SwRedlineExtraData* CreateNew() const;
89 virtual void Reject( SwPaM& rPam ) const;
90 virtual int operator == ( const SwRedlineExtraData& ) const;
94 class SW_DLLPUBLIC SwRedlineData
96 friend class SwRedline;
97 SwRedlineData* pNext; // Verweis auf weitere Daten
98 SwRedlineExtraData* pExtraData;
100 String sComment;
101 DateTime aStamp;
102 RedlineType_t eType;
103 USHORT nAuthor, nSeqNo;
105 public:
106 SwRedlineData( RedlineType_t eT, USHORT nAut );
107 SwRedlineData( const SwRedlineData& rCpy, BOOL bCpyNext = TRUE );
109 // fuer sw3io: pNext/pExtraData gehen in eigenen Besitz ueber!
110 SwRedlineData( RedlineType_t eT, USHORT nAut, const DateTime& rDT,
111 const String& rCmnt, SwRedlineData* pNxt,
112 SwRedlineExtraData* pExtraData = 0 );
114 ~SwRedlineData();
116 int operator==( const SwRedlineData& rCmp ) const
118 return nAuthor == rCmp.nAuthor &&
119 eType == rCmp.eType &&
120 sComment == rCmp.sComment &&
121 (( !pNext && !rCmp.pNext ) ||
122 ( pNext && rCmp.pNext && *pNext == *rCmp.pNext )) &&
123 (( !pExtraData && !rCmp.pExtraData ) ||
124 ( pExtraData && rCmp.pExtraData &&
125 *pExtraData == *rCmp.pExtraData ));
127 int operator!=( const SwRedlineData& rCmp ) const
128 { return !operator==( rCmp ); }
130 RedlineType_t GetType() const
131 { return ((RedlineType_t)(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
132 RedlineType_t GetRealType() const { return eType; }
133 USHORT GetAuthor() const { return nAuthor; }
134 const String& GetComment() const { return sComment; }
135 const DateTime& GetTimeStamp() const { return aStamp; }
136 inline const SwRedlineData* Next() const{ return pNext; }
138 void SetComment( const String& rS ) { sComment = rS; }
139 void SetTimeStamp( const DateTime& rDT ) { aStamp = rDT; }
141 void SetAutoFmtFlag()
142 { eType = (RedlineType_t)(eType | nsRedlineType_t::REDLINE_FORM_AUTOFMT); }
143 int CanCombine( const SwRedlineData& rCmp ) const
145 return nAuthor == rCmp.nAuthor &&
146 eType == rCmp.eType &&
147 sComment == rCmp.sComment &&
148 GetTimeStamp() == rCmp.GetTimeStamp() &&
149 (( !pNext && !rCmp.pNext ) ||
150 ( pNext && rCmp.pNext &&
151 pNext->CanCombine( *rCmp.pNext ))) &&
152 (( !pExtraData && !rCmp.pExtraData ) ||
153 ( pExtraData && rCmp.pExtraData &&
154 *pExtraData == *rCmp.pExtraData ));
157 // ExtraData wird kopiert, der Pointer geht also NICHT in den Besitz
158 // des RedlineObjectes!
159 void SetExtraData( const SwRedlineExtraData* pData );
160 const SwRedlineExtraData* GetExtraData() const { return pExtraData; }
162 // fuers UI-seitige zusammenfassen von Redline-Actionen. Wird z.Z. nur
163 // fuers Autoformat mit Redline benoetigt. Der Wert != 0 bedeutet dabei,
164 // das es noch weitere geben kann!
165 USHORT GetSeqNo() const { return nSeqNo; }
166 void SetSeqNo( USHORT nNo ) { nSeqNo = nNo; }
168 String GetDescr() const;
172 class SW_DLLPUBLIC SwRedline : public SwPaM
174 SwRedlineData* pRedlineData;
175 SwNodeIndex* pCntntSect;
176 BOOL bDelLastPara : 1;
177 BOOL bIsLastParaDelete : 1;
178 BOOL bIsVisible : 1;
180 void MoveToSection();
181 void CopyToSection();
182 void DelCopyOfSection();
183 void MoveFromSection();
185 public:
186 SwRedline( RedlineType_t eType, const SwPaM& rPam );
187 SwRedline( const SwRedlineData& rData, const SwPaM& rPam );
188 SwRedline( const SwRedlineData& rData, const SwPosition& rPos );
189 // fuer sw3io: pData geht in eigenen Besitz ueber!
190 SwRedline(SwRedlineData* pData, const SwPosition& rPos, BOOL bVsbl,
191 BOOL bDelLP, BOOL bIsPD) :
192 SwPaM( rPos ), pRedlineData( pData ), pCntntSect( 0 ),
193 bDelLastPara( bDelLP ), bIsLastParaDelete( bIsPD ), bIsVisible( bVsbl )
195 SwRedline( const SwRedline& );
196 virtual ~SwRedline();
198 SwNodeIndex* GetContentIdx() const { return pCntntSect; }
199 // fuers Undo
200 void SetContentIdx( const SwNodeIndex* );
202 BOOL IsVisible() const { return bIsVisible; }
203 BOOL IsDelLastPara() const { return bDelLastPara; }
205 // das BOOL besagt, ob nach dem setzen der Pos kein Bereich mehr
206 // aufgespannt ist. -> TRUE, ansonten Bereich und FALSE
207 void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = 0 )
209 if( !pSttPtr ) pSttPtr = Start();
210 *pSttPtr = rPos;
212 void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = 0 )
214 if( !pEndPtr ) pEndPtr = End();
215 *pEndPtr = rPos;
217 // liegt eine gueltige Selektion vor?
218 BOOL HasValidRange() const;
220 const SwRedlineData& GetRedlineData(USHORT nPos = 0) const;
221 int operator==( const SwRedlineData& rCmp ) const
222 { return *pRedlineData == rCmp; }
223 int operator!=( const SwRedlineData& rCmp ) const
224 { return *pRedlineData != rCmp; }
225 void SetAutoFmtFlag() { pRedlineData->SetAutoFmtFlag(); }
227 USHORT GetStackCount() const;
228 USHORT GetAuthor( USHORT nPos = 0) const;
229 const String& GetAuthorString( USHORT nPos = 0 ) const;
230 const DateTime& GetTimeStamp( USHORT nPos = 0) const;
231 RedlineType_t GetRealType( USHORT nPos = 0 ) const;
232 RedlineType_t GetType( USHORT nPos = 0) const
233 { return ( (RedlineType_t)(GetRealType( nPos ) & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
234 const String& GetComment( USHORT nPos = 0 ) const;
236 void SetComment( const String& rS ) { pRedlineData->SetComment( rS ); }
238 // ExtraData wird kopiert, der Pointer geht also NICHT in den Besitz
239 // des RedlineObjectes!
240 void SetExtraData( const SwRedlineExtraData* pData )
241 { pRedlineData->SetExtraData( pData ); }
242 const SwRedlineExtraData* GetExtraData() const
243 { return pRedlineData->GetExtraData(); }
245 // fuers UI-seitige zusammenfassen von Redline-Actionen. Wird z.Z. nur
246 // fuers Autoformat mit Redline benoetigt. Der Wert != 0 bedeutet dabei,
247 // das es noch weitere geben kann!
248 USHORT GetSeqNo() const { return pRedlineData->GetSeqNo(); }
249 void SetSeqNo( USHORT nNo ) { pRedlineData->SetSeqNo( nNo ); }
251 // Beim Hide/ShowOriginal wird 2 mal ueber die Liste gelaufen, damit
252 // die Del-Redlines per Copy und Delete versteckt werden. Beim Move
253 // wird sonst die Attributierung falsch behandelt.
254 // Alle anderen Aufrufer muessen immer 0 angeben.
255 void CallDisplayFunc( USHORT nLoop = 0 );
256 void Show( USHORT nLoop = 0 );
257 void Hide( USHORT nLoop = 0 );
258 void ShowOriginal( USHORT nLoop = 0 );
260 // calculates the intersection with text node number nNdIdx
261 void CalcStartEnd( ULONG nNdIdx, USHORT& nStart, USHORT& nEnd ) const;
263 void InvalidateRange(); // das Layout anstossen
265 BOOL IsOwnRedline( const SwRedline& rRedl ) const
266 { return GetAuthor() == rRedl.GetAuthor(); }
267 BOOL CanCombine( const SwRedline& rRedl ) const;
269 void PushData( const SwRedline& rRedl, BOOL bOwnAsNext = TRUE );
270 BOOL PopData();
272 // #111827#
274 Returns textual description of this a redline data element of
275 this redline.
277 @param nPos index of the redline data element to describe
279 The textual description of the selected element contains the
280 kind of redline and the possibly shortened text of the redline.
282 @return textual description of the selected redline data element
284 String GetDescr(USHORT nPos = 0);
286 int operator==( const SwRedline& ) const;
287 int operator<( const SwRedline& ) const;
290 class SW_DLLPUBLIC SwRedlineHint : public SfxHint
292 #define SWREDLINE_INSERTED 1
293 #define SWREDLINE_REMOVED 2
294 #define SWREDLINE_FOCUS 3
295 #define SWREDLINE_CHANGED 4
296 #define SWREDLINE_LANGUAGE 5
298 const SwRedline* pRedline;
299 sal_Int16 nWhich;
301 public:
302 SwRedlineHint( const SwRedline* p, sal_Int16 n )
303 : pRedline(p)
304 , nWhich(n)
307 TYPEINFO();
308 const SwRedline* GetRedline() const { return pRedline; }
309 sal_Int16 Which() const { return nWhich; }
313 #endif