LCOV - code coverage report
Current view: top level - sw/source/core/text - txtpaint.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 37 70.3 %
Date: 2012-08-25 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 33 88 37.5 %

           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 "txtpaint.hxx"
      31                 :            : #include "swrect.hxx"
      32                 :            : #include "rootfrm.hxx"
      33                 :            : 
      34                 :            : /*************************************************************************
      35                 :            :  *                      SwSaveClip::Reset()
      36                 :            :  *************************************************************************/
      37                 :            : 
      38                 :      14019 : void SwSaveClip::Reset()
      39                 :            : {
      40                 :            :     // We recover the old state
      41 [ +  + ][ +  + ]:      14019 :     if( pOut && bChg )
      42                 :            :     {
      43         [ -  + ]:       9175 :         if ( pOut->GetConnectMetaFile() )
      44                 :          0 :             pOut->Pop();
      45                 :            :         else
      46                 :            :         {
      47         [ -  + ]:       9175 :             if( bOn )
      48                 :          0 :                 pOut->SetClipRegion( aClip );
      49                 :            :             else
      50                 :       9175 :                 pOut->SetClipRegion();
      51                 :            :         }
      52                 :       9175 :         bChg = sal_False;
      53                 :            :     }
      54                 :      14019 : }
      55                 :            : 
      56                 :            : /*************************************************************************
      57                 :            :  *                      SwSaveClip::_ChgClip()
      58                 :            :  *************************************************************************/
      59                 :            : 
      60                 :       9175 : void SwSaveClip::_ChgClip( const SwRect &rRect, const SwTxtFrm* pFrm,
      61                 :            :                            sal_Bool bEnlargeRect )
      62                 :            : {
      63                 :       9175 :     SwRect aOldRect( rRect );
      64 [ +  - ][ -  + ]:       9175 :     const sal_Bool bVertical = pFrm && pFrm->IsVertical();
                 [ +  - ]
      65                 :            : 
      66 [ +  - ][ +  - ]:       9175 :     if ( pFrm && pFrm->IsRightToLeft() )
         [ -  + ][ -  + ]
      67         [ #  # ]:          0 :         pFrm->SwitchLTRtoRTL( (SwRect&)rRect );
      68                 :            : 
      69         [ -  + ]:       9175 :     if ( bVertical )
      70         [ #  # ]:          0 :         pFrm->SwitchHorizontalToVertical( (SwRect&)rRect );
      71                 :            : 
      72 [ +  - ][ +  - ]:       9175 :     if ( !pOut || (!rRect.HasArea() && !pOut->IsClipRegion()) )
         [ -  + ][ #  # ]
                 [ -  + ]
      73                 :            :     {
      74                 :          0 :         (SwRect&)rRect = aOldRect;
      75                 :            :         return;
      76                 :            :     }
      77                 :            : 
      78         [ +  - ]:       9175 :     if ( !bChg )
      79                 :            :     {
      80         [ -  + ]:       9175 :         if ( pOut->GetConnectMetaFile() )
      81         [ #  # ]:          0 :             pOut->Push();
      82         [ -  + ]:       9175 :         else if ( bOn )
      83 [ #  # ][ #  # ]:          0 :             aClip = pOut->GetClipRegion();
                 [ #  # ]
      84                 :            :     }
      85                 :            : 
      86 [ +  - ][ -  + ]:       9175 :     if ( !rRect.HasArea() )
      87         [ #  # ]:          0 :         pOut->SetClipRegion();
      88                 :            :     else
      89                 :            :     {
      90         [ +  - ]:       9175 :         Rectangle aRect( rRect.SVRect() );
      91                 :            : 
      92                 :            :         // Having underscores in our line, we enlarged the repaint area
      93                 :            :         // (see frmform.cxx) because for some fonts it could be too small.
      94                 :            :         // Consequently, we have to enlarge the clipping rectangle as well.
      95 [ +  + ][ +  - ]:       9175 :         if ( bEnlargeRect && ! bVertical )
      96                 :         11 :             aRect.Bottom() += 40;
      97                 :            : 
      98                 :            :         // If the ClipRect is identical, nothing will happen
      99         [ -  + ]:       9175 :         if( pOut->IsClipRegion() ) // no && because of Mac
     100                 :            :         {
     101 [ #  # ][ #  # ]:          0 :             if ( aRect == pOut->GetClipRegion().GetBoundRect() )
         [ #  # ][ #  # ]
                 [ #  # ]
     102                 :            :             {
     103                 :          0 :                 (SwRect&)rRect = aOldRect;
     104                 :            :                 return;
     105                 :            :             }
     106                 :            :         }
     107                 :            : 
     108 [ +  - ][ -  + ]:       9175 :         if( SwRootFrm::HasSameRect( rRect ) )
     109         [ #  # ]:          0 :             pOut->SetClipRegion();
     110                 :            :         else
     111                 :            :         {
     112         [ +  - ]:       9175 :             const Region aClipRegion( aRect );
     113 [ +  - ][ +  - ]:       9175 :             pOut->SetClipRegion( aClipRegion );
     114                 :            :         }
     115                 :            : #ifdef DBG_UTIL
     116                 :            :         static sal_Bool bDbg = sal_False;
     117                 :            :         if( bDbg )
     118                 :            :         {
     119                 :            :             DbgBackColor aDbg( pOut, bDbg, COL_RED );
     120                 :            :             pOut->DrawRect( aRect );
     121                 :            :         }
     122                 :            : #endif
     123                 :            :     }
     124                 :       9175 :     bChg = sal_True;
     125                 :            : 
     126                 :       9175 :     (SwRect&)rRect = aOldRect;
     127                 :            : }
     128                 :            : 
     129                 :            : 
     130                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10