Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _REDLNITR_HXX
20 : #define _REDLNITR_HXX
21 :
22 : #include "ndhints.hxx"
23 :
24 : #include <IDocumentRedlineAccess.hxx>
25 :
26 : #include "swfont.hxx"
27 : #include <vector>
28 :
29 : class SwTxtNode;
30 : class SwDoc;
31 : class SfxItemSet;
32 : class SwAttrHandler;
33 :
34 : class SwExtend
35 : {
36 : SwFont *pFnt;
37 : const std::vector<sal_uInt16> ⇒ // 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 0 : bool Inside() const { return ( nPos >= nStart && nPos < nEnd ); }
43 : void ActualizeFont( SwFont &rFnt, xub_StrLen nAttr );
44 : public:
45 0 : SwExtend( const std::vector<sal_uInt16> &rA, xub_StrLen nSt ) : pFnt(0), rArr( rA ),
46 0 : nStart( nSt ), nPos( STRING_LEN ), nEnd( nStart + rA.size() ) {}
47 0 : ~SwExtend() { delete pFnt; }
48 0 : bool IsOn() const { return pFnt != 0; }
49 0 : void Reset() { if( pFnt ) { delete pFnt; pFnt = NULL; } nPos = STRING_LEN; }
50 0 : sal_Bool Leave( SwFont& rFnt, xub_StrLen nNew )
51 0 : { 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 0 : SwFont* GetFont() { return pFnt; }
55 0 : void UpdateFont( SwFont &rFnt ) { ActualizeFont( rFnt, rArr[ nPos - nStart ] ); }
56 : };
57 :
58 : class SwRedlineItr
59 : {
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;
72 :
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 201 : inline short EnterExtend( SwFont& rFnt, xub_StrLen nNew )
79 201 : { if( pExt ) return pExt->Enter( rFnt, nNew ); return 0; }
80 21 : inline xub_StrLen NextExtend( xub_StrLen nNext )
81 21 : { 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 166 : inline bool IsOn() const { return bOn || ( pExt && pExt->IsOn() ); }
88 163 : inline void Clear( SwFont* pFnt ) { if( bOn ) _Clear( pFnt ); }
89 : void ChangeTxtAttr( SwFont* pFnt, SwTxtAttr &rHt, sal_Bool bChg );
90 201 : inline short Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld )
91 201 : { if( bShow || pExt ) return _Seek( rFnt, nNew, nOld ); return 0; }
92 9 : inline void Reset() { if( nAct != nFirst ) nAct = STRING_LEN;
93 9 : if( pExt ) pExt->Reset(); }
94 21 : inline xub_StrLen GetNextRedln( xub_StrLen nNext )
95 21 : { if( bShow || pExt ) return _GetNextRedln( nNext ); return nNext; }
96 0 : inline sal_Bool ChkSpecialUnderline() const
97 0 : { if ( IsOn() ) return _ChkSpecialUnderline(); return sal_False; }
98 : sal_Bool CheckLine( xub_StrLen nChkStart, xub_StrLen nChkEnd );
99 0 : inline sal_Bool LeaveExtend( SwFont& rFnt, xub_StrLen nNew )
100 0 : { return pExt->Leave(rFnt, nNew ); }
101 330 : inline bool ExtOn() { if( pExt ) return pExt->IsOn(); return false; }
102 0 : inline void UpdateExtFont( SwFont &rFnt ) {
103 : OSL_ENSURE( ExtOn(), "UpdateExtFont without ExtOn" );
104 0 : pExt->UpdateFont( rFnt ); }
105 : };
106 :
107 :
108 : #endif
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|