update credits
[LibreOffice.git] / sw / source / core / text / redlnitr.hxx
blob80bdba19395ee439cd3f19f6da7bf9ad32de69ce
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _REDLNITR_HXX
20 #define _REDLNITR_HXX
22 #include "ndhints.hxx"
24 #include <IDocumentRedlineAccess.hxx>
26 #include "swfont.hxx"
27 #include <vector>
29 class SwTxtNode;
30 class SwDoc;
31 class SfxItemSet;
32 class SwAttrHandler;
34 class SwExtend
36 SwFont *pFnt;
37 const std::vector<sal_uInt16> &rArr; // XAMA: Array of xub_StrLen
38 xub_StrLen nStart;
39 xub_StrLen nPos;
40 xub_StrLen nEnd;
41 sal_Bool _Leave( SwFont& rFnt, xub_StrLen nNew );
42 bool Inside() const { return ( nPos >= nStart && nPos < nEnd ); }
43 void ActualizeFont( SwFont &rFnt, xub_StrLen nAttr );
44 public:
45 SwExtend( const std::vector<sal_uInt16> &rA, xub_StrLen nSt ) : pFnt(0), rArr( rA ),
46 nStart( nSt ), nPos( STRING_LEN ), nEnd( nStart + rA.size() ) {}
47 ~SwExtend() { delete pFnt; }
48 bool IsOn() const { return pFnt != 0; }
49 void Reset() { if( pFnt ) { delete pFnt; pFnt = NULL; } nPos = STRING_LEN; }
50 sal_Bool Leave( SwFont& rFnt, xub_StrLen nNew )
51 { if( pFnt ) return _Leave( rFnt, nNew ); return sal_False; }
52 short Enter( SwFont& rFnt, xub_StrLen nNew );
53 xub_StrLen Next( xub_StrLen nNext );
54 SwFont* GetFont() { return pFnt; }
55 void UpdateFont( SwFont &rFnt ) { ActualizeFont( rFnt, rArr[ nPos - nStart ] ); }
58 class SwRedlineItr
60 std::deque<SwTxtAttr *> m_Hints;
61 const SwDoc& rDoc;
62 SwAttrHandler& rAttrHandler;
63 SfxItemSet *pSet;
64 SwExtend *pExt;
65 sal_uLong nNdIdx;
66 xub_StrLen nFirst;
67 xub_StrLen nAct;
68 xub_StrLen nStart;
69 xub_StrLen nEnd;
70 sal_Bool bOn;
71 sal_Bool bShow;
73 void _Clear( SwFont* pFnt );
74 sal_Bool _ChkSpecialUnderline() const;
75 void FillHints( MSHORT nAuthor, RedlineType_t eType );
76 short _Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld );
77 xub_StrLen _GetNextRedln( xub_StrLen nNext );
78 inline short EnterExtend( SwFont& rFnt, xub_StrLen nNew )
79 { if( pExt ) return pExt->Enter( rFnt, nNew ); return 0; }
80 inline xub_StrLen NextExtend( xub_StrLen nNext )
81 { if( pExt ) return pExt->Next( nNext ); return nNext; }
82 public:
83 SwRedlineItr( const SwTxtNode& rTxtNd, SwFont& rFnt, SwAttrHandler& rAH,
84 xub_StrLen nRedlPos, sal_Bool bShw, const std::vector<sal_uInt16> *pArr = 0,
85 xub_StrLen nStart = STRING_LEN );
86 ~SwRedlineItr();
87 inline bool IsOn() const { return bOn || ( pExt && pExt->IsOn() ); }
88 inline void Clear( SwFont* pFnt ) { if( bOn ) _Clear( pFnt ); }
89 void ChangeTxtAttr( SwFont* pFnt, SwTxtAttr &rHt, sal_Bool bChg );
90 inline short Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld )
91 { if( bShow || pExt ) return _Seek( rFnt, nNew, nOld ); return 0; }
92 inline void Reset() { if( nAct != nFirst ) nAct = STRING_LEN;
93 if( pExt ) pExt->Reset(); }
94 inline xub_StrLen GetNextRedln( xub_StrLen nNext )
95 { if( bShow || pExt ) return _GetNextRedln( nNext ); return nNext; }
96 inline sal_Bool ChkSpecialUnderline() const
97 { if ( IsOn() ) return _ChkSpecialUnderline(); return sal_False; }
98 sal_Bool CheckLine( xub_StrLen nChkStart, xub_StrLen nChkEnd );
99 inline sal_Bool LeaveExtend( SwFont& rFnt, xub_StrLen nNew )
100 { return pExt->Leave(rFnt, nNew ); }
101 inline bool ExtOn() { if( pExt ) return pExt->IsOn(); return false; }
102 inline void UpdateExtFont( SwFont &rFnt ) {
103 OSL_ENSURE( ExtOn(), "UpdateExtFont without ExtOn" );
104 pExt->UpdateFont( rFnt ); }
108 #endif
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */