xref: /aoo41x/main/sw/source/core/text/redlnitr.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	_REDLNITR_HXX
24cdf0e10cSrcweir #define	_REDLNITR_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "ndhints.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef IDOCUMENTREDLINEACCESS_HXX_INCLUDED
29cdf0e10cSrcweir #include <IDocumentRedlineAccess.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "swfont.hxx"
33cdf0e10cSrcweir #ifndef _SVSTDARR_USHORTS
34cdf0e10cSrcweir #define _SVSTDARR_USHORTS
35cdf0e10cSrcweir #include <svl/svstdarr.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir 
38cdf0e10cSrcweir class SwTxtNode;
39cdf0e10cSrcweir class SwDoc;
40cdf0e10cSrcweir class SfxItemSet;
41cdf0e10cSrcweir class SwAttrHandler;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class SwExtend
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 	SwFont *pFnt;
46cdf0e10cSrcweir 	const SvUShorts &rArr;	// XAMA: Array of xub_StrLen
47cdf0e10cSrcweir 	xub_StrLen nStart;
48cdf0e10cSrcweir 	xub_StrLen nPos;
49cdf0e10cSrcweir 	xub_StrLen nEnd;
50cdf0e10cSrcweir 	sal_Bool _Leave( SwFont& rFnt, xub_StrLen nNew );
Inside() const51cdf0e10cSrcweir 	sal_Bool Inside() const { return ( nPos >= nStart && nPos < nEnd ); }
52cdf0e10cSrcweir     void ActualizeFont( SwFont &rFnt, xub_StrLen nAttr );
53cdf0e10cSrcweir public:
SwExtend(const SvUShorts & rA,xub_StrLen nSt)54cdf0e10cSrcweir     SwExtend( const SvUShorts &rA, xub_StrLen nSt ) : pFnt(0), rArr( rA ),
55cdf0e10cSrcweir 		nStart( nSt ), nPos( STRING_LEN ), nEnd( nStart + rA.Count() ) {}
~SwExtend()56cdf0e10cSrcweir 	~SwExtend() { delete pFnt; }
IsOn() const57cdf0e10cSrcweir 	sal_Bool IsOn() const { return pFnt != 0; }
Reset()58cdf0e10cSrcweir 	void Reset() { if( pFnt ) { delete pFnt; pFnt = NULL; } nPos = STRING_LEN; }
Leave(SwFont & rFnt,xub_StrLen nNew)59cdf0e10cSrcweir 	sal_Bool Leave( SwFont& rFnt, xub_StrLen nNew )
60cdf0e10cSrcweir 		{ if( pFnt ) return _Leave( rFnt, nNew ); return sal_False; }
61cdf0e10cSrcweir 	short Enter( SwFont& rFnt, xub_StrLen nNew );
62cdf0e10cSrcweir 	xub_StrLen Next( xub_StrLen nNext );
GetFont()63cdf0e10cSrcweir     SwFont* GetFont()  { return pFnt; }
UpdateFont(SwFont & rFnt)64cdf0e10cSrcweir     void UpdateFont( SwFont &rFnt ) { ActualizeFont( rFnt, rArr[ nPos - nStart ] ); }
65cdf0e10cSrcweir };
66cdf0e10cSrcweir 
67cdf0e10cSrcweir class SwRedlineItr
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	SwpHtStart_SAR aHints;
70cdf0e10cSrcweir 	const SwDoc& rDoc;
71cdf0e10cSrcweir 	const SwTxtNode& rNd;
72cdf0e10cSrcweir     SwAttrHandler& rAttrHandler;
73cdf0e10cSrcweir     SfxItemSet *pSet;
74cdf0e10cSrcweir 	SwExtend *pExt;
75cdf0e10cSrcweir     sal_uLong nNdIdx;
76cdf0e10cSrcweir 	xub_StrLen nFirst;
77cdf0e10cSrcweir 	xub_StrLen nAct;
78cdf0e10cSrcweir 	xub_StrLen nStart;
79cdf0e10cSrcweir 	xub_StrLen nEnd;
80cdf0e10cSrcweir 	sal_Bool bOn;
81cdf0e10cSrcweir 	sal_Bool bShow;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	void _Clear( SwFont* pFnt );
84cdf0e10cSrcweir 	sal_Bool _ChkSpecialUnderline() const;
85cdf0e10cSrcweir 	void FillHints( MSHORT nAuthor, RedlineType_t eType );
86cdf0e10cSrcweir 	short _Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld );
87cdf0e10cSrcweir 	xub_StrLen _GetNextRedln( xub_StrLen nNext );
EnterExtend(SwFont & rFnt,xub_StrLen nNew)88cdf0e10cSrcweir 	inline short EnterExtend( SwFont& rFnt, xub_StrLen nNew )
89cdf0e10cSrcweir 		{ if( pExt ) return pExt->Enter( rFnt, nNew ); return 0; }
NextExtend(xub_StrLen nNext)90cdf0e10cSrcweir 	inline xub_StrLen NextExtend( xub_StrLen nNext )
91cdf0e10cSrcweir 		{ if( pExt ) return pExt->Next( nNext ); return nNext; }
92cdf0e10cSrcweir public:
93cdf0e10cSrcweir     SwRedlineItr( const SwTxtNode& rTxtNd, SwFont& rFnt, SwAttrHandler& rAH,
94cdf0e10cSrcweir         xub_StrLen nRedlPos, sal_Bool bShw, const SvUShorts *pArr = 0,
95cdf0e10cSrcweir         xub_StrLen nStart = STRING_LEN );
96cdf0e10cSrcweir 	~SwRedlineItr();
IsOn() const97cdf0e10cSrcweir 	inline sal_Bool IsOn() const { return bOn || ( pExt && pExt->IsOn() ); }
Clear(SwFont * pFnt)98cdf0e10cSrcweir 	inline void Clear( SwFont* pFnt ) { if( bOn ) _Clear( pFnt ); }
99cdf0e10cSrcweir     void ChangeTxtAttr( SwFont* pFnt, SwTxtAttr &rHt, sal_Bool bChg );
Seek(SwFont & rFnt,xub_StrLen nNew,xub_StrLen nOld)100cdf0e10cSrcweir     inline short Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld )
101cdf0e10cSrcweir 		{ if( bShow || pExt ) return _Seek( rFnt, nNew, nOld ); return 0; }
Reset()102cdf0e10cSrcweir 	inline void Reset() { if( nAct != nFirst ) nAct = STRING_LEN;
103cdf0e10cSrcweir 						  if( pExt ) pExt->Reset(); }
GetNextRedln(xub_StrLen nNext)104cdf0e10cSrcweir 	inline xub_StrLen GetNextRedln( xub_StrLen nNext )
105cdf0e10cSrcweir 		{ if( bShow || pExt ) return _GetNextRedln( nNext ); return nNext; }
ChkSpecialUnderline() const106cdf0e10cSrcweir 	inline sal_Bool ChkSpecialUnderline() const
107cdf0e10cSrcweir 		{ if ( IsOn() ) return _ChkSpecialUnderline(); return sal_False; }
108cdf0e10cSrcweir 	sal_Bool CheckLine( xub_StrLen nChkStart, xub_StrLen nChkEnd );
LeaveExtend(SwFont & rFnt,xub_StrLen nNew)109cdf0e10cSrcweir     inline sal_Bool LeaveExtend( SwFont& rFnt, xub_StrLen nNew )
110cdf0e10cSrcweir 		{ return pExt->Leave(rFnt, nNew ); }
ExtOn()111cdf0e10cSrcweir 	inline sal_Bool ExtOn() { if( pExt ) return pExt->IsOn(); return sal_False; }
UpdateExtFont(SwFont & rFnt)112cdf0e10cSrcweir     inline void UpdateExtFont( SwFont &rFnt ) {
113cdf0e10cSrcweir         ASSERT( ExtOn(), "UpdateExtFont without ExtOn" )
114cdf0e10cSrcweir         pExt->UpdateFont( rFnt ); }
115cdf0e10cSrcweir };
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118cdf0e10cSrcweir #endif
119cdf0e10cSrcweir 
120