1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _REDLNITR_HXX 28 #define _REDLNITR_HXX 29 30 #include "ndhints.hxx" 31 32 #ifndef IDOCUMENTREDLINEACCESS_HXX_INCLUDED 33 #include <IDocumentRedlineAccess.hxx> 34 #endif 35 36 #include "swfont.hxx" 37 #ifndef _SVSTDARR_USHORTS 38 #define _SVSTDARR_USHORTS 39 #include <svl/svstdarr.hxx> 40 #endif 41 42 class SwTxtNode; 43 class SwDoc; 44 class SfxItemSet; 45 class SwAttrHandler; 46 47 class SwExtend 48 { 49 SwFont *pFnt; 50 const SvUShorts ⇒ // XAMA: Array of xub_StrLen 51 xub_StrLen nStart; 52 xub_StrLen nPos; 53 xub_StrLen nEnd; 54 sal_Bool _Leave( SwFont& rFnt, xub_StrLen nNew ); 55 sal_Bool Inside() const { return ( nPos >= nStart && nPos < nEnd ); } 56 void ActualizeFont( SwFont &rFnt, xub_StrLen nAttr ); 57 public: 58 SwExtend( const SvUShorts &rA, xub_StrLen nSt ) : pFnt(0), rArr( rA ), 59 nStart( nSt ), nPos( STRING_LEN ), nEnd( nStart + rA.Count() ) {} 60 ~SwExtend() { delete pFnt; } 61 sal_Bool IsOn() const { return pFnt != 0; } 62 void Reset() { if( pFnt ) { delete pFnt; pFnt = NULL; } nPos = STRING_LEN; } 63 sal_Bool Leave( SwFont& rFnt, xub_StrLen nNew ) 64 { if( pFnt ) return _Leave( rFnt, nNew ); return sal_False; } 65 short Enter( SwFont& rFnt, xub_StrLen nNew ); 66 xub_StrLen Next( xub_StrLen nNext ); 67 SwFont* GetFont() { return pFnt; } 68 void UpdateFont( SwFont &rFnt ) { ActualizeFont( rFnt, rArr[ nPos - nStart ] ); } 69 }; 70 71 class SwRedlineItr 72 { 73 SwpHtStart_SAR aHints; 74 const SwDoc& rDoc; 75 const SwTxtNode& rNd; 76 SwAttrHandler& rAttrHandler; 77 SfxItemSet *pSet; 78 SwExtend *pExt; 79 sal_uLong nNdIdx; 80 xub_StrLen nFirst; 81 xub_StrLen nAct; 82 xub_StrLen nStart; 83 xub_StrLen nEnd; 84 sal_Bool bOn; 85 sal_Bool bShow; 86 87 void _Clear( SwFont* pFnt ); 88 sal_Bool _ChkSpecialUnderline() const; 89 void FillHints( MSHORT nAuthor, RedlineType_t eType ); 90 short _Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld ); 91 xub_StrLen _GetNextRedln( xub_StrLen nNext ); 92 inline short EnterExtend( SwFont& rFnt, xub_StrLen nNew ) 93 { if( pExt ) return pExt->Enter( rFnt, nNew ); return 0; } 94 inline xub_StrLen NextExtend( xub_StrLen nNext ) 95 { if( pExt ) return pExt->Next( nNext ); return nNext; } 96 public: 97 SwRedlineItr( const SwTxtNode& rTxtNd, SwFont& rFnt, SwAttrHandler& rAH, 98 xub_StrLen nRedlPos, sal_Bool bShw, const SvUShorts *pArr = 0, 99 xub_StrLen nStart = STRING_LEN ); 100 ~SwRedlineItr(); 101 inline sal_Bool IsOn() const { return bOn || ( pExt && pExt->IsOn() ); } 102 inline void Clear( SwFont* pFnt ) { if( bOn ) _Clear( pFnt ); } 103 void ChangeTxtAttr( SwFont* pFnt, SwTxtAttr &rHt, sal_Bool bChg ); 104 inline short Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld ) 105 { if( bShow || pExt ) return _Seek( rFnt, nNew, nOld ); return 0; } 106 inline void Reset() { if( nAct != nFirst ) nAct = STRING_LEN; 107 if( pExt ) pExt->Reset(); } 108 inline xub_StrLen GetNextRedln( xub_StrLen nNext ) 109 { if( bShow || pExt ) return _GetNextRedln( nNext ); return nNext; } 110 inline sal_Bool ChkSpecialUnderline() const 111 { if ( IsOn() ) return _ChkSpecialUnderline(); return sal_False; } 112 sal_Bool CheckLine( xub_StrLen nChkStart, xub_StrLen nChkEnd ); 113 inline sal_Bool LeaveExtend( SwFont& rFnt, xub_StrLen nNew ) 114 { return pExt->Leave(rFnt, nNew ); } 115 inline sal_Bool ExtOn() { if( pExt ) return pExt->IsOn(); return sal_False; } 116 inline void UpdateExtFont( SwFont &rFnt ) { 117 ASSERT( ExtOn(), "UpdateExtFont without ExtOn" ) 118 pExt->UpdateFont( rFnt ); } 119 }; 120 121 122 #endif 123 124