LCOV - code coverage report
Current view: top level - sw/source/core/objectpositioning - environmentofanchoredobject.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 28 28 100.0 %
Date: 2015-06-13 12:38:46 Functions: 6 6 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             : #include <environmentofanchoredobject.hxx>
      21             : #include <frame.hxx>
      22             : #include <pagefrm.hxx>
      23             : #include <flyfrm.hxx>
      24             : 
      25             : using namespace objectpositioning;
      26             : 
      27        4587 : SwEnvironmentOfAnchoredObject::SwEnvironmentOfAnchoredObject(
      28             :                                                 const bool   _bFollowTextFlow )
      29        4587 :     : mbFollowTextFlow( _bFollowTextFlow )
      30        4587 : {}
      31             : 
      32        4587 : SwEnvironmentOfAnchoredObject::~SwEnvironmentOfAnchoredObject()
      33        4587 : {}
      34             : 
      35             : /** determine environment layout frame for possible horizontal object positions */
      36        9174 : const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(
      37             :                                             const SwFrm& _rHoriOrientFrm ) const
      38             : {
      39        9174 :     const SwFrm* pHoriEnvironmentLayFrm = &_rHoriOrientFrm;
      40             : 
      41        9174 :     if ( !mbFollowTextFlow )
      42             :     {
      43             :         // No exception any more for page alignment.
      44             :         // the page frame determines the horizontal layout environment.
      45        8996 :         pHoriEnvironmentLayFrm = _rHoriOrientFrm.FindPageFrm();
      46             :     }
      47             :     else
      48             :     {
      49        1744 :         while ( !pHoriEnvironmentLayFrm->IsCellFrm() &&
      50        1042 :                 !pHoriEnvironmentLayFrm->IsFlyFrm() &&
      51         518 :                 !pHoriEnvironmentLayFrm->IsPageFrm() )
      52             :         {
      53         346 :             pHoriEnvironmentLayFrm = pHoriEnvironmentLayFrm->GetUpper();
      54             :             OSL_ENSURE( pHoriEnvironmentLayFrm,
      55             :                     "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - no page|fly|cell frame found" );
      56             :         }
      57             :     }
      58             : 
      59             :     OSL_ENSURE( pHoriEnvironmentLayFrm->ISA(SwLayoutFrm),
      60             :                 "SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
      61             : 
      62        9174 :     return static_cast<const SwLayoutFrm&>(*pHoriEnvironmentLayFrm);
      63             : }
      64             : 
      65             : /** determine environment layout frame for possible vertical object positions */
      66        9174 : const SwLayoutFrm& SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(
      67             :                                             const SwFrm& _rVertOrientFrm ) const
      68             : {
      69        9174 :     const SwFrm* pVertEnvironmentLayFrm = &_rVertOrientFrm;
      70             : 
      71        9174 :     if ( !mbFollowTextFlow )
      72             :     {
      73             :         // No exception any more for page alignment.
      74             :         // the page frame determines the vertical layout environment.
      75        8996 :         pVertEnvironmentLayFrm = _rVertOrientFrm.FindPageFrm();
      76             :     }
      77             :     else
      78             :     {
      79         973 :         while ( !pVertEnvironmentLayFrm->IsCellFrm() &&
      80         522 :                 !pVertEnvironmentLayFrm->IsFlyFrm() &&
      81         480 :                 !pVertEnvironmentLayFrm->IsHeaderFrm() &&
      82         438 :                 !pVertEnvironmentLayFrm->IsFooterFrm() &&
      83         438 :                 !pVertEnvironmentLayFrm->IsFootnoteFrm() &&
      84         575 :                 !pVertEnvironmentLayFrm->IsPageBodyFrm() &&
      85          89 :                 !pVertEnvironmentLayFrm->IsPageFrm() )
      86             :         {
      87          89 :             pVertEnvironmentLayFrm = pVertEnvironmentLayFrm->GetUpper();
      88             :             OSL_ENSURE( pVertEnvironmentLayFrm,
      89             :                     "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - proposed frame not found" );
      90             :         }
      91             :     }
      92             : 
      93             :     OSL_ENSURE( pVertEnvironmentLayFrm->ISA(SwLayoutFrm),
      94             :                 "SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrm(..) - found frame isn't a layout frame" );
      95             : 
      96        9174 :     return static_cast<const SwLayoutFrm&>(*pVertEnvironmentLayFrm);
      97         177 : }
      98             : 
      99             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11