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 : :
29 : :
30 : : #include "viewsh.hxx"
31 : : #include "rootfrm.hxx" // GetOleShell()
32 : : #include "txtfrm.hxx" // FindRootFrm()
33 : : #include "blink.hxx"
34 : : #include "porlin.hxx"
35 : : #include "porlay.hxx" // SwLineLayout
36 : :
37 : : // Sichtbare Zeit:
38 : : #define BLINK_ON_TIME 2400L
39 : : // Nihct sichtbare Zeit:
40 : : #define BLINK_OFF_TIME 800L
41 : :
42 : : /*************************************************************************
43 : : * pBlink points to the instance where blinking portions need to register.
44 : : * If necessary, it needs to be created by SwBlink.
45 : : * They are then triggered rhythimcally for a repaint. They can query
46 : : * for being visible or invisible with IsVisible().
47 : : *************************************************************************/
48 : : SwBlink *pBlink = NULL;
49 : :
50 : :
51 [ + - ]: 2 : SwBlink::SwBlink()
52 : : {
53 : 2 : bVisible = sal_True;
54 : : // Prepare the timer
55 [ + - ]: 2 : aTimer.SetTimeout( BLINK_ON_TIME );
56 [ + - ]: 2 : aTimer.SetTimeoutHdl( LINK(this, SwBlink, Blinker) );
57 : 2 : }
58 : :
59 [ + - ]: 2 : SwBlink::~SwBlink( )
60 : : {
61 [ + - ]: 2 : aTimer.Stop();
62 : 2 : }
63 : :
64 : : /*************************************************************************
65 : : * SwBlink::Blinker (timer):
66 : : * Toggle visibility flag
67 : : * Determine the repaint rectangle and invalidate them in their OleShells.
68 : : *************************************************************************/
69 : :
70 : 8 : IMPL_LINK_NOARG(SwBlink, Blinker)
71 : : {
72 : 8 : bVisible = !bVisible;
73 [ + + ]: 8 : if( bVisible )
74 : 4 : aTimer.SetTimeout( BLINK_ON_TIME );
75 : : else
76 : 4 : aTimer.SetTimeout( BLINK_OFF_TIME );
77 [ + + ]: 8 : if( !aList.empty() )
78 : : {
79 : :
80 [ + - ][ + - ]: 12 : for( SwBlinkList::iterator it = aList.begin(); it != aList.end(); )
[ + - ][ + + ]
81 : : {
82 [ + - ]: 8 : const SwBlinkPortion* pTmp = &*it;
83 [ + - + - ]: 16 : if( pTmp->GetRootFrm() &&
[ + - ]
84 : 8 : ((SwRootFrm*)pTmp->GetRootFrm())->GetCurrShell() )
85 : : {
86 [ + - ]: 8 : ++it;
87 : :
88 : 8 : Point aPos = pTmp->GetPos();
89 : : long nWidth, nHeight;
90 [ - - - + ]: 8 : switch ( pTmp->GetDirection() )
91 : : {
92 : : case 900:
93 : 0 : aPos.X() -= pTmp->GetPortion()->GetAscent();
94 : 0 : aPos.Y() -= pTmp->GetPortion()->Width();
95 : 0 : nWidth = pTmp->GetPortion()->SvLSize().Height();
96 : 0 : nHeight = pTmp->GetPortion()->SvLSize().Width();
97 : 0 : break;
98 : : case 1800:
99 : 0 : aPos.Y() -= pTmp->GetPortion()->Height() -
100 : 0 : pTmp->GetPortion()->GetAscent();
101 : 0 : aPos.X() -= pTmp->GetPortion()->Width();
102 : 0 : nWidth = pTmp->GetPortion()->SvLSize().Width();
103 : 0 : nHeight = pTmp->GetPortion()->SvLSize().Height();
104 : 0 : break;
105 : : case 2700:
106 : 0 : aPos.X() -= pTmp->GetPortion()->Height() -
107 : 0 : pTmp->GetPortion()->GetAscent();
108 : 0 : nWidth = pTmp->GetPortion()->SvLSize().Height();
109 : 0 : nHeight = pTmp->GetPortion()->SvLSize().Width();
110 : 0 : break;
111 : : default:
112 : 8 : aPos.Y() -= pTmp->GetPortion()->GetAscent();
113 : 8 : nWidth = pTmp->GetPortion()->SvLSize().Width();
114 : 8 : nHeight = pTmp->GetPortion()->SvLSize().Height();
115 : : }
116 : :
117 [ + - ]: 8 : Rectangle aRefresh( aPos, Size( nWidth, nHeight ) );
118 : 8 : aRefresh.Right() += ( aRefresh.Bottom()- aRefresh.Top() ) / 8;
119 : 8 : ((SwRootFrm*)pTmp->GetRootFrm())
120 [ + - + - ]: 16 : ->GetCurrShell()->InvalidateWindows( aRefresh );
121 : : }
122 : : else // Portions without a shell can be removed from the list
123 [ # # ]: 0 : aList.erase( it );
124 : : }
125 : : }
126 : : else // If the list is empty, the timer can be stopped
127 : 4 : aTimer.Stop();
128 : 8 : return sal_True;
129 : : }
130 : :
131 : 240 : void SwBlink::Insert( const Point& rPoint, const SwLinePortion* pPor,
132 : : const SwTxtFrm *pTxtFrm, sal_uInt16 nDir )
133 : : {
134 [ + - ]: 240 : SwBlinkPortion *pBlinkPor = new SwBlinkPortion( pPor, nDir );
135 : :
136 [ + - ]: 240 : SwBlinkList::iterator it = aList.find( *pBlinkPor );
137 [ + - ][ + - ]: 240 : if( it != aList.end() )
[ + + ]
138 : : {
139 [ + - ]: 16 : (*it).SetPos( rPoint );
140 : 16 : delete pBlinkPor;
141 : : }
142 : : else
143 : : {
144 : 224 : pBlinkPor->SetPos( rPoint );
145 : 224 : pBlinkPor->SetRootFrm( pTxtFrm->getRootFrm() );
146 [ + - ]: 224 : aList.insert( pBlinkPor );
147 : 224 : pTxtFrm->SetBlinkPor();
148 [ + + ][ + + ]: 224 : if( pPor->IsLayPortion() || pPor->IsParaPortion() )
[ + - ]
149 : 12 : ((SwLineLayout*)pPor)->SetBlinking( sal_True );
150 : :
151 [ + + ]: 224 : if( !aTimer.IsActive() )
152 [ + - ]: 4 : aTimer.Start();
153 : : }
154 : 240 : }
155 : :
156 : 0 : void SwBlink::Replace( const SwLinePortion* pOld, const SwLinePortion* pNew )
157 : : {
158 : : // setting direction to 0 because direction does not matter
159 : : // for this operation
160 : 0 : SwBlinkPortion aBlink( pOld, 0 );
161 [ # # ]: 0 : SwBlinkList::iterator it = aList.find( aBlink );
162 [ # # ][ # # ]: 0 : if( it != aList.end() )
[ # # ]
163 : : {
164 [ # # ][ # # ]: 0 : SwBlinkPortion* aTmp = new SwBlinkPortion( &*it, pNew );
165 [ # # ]: 0 : aList.erase( it );
166 [ # # ]: 0 : aList.insert( aTmp );
167 : : }
168 : 0 : }
169 : :
170 : 4410 : void SwBlink::Delete( const SwLinePortion* pPor )
171 : : {
172 : : // setting direction to 0 because direction does not matter
173 : : // for this operation
174 : 4410 : SwBlinkPortion aBlink( pPor, 0 );
175 [ + - ]: 4410 : aList.erase( aBlink );
176 : 4410 : }
177 : :
178 : 74 : void SwBlink::FrmDelete( const SwRootFrm* pRoot )
179 : : {
180 [ + - ][ + - ]: 74 : for( SwBlinkList::iterator it = aList.begin(); it != aList.end(); )
[ + - ][ - + ]
181 : : {
182 [ # # ][ # # ]: 0 : if( pRoot == (*it).GetRootFrm() )
183 [ # # ]: 0 : aList.erase( it );
184 : : else
185 [ # # ]: 0 : ++it;
186 : : }
187 : 74 : }
188 : :
189 : :
190 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|