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 INCLUDED_SW_SOURCE_CORE_TEXT_REDLNITR_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_TEXT_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 sal_uInt16
38 : sal_Int32 nStart;
39 : sal_Int32 nPos;
40 : sal_Int32 nEnd;
41 : bool _Leave( SwFont& rFnt, sal_Int32 nNew );
42 0 : bool Inside() const { return ( nPos >= nStart && nPos < nEnd ); }
43 : void ActualizeFont( SwFont &rFnt, sal_uInt16 nAttr );
44 : public:
45 0 : SwExtend( const std::vector<sal_uInt16> &rA, sal_Int32 nSt ) : pFnt(0), rArr( rA ),
46 0 : nStart( nSt ), nPos( COMPLETE_STRING ), 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 = COMPLETE_STRING; }
50 0 : bool Leave( SwFont& rFnt, sal_Int32 nNew )
51 0 : { return pFnt && _Leave( rFnt, nNew ); }
52 : short Enter( SwFont& rFnt, sal_Int32 nNew );
53 : sal_Int32 Next( sal_Int32 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 : sal_Int32 nFirst;
67 : sal_Int32 nAct;
68 : sal_Int32 nStart;
69 : sal_Int32 nEnd;
70 : bool bOn;
71 : bool bShow;
72 :
73 : void _Clear( SwFont* pFnt );
74 : bool _ChkSpecialUnderline() const;
75 : void FillHints( MSHORT nAuthor, RedlineType_t eType );
76 : short _Seek( SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld );
77 : sal_Int32 _GetNextRedln( sal_Int32 nNext );
78 0 : short EnterExtend( SwFont& rFnt, sal_Int32 nNew )
79 0 : { if( pExt ) return pExt->Enter( rFnt, nNew ); return 0; }
80 0 : sal_Int32 NextExtend( sal_Int32 nNext )
81 0 : { if( pExt ) return pExt->Next( nNext ); return nNext; }
82 : public:
83 : SwRedlineItr( const SwTxtNode& rTxtNd, SwFont& rFnt, SwAttrHandler& rAH,
84 : sal_Int32 nRedlPos, bool bShw, const std::vector<sal_uInt16> *pArr = 0,
85 : sal_Int32 nExtStart = COMPLETE_STRING );
86 : ~SwRedlineItr();
87 0 : inline bool IsOn() const { return bOn || ( pExt && pExt->IsOn() ); }
88 0 : inline void Clear( SwFont* pFnt ) { if( bOn ) _Clear( pFnt ); }
89 : void ChangeTxtAttr( SwFont* pFnt, SwTxtAttr &rHt, bool bChg );
90 0 : inline short Seek( SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld )
91 0 : { if( bShow || pExt ) return _Seek( rFnt, nNew, nOld ); return 0; }
92 0 : inline void Reset() { if( nAct != nFirst ) nAct = COMPLETE_STRING;
93 0 : if( pExt ) pExt->Reset(); }
94 0 : inline sal_Int32 GetNextRedln( sal_Int32 nNext )
95 0 : { if( bShow || pExt ) return _GetNextRedln( nNext ); return nNext; }
96 0 : inline bool ChkSpecialUnderline() const
97 0 : { return IsOn() && _ChkSpecialUnderline(); }
98 : bool CheckLine( sal_Int32 nChkStart, sal_Int32 nChkEnd );
99 0 : inline bool LeaveExtend( SwFont& rFnt, sal_Int32 nNew )
100 0 : { return pExt->Leave(rFnt, nNew ); }
101 0 : 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 : #endif
108 :
109 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|