LCOV - code coverage report
Current view: top level - sw/source/core/layout - softpagebreak.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 24 59 40.7 %
Date: 2014-11-03 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             : #include "txtfrm.hxx"
      21             : #include "pagefrm.hxx"
      22             : #include "swtable.hxx"
      23             : #include "frmfmt.hxx"
      24             : #include "rowfrm.hxx"
      25             : #include "tabfrm.hxx"
      26             : #include "switerator.hxx"
      27             : 
      28        1584 : void SwTxtNode::fillSoftPageBreakList( SwSoftPageBreakList& rBreak ) const
      29             : {
      30        1584 :     SwIterator<SwTxtFrm,SwTxtNode> aIter( *this );
      31        3030 :     for( const SwTxtFrm *pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
      32             :     {
      33             :         // No soft page break in header or footer
      34        1584 :         if( pFrm->FindFooterOrHeader() || pFrm->IsInFly() )
      35        1722 :             return;
      36             :         // No soft page break if I'm not the first frame in my layout frame
      37        1446 :         if( pFrm->GetIndPrev() )
      38         842 :             continue;
      39         604 :         const SwPageFrm* pPage = pFrm->FindPageFrm();
      40             :         // No soft page break at the first page
      41         604 :         if( pPage && pPage->GetPrev() )
      42             :         {
      43          26 :             const SwCntntFrm* pFirst2 = pPage->FindFirstBodyCntnt();
      44             :             // Special handling for content frame in table frames
      45          26 :             if( pFrm->IsInTab() )
      46             :             {
      47             :                 // No soft page break if I'm in a table but the first content frame
      48             :                 // at my page is not in a table
      49           0 :                 if( !pFirst2 || !pFirst2->IsInTab() )
      50           0 :                     continue;
      51           0 :                 const SwLayoutFrm *pRow = pFrm->GetUpper();
      52             :                 // Looking for the "most upper" row frame,
      53             :                 // skipping sub tables and/or table in table
      54           0 :                 while( !pRow->IsRowFrm() || !pRow->GetUpper()->IsTabFrm() ||
      55           0 :                     pRow->GetUpper()->GetUpper()->IsInTab() )
      56           0 :                     pRow = pRow->GetUpper();
      57           0 :                 const SwTabFrm *pTab = pRow->FindTabFrm();
      58             :                 // For master tables the soft page break will exported at the table row,
      59             :                 // not at the content frame.
      60             :                 // If the first content is outside my table frame, no soft page break.
      61           0 :                 if( !pTab->IsFollow() || !pTab->IsAnLower( pFirst2 ) )
      62           0 :                     continue;
      63             :                 // Only content of non-heading-rows can get a soft page break
      64           0 :                 const SwFrm* pFirstRow = pTab->GetFirstNonHeadlineRow();
      65             :                 // If there's no follow flow line, the soft page break will be
      66             :                 // exported at the row, not at the content.
      67           0 :                 if( pRow == pFirstRow &&
      68           0 :                     pTab->FindMaster( false )->HasFollowFlowLine() )
      69             :                 {
      70             :                     // Now we have the row which causes a new page,
      71             :                     // this row is a follow flow line and therefore cannot get
      72             :                     // the soft page break itself.
      73             :                     // Every first content frame of every cell frane in this row
      74             :                     // will get the soft page break
      75           0 :                     const SwFrm* pCell = pRow->Lower();
      76           0 :                     while( pCell )
      77             :                     {
      78           0 :                         pFirst2 = static_cast<const SwLayoutFrm*>(pCell)->ContainsCntnt();
      79           0 :                         if( pFirst2 == pFrm )
      80             :                         {   // Here we are: a first content inside a cell
      81             :                             // inside the splitted row => soft page break
      82           0 :                             rBreak.insert( pFrm->GetOfst() );
      83           0 :                             break;
      84             :                         }
      85           0 :                         pCell = pCell->GetNext();
      86             :                     }
      87             :                 }
      88             :             }
      89             :             else // No soft page break if there's a "hard" page break attribute
      90          26 :             if( pFirst2 == pFrm && !pFrm->IsPageBreak( true ) )
      91          12 :                 rBreak.insert( pFrm->GetOfst() );
      92             :         }
      93        1446 :     }
      94             : }
      95             : 
      96           4 : bool SwTableLine::hasSoftPageBreak() const
      97             : {
      98             :     // No soft page break for sub tables
      99           4 :     if( GetUpper() || !GetFrmFmt() )
     100           0 :         return false;
     101           4 :     SwIterator<SwRowFrm,SwFmt> aIter( *GetFrmFmt() );
     102           4 :     for( SwRowFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
     103             :     {
     104           4 :         if( pLast->GetTabLine() == this )
     105             :         {
     106           4 :             const SwTabFrm* pTab = pLast->FindTabFrm();
     107             :             // No soft page break for
     108             :             //   tables with prevs, i.e. if the frame is not the first in its layout frame
     109             :             //   tables in footer or header
     110             :             //   tables in flies
     111             :             //   inner tables of nested tables
     112             :             //   master table frames with "hard" page break attribute
     113          12 :             if( pTab->GetIndPrev() || pTab->FindFooterOrHeader()
     114          12 :                 || pTab->IsInFly() || pTab->GetUpper()->IsInTab() ||
     115           0 :                 ( !pTab->IsFollow() && pTab->IsPageBreak( true ) ) )
     116           4 :                 return false;
     117           0 :             const SwPageFrm* pPage = pTab->FindPageFrm();
     118             :             // No soft page break at the first page of the document
     119           0 :             if( pPage && !pPage->GetPrev() )
     120           0 :                 return false;
     121           0 :             const SwCntntFrm* pFirst = pPage ? pPage->FindFirstBodyCntnt() : NULL;
     122             :             // No soft page break for
     123             :             //   tables which does not contain the first body content of the page
     124           0 :             if( !pFirst || !pTab->IsAnLower( pFirst->FindTabFrm() ) )
     125           0 :                 return false;
     126             :             // The row which could get a soft page break must be either the first
     127             :             // row of a master table frame or the first "non-headline-row" of a
     128             :             // follow table frame...
     129           0 :             const SwFrm* pRow = pTab->IsFollow() ?
     130           0 :                 pTab->GetFirstNonHeadlineRow() : pTab->Lower();
     131           0 :             if( pRow == pLast )
     132             :             {
     133             :                 // The last check: no soft page break for "follow" table lines
     134           0 :                 if( pTab->IsFollow() && pTab->FindMaster( false )->HasFollowFlowLine() )
     135           0 :                     return false;
     136           0 :                 return true;
     137             :             }
     138           0 :             return false;
     139             :         }
     140             :     }
     141           0 :     return false;
     142         270 : }
     143             : 
     144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10