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

Generated by: LCOV version 1.10