xref: /trunk/main/sw/source/core/text/redlnitr.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef	_REDLNITR_HXX
24 #define	_REDLNITR_HXX
25 
26 #include "ndhints.hxx"
27 
28 #ifndef IDOCUMENTREDLINEACCESS_HXX_INCLUDED
29 #include <IDocumentRedlineAccess.hxx>
30 #endif
31 
32 #include "swfont.hxx"
33 #ifndef _SVSTDARR_USHORTS
34 #define _SVSTDARR_USHORTS
35 #include <svl/svstdarr.hxx>
36 #endif
37 
38 class SwTxtNode;
39 class SwDoc;
40 class SfxItemSet;
41 class SwAttrHandler;
42 
43 class SwExtend
44 {
45 	SwFont *pFnt;
46 	const SvUShorts &rArr;	// XAMA: Array of xub_StrLen
47 	xub_StrLen nStart;
48 	xub_StrLen nPos;
49 	xub_StrLen nEnd;
50 	sal_Bool _Leave( SwFont& rFnt, xub_StrLen nNew );
Inside() const51 	sal_Bool Inside() const { return ( nPos >= nStart && nPos < nEnd ); }
52     void ActualizeFont( SwFont &rFnt, xub_StrLen nAttr );
53 public:
SwExtend(const SvUShorts & rA,xub_StrLen nSt)54     SwExtend( const SvUShorts &rA, xub_StrLen nSt ) : pFnt(0), rArr( rA ),
55 		nStart( nSt ), nPos( STRING_LEN ), nEnd( nStart + rA.Count() ) {}
~SwExtend()56 	~SwExtend() { delete pFnt; }
IsOn() const57 	sal_Bool IsOn() const { return pFnt != 0; }
Reset()58 	void Reset() { if( pFnt ) { delete pFnt; pFnt = NULL; } nPos = STRING_LEN; }
Leave(SwFont & rFnt,xub_StrLen nNew)59 	sal_Bool Leave( SwFont& rFnt, xub_StrLen nNew )
60 		{ if( pFnt ) return _Leave( rFnt, nNew ); return sal_False; }
61 	short Enter( SwFont& rFnt, xub_StrLen nNew );
62 	xub_StrLen Next( xub_StrLen nNext );
GetFont()63     SwFont* GetFont()  { return pFnt; }
UpdateFont(SwFont & rFnt)64     void UpdateFont( SwFont &rFnt ) { ActualizeFont( rFnt, rArr[ nPos - nStart ] ); }
65 };
66 
67 class SwRedlineItr
68 {
69 	SwpHtStart_SAR aHints;
70 	const SwDoc& rDoc;
71 	const SwTxtNode& rNd;
72     SwAttrHandler& rAttrHandler;
73     SfxItemSet *pSet;
74 	SwExtend *pExt;
75     sal_uLong nNdIdx;
76 	xub_StrLen nFirst;
77 	xub_StrLen nAct;
78 	xub_StrLen nStart;
79 	xub_StrLen nEnd;
80 	sal_Bool bOn;
81 	sal_Bool bShow;
82 
83 	void _Clear( SwFont* pFnt );
84 	sal_Bool _ChkSpecialUnderline() const;
85 	void FillHints( MSHORT nAuthor, RedlineType_t eType );
86 	short _Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld );
87 	xub_StrLen _GetNextRedln( xub_StrLen nNext );
EnterExtend(SwFont & rFnt,xub_StrLen nNew)88 	inline short EnterExtend( SwFont& rFnt, xub_StrLen nNew )
89 		{ if( pExt ) return pExt->Enter( rFnt, nNew ); return 0; }
NextExtend(xub_StrLen nNext)90 	inline xub_StrLen NextExtend( xub_StrLen nNext )
91 		{ if( pExt ) return pExt->Next( nNext ); return nNext; }
92 public:
93     SwRedlineItr( const SwTxtNode& rTxtNd, SwFont& rFnt, SwAttrHandler& rAH,
94         xub_StrLen nRedlPos, sal_Bool bShw, const SvUShorts *pArr = 0,
95         xub_StrLen nStart = STRING_LEN );
96 	~SwRedlineItr();
IsOn() const97 	inline sal_Bool IsOn() const { return bOn || ( pExt && pExt->IsOn() ); }
Clear(SwFont * pFnt)98 	inline void Clear( SwFont* pFnt ) { if( bOn ) _Clear( pFnt ); }
99     void ChangeTxtAttr( SwFont* pFnt, SwTxtAttr &rHt, sal_Bool bChg );
Seek(SwFont & rFnt,xub_StrLen nNew,xub_StrLen nOld)100     inline short Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld )
101 		{ if( bShow || pExt ) return _Seek( rFnt, nNew, nOld ); return 0; }
Reset()102 	inline void Reset() { if( nAct != nFirst ) nAct = STRING_LEN;
103 						  if( pExt ) pExt->Reset(); }
GetNextRedln(xub_StrLen nNext)104 	inline xub_StrLen GetNextRedln( xub_StrLen nNext )
105 		{ if( bShow || pExt ) return _GetNextRedln( nNext ); return nNext; }
ChkSpecialUnderline() const106 	inline sal_Bool ChkSpecialUnderline() const
107 		{ if ( IsOn() ) return _ChkSpecialUnderline(); return sal_False; }
108 	sal_Bool CheckLine( xub_StrLen nChkStart, xub_StrLen nChkEnd );
LeaveExtend(SwFont & rFnt,xub_StrLen nNew)109     inline sal_Bool LeaveExtend( SwFont& rFnt, xub_StrLen nNew )
110 		{ return pExt->Leave(rFnt, nNew ); }
ExtOn()111 	inline sal_Bool ExtOn() { if( pExt ) return pExt->IsOn(); return sal_False; }
UpdateExtFont(SwFont & rFnt)112     inline void UpdateExtFont( SwFont &rFnt ) {
113         ASSERT( ExtOn(), "UpdateExtFont without ExtOn" )
114         pExt->UpdateFont( rFnt ); }
115 };
116 
117 
118 #endif
119 
120