Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _REDLNITR_HXX
29 : : #define _REDLNITR_HXX
30 : :
31 : : #include "ndhints.hxx"
32 : :
33 : : #include <IDocumentRedlineAccess.hxx>
34 : :
35 : : #include "swfont.hxx"
36 : : #include <vector>
37 : :
38 : : class SwTxtNode;
39 : : class SwDoc;
40 : : class SfxItemSet;
41 : : class SwAttrHandler;
42 : :
43 : : class SwExtend
44 : : {
45 : : SwFont *pFnt;
46 : : const std::vector<sal_uInt16> ⇒ // 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 );
51 [ # # ][ # # ]: 0 : sal_Bool Inside() const { return ( nPos >= nStart && nPos < nEnd ); }
52 : : void ActualizeFont( SwFont &rFnt, xub_StrLen nAttr );
53 : : public:
54 : 0 : SwExtend( const std::vector<sal_uInt16> &rA, xub_StrLen nSt ) : pFnt(0), rArr( rA ),
55 : 0 : nStart( nSt ), nPos( STRING_LEN ), nEnd( nStart + rA.size() ) {}
56 [ # # ]: 0 : ~SwExtend() { delete pFnt; }
57 : 0 : sal_Bool IsOn() const { return pFnt != 0; }
58 [ # # ][ # # ]: 0 : void Reset() { if( pFnt ) { delete pFnt; pFnt = NULL; } nPos = STRING_LEN; }
59 : 0 : sal_Bool Leave( SwFont& rFnt, xub_StrLen nNew )
60 [ # # ]: 0 : { if( pFnt ) return _Leave( rFnt, nNew ); return sal_False; }
61 : : short Enter( SwFont& rFnt, xub_StrLen nNew );
62 : : xub_StrLen Next( xub_StrLen nNext );
63 : 0 : SwFont* GetFont() { return pFnt; }
64 : 0 : void UpdateFont( SwFont &rFnt ) { ActualizeFont( rFnt, rArr[ nPos - nStart ] ); }
65 : : };
66 : :
67 : : class SwRedlineItr
68 : : {
69 : : std::deque<SwTxtAttr *> m_Hints;
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 );
88 : 0 : inline short EnterExtend( SwFont& rFnt, xub_StrLen nNew )
89 [ # # ]: 0 : { if( pExt ) return pExt->Enter( rFnt, nNew ); return 0; }
90 : 0 : inline xub_StrLen NextExtend( xub_StrLen nNext )
91 [ # # ]: 0 : { 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 std::vector<sal_uInt16> *pArr = 0,
95 : : xub_StrLen nStart = STRING_LEN );
96 : : ~SwRedlineItr();
97 [ # # ][ # # ]: 0 : inline sal_Bool IsOn() const { return bOn || ( pExt && pExt->IsOn() ); }
[ # # ]
98 [ # # ]: 0 : inline void Clear( SwFont* pFnt ) { if( bOn ) _Clear( pFnt ); }
99 : : void ChangeTxtAttr( SwFont* pFnt, SwTxtAttr &rHt, sal_Bool bChg );
100 : 0 : inline short Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld )
101 [ # # ][ # # ]: 0 : { if( bShow || pExt ) return _Seek( rFnt, nNew, nOld ); return 0; }
102 [ # # ]: 0 : inline void Reset() { if( nAct != nFirst ) nAct = STRING_LEN;
103 [ # # ]: 0 : if( pExt ) pExt->Reset(); }
104 : 0 : inline xub_StrLen GetNextRedln( xub_StrLen nNext )
105 [ # # ][ # # ]: 0 : { if( bShow || pExt ) return _GetNextRedln( nNext ); return nNext; }
106 : 0 : inline sal_Bool ChkSpecialUnderline() const
107 [ # # ]: 0 : { if ( IsOn() ) return _ChkSpecialUnderline(); return sal_False; }
108 : : sal_Bool CheckLine( xub_StrLen nChkStart, xub_StrLen nChkEnd );
109 : 0 : inline sal_Bool LeaveExtend( SwFont& rFnt, xub_StrLen nNew )
110 : 0 : { return pExt->Leave(rFnt, nNew ); }
111 [ # # ]: 0 : inline sal_Bool ExtOn() { if( pExt ) return pExt->IsOn(); return sal_False; }
112 : 0 : inline void UpdateExtFont( SwFont &rFnt ) {
113 : : OSL_ENSURE( ExtOn(), "UpdateExtFont without ExtOn" );
114 : 0 : pExt->UpdateFont( rFnt ); }
115 : : };
116 : :
117 : :
118 : : #endif
119 : :
120 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|