xref: /aoo42x/main/sw/inc/redline.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _REDLINE_HXX
24cdf0e10cSrcweir #define _REDLINE_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <tools/datetime.hxx>
27cdf0e10cSrcweir #include <tools/string.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #define _SVSTDARR_USHORTS
30cdf0e10cSrcweir #include <svl/svstdarr.hxx>
31cdf0e10cSrcweir #include <pam.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <IDocumentRedlineAccess.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <svl/smplhint.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class SfxItemSet;
38cdf0e10cSrcweir class SwView;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir class SwRedlineExtraData
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 	SwRedlineExtraData( const SwRedlineExtraData& );
43cdf0e10cSrcweir 	SwRedlineExtraData& operator=( const SwRedlineExtraData& );
44cdf0e10cSrcweir 
45cdf0e10cSrcweir protected:
SwRedlineExtraData()46cdf0e10cSrcweir 	SwRedlineExtraData() {}
47cdf0e10cSrcweir 
48cdf0e10cSrcweir public:
49cdf0e10cSrcweir 	virtual ~SwRedlineExtraData();
50cdf0e10cSrcweir 	virtual SwRedlineExtraData* CreateNew() const = 0;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 	virtual void Accept( SwPaM& rPam ) const;
53cdf0e10cSrcweir 	virtual void Reject( SwPaM& rPam ) const;
54cdf0e10cSrcweir 	virtual int operator == ( const SwRedlineExtraData& ) const;
55cdf0e10cSrcweir };
56cdf0e10cSrcweir 
57cdf0e10cSrcweir class SwRedlineExtraData_FmtColl : public SwRedlineExtraData
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	String sFmtNm;
60cdf0e10cSrcweir 	SfxItemSet* pSet;
61cdf0e10cSrcweir 	sal_uInt16 nPoolId;
62cdf0e10cSrcweir public:
63cdf0e10cSrcweir 	SwRedlineExtraData_FmtColl( const String& rColl, sal_uInt16 nPoolFmtId,
64cdf0e10cSrcweir 								const SfxItemSet* pSet = 0 );
65cdf0e10cSrcweir 	virtual ~SwRedlineExtraData_FmtColl();
66cdf0e10cSrcweir 	virtual SwRedlineExtraData* CreateNew() const;
67cdf0e10cSrcweir 	virtual void Reject( SwPaM& rPam ) const;
68cdf0e10cSrcweir 	virtual int operator == ( const SwRedlineExtraData& ) const;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	void SetItemSet( const SfxItemSet& rSet );
71cdf0e10cSrcweir };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir class SwRedlineExtraData_Format : public SwRedlineExtraData
74cdf0e10cSrcweir {
75cdf0e10cSrcweir 	SvUShorts aWhichIds;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	SwRedlineExtraData_Format( const SwRedlineExtraData_Format& rCpy );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir public:
80cdf0e10cSrcweir 	SwRedlineExtraData_Format( const SfxItemSet& rSet );
81cdf0e10cSrcweir 	virtual ~SwRedlineExtraData_Format();
82cdf0e10cSrcweir 	virtual SwRedlineExtraData* CreateNew() const;
83cdf0e10cSrcweir 	virtual void Reject( SwPaM& rPam ) const;
84cdf0e10cSrcweir 	virtual int operator == ( const SwRedlineExtraData& ) const;
85cdf0e10cSrcweir };
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir class SW_DLLPUBLIC SwRedlineData
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	friend class SwRedline;
91cdf0e10cSrcweir 	SwRedlineData* pNext;		// Verweis auf weitere Daten
92cdf0e10cSrcweir 	SwRedlineExtraData* pExtraData;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	String sComment;
95cdf0e10cSrcweir 	DateTime aStamp;
96cdf0e10cSrcweir 	RedlineType_t eType;
97cdf0e10cSrcweir 	sal_uInt16 nAuthor, nSeqNo;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir public:
100cdf0e10cSrcweir 	SwRedlineData( RedlineType_t eT, sal_uInt16 nAut );
101cdf0e10cSrcweir 	SwRedlineData( const SwRedlineData& rCpy, sal_Bool bCpyNext = sal_True );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	// fuer sw3io: pNext/pExtraData gehen in eigenen Besitz ueber!
104cdf0e10cSrcweir 	SwRedlineData( RedlineType_t eT, sal_uInt16 nAut, const DateTime& rDT,
105cdf0e10cSrcweir 				   const String& rCmnt, SwRedlineData* pNxt,
106cdf0e10cSrcweir 					SwRedlineExtraData* pExtraData = 0 );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	~SwRedlineData();
109cdf0e10cSrcweir 
operator ==(const SwRedlineData & rCmp) const110cdf0e10cSrcweir 	int operator==( const SwRedlineData& rCmp ) const
111cdf0e10cSrcweir 		{
112cdf0e10cSrcweir 			return nAuthor == rCmp.nAuthor &&
113cdf0e10cSrcweir 					eType == rCmp.eType &&
114cdf0e10cSrcweir 					sComment == rCmp.sComment &&
115cdf0e10cSrcweir 					(( !pNext && !rCmp.pNext ) ||
116cdf0e10cSrcweir 						( pNext && rCmp.pNext && *pNext == *rCmp.pNext )) &&
117cdf0e10cSrcweir 					(( !pExtraData && !rCmp.pExtraData ) ||
118cdf0e10cSrcweir 						( pExtraData && rCmp.pExtraData &&
119cdf0e10cSrcweir 							*pExtraData == *rCmp.pExtraData ));
120cdf0e10cSrcweir 		}
operator !=(const SwRedlineData & rCmp) const121cdf0e10cSrcweir 	int operator!=( const SwRedlineData& rCmp ) const
122cdf0e10cSrcweir 		{	return !operator==( rCmp ); }
123cdf0e10cSrcweir 
GetType() const124cdf0e10cSrcweir 	RedlineType_t GetType() const
125cdf0e10cSrcweir   { return ((RedlineType_t)(eType & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
GetRealType() const126cdf0e10cSrcweir 	RedlineType_t GetRealType() const { return eType; }
GetAuthor() const127cdf0e10cSrcweir 	sal_uInt16 GetAuthor() const 				{ return nAuthor; }
GetComment() const128cdf0e10cSrcweir 	const String& GetComment() const 		{ return sComment; }
GetTimeStamp() const129cdf0e10cSrcweir 	const DateTime& GetTimeStamp() const 	{ return aStamp; }
Next() const130cdf0e10cSrcweir 	inline const SwRedlineData* Next() const{ return pNext;	}
131cdf0e10cSrcweir 
SetComment(const String & rS)132cdf0e10cSrcweir     void SetComment( const String& rS )     { sComment = rS; }
SetTimeStamp(const DateTime & rDT)133cdf0e10cSrcweir     void SetTimeStamp( const DateTime& rDT ) { aStamp = rDT; }
134cdf0e10cSrcweir 
SetAutoFmtFlag()135cdf0e10cSrcweir     void SetAutoFmtFlag()
136cdf0e10cSrcweir   { eType = (RedlineType_t)(eType | nsRedlineType_t::REDLINE_FORM_AUTOFMT); }
CanCombine(const SwRedlineData & rCmp) const137cdf0e10cSrcweir 	int CanCombine( const SwRedlineData& rCmp ) const
138cdf0e10cSrcweir 		{
139cdf0e10cSrcweir 			return nAuthor == rCmp.nAuthor &&
140cdf0e10cSrcweir 					eType == rCmp.eType &&
141cdf0e10cSrcweir 					sComment == rCmp.sComment &&
142cdf0e10cSrcweir 					GetTimeStamp() == rCmp.GetTimeStamp() &&
143cdf0e10cSrcweir 					(( !pNext && !rCmp.pNext ) ||
144cdf0e10cSrcweir 						( pNext && rCmp.pNext &&
145cdf0e10cSrcweir 						pNext->CanCombine( *rCmp.pNext ))) &&
146cdf0e10cSrcweir 					(( !pExtraData && !rCmp.pExtraData ) ||
147cdf0e10cSrcweir 						( pExtraData && rCmp.pExtraData &&
148cdf0e10cSrcweir 							*pExtraData == *rCmp.pExtraData ));
149cdf0e10cSrcweir 		}
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	// ExtraData wird kopiert, der Pointer geht also NICHT in den Besitz
152cdf0e10cSrcweir 	// des RedlineObjectes!
153cdf0e10cSrcweir 	void SetExtraData( const SwRedlineExtraData* pData );
GetExtraData() const154cdf0e10cSrcweir 	const SwRedlineExtraData* GetExtraData() const { return pExtraData; }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 	// fuers UI-seitige zusammenfassen von Redline-Actionen. Wird z.Z. nur
157cdf0e10cSrcweir 	// fuers Autoformat mit Redline benoetigt. Der Wert != 0 bedeutet dabei,
158cdf0e10cSrcweir 	// das es noch weitere geben kann!
GetSeqNo() const159cdf0e10cSrcweir 	sal_uInt16 GetSeqNo() const 					{ return nSeqNo; }
SetSeqNo(sal_uInt16 nNo)160cdf0e10cSrcweir 	void SetSeqNo( sal_uInt16 nNo ) 				{ nSeqNo = nNo; }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     String GetDescr() const;
163cdf0e10cSrcweir };
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 
166cdf0e10cSrcweir class SW_DLLPUBLIC SwRedline : public SwPaM
167cdf0e10cSrcweir {
168cdf0e10cSrcweir 	SwRedlineData* pRedlineData;
169cdf0e10cSrcweir 	SwNodeIndex* pCntntSect;
170cdf0e10cSrcweir 	sal_Bool bDelLastPara : 1;
171cdf0e10cSrcweir 	sal_Bool bIsLastParaDelete : 1;
172cdf0e10cSrcweir 	sal_Bool bIsVisible : 1;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	void MoveToSection();
175cdf0e10cSrcweir 	void CopyToSection();
176cdf0e10cSrcweir 	void DelCopyOfSection();
177cdf0e10cSrcweir 	void MoveFromSection();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir public:
180cdf0e10cSrcweir 	SwRedline( RedlineType_t eType, const SwPaM& rPam );
181cdf0e10cSrcweir 	SwRedline( const SwRedlineData& rData, const SwPaM& rPam );
182cdf0e10cSrcweir 	SwRedline( const SwRedlineData& rData, const SwPosition& rPos );
183cdf0e10cSrcweir 	// fuer sw3io: pData geht in eigenen Besitz ueber!
SwRedline(SwRedlineData * pData,const SwPosition & rPos,sal_Bool bVsbl,sal_Bool bDelLP,sal_Bool bIsPD)184cdf0e10cSrcweir 	SwRedline(SwRedlineData* pData, const SwPosition& rPos, sal_Bool bVsbl,
185cdf0e10cSrcweir 			   sal_Bool bDelLP, sal_Bool bIsPD) :
186cdf0e10cSrcweir 		SwPaM( rPos ), pRedlineData( pData ), pCntntSect( 0 ),
187cdf0e10cSrcweir 		bDelLastPara( bDelLP ), bIsLastParaDelete( bIsPD ), bIsVisible( bVsbl )
188cdf0e10cSrcweir 	{}
189cdf0e10cSrcweir 	SwRedline( const SwRedline& );
190cdf0e10cSrcweir 	virtual ~SwRedline();
191cdf0e10cSrcweir 
GetContentIdx() const192cdf0e10cSrcweir 	SwNodeIndex* GetContentIdx() const { return pCntntSect; }
193cdf0e10cSrcweir 	// fuers Undo
194cdf0e10cSrcweir 	void SetContentIdx( const SwNodeIndex* );
195cdf0e10cSrcweir 
IsVisible() const196cdf0e10cSrcweir 	sal_Bool IsVisible() const { return bIsVisible; }
IsDelLastPara() const197cdf0e10cSrcweir 	sal_Bool IsDelLastPara() const { return bDelLastPara; }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	// das sal_Bool besagt, ob nach dem setzen der Pos kein Bereich mehr
200cdf0e10cSrcweir 	// aufgespannt ist. -> sal_True, ansonten Bereich und sal_False
SetStart(const SwPosition & rPos,SwPosition * pSttPtr=0)201cdf0e10cSrcweir 	void SetStart( const SwPosition& rPos, SwPosition* pSttPtr = 0 )
202cdf0e10cSrcweir 	{
203cdf0e10cSrcweir 		if( !pSttPtr ) pSttPtr = Start();
204cdf0e10cSrcweir 		*pSttPtr = rPos;
205cdf0e10cSrcweir 	}
SetEnd(const SwPosition & rPos,SwPosition * pEndPtr=0)206cdf0e10cSrcweir 	void SetEnd( const SwPosition& rPos, SwPosition* pEndPtr = 0 )
207cdf0e10cSrcweir 	{
208cdf0e10cSrcweir 		if( !pEndPtr ) pEndPtr = End();
209cdf0e10cSrcweir 		*pEndPtr = rPos;
210cdf0e10cSrcweir 	}
211cdf0e10cSrcweir 	// liegt eine gueltige Selektion vor?
212cdf0e10cSrcweir 	sal_Bool HasValidRange() const;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	const SwRedlineData& GetRedlineData(sal_uInt16 nPos = 0) const;
operator ==(const SwRedlineData & rCmp) const215cdf0e10cSrcweir 	int operator==( const SwRedlineData& rCmp ) const
216cdf0e10cSrcweir 		{ return *pRedlineData == rCmp; }
operator !=(const SwRedlineData & rCmp) const217cdf0e10cSrcweir 	int operator!=( const SwRedlineData& rCmp ) const
218cdf0e10cSrcweir 		{ return *pRedlineData != rCmp; }
SetAutoFmtFlag()219cdf0e10cSrcweir 	void SetAutoFmtFlag()				{ pRedlineData->SetAutoFmtFlag(); }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	sal_uInt16 GetStackCount() const;
222cdf0e10cSrcweir 	sal_uInt16 GetAuthor( sal_uInt16 nPos = 0) const;
223cdf0e10cSrcweir 	const String& GetAuthorString( sal_uInt16 nPos = 0 ) const;
224cdf0e10cSrcweir 	const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
225cdf0e10cSrcweir     RedlineType_t GetRealType( sal_uInt16 nPos = 0 ) const;
GetType(sal_uInt16 nPos=0) const226cdf0e10cSrcweir 	RedlineType_t GetType( sal_uInt16 nPos = 0) const
227cdf0e10cSrcweir   { return ( (RedlineType_t)(GetRealType( nPos ) & nsRedlineType_t::REDLINE_NO_FLAG_MASK)); }
228cdf0e10cSrcweir 	const String& GetComment( sal_uInt16 nPos = 0 ) const;
229cdf0e10cSrcweir 
SetComment(const String & rS)230cdf0e10cSrcweir 	void SetComment( const String& rS ) { pRedlineData->SetComment( rS ); }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	// ExtraData wird kopiert, der Pointer geht also NICHT in den Besitz
233cdf0e10cSrcweir 	// des RedlineObjectes!
SetExtraData(const SwRedlineExtraData * pData)234cdf0e10cSrcweir 	void SetExtraData( const SwRedlineExtraData* pData )
235cdf0e10cSrcweir 		{ pRedlineData->SetExtraData( pData ); }
GetExtraData() const236cdf0e10cSrcweir 	const SwRedlineExtraData* GetExtraData() const
237cdf0e10cSrcweir 		{ return pRedlineData->GetExtraData(); }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	// fuers UI-seitige zusammenfassen von Redline-Actionen. Wird z.Z. nur
240cdf0e10cSrcweir 	// fuers Autoformat mit Redline benoetigt. Der Wert != 0 bedeutet dabei,
241cdf0e10cSrcweir 	// das es noch weitere geben kann!
GetSeqNo() const242cdf0e10cSrcweir 	sal_uInt16 GetSeqNo() const 			{ return pRedlineData->GetSeqNo(); }
SetSeqNo(sal_uInt16 nNo)243cdf0e10cSrcweir 	void SetSeqNo( sal_uInt16 nNo ) 		{ pRedlineData->SetSeqNo( nNo ); }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	// Beim Hide/ShowOriginal wird 2 mal ueber die Liste gelaufen, damit
246cdf0e10cSrcweir 	//	die Del-Redlines per Copy und Delete versteckt werden. Beim Move
247cdf0e10cSrcweir 	//	wird sonst die Attributierung falsch behandelt.
248cdf0e10cSrcweir 	// Alle anderen Aufrufer muessen immer 0 angeben.
249cdf0e10cSrcweir 	void CallDisplayFunc( sal_uInt16 nLoop = 0 );
250cdf0e10cSrcweir 	void Show( sal_uInt16 nLoop = 0 );
251cdf0e10cSrcweir 	void Hide( sal_uInt16 nLoop = 0 );
252cdf0e10cSrcweir 	void ShowOriginal( sal_uInt16 nLoop = 0 );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     // calculates the intersection with text node number nNdIdx
255cdf0e10cSrcweir     void CalcStartEnd( sal_uLong nNdIdx, sal_uInt16& nStart, sal_uInt16& nEnd ) const;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     void InvalidateRange();     // das Layout anstossen
258cdf0e10cSrcweir 
IsOwnRedline(const SwRedline & rRedl) const259cdf0e10cSrcweir 	sal_Bool IsOwnRedline( const SwRedline& rRedl ) const
260cdf0e10cSrcweir 		{ return GetAuthor() == rRedl.GetAuthor(); }
261cdf0e10cSrcweir 	sal_Bool CanCombine( const SwRedline& rRedl ) const;
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 	void PushData( const SwRedline& rRedl, sal_Bool bOwnAsNext = sal_True );
264cdf0e10cSrcweir 	sal_Bool PopData();
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     // #111827#
267cdf0e10cSrcweir     /**
268cdf0e10cSrcweir        Returns textual description of this a redline data element of
269cdf0e10cSrcweir        this redline.
270cdf0e10cSrcweir 
271cdf0e10cSrcweir        @param nPos index of the redline data element to describe
272cdf0e10cSrcweir 
273cdf0e10cSrcweir        The textual description of the selected element contains the
274cdf0e10cSrcweir        kind of redline and the possibly shortened text of the redline.
275cdf0e10cSrcweir 
276cdf0e10cSrcweir        @return textual description of the selected redline data element
277cdf0e10cSrcweir      */
278cdf0e10cSrcweir     String GetDescr(sal_uInt16 nPos = 0);
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 	int operator==( const SwRedline& ) const;
281cdf0e10cSrcweir 	int operator<( const SwRedline& ) const;
282cdf0e10cSrcweir };
283cdf0e10cSrcweir 
284cdf0e10cSrcweir class SW_DLLPUBLIC SwRedlineHint : public SfxHint
285cdf0e10cSrcweir {
286cdf0e10cSrcweir #define SWREDLINE_INSERTED	1
287cdf0e10cSrcweir #define SWREDLINE_REMOVED	2
288cdf0e10cSrcweir #define SWREDLINE_FOCUS		3
289cdf0e10cSrcweir #define SWREDLINE_CHANGED	4
290cdf0e10cSrcweir #define SWREDLINE_LANGUAGE	5
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 	const SwRedline* pRedline;
293cdf0e10cSrcweir 	sal_Int16 nWhich;
294cdf0e10cSrcweir 	const SwView* pView;
295cdf0e10cSrcweir 
296cdf0e10cSrcweir public:
SwRedlineHint(const SwRedline * p,sal_Int16 n,const SwView * pV=0)297cdf0e10cSrcweir 	SwRedlineHint( const SwRedline* p, sal_Int16 n, const SwView* pV = 0)
298cdf0e10cSrcweir 		: pRedline(p)
299cdf0e10cSrcweir 		, nWhich(n)
300cdf0e10cSrcweir 		, pView(pV)
301cdf0e10cSrcweir         {}
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 	TYPEINFO();
GetRedline() const304cdf0e10cSrcweir 	const SwRedline* GetRedline() const { return pRedline; }
Which() const305cdf0e10cSrcweir 	sal_Int16 Which() const { return nWhich; }
GetView() const306cdf0e10cSrcweir         const SwView* GetView() const { return pView; }
307cdf0e10cSrcweir };
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 
310cdf0e10cSrcweir #endif
311