LCOV - code coverage report
Current view: top level - sw/source/core/layout - objectformatterlayfrm.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 55 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 <objectformatterlayfrm.hxx>
      21             : #include <anchoredobject.hxx>
      22             : #include <sortedobjs.hxx>
      23             : #include <pagefrm.hxx>
      24             : 
      25             : // #124218#
      26             : #include <layact.hxx>
      27             : 
      28           0 : SwObjectFormatterLayFrm::SwObjectFormatterLayFrm( SwLayoutFrm& _rAnchorLayFrm,
      29             :                                                   const SwPageFrm& _rPageFrm,
      30             :                                                   SwLayAction* _pLayAction )
      31             :     : SwObjectFormatter( _rPageFrm, _pLayAction ),
      32           0 :       mrAnchorLayFrm( _rAnchorLayFrm )
      33             : {
      34           0 : }
      35             : 
      36           0 : SwObjectFormatterLayFrm::~SwObjectFormatterLayFrm()
      37             : {
      38           0 : }
      39             : 
      40           0 : SwObjectFormatterLayFrm* SwObjectFormatterLayFrm::CreateObjFormatter(
      41             :                                                 SwLayoutFrm& _rAnchorLayFrm,
      42             :                                                 const SwPageFrm& _rPageFrm,
      43             :                                                 SwLayAction* _pLayAction )
      44             : {
      45           0 :     if ( !_rAnchorLayFrm.IsPageFrm() &&
      46           0 :          !_rAnchorLayFrm.IsFlyFrm() )
      47             :     {
      48             :         OSL_FAIL( "<SwObjectFormatterLayFrm::CreateObjFormatter(..)> - unexcepted type of anchor frame " );
      49           0 :         return 0L;
      50             :     }
      51             : 
      52           0 :     SwObjectFormatterLayFrm* pObjFormatter = 0L;
      53             : 
      54             :     // create object formatter, if floating screen objects are registered at
      55             :     // given anchor layout frame.
      56           0 :     if ( _rAnchorLayFrm.GetDrawObjs() ||
      57           0 :          ( _rAnchorLayFrm.IsPageFrm() &&
      58           0 :             static_cast<SwPageFrm&>(_rAnchorLayFrm).GetSortedObjs() ) )
      59             :     {
      60             :         pObjFormatter =
      61           0 :             new SwObjectFormatterLayFrm( _rAnchorLayFrm, _rPageFrm, _pLayAction );
      62             :     }
      63             : 
      64           0 :     return pObjFormatter;
      65             : }
      66             : 
      67           0 : SwFrm& SwObjectFormatterLayFrm::GetAnchorFrm()
      68             : {
      69           0 :     return mrAnchorLayFrm;
      70             : }
      71             : 
      72             : // #i40147# - add parameter <_bCheckForMovedFwd>.
      73             : // Not relevant for objects anchored at layout frame.
      74           0 : bool SwObjectFormatterLayFrm::DoFormatObj( SwAnchoredObject& _rAnchoredObj,
      75             :                                            const bool )
      76             : {
      77           0 :     _FormatObj( _rAnchoredObj );
      78             : 
      79             :     // #124218# - consider that the layout action has to be
      80             :     // restarted due to a deleted page frame.
      81           0 :     return GetLayAction() ? !GetLayAction()->IsAgain() : true;
      82             : }
      83             : 
      84           0 : bool SwObjectFormatterLayFrm::DoFormatObjs()
      85             : {
      86           0 :     bool bSuccess( true );
      87             : 
      88           0 :     bSuccess = _FormatObjsAtFrm();
      89             : 
      90           0 :     if ( bSuccess && GetAnchorFrm().IsPageFrm() )
      91             :     {
      92             :         // anchor layout frame is a page frame.
      93             :         // Thus, format also all anchored objects, which are registered at
      94             :         // this page frame, whose 'anchor' isn't on this page frame and whose
      95             :         // anchor frame is valid.
      96           0 :         bSuccess = _AdditionalFormatObjsOnPage();
      97             :     }
      98             : 
      99           0 :     return bSuccess;
     100             : }
     101             : 
     102             : /** method to format all anchored objects, which are registered at
     103             :     the page frame, whose 'anchor' isn't on this page frame and whose
     104             :     anchor frame is valid.
     105             : 
     106             :     OD 2004-07-02 #i28701#
     107             : */
     108           0 : bool SwObjectFormatterLayFrm::_AdditionalFormatObjsOnPage()
     109             : {
     110           0 :     if ( !GetAnchorFrm().IsPageFrm() )
     111             :     {
     112             :         OSL_FAIL( "<SwObjectFormatterLayFrm::_AdditionalFormatObjsOnPage()> - mis-usage of method, call only for anchor frames of type page frame" );
     113           0 :         return true;
     114             :     }
     115             : 
     116             :     // #124218# - consider, if the layout action
     117             :     // has to be restarted due to a delete of a page frame.
     118           0 :     if ( GetLayAction() && GetLayAction()->IsAgain() )
     119             :     {
     120           0 :         return false;
     121             :     }
     122             : 
     123           0 :     SwPageFrm& rPageFrm = static_cast<SwPageFrm&>(GetAnchorFrm());
     124             : 
     125           0 :     if ( !rPageFrm.GetSortedObjs() )
     126             :     {
     127             :         // nothing to do, if no floating screen object is registered at the anchor frame.
     128           0 :         return true;
     129             :     }
     130             : 
     131           0 :     bool bSuccess( true );
     132             : 
     133           0 :     sal_uInt32 i = 0;
     134           0 :     for ( ; i < rPageFrm.GetSortedObjs()->Count(); ++i )
     135             :     {
     136           0 :         SwAnchoredObject* pAnchoredObj = (*rPageFrm.GetSortedObjs())[i];
     137             : 
     138             :         // #i51941# - do not format object, which are anchored
     139             :         // inside or at fly frame.
     140           0 :         if ( pAnchoredObj->GetAnchorFrm()->FindFlyFrm() )
     141             :         {
     142           0 :             continue;
     143             :         }
     144             :         // #i33751#, #i34060# - method <GetPageFrmOfAnchor()>
     145             :         // is replaced by method <FindPageFrmOfAnchor()>. It's return value
     146             :         // have to be checked.
     147           0 :         SwPageFrm* pPageFrmOfAnchor = pAnchoredObj->FindPageFrmOfAnchor();
     148             :         // #i26945# - check, if the page frame of the
     149             :         // object's anchor frame isn't the given page frame
     150             :         OSL_ENSURE( pPageFrmOfAnchor,
     151             :                 "<SwObjectFormatterLayFrm::_AdditionalFormatObjsOnPage()> - missing page frame" );
     152           0 :         if ( pPageFrmOfAnchor &&
     153             :              // #i35911#
     154           0 :              pPageFrmOfAnchor->GetPhyPageNum() < rPageFrm.GetPhyPageNum() )
     155             :         {
     156             :             // if format of object fails, stop formatting and pass fail to
     157             :             // calling method via the return value.
     158           0 :             if ( !DoFormatObj( *pAnchoredObj ) )
     159             :             {
     160           0 :                 bSuccess = false;
     161           0 :                 break;
     162             :             }
     163             : 
     164             :             // considering changes at <GetAnchorFrm().GetDrawObjs()> during
     165             :             // format of the object.
     166           0 :             if ( !rPageFrm.GetSortedObjs() ||
     167           0 :                  i > rPageFrm.GetSortedObjs()->Count() )
     168             :             {
     169           0 :                 break;
     170             :             }
     171             :             else
     172             :             {
     173             :                 sal_uInt32 nActPosOfObj =
     174           0 :                     rPageFrm.GetSortedObjs()->ListPosOf( *pAnchoredObj );
     175           0 :                 if ( nActPosOfObj == rPageFrm.GetSortedObjs()->Count() ||
     176             :                      nActPosOfObj > i )
     177             :                 {
     178           0 :                     --i;
     179             :                 }
     180           0 :                 else if ( nActPosOfObj < i )
     181             :                 {
     182           0 :                     i = nActPosOfObj;
     183             :                 }
     184             :             }
     185             :         }
     186             :     } // end of loop on <rPageFrm.GetSortedObjs()>
     187             : 
     188           0 :     return bSuccess;
     189             : }
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10