android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / text / widorp.cxx
blob11e4193d7bd0b2707d13da155fa05f4fed45a7c1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <layfrm.hxx>
21 #include <ftnboss.hxx>
22 #include <ndtxt.hxx>
23 #include <paratr.hxx>
24 #include <editeng/orphitem.hxx>
25 #include <editeng/widwitem.hxx>
26 #include <editeng/keepitem.hxx>
27 #include <editeng/spltitem.hxx>
28 #include <frmatr.hxx>
29 #include <txtftn.hxx>
30 #include <fmtftn.hxx>
31 #include <rowfrm.hxx>
33 #include "widorp.hxx"
34 #include <txtfrm.hxx>
35 #include "itrtxt.hxx"
36 #include <sectfrm.hxx>
37 #include <ftnfrm.hxx>
38 #include <pagefrm.hxx>
39 #include <IDocumentSettingAccess.hxx>
40 #include <sortedobjs.hxx>
41 #include <anchoredobject.hxx>
42 #include <flyfrm.hxx>
44 #undef WIDOWTWIPS
46 namespace
49 // A Follow on the same page as its master is nasty.
50 bool IsNastyFollow( const SwTextFrame *pFrame )
52 OSL_ENSURE( !pFrame->IsFollow() || !pFrame->GetPrev() ||
53 static_cast<const SwTextFrame*>(pFrame->GetPrev())->GetFollow() == pFrame,
54 "IsNastyFollow: What is going on here?" );
55 return pFrame->IsFollow() && pFrame->GetPrev();
60 SwTextFrameBreak::SwTextFrameBreak( SwTextFrame *pNewFrame, const SwTwips nRst )
61 : m_nRstHeight(nRst), m_pFrame(pNewFrame)
63 SwSwapIfSwapped swap(m_pFrame);
64 SwRectFnSet aRectFnSet(m_pFrame);
65 m_nOrigin = aRectFnSet.GetPrtTop(*m_pFrame);
66 m_bKeep = !m_pFrame->IsMoveable() || IsNastyFollow( m_pFrame );
67 if( !m_bKeep && m_pFrame->IsInSct() )
69 const SwSectionFrame* const pSct = m_pFrame->FindSctFrame();
70 m_bKeep = pSct->Lower()->IsColumnFrame() && !pSct->MoveAllowed( m_pFrame );
72 m_bKeep = m_bKeep || !m_pFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetSplit().GetValue() ||
73 m_pFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetKeep().GetValue();
74 m_bBreak = false;
76 if( !m_nRstHeight && !m_pFrame->IsFollow() && m_pFrame->IsInFootnote() && m_pFrame->HasPara() )
78 m_nRstHeight = m_pFrame->GetFootnoteFrameHeight();
79 m_nRstHeight += aRectFnSet.GetHeight(m_pFrame->getFramePrintArea()) -
80 aRectFnSet.GetHeight(m_pFrame->getFrameArea());
81 if( m_nRstHeight < 0 )
82 m_nRstHeight = 0;
86 /**
87 * BP 18.6.93: Widows.
88 * In contrast to the first implementation the Widows are not calculated
89 * in advance but detected when formatting the split Follow.
90 * In Master the Widows-calculation is dropped completely
91 * (nWidows is manipulated). If the Follow detects that the
92 * Widows rule applies it sends a Prepare to its predecessor.
93 * A special problem is when the Widow rule applies but in Master
94 * there are some lines available.
96 * BP(22.07.92): Calculation of Widows and Orphans.
97 * The method returns true if one of the rules matches.
99 * One difficulty with Widows and different formats between
100 * Master- and Follow-Frame:
101 * Example: If the first column is 3cm and the second is 4cm and
102 * Widows is set to 3, the decision if the Widows rule matches can not
103 * be done until the Follow is formatted. Unfortunately this is crucial
104 * to decide if the whole paragraph goes to the next page or not.
106 bool SwTextFrameBreak::IsInside( SwTextMargin const &rLine ) const
108 bool bFit = false;
110 SwSwapIfSwapped swap(m_pFrame);
111 SwRectFnSet aRectFnSet(m_pFrame);
112 // nOrigin is an absolute value, rLine refers to the swapped situation.
114 SwTwips nTmpY;
115 if ( m_pFrame->IsVertical() )
116 nTmpY = m_pFrame->SwitchHorizontalToVertical( rLine.Y() + rLine.GetLineHeight() );
117 else
118 nTmpY = rLine.Y() + rLine.GetLineHeight();
120 SwTwips nLineHeight = aRectFnSet.YDiff( nTmpY , m_nOrigin );
122 // Calculate extra space for bottom border.
123 nLineHeight += aRectFnSet.GetBottomMargin(*m_pFrame);
125 if( m_nRstHeight )
126 bFit = m_nRstHeight >= nLineHeight;
127 else
129 // The Frame has a height to fit on the page.
130 SwTwips nHeight =
131 aRectFnSet.YDiff( aRectFnSet.GetPrtBottom(*m_pFrame->GetUpper()), m_nOrigin );
132 SwTwips nDiff = nHeight - nLineHeight;
134 // Hide whitespace may require not to insert a new page.
135 SwPageFrame* pPageFrame = m_pFrame->FindPageFrame();
136 if (!pPageFrame->CheckPageHeightValidForHideWhitespace(nDiff))
137 nDiff = 0;
139 // If everything is inside the existing frame the result is true;
140 bFit = nDiff >= 0;
142 // If it didn't fit, try to add the space of footnotes that are anchored
143 // in frames below (in next-chain of) this one as they will need to move
144 // forward anyway if this frame is split.
145 // - except if in tables (need to check if row is splittable?
146 // also, multiple columns looks difficult)
147 if (!bFit && !m_pFrame->IsInTab())
149 if (SwFootnoteBossFrame const*const pBoss = m_pFrame->FindFootnoteBossFrame())
151 if (SwFootnoteContFrame const*const pCont = pBoss->FindFootnoteCont())
153 SwContentFrame const* pContent(m_pFrame);
154 while (pContent->HasFollow())
156 pContent = pContent->GetFollow();
158 // start with first text frame that isn't a follow
159 // (ignoring Keep attribute for now, MakeAll should handle it?)
160 pContent = pContent->GetNextContentFrame();
161 ::std::set<SwContentFrame const*> nextFrames;
162 while (pBoss->IsAnLower(pContent))
164 nextFrames.insert(pContent);
165 pContent = pContent->GetNextContentFrame();
167 SwTwips nNextFootnotes(0);
168 for (SwFootnoteFrame const* pFootnote = static_cast<SwFootnoteFrame const*>(pCont->Lower());
169 pFootnote != nullptr;
170 pFootnote = static_cast<SwFootnoteFrame const*>(pFootnote->GetNext()))
172 SwContentFrame const*const pAnchor = pFootnote->GetRef();
173 if (nextFrames.find(pAnchor) != nextFrames.end())
175 nNextFootnotes += aRectFnSet.GetHeight(pFootnote->getFrameArea());
178 bFit = 0 <= nDiff + nNextFootnotes;
179 SAL_INFO_IF(bFit, "sw.core", "no text frame break because ignoring "
180 << nNextFootnotes << " footnote height");
184 if (!bFit && rLine.MaybeHasHints() && m_pFrame->GetFollow()
185 // tdf#153319 RemoveFootnote only works if this frame doesn't
186 && !rLine.GetNext() // contain the footnote portion
187 // if using same footnote container as the follow, pointless to try?
188 && m_pFrame->FindFootnoteBossFrame() != m_pFrame->GetFollow()->FindFootnoteBossFrame())
190 // possibly a footnote that is anchored beyond the end of this
191 // (the last) line is in the way, try to remove it and check again
192 m_pFrame->RemoveFootnote(rLine.GetEnd());
193 nHeight = aRectFnSet.YDiff( aRectFnSet.GetPrtBottom(*m_pFrame->GetUpper()), m_nOrigin );
194 bFit = nHeight >= nLineHeight;
196 if ( !bFit )
198 if ( rLine.GetNext() &&
199 m_pFrame->IsInTab() && !m_pFrame->GetFollow() && !m_pFrame->GetIndNext() )
201 // add additional space taken as lower space as last content in a table
202 // for all text lines except the last one.
203 nHeight += m_pFrame->CalcAddLowerSpaceAsLastInTableCell();
204 bFit = nHeight >= nLineHeight;
207 if( !bFit )
209 // The LineHeight exceeds the current Frame height.
210 // Call a test Grow to detect if the Frame could
211 // grow the requested area.
212 nHeight += m_pFrame->GrowTst( LONG_MAX );
214 // The Grow() returns the height by which the Upper of the TextFrame
215 // would let the TextFrame grow.
216 // The TextFrame itself can grow as much as it wants.
217 bFit = nHeight >= nLineHeight;
221 return bFit;
224 bool SwTextFrameBreak::IsBreakNow( SwTextMargin &rLine )
226 SwSwapIfSwapped swap(m_pFrame);
228 // bKeep is stronger than IsBreakNow()
229 // Is there enough space ?
230 if( m_bKeep || IsInside( rLine ) )
231 m_bBreak = false;
232 else
234 /* This class assumes that the SwTextMargin is processed from Top to
235 * Bottom. Because of performance reasons we stop splitting in the
236 * following cases:
237 * If only one line does not fit.
238 * Special case: with DummyPortions there is LineNr == 1, though we
239 * want to split.
241 // Include DropLines
243 bool bFirstLine = 1 == rLine.GetLineNr() && !rLine.GetPrev();
244 m_bBreak = true;
246 if (bFirstLine && m_pFrame->IsEmptyWithSplitFly())
248 // Not really the first line, visually we may have a previous line (including the fly
249 // frame) already.
250 bFirstLine = false;
253 if( ( bFirstLine && m_pFrame->GetIndPrev() )
254 || ( rLine.GetLineNr() <= rLine.GetDropLines() ) )
256 m_bKeep = true;
257 m_bBreak = false;
259 else if(bFirstLine && m_pFrame->IsInFootnote() && !m_pFrame->FindFootnoteFrame()->GetPrev())
261 SwLayoutFrame* pTmp = m_pFrame->FindFootnoteBossFrame()->FindBodyCont();
262 if( !pTmp || !pTmp->Lower() )
263 m_bBreak = false;
267 return m_bBreak;
270 void SwTextFrameBreak::SetRstHeight( const SwTextMargin &rLine )
272 // Consider bottom margin
273 SwRectFnSet aRectFnSet(m_pFrame);
275 m_nRstHeight = aRectFnSet.GetBottomMargin(*m_pFrame);
277 if ( aRectFnSet.IsVert() )
279 if ( m_pFrame->IsVertLR() )
280 m_nRstHeight = aRectFnSet.YDiff( m_pFrame->SwitchHorizontalToVertical( rLine.Y() ) , m_nOrigin );
281 else
282 m_nRstHeight += m_nOrigin - m_pFrame->SwitchHorizontalToVertical( rLine.Y() );
284 else
285 m_nRstHeight += rLine.Y() - m_nOrigin;
288 WidowsAndOrphans::WidowsAndOrphans( SwTextFrame *pNewFrame, const SwTwips nRst,
289 bool bChkKeep )
290 : SwTextFrameBreak( pNewFrame, nRst ), m_nWidLines( 0 ), m_nOrphLines( 0 )
292 SwSwapIfSwapped swap(m_pFrame);
294 if( m_bKeep )
296 // If paragraph should not be split but is larger than
297 // the page, then bKeep is overruled.
298 if( bChkKeep && !m_pFrame->GetPrev() && !m_pFrame->IsInFootnote() &&
299 m_pFrame->IsMoveable() &&
300 ( !m_pFrame->IsInSct() || m_pFrame->FindSctFrame()->MoveAllowed(m_pFrame) ) )
301 m_bKeep = false;
302 // Even if Keep is set, Orphans has to be respected.
303 // e.g. if there are chained frames where a Follow in the last frame
304 // receives a Keep, because it is not (forward) movable -
305 // nevertheless the paragraph can request lines from the Master
306 // because of the Orphan rule.
307 if( m_pFrame->IsFollow() )
308 m_nWidLines = m_pFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetWidows().GetValue();
310 else
312 const SwAttrSet& rSet = m_pFrame->GetTextNodeForParaProps()->GetSwAttrSet();
313 const SvxOrphansItem &rOrph = rSet.GetOrphans();
314 if ( rOrph.GetValue() > 1 )
315 m_nOrphLines = rOrph.GetValue();
316 if ( m_pFrame->IsFollow() )
317 m_nWidLines = rSet.GetWidows().GetValue();
321 if ( !(m_bKeep || m_nWidLines || m_nOrphLines) )
322 return;
324 bool bResetFlags = false;
326 bool bWordTableCell = false;
327 if (m_pFrame->IsInFly())
329 // Enable widow / orphan control in Word-style table cells in split rows, at least inside
330 // flys.
331 const SwDoc& rDoc = m_pFrame->GetTextNodeForParaProps()->GetDoc();
332 const IDocumentSettingAccess& rIDSA = rDoc.getIDocumentSettingAccess();
333 bWordTableCell = rIDSA.get(DocumentSettingId::TABLE_ROW_KEEP);
336 if ( m_pFrame->IsInTab() && !bWordTableCell )
338 // For compatibility reasons, we disable Keep/Widows/Orphans
339 // inside splittable row frames:
340 if ( m_pFrame->GetNextCellLeaf() || m_pFrame->IsInFollowFlowRow() )
342 const SwFrame* pTmpFrame = m_pFrame->GetUpper();
343 while ( !pTmpFrame->IsRowFrame() )
344 pTmpFrame = pTmpFrame->GetUpper();
345 if ( static_cast<const SwRowFrame*>(pTmpFrame)->IsRowSplitAllowed() )
346 bResetFlags = true;
350 if( m_pFrame->IsInFootnote() && !m_pFrame->GetIndPrev() )
352 // Inside of footnotes there are good reasons to turn off the Keep attribute
353 // as well as Widows/Orphans.
354 SwFootnoteFrame *pFootnote = m_pFrame->FindFootnoteFrame();
355 const bool bFt = !pFootnote->GetAttr()->GetFootnote().IsEndNote();
356 if( !pFootnote->GetPrev() &&
357 pFootnote->FindFootnoteBossFrame( bFt ) != pFootnote->GetRef()->FindFootnoteBossFrame( bFt )
358 && ( !m_pFrame->IsInSct() || m_pFrame->FindSctFrame()->MoveAllowed(m_pFrame) ) )
360 bResetFlags = true;
364 if ( bResetFlags )
366 m_bKeep = false;
367 m_nOrphLines = 0;
368 m_nWidLines = 0;
373 * The Find*-Methods do not only search, but adjust the SwTextMargin to the
374 * line where the paragraph should have a break and truncate the paragraph there.
375 * FindBreak()
377 bool WidowsAndOrphans::FindBreak( SwTextFrame *pFrame, SwTextMargin &rLine,
378 bool bHasToFit )
380 // i#16128 - Why member <pFrame> _*and*_ parameter <pFrame>??
381 // Thus, assertion on situation, that these are different to figure out why.
382 OSL_ENSURE( m_pFrame == pFrame, "<WidowsAndOrphans::FindBreak> - pFrame != pFrame" );
384 SwSwapIfSwapped swap(m_pFrame);
386 bool bRet = true;
387 sal_uInt16 nOldOrphans = m_nOrphLines;
388 if( bHasToFit )
389 m_nOrphLines = 0;
390 rLine.Bottom();
392 if( !IsBreakNowWidAndOrp( rLine ) )
393 bRet = false;
394 if( !FindWidows( pFrame, rLine ) )
396 bool bBack = false;
398 while( IsBreakNowWidAndOrp( rLine ) )
400 if( rLine.PrevLine() )
401 bBack = true;
402 else
403 break;
405 // Usually Orphans are not taken into account for HasToFit.
406 // But if Dummy-Lines are concerned and the Orphans rule is violated
407 // we make an exception: We leave behind one Dummyline and take
408 // the whole text to the next page/column.
409 if( rLine.GetLineNr() <= nOldOrphans &&
410 rLine.GetInfo().GetParaPortion()->IsDummy() &&
411 ( ( bHasToFit && bRet ) || IsBreakNow( rLine ) ) )
412 rLine.Top();
414 rLine.TruncLines( true );
415 bRet = bBack;
417 m_nOrphLines = nOldOrphans;
419 return bRet;
423 * FindWidows positions the SwTextMargin of the Master to the line where to
424 * break by examining and formatting the Follow.
425 * Returns true if the Widows-rule matches, that means that the
426 * paragraph should not be split (keep) !
428 bool WidowsAndOrphans::FindWidows( SwTextFrame *pFrame, SwTextMargin &rLine )
430 OSL_ENSURE( ! pFrame->IsVertical() || ! pFrame->IsSwapped(),
431 "WidowsAndOrphans::FindWidows with swapped frame" );
433 if( !m_nWidLines || !pFrame->IsFollow() )
434 return false;
436 rLine.Bottom();
438 // We can still cut something off
439 SwTextFrame *pMaster = pFrame->FindMaster();
440 OSL_ENSURE(pMaster, "+WidowsAndOrphans::FindWidows: Widows in a master?");
441 if( !pMaster )
442 return false;
444 // If the first line of the Follow does not fit, the master
445 // probably is full of Dummies. In this case a PrepareHint::Widows would be fatal.
446 if( pMaster->GetOffset() == pFrame->GetOffset() )
447 return false;
449 // Remaining height of the master
450 SwRectFnSet aRectFnSet(pFrame);
452 const SwTwips nDocPrtTop = aRectFnSet.GetPrtTop(*pFrame);
453 SwTwips nOldHeight;
454 SwTwips nTmpY = rLine.Y() + rLine.GetLineHeight();
456 if ( aRectFnSet.IsVert() )
458 nTmpY = pFrame->SwitchHorizontalToVertical( nTmpY );
459 nOldHeight = -aRectFnSet.GetHeight(pFrame->getFramePrintArea());
461 else
462 nOldHeight = aRectFnSet.GetHeight(pFrame->getFramePrintArea());
464 const SwTwips nChg = aRectFnSet.YDiff( nTmpY, nDocPrtTop + nOldHeight );
466 // below the Widows-threshold...
467 if( rLine.GetLineNr() >= m_nWidLines )
469 // Follow to Master I
470 // If the Follow *grows*, there is the chance for the Master to
471 // receive lines, that it was forced to hand over to the Follow lately:
472 // Prepare(Need); check that below nChg!
473 // (0W, 2O, 2M, 2F) + 1F = 3M, 2F
474 if( rLine.GetLineNr() > m_nWidLines && pFrame->IsJustWidow() )
476 // If the Master is locked, it has probably just donated a line
477 // to us, we don't return that just because we turned it into
478 // multiple lines (e.g. via frames).
479 if( !pMaster->IsLocked() && pMaster->GetUpper() )
481 const SwTwips nTmpRstHeight = aRectFnSet.BottomDist( pMaster->getFrameArea(),
482 aRectFnSet.GetPrtBottom(*pMaster->GetUpper()) );
483 if ( nTmpRstHeight >=
484 rLine.GetInfo().GetParaPortion()->Height() )
486 pMaster->Prepare( PrepareHint::AdjustSizeWithoutFormatting );
487 pMaster->InvalidateSize_();
488 pMaster->InvalidatePage();
492 pFrame->SetJustWidow( false );
494 return false;
497 // Follow to Master II
498 // If the Follow *shrinks*, maybe the Master can absorb the whole Orphan.
499 // (0W, 2O, 2M, 1F) - 1F = 3M, 0F -> PrepareHint::AdjustSizeWithoutFormatting
500 // (0W, 2O, 3M, 2F) - 1F = 2M, 2F -> PrepareHint::Widows
502 if( 0 > nChg && !pMaster->IsLocked() && pMaster->GetUpper() )
504 SwTwips nTmpRstHeight = aRectFnSet.BottomDist( pMaster->getFrameArea(),
505 aRectFnSet.GetPrtBottom(*pMaster->GetUpper()) );
506 if( nTmpRstHeight >= rLine.GetInfo().GetParaPortion()->Height() )
508 pMaster->Prepare( PrepareHint::AdjustSizeWithoutFormatting );
509 pMaster->InvalidateSize_();
510 pMaster->InvalidatePage();
511 pFrame->SetJustWidow( false );
512 return false;
516 // Master to Follow
517 // If the Follow contains fewer lines than Widows after formatting,
518 // we still can move over some lines from the Master. If this triggers
519 // the Orphans rule of the Master, the Master frame must be Grow()n
520 // in its CalcPreps(), such that it won't fit onto its page anymore.
521 // But if the Master Frame can still lose a few lines, we need to
522 // do a Shrink() in the CalcPreps(); the Follow with the Widows then
523 // moves onto the page of the Master, but remains unsplit, so that
524 // it (finally) moves onto the next page. So much for the theory!
526 // We only request one line at a time for now, because a Master's line
527 // could result in multiple lines for us.
528 // Therefore, the CalcFollow() remains in control until the Follow got all
529 // necessary lines.
530 sal_Int32 nNeed = 1; // was: nWidLines - rLine.GetLineNr();
532 // Special case: Master cannot give lines to follow
533 // i#91421
534 if ( !pMaster->GetIndPrev() )
536 pMaster->ChgThisLines();
537 sal_Int32 nLines = pMaster->GetThisLines();
538 if(nLines == 0 && pMaster->HasPara())
540 const SwParaPortion *pMasterPara = pMaster->GetPara();
541 if(pMasterPara && pMasterPara->GetNext())
542 nLines = 2;
544 if( nLines <= nNeed )
545 return false;
547 if (pFrame->IsInTab())
549 const SwFrame* pRow = pFrame;
550 while (pRow && !pRow->IsRowFrame())
552 pRow = pRow->GetUpper();
555 if (pRow && pRow->HasFixSize())
557 // This is a follow frame and our side is fixed.
558 const SwAttrSet& rSet = pFrame->GetTextNodeForParaProps()->GetSwAttrSet();
559 const SvxOrphansItem& rOrph = rSet.GetOrphans();
560 if (nLines <= static_cast<sal_Int32>(rOrph.GetValue()))
562 // If the master gives us a line as part of widow control, then its orphan
563 // control will move everything to the follow, which is worse than having no
564 // widow / orphan control at all. Don't send a Widows prepare hint, in this
565 // case.
566 return true;
572 pMaster->Prepare( PrepareHint::Widows, static_cast<void*>(&nNeed) );
573 return true;
576 namespace sw {
578 auto FindNonFlyPortion(SwLineLayout const& rLine) -> bool
580 for (SwLinePortion const* pPortion = rLine.GetFirstPortion();
581 pPortion; pPortion = pPortion->GetNextPortion())
583 switch (pPortion->GetWhichPor())
585 case PortionType::Fly:
586 case PortionType::Glue:
587 case PortionType::Margin:
588 break;
589 default:
591 return true;
595 return false;
598 } // namespace sw
600 bool WidowsAndOrphans::WouldFit( SwTextMargin &rLine, SwTwips &rMaxHeight, bool bTst, bool bMoveBwd )
602 // Here it does not matter, if pFrame is swapped or not.
603 // IsInside() takes care of itself
605 // We expect that rLine is set to the last line
606 OSL_ENSURE( !rLine.GetNext(), "WouldFit: aLine::Bottom missed!" );
607 sal_Int32 nLineCnt = rLine.GetLineNr();
609 // First satisfy the Orphans-rule and the wish for initials ...
610 const sal_uInt16 nMinLines = std::max( GetOrphansLines(), rLine.GetDropLines() );
611 if ( nLineCnt < nMinLines )
612 return false;
614 rLine.Top();
615 SwTwips nLineSum = rLine.GetLineHeight();
617 // tdf#146500 for MoveBwd(), want at least 1 line with non-fly
618 bool hasNonFly(!bMoveBwd);
619 if (!hasNonFly)
621 hasNonFly = ::sw::FindNonFlyPortion(*rLine.GetCurr());
623 while (nMinLines > rLine.GetLineNr() || !hasNonFly)
625 if( !rLine.NextLine() )
627 if (nMinLines > rLine.GetLineNr())
628 return false;
629 else
630 break;
632 nLineSum += rLine.GetLineHeight();
633 if (!hasNonFly)
635 hasNonFly = ::sw::FindNonFlyPortion(*rLine.GetCurr());
639 // We do not fit
640 if( !IsInside( rLine ) )
641 return false;
643 // Check the Widows-rule
644 if( !m_nWidLines && !m_pFrame->IsFollow() )
646 // Usually we only have to check for Widows if we are a Follow.
647 // On WouldFit the rule has to be checked for the Master too,
648 // because we are just in the middle of calculating the break.
649 // In Ctor of WidowsAndOrphans the nWidLines are only calced for
650 // Follows from the AttrSet - so we catch up now:
651 const SwAttrSet& rSet = m_pFrame->GetTextNodeForParaProps()->GetSwAttrSet();
652 m_nWidLines = rSet.GetWidows().GetValue();
655 // After Orphans/Initials, do enough lines remain for Widows?
656 // If we are currently doing a test formatting, we may not
657 // consider the widows rule for two reasons:
658 // 1. The columns may have different widths.
659 // Widow lines would have wrong width.
660 // 2. Test formatting is only done up to the given space.
661 // we do not have any lines for widows at all.
662 if( bTst || nLineCnt - nMinLines >= m_nWidLines )
664 if( rMaxHeight >= nLineSum )
666 rMaxHeight -= nLineSum;
667 return true;
670 return false;
673 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */