1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10*efeef26fSAndrew Rist *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19*efeef26fSAndrew Rist *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include "viewsh.hxx"
30cdf0e10cSrcweir #include "rootfrm.hxx" // GetOleShell()
31cdf0e10cSrcweir #include "txtfrm.hxx" // FindRootFrm()
32cdf0e10cSrcweir #include "blink.hxx"
33cdf0e10cSrcweir #include "porlin.hxx"
34cdf0e10cSrcweir #include "porlay.hxx" // SwLineLayout
35cdf0e10cSrcweir
36cdf0e10cSrcweir // Sichtbare Zeit:
37cdf0e10cSrcweir #define BLINK_ON_TIME 2400L
38cdf0e10cSrcweir // Nihct sichtbare Zeit:
39cdf0e10cSrcweir #define BLINK_OFF_TIME 800L
40cdf0e10cSrcweir
41cdf0e10cSrcweir /*************************************************************************
42cdf0e10cSrcweir * pBlink zeigt auf die Instanz, bei der sich blinkende Portions anmelden
43cdf0e10cSrcweir * muessen, ggf. muss pBlink erst per new SwBlink angelegt werden.
44cdf0e10cSrcweir * Diese werden dann rhythmisch zum Repaint angeregt und koennen abfragen,
45cdf0e10cSrcweir * ob sie zur Zeit sichtbar oder unsichtbar sein sollen ( IsVisible() ).
46cdf0e10cSrcweir *************************************************************************/
47cdf0e10cSrcweir SwBlink *pBlink = NULL;
48cdf0e10cSrcweir
49cdf0e10cSrcweir
50cdf0e10cSrcweir // Liste von blinkenden Portions
SV_IMPL_OP_PTRARR_SORT(SwBlinkList,SwBlinkPortionPtr)51cdf0e10cSrcweir SV_IMPL_OP_PTRARR_SORT( SwBlinkList, SwBlinkPortionPtr )
52cdf0e10cSrcweir
53cdf0e10cSrcweir SwBlink::SwBlink()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir bVisible = sal_True;
56cdf0e10cSrcweir // Den Timer vorbereiten
57cdf0e10cSrcweir aTimer.SetTimeout( BLINK_ON_TIME );
58cdf0e10cSrcweir aTimer.SetTimeoutHdl( LINK(this, SwBlink, Blinker) );
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
~SwBlink()61cdf0e10cSrcweir SwBlink::~SwBlink( )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir aTimer.Stop();
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
66cdf0e10cSrcweir /*************************************************************************
67cdf0e10cSrcweir * SwBlink::Blinker (Timerablauf):
68cdf0e10cSrcweir * Sichtbar/unsichtbar-Flag toggeln.
69cdf0e10cSrcweir * Repaint-Rechtecke der Blinkportions ermitteln und an ihren OleShells
70cdf0e10cSrcweir * invalidieren.
71cdf0e10cSrcweir *************************************************************************/
72cdf0e10cSrcweir
IMPL_LINK(SwBlink,Blinker,Timer *,EMPTYARG)73cdf0e10cSrcweir IMPL_LINK( SwBlink, Blinker, Timer *, EMPTYARG )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir bVisible = !bVisible;
76cdf0e10cSrcweir if( bVisible )
77cdf0e10cSrcweir aTimer.SetTimeout( BLINK_ON_TIME );
78cdf0e10cSrcweir else
79cdf0e10cSrcweir aTimer.SetTimeout( BLINK_OFF_TIME );
80cdf0e10cSrcweir if( aList.Count() )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir
83cdf0e10cSrcweir for( MSHORT nPos = 0; nPos < aList.Count(); )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir const SwBlinkPortion* pTmp = aList[ nPos ];
86cdf0e10cSrcweir if( pTmp->GetRootFrm() &&
87cdf0e10cSrcweir ((SwRootFrm*)pTmp->GetRootFrm())->GetCurrShell() )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir ++nPos;
90cdf0e10cSrcweir
91cdf0e10cSrcweir Point aPos = pTmp->GetPos();
92cdf0e10cSrcweir long nWidth, nHeight;
93cdf0e10cSrcweir switch ( pTmp->GetDirection() )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir case 900:
96cdf0e10cSrcweir aPos.X() -= pTmp->GetPortion()->GetAscent();
97cdf0e10cSrcweir aPos.Y() -= pTmp->GetPortion()->Width();
98cdf0e10cSrcweir nWidth = pTmp->GetPortion()->SvLSize().Height();
99cdf0e10cSrcweir nHeight = pTmp->GetPortion()->SvLSize().Width();
100cdf0e10cSrcweir break;
101cdf0e10cSrcweir case 1800:
102cdf0e10cSrcweir aPos.Y() -= pTmp->GetPortion()->Height() -
103cdf0e10cSrcweir pTmp->GetPortion()->GetAscent();
104cdf0e10cSrcweir aPos.X() -= pTmp->GetPortion()->Width();
105cdf0e10cSrcweir nWidth = pTmp->GetPortion()->SvLSize().Width();
106cdf0e10cSrcweir nHeight = pTmp->GetPortion()->SvLSize().Height();
107cdf0e10cSrcweir break;
108cdf0e10cSrcweir case 2700:
109cdf0e10cSrcweir aPos.X() -= pTmp->GetPortion()->Height() -
110cdf0e10cSrcweir pTmp->GetPortion()->GetAscent();
111cdf0e10cSrcweir nWidth = pTmp->GetPortion()->SvLSize().Height();
112cdf0e10cSrcweir nHeight = pTmp->GetPortion()->SvLSize().Width();
113cdf0e10cSrcweir break;
114cdf0e10cSrcweir default:
115cdf0e10cSrcweir aPos.Y() -= pTmp->GetPortion()->GetAscent();
116cdf0e10cSrcweir nWidth = pTmp->GetPortion()->SvLSize().Width();
117cdf0e10cSrcweir nHeight = pTmp->GetPortion()->SvLSize().Height();
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir Rectangle aRefresh( aPos, Size( nWidth, nHeight ) );
121cdf0e10cSrcweir aRefresh.Right() += ( aRefresh.Bottom()- aRefresh.Top() ) / 8;
122cdf0e10cSrcweir ((SwRootFrm*)pTmp->GetRootFrm())
123cdf0e10cSrcweir ->GetCurrShell()->InvalidateWindows( aRefresh );
124cdf0e10cSrcweir }
125cdf0e10cSrcweir else // Portions ohne Shell koennen aus der Liste entfernt werden.
126cdf0e10cSrcweir aList.Remove( nPos );
127cdf0e10cSrcweir }
128cdf0e10cSrcweir }
129cdf0e10cSrcweir else // Wenn die Liste leer ist, kann der Timer gestoppt werden.
130cdf0e10cSrcweir aTimer.Stop();
131cdf0e10cSrcweir return sal_True;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
Insert(const Point & rPoint,const SwLinePortion * pPor,const SwTxtFrm * pTxtFrm,sal_uInt16 nDir)134cdf0e10cSrcweir void SwBlink::Insert( const Point& rPoint, const SwLinePortion* pPor,
135cdf0e10cSrcweir const SwTxtFrm *pTxtFrm, sal_uInt16 nDir )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir SwBlinkPortion *pBlinkPor = new SwBlinkPortion( pPor, nDir );
138cdf0e10cSrcweir
139cdf0e10cSrcweir MSHORT nPos;
140cdf0e10cSrcweir if( aList.Seek_Entry( pBlinkPor, &nPos ) )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir aList[ nPos ]->SetPos( rPoint );
143cdf0e10cSrcweir delete pBlinkPor;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir else
146cdf0e10cSrcweir {
147cdf0e10cSrcweir pBlinkPor->SetPos( rPoint );
148cdf0e10cSrcweir pBlinkPor->SetRootFrm( pTxtFrm->getRootFrm() );
149cdf0e10cSrcweir aList.Insert( pBlinkPor );
150cdf0e10cSrcweir pTxtFrm->SetBlinkPor();
151cdf0e10cSrcweir if( pPor->IsLayPortion() || pPor->IsParaPortion() )
152cdf0e10cSrcweir ((SwLineLayout*)pPor)->SetBlinking( sal_True );
153cdf0e10cSrcweir
154cdf0e10cSrcweir if( !aTimer.IsActive() )
155cdf0e10cSrcweir aTimer.Start();
156cdf0e10cSrcweir }
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
Replace(const SwLinePortion * pOld,const SwLinePortion * pNew)159cdf0e10cSrcweir void SwBlink::Replace( const SwLinePortion* pOld, const SwLinePortion* pNew )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir // setting direction to 0 because direction does not matter
162cdf0e10cSrcweir // for this operation
163cdf0e10cSrcweir SwBlinkPortion aBlink( pOld, 0 );
164cdf0e10cSrcweir MSHORT nPos;
165cdf0e10cSrcweir if( aList.Seek_Entry( &aBlink, &nPos ) )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir SwBlinkPortion* pTmp = new SwBlinkPortion( aList[ nPos ], pNew );
168cdf0e10cSrcweir aList.Remove( nPos );
169cdf0e10cSrcweir aList.Insert( pTmp );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
Delete(const SwLinePortion * pPor)173cdf0e10cSrcweir void SwBlink::Delete( const SwLinePortion* pPor )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir // setting direction to 0 because direction does not matter
176cdf0e10cSrcweir // for this operation
177cdf0e10cSrcweir SwBlinkPortion aBlink( pPor, 0 );
178cdf0e10cSrcweir MSHORT nPos;
179cdf0e10cSrcweir if( aList.Seek_Entry( &aBlink, &nPos ) )
180cdf0e10cSrcweir aList.Remove( nPos );
181cdf0e10cSrcweir }
182cdf0e10cSrcweir
FrmDelete(const SwRootFrm * pRoot)183cdf0e10cSrcweir void SwBlink::FrmDelete( const SwRootFrm* pRoot )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir for( MSHORT nPos = 0; nPos < aList.Count(); )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir if( pRoot == aList[ nPos ]->GetRootFrm() )
188cdf0e10cSrcweir aList.Remove( nPos );
189cdf0e10cSrcweir else
190cdf0e10cSrcweir ++nPos;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir }
193cdf0e10cSrcweir
194cdf0e10cSrcweir
195