LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/text - txtpaint.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 40 70.0 %
Date: 2013-07-09 Functions: 4 4 100.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 "txtpaint.hxx"
      22             : #include "swrect.hxx"
      23             : #include "rootfrm.hxx"
      24             : 
      25             : /*************************************************************************
      26             :  *                      SwSaveClip::Reset()
      27             :  *************************************************************************/
      28             : 
      29        6695 : void SwSaveClip::Reset()
      30             : {
      31             :     // We recover the old state
      32        6695 :     if( pOut && bChg )
      33             :     {
      34        4314 :         if ( pOut->GetConnectMetaFile() )
      35           0 :             pOut->Pop();
      36             :         else
      37             :         {
      38        4314 :             if( bOn )
      39           0 :                 pOut->SetClipRegion( aClip );
      40             :             else
      41        4314 :                 pOut->SetClipRegion();
      42             :         }
      43        4314 :         bChg = sal_False;
      44             :     }
      45        6695 : }
      46             : 
      47             : /*************************************************************************
      48             :  *                      SwSaveClip::_ChgClip()
      49             :  *************************************************************************/
      50             : 
      51        4317 : void SwSaveClip::_ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm,
      52             :                            sal_Bool bEnlargeRect )
      53             : {
      54        4317 :     SwRect aOldRect( rRect );
      55        4317 :     const sal_Bool bVertical = pFrm && pFrm->IsVertical();
      56             : 
      57        4317 :     if ( pFrm && pFrm->IsRightToLeft() )
      58           0 :         pFrm->SwitchLTRtoRTL( (SwRect&)rRect );
      59             : 
      60        4317 :     if ( bVertical )
      61           0 :         pFrm->SwitchHorizontalToVertical( (SwRect&)rRect );
      62             : 
      63        4317 :     if ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
      64             :     {
      65           0 :         (SwRect&)rRect = aOldRect;
      66           0 :         return;
      67             :     }
      68             : 
      69        4317 :     if ( !bChg )
      70             :     {
      71        4314 :         if ( pOut->GetConnectMetaFile() )
      72           0 :             pOut->Push();
      73        4314 :         else if ( bOn )
      74           0 :             aClip = pOut->GetClipRegion();
      75             :     }
      76             : 
      77        4317 :     if ( !rRect.HasArea() )
      78           0 :         pOut->SetClipRegion();
      79             :     else
      80             :     {
      81        4317 :         Rectangle aRect( rRect.SVRect() );
      82             : 
      83             :         // Having underscores in our line, we enlarged the repaint area
      84             :         // (see frmform.cxx) because for some fonts it could be too small.
      85             :         // Consequently, we have to enlarge the clipping rectangle as well.
      86        4317 :         if ( bEnlargeRect && ! bVertical )
      87           5 :             aRect.Bottom() += 40;
      88             : 
      89             :         // If the ClipRect is identical, nothing will happen
      90        4317 :         if( pOut->IsClipRegion() ) // no && because of Mac
      91             :         {
      92           3 :             if ( aRect == pOut->GetClipRegion().GetBoundRect() )
      93             :             {
      94           0 :                 (SwRect&)rRect = aOldRect;
      95           0 :                 return;
      96             :             }
      97             :         }
      98             : 
      99        4317 :         if( SwRootFrm::HasSameRect( rRect ) )
     100           0 :             pOut->SetClipRegion();
     101             :         else
     102             :         {
     103        4317 :             const Region aClipRegion( aRect );
     104        4317 :             pOut->SetClipRegion( aClipRegion );
     105             :         }
     106             : #ifdef DBG_UTIL
     107             :         static sal_Bool bDbg = sal_False;
     108             :         if( bDbg )
     109             :         {
     110             :             DbgBackColor aDbg( pOut, bDbg, COL_RED );
     111             :             pOut->DrawRect( aRect );
     112             :         }
     113             : #endif
     114             :     }
     115        4317 :     bChg = sal_True;
     116             : 
     117        4317 :     (SwRect&)rRect = aOldRect;
     118          99 : }
     119             : 
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10