LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/text - blink.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 80 0.0 %
Date: 2012-12-27 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10