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 <calbck.hxx>
27 :
28 1949 : void SwTextNode::fillSoftPageBreakList( SwSoftPageBreakList& rBreak ) const
29 : {
30 1949 : SwIterator<SwTextFrm,SwTextNode> aIter( *this );
31 3707 : for( const SwTextFrm *pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
32 : {
33 : // No soft page break in header or footer
34 1936 : if( pFrm->FindFooterOrHeader() || pFrm->IsInFly() )
35 2127 : return;
36 : // No soft page break if I'm not the first frame in my layout frame
37 1758 : if( pFrm->GetIndPrev() )
38 919 : continue;
39 839 : const SwPageFrm* pPage = pFrm->FindPageFrm();
40 : // No soft page break at the first page
41 839 : if( pPage && pPage->GetPrev() )
42 : {
43 198 : const SwContentFrm* pFirst2 = pPage->FindFirstBodyContent();
44 : // Special handling for content frame in table frames
45 198 : 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 161 : if( !pFirst2 || !pFirst2->IsInTab() )
50 64 : continue;
51 97 : const SwLayoutFrm *pRow = pFrm->GetUpper();
52 : // Looking for the "most upper" row frame,
53 : // skipping sub tables and/or table in table
54 388 : while( !pRow->IsRowFrm() || !pRow->GetUpper()->IsTabFrm() ||
55 97 : pRow->GetUpper()->GetUpper()->IsInTab() )
56 97 : pRow = pRow->GetUpper();
57 97 : 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 97 : if( !pTab->IsFollow() || !pTab->IsAnLower( pFirst2 ) )
62 62 : continue;
63 : // Only content of non-heading-rows can get a soft page break
64 35 : 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 45 : if( pRow == pFirstRow &&
68 10 : 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 5 : const SwFrm* pCell = pRow->Lower();
76 12 : while( pCell )
77 : {
78 7 : pFirst2 = static_cast<const SwLayoutFrm*>(pCell)->ContainsContent();
79 7 : if( pFirst2 == pFrm )
80 : { // Here we are: a first content inside a cell
81 : // inside the splitted row => soft page break
82 5 : rBreak.insert( pFrm->GetOfst() );
83 5 : break;
84 : }
85 2 : pCell = pCell->GetNext();
86 : }
87 : }
88 : }
89 : else // No soft page break if there's a "hard" page break attribute
90 37 : if( pFirst2 == pFrm && !pFrm->IsPageBreak( true ) )
91 7 : rBreak.insert( pFrm->GetOfst() );
92 : }
93 1771 : }
94 : }
95 :
96 40 : bool SwTableLine::hasSoftPageBreak() const
97 : {
98 : // No soft page break for sub tables
99 40 : if( GetUpper() || !GetFrameFormat() )
100 0 : return false;
101 40 : SwIterator<SwRowFrm,SwFormat> aIter( *GetFrameFormat() );
102 40 : for( SwRowFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
103 : {
104 40 : if( pLast->GetTabLine() == this )
105 : {
106 40 : 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 92 : if( pTab->GetIndPrev() || pTab->FindFooterOrHeader()
114 92 : || pTab->IsInFly() || pTab->GetUpper()->IsInTab() ||
115 10 : ( !pTab->IsFollow() && pTab->IsPageBreak( true ) ) )
116 30 : return false;
117 10 : const SwPageFrm* pPage = pTab->FindPageFrm();
118 : // No soft page break at the first page of the document
119 10 : if( pPage && !pPage->GetPrev() )
120 0 : return false;
121 10 : const SwContentFrm* pFirst = pPage ? pPage->FindFirstBodyContent() : NULL;
122 : // No soft page break for
123 : // tables which does not contain the first body content of the page
124 10 : 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 10 : const SwFrm* pRow = pTab->IsFollow() ?
130 10 : pTab->GetFirstNonHeadlineRow() : pTab->Lower();
131 10 : if( pRow == pLast )
132 : {
133 : // The last check: no soft page break for "follow" table lines
134 5 : if( pTab->IsFollow() && pTab->FindMaster( false )->HasFollowFlowLine() )
135 4 : return false;
136 1 : return true;
137 : }
138 5 : return false;
139 : }
140 : }
141 0 : return false;
142 177 : }
143 :
144 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|