LCOV - code coverage report
Current view: top level - sw/source/core/objectpositioning - environmentofanchoredobject.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 27 55.6 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 28 7.1 %

           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                 :            : #ifndef _ENVIRONMENTOFANCHOREDOBJECT
      30                 :            : #include <environmentofanchoredobject.hxx>
      31                 :            : #endif
      32                 :            : #include <frame.hxx>
      33                 :            : #include <pagefrm.hxx>
      34                 :            : #include <flyfrm.hxx>
      35                 :            : 
      36                 :            : using namespace objectpositioning;
      37                 :            : 
      38                 :        339 : SwEnvironmentOfAnchoredObject::SwEnvironmentOfAnchoredObject(
      39                 :            :                                                 const bool   _bFollowTextFlow )
      40                 :        339 :     : mbFollowTextFlow( _bFollowTextFlow )
      41                 :        339 : {}
      42                 :            : 
      43                 :        339 : SwEnvironmentOfAnchoredObject::~SwEnvironmentOfAnchoredObject()
      44                 :        339 : {}
      45                 :            : 
      46                 :            : /** determine environment layout frame for possible horizontal object positions
      47                 :            : 
      48                 :            :     @author OD
      49                 :            : */
      50                 :        630 : const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(
      51                 :            :                                             const SwFrm& _rHoriOrientFrm ) const
      52                 :            : {
      53                 :        630 :     const SwFrm* pHoriEnvironmentLayFrm = &_rHoriOrientFrm;
      54                 :            : 
      55         [ +  - ]:        630 :     if ( !mbFollowTextFlow )
      56                 :            :     {
      57                 :            :         // No exception any more for page alignment.
      58                 :            :         // the page frame determines the horizontal layout environment.
      59                 :        630 :         pHoriEnvironmentLayFrm = _rHoriOrientFrm.FindPageFrm();
      60                 :            :     }
      61                 :            :     else
      62                 :            :     {
      63   [ #  #  #  #  :          0 :         while ( !pHoriEnvironmentLayFrm->IsCellFrm() &&
           #  # ][ #  # ]
      64                 :          0 :                 !pHoriEnvironmentLayFrm->IsFlyFrm() &&
      65                 :          0 :                 !pHoriEnvironmentLayFrm->IsPageFrm() )
      66                 :            :         {
      67                 :          0 :             pHoriEnvironmentLayFrm = pHoriEnvironmentLayFrm->GetUpper();
      68                 :            :             OSL_ENSURE( pHoriEnvironmentLayFrm,
      69                 :            :                     "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - no page|fly|cell frame found" );
      70                 :            :         }
      71                 :            :     }
      72                 :            : 
      73                 :            :     OSL_ENSURE( pHoriEnvironmentLayFrm->ISA(SwLayoutFrm),
      74                 :            :                 "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
      75                 :            : 
      76                 :        630 :     return static_cast<const SwLayoutFrm&>(*pHoriEnvironmentLayFrm);
      77                 :            : }
      78                 :            : 
      79                 :            : /** determine environment layout frame for possible vertical object positions
      80                 :            : */
      81                 :        630 : const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(
      82                 :            :                                             const SwFrm& _rVertOrientFrm ) const
      83                 :            : {
      84                 :        630 :     const SwFrm* pVertEnvironmentLayFrm = &_rVertOrientFrm;
      85                 :            : 
      86         [ +  - ]:        630 :     if ( !mbFollowTextFlow )
      87                 :            :     {
      88                 :            :         // No exception any more for page alignment.
      89                 :            :         // the page frame determines the vertical layout environment.
      90                 :        630 :         pVertEnvironmentLayFrm = _rVertOrientFrm.FindPageFrm();
      91                 :            :     }
      92                 :            :     else
      93                 :            :     {
      94   [ #  #  #  #  :          0 :         while ( !pVertEnvironmentLayFrm->IsCellFrm() &&
          #  #  #  #  #  
             #  #  #  #  
              # ][ #  # ]
      95                 :          0 :                 !pVertEnvironmentLayFrm->IsFlyFrm() &&
      96                 :          0 :                 !pVertEnvironmentLayFrm->IsHeaderFrm() &&
      97                 :          0 :                 !pVertEnvironmentLayFrm->IsFooterFrm() &&
      98                 :          0 :                 !pVertEnvironmentLayFrm->IsFtnFrm() &&
      99                 :          0 :                 !pVertEnvironmentLayFrm->IsPageBodyFrm() &&
     100                 :          0 :                 !pVertEnvironmentLayFrm->IsPageFrm() )
     101                 :            :         {
     102                 :          0 :             pVertEnvironmentLayFrm = pVertEnvironmentLayFrm->GetUpper();
     103                 :            :             OSL_ENSURE( pVertEnvironmentLayFrm,
     104                 :            :                     "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - proposed frame not found" );
     105                 :            :         }
     106                 :            :     }
     107                 :            : 
     108                 :            :     OSL_ENSURE( pVertEnvironmentLayFrm->ISA(SwLayoutFrm),
     109                 :            :                 "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
     110                 :            : 
     111                 :        630 :     return static_cast<const SwLayoutFrm&>(*pVertEnvironmentLayFrm);
     112                 :            : }
     113                 :            : 
     114                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10