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