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

Generated by: LCOV version 1.10