LibreOffice Module sw (master) 1
frmform.cxx
Go to the documentation of this file.
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 <config_wasm_strip.h>
21
22#include <sal/config.h>
23#include <sal/log.hxx>
24
26#include <anchoredobject.hxx>
27#include <bodyfrm.hxx>
28#include <hintids.hxx>
29#include <editeng/keepitem.hxx>
31#include <pagefrm.hxx>
32#include <ndtxt.hxx>
33#include <ftnfrm.hxx>
34#include <txtftn.hxx>
35#include <fmtftn.hxx>
36#include <paratr.hxx>
37#include <viewopt.hxx>
38#include <viewsh.hxx>
39#include <frmatr.hxx>
40#include <pam.hxx>
41#include <fmtanchr.hxx>
42#include "itrform2.hxx"
43#include "widorp.hxx"
44#include "txtcache.hxx"
45#include <sectfrm.hxx>
46#include <rootfrm.hxx>
47#include <frmfmt.hxx>
48#include <sortedobjs.hxx>
49#include <editeng/tstpitem.hxx>
50#include <redline.hxx>
51#include <comphelper/lok.hxx>
52#include <flyfrms.hxx>
53#include <frmtool.hxx>
54#include <layouter.hxx>
55
56// Tolerance in formatting and text output
57#define SLOPPY_TWIPS 5
58
59namespace {
60
61class FormatLevel
62{
63 static sal_uInt16 s_nLevel;
64public:
65 FormatLevel() { ++s_nLevel; }
66 ~FormatLevel() { --s_nLevel; }
67 static sal_uInt16 GetLevel() { return s_nLevel; }
68 static bool LastLevel() { return 10 < s_nLevel; }
69};
70
71}
72
73sal_uInt16 FormatLevel::s_nLevel = 0;
74
75void ValidateText( SwFrame *pFrame ) // Friend of frame
76{
77 if ( ( ! pFrame->IsVertical() &&
78 pFrame->getFrameArea().Width() == pFrame->GetUpper()->getFramePrintArea().Width() ) ||
79 ( pFrame->IsVertical() &&
80 pFrame->getFrameArea().Height() == pFrame->GetUpper()->getFramePrintArea().Height() ) )
81 {
82 pFrame->setFrameAreaSizeValid(true);
83 }
84}
85
87{
88 vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
89 // Validate surroundings to avoid oscillation
90 SwSwapIfSwapped swap( this );
91
92 if ( !IsInFly() && !IsInTab() )
93 { // Only validate 'this' when inside a fly, the rest should actually only be
94 // needed for footnotes, which do not exist in flys.
96 if( pSct )
97 {
98 if( !pSct->IsColLocked() )
99 pSct->ColLock();
100 else
101 pSct = nullptr;
102 }
103
104 SwFrame *pUp = GetUpper();
105 pUp->Calc(pRenderContext);
106 if( pSct )
107 pSct->ColUnlock();
108 }
109 ValidateText( this );
110
111 // We at least have to save the MustFit flag!
112 assert(HasPara() && "ResetPreps(), missing ParaPortion, SwCache bug?");
113 SwParaPortion *pPara = GetPara();
114 const bool bMustFit = pPara->IsPrepMustFit();
115 ResetPreps();
116 pPara->SetPrepMustFit( bMustFit );
117}
118
119// After a RemoveFootnote the BodyFrame and all Frames contained within it, need to be
120// recalculated, so that the DeadLine is right.
121// First we search outwards, on the way back we calculate everything.
122static void ValidateBodyFrame_( SwFrame *pFrame )
123{
124 vcl::RenderContext* pRenderContext = pFrame ? pFrame->getRootFrame()->GetCurrShell()->GetOut() : nullptr;
125 if( !pFrame || pFrame->IsCellFrame() )
126 return;
127
128 if( !pFrame->IsBodyFrame() && pFrame->GetUpper() )
129 ValidateBodyFrame_( pFrame->GetUpper() );
130 if( !pFrame->IsSctFrame() )
131 pFrame->Calc(pRenderContext);
132 else
133 {
134 const bool bOld = static_cast<SwSectionFrame*>(pFrame)->IsContentLocked();
135 static_cast<SwSectionFrame*>(pFrame)->SetContentLock( true );
136 pFrame->Calc(pRenderContext);
137 if( !bOld )
138 static_cast<SwSectionFrame*>(pFrame)->SetContentLock( false );
139 }
140}
141
143{
144 SwSwapIfSwapped swap( this );
145
146 // See comment in ValidateFrame()
147 if ( !IsInFly() && !IsInTab() &&
148 !( IsInSct() && FindSctFrame()->Lower()->IsColumnFrame() ) )
150}
151
153{
154 SwSwapIfNotSwapped swap(const_cast<SwTextFrame *>(this));
155
156 OSL_ENSURE( HasPara(), "SwTextFrame::GetDropRect_: try again next year." );
157 SwTextSizeInfo aInf( const_cast<SwTextFrame*>(this) );
158 SwTextMargin aLine( const_cast<SwTextFrame*>(this), &aInf );
159 if( aLine.GetDropLines() )
160 {
161 rRect.Top( aLine.Y() );
162 rRect.Left( aLine.GetLineStart() );
163 rRect.Height( aLine.GetDropHeight() );
164 rRect.Width( aLine.GetDropLeft() );
165
166 if ( IsRightToLeft() )
167 SwitchLTRtoRTL( rRect );
168
169 if ( IsVertical() )
171 return true;
172 }
173
174 return false;
175}
176
178{
179 vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
180 SwSwapIfSwapped swap( this );
181
182 OSL_ENSURE( HasFollow(), "CalcFollow: missing Follow." );
183
184 SwTextFrame* pMyFollow = GetFollow();
185
186 SwParaPortion *pPara = GetPara();
187 const bool bFollowField = pPara && pPara->IsFollowField();
188
189 if( !pMyFollow->GetOffset() || pMyFollow->GetOffset() != nTextOfst ||
190 bFollowField || pMyFollow->IsFieldFollow() ||
191 ( pMyFollow->IsVertical() && !pMyFollow->getFramePrintArea().Width() ) ||
192 ( ! pMyFollow->IsVertical() && !pMyFollow->getFramePrintArea().Height() ) )
193 {
194#if OSL_DEBUG_LEVEL > 0
195 const SwFrame *pOldUp = GetUpper();
196#endif
197
198 SwRectFnSet aRectFnSet(this);
199 SwTwips nOldBottom = aRectFnSet.GetBottom(GetUpper()->getFrameArea());
200 SwTwips nMyPos = aRectFnSet.GetTop(getFrameArea());
201
202 const SwPageFrame *pPage = nullptr;
203 bool bOldInvaContent = true;
204 if ( !IsInFly() && GetNext() )
205 {
206 pPage = FindPageFrame();
207 // Minimize (reset if possible) invalidations: see below
208 bOldInvaContent = pPage->IsInvalidContent();
209 }
210
211 pMyFollow->SetOffset_( nTextOfst );
212 pMyFollow->SetFieldFollow( bFollowField );
213 if( HasFootnote() || pMyFollow->HasFootnote() )
214 {
217 if( pPara )
218 {
219 pPara->GetReformat() = SwCharRange();
220 pPara->SetDelta(0);
221 }
222 }
223
224 // The footnote area must not get larger
226
227 pMyFollow->CalcFootnoteFlag();
228 if ( !pMyFollow->GetNext() && !pMyFollow->HasFootnote() )
229 nOldBottom = aRectFnSet.IsVert() ? 0 : LONG_MAX;
230
231 // tdf#122892 check flag:
232 // 1. WidowsAndOrphans::FindWidows() determines follow is a widow
233 // 2. SwTextFrame::PrepWidows() calls SetPrepWidows() on master;
234 // if it can spare lines, master truncates one line
235 // 3. SwTextFrame::CalcPreps() on master (below);
236 // unless IsPrepMustFit(), if master hasn't shrunk via 2., it will SetWidow()
237 // 4. loop must exit then, because the follow didn't grow so nothing will ever change
238 while (!IsWidow())
239 {
240 if( !FormatLevel::LastLevel() )
241 {
242 // If the follow is contained within a column section or column
243 // frame, we need to calculate that first. This is because the
244 // FormatWidthCols() does not work if it is called from MakeAll
245 // of the _locked_ follow.
246 SwSectionFrame* pSct = pMyFollow->FindSctFrame();
247 if( pSct && !pSct->IsAnLower( this ) )
248 {
249 if( pSct->GetFollow() )
250 pSct->SimpleFormat();
251 else if( ( pSct->IsVertical() && !pSct->getFrameArea().Width() ) ||
252 ( ! pSct->IsVertical() && !pSct->getFrameArea().Height() ) )
253 break;
254 }
255 // i#11760 - Intrinsic format of follow is controlled.
256 if ( FollowFormatAllowed() )
257 {
258 // i#11760 - No nested format of follows, if
259 // text frame is contained in a column frame.
260 // Thus, forbid intrinsic format of follow.
261 {
262 bool bIsFollowInColumn = false;
263 SwFrame* pFollowUpper = pMyFollow->GetUpper();
264 while ( pFollowUpper )
265 {
266 if ( pFollowUpper->IsColumnFrame() )
267 {
268 bIsFollowInColumn = true;
269 break;
270 }
271 if ( pFollowUpper->IsPageFrame() ||
272 pFollowUpper->IsFlyFrame() )
273 {
274 break;
275 }
276 pFollowUpper = pFollowUpper->GetUpper();
277 }
278 if ( bIsFollowInColumn )
279 {
280 pMyFollow->ForbidFollowFormat();
281 }
282 }
283
284 pMyFollow->Calc(pRenderContext);
285 // The Follow can tell from its getFrameArea().Height() that something went wrong
286 OSL_ENSURE( !pMyFollow->GetPrev(), "SwTextFrame::CalcFollow: cheesy follow" );
287 if( pMyFollow->GetPrev() )
288 {
289 pMyFollow->Prepare();
290 pMyFollow->Calc(pRenderContext);
291 OSL_ENSURE( !pMyFollow->GetPrev(), "SwTextFrame::CalcFollow: very cheesy follow" );
292 }
293
294 // i#11760 - Reset control flag for follow format.
295 pMyFollow->AllowFollowFormat();
296 }
297
298 // Make sure that the Follow gets painted
299 pMyFollow->SetCompletePaint();
300 }
301
302 pPara = GetPara();
303 // As long as the Follow requests lines due to Orphans, it is
304 // passed these and is formatted again if possible
305 if( pPara && pPara->IsPrepWidows() )
306 CalcPreps();
307 else
308 break;
309 }
310
311 if( HasFootnote() || pMyFollow->HasFootnote() )
312 {
315 if( pPara )
316 {
317 pPara->GetReformat() = SwCharRange();
318 pPara->SetDelta(0);
319 }
320 }
321
322 if ( pPage && !bOldInvaContent )
323 pPage->ValidateContent();
324
325#if OSL_DEBUG_LEVEL > 0
326 OSL_ENSURE( pOldUp == GetUpper(), "SwTextFrame::CalcFollow: heavy follow" );
327#endif
328
329 const tools::Long nRemaining =
330 - aRectFnSet.BottomDist( GetUpper()->getFrameArea(), nOldBottom );
331 if ( nRemaining > 0 &&
332 nRemaining != ( aRectFnSet.IsVert() ?
333 nMyPos - getFrameArea().Right() :
334 getFrameArea().Top() - nMyPos ) )
335 {
336 return true;
337 }
338 }
339
340 return false;
341}
342
344{
345 Point aOldPos = getFrameArea().Pos();
347
348 // Recalc split flys if our position changed.
349 if (aOldPos != getFrameArea().Pos())
350 {
351 // Find the master frame.
352 const SwTextFrame* pMaster = this;
353 while (pMaster->IsFollow())
354 {
355 pMaster = pMaster->FindMaster();
356 }
357 // Find which flys are effectively anchored to this frame.
358 for (const auto& pFly : pMaster->GetSplitFlyDrawObjs())
359 {
360 SwTextFrame* pFlyAnchor = pFly->FindAnchorCharFrame();
361 if (pFlyAnchor != this)
362 {
363 continue;
364 }
365 // Possibly this fly was positioned relative to us, invalidate its position now that our
366 // position is changed.
367 pFly->UnlockPosition();
368 pFly->InvalidatePos();
369 }
370 }
371
372 // Inform LOK clients about change in position of redlines (if any)
374 return;
375
376 SwTextNode const* pTextNode = GetTextNodeFirst();
377 const SwRedlineTable& rTable = pTextNode->getIDocumentRedlineAccess().GetRedlineTable();
378 for (SwRedlineTable::size_type nRedlnPos = 0; nRedlnPos < rTable.size(); ++nRedlnPos)
379 {
380 SwRangeRedline* pRedln = rTable[nRedlnPos];
381 if (pTextNode->GetIndex() == pRedln->GetPoint()->GetNode().GetIndex())
382 {
384 if (GetMergedPara()
385 && pRedln->GetType() == RedlineType::Delete
386 && pRedln->GetPoint()->GetNode() != pRedln->GetMark()->GetNode())
387 {
388 pTextNode = pRedln->End()->GetNode().GetTextNode();
389 }
390 }
391 }
392}
393
394void SwTextFrame::AdjustFrame( const SwTwips nChgHght, bool bHasToFit )
395{
396 vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
397 if( IsUndersized() )
398 {
399 if( GetOffset() && !IsFollow() ) // A scrolled paragraph (undersized)
400 return;
401 SetUndersized( nChgHght == 0 || bHasToFit );
402 }
403
404 // AdjustFrame is called with a swapped frame during
405 // formatting but the frame is not swapped during FormatEmpty
406 SwSwapIfSwapped swap( this );
407 SwRectFnSet aRectFnSet(this);
408
409 // The Frame's size variable is incremented by Grow or decremented by Shrink.
410 // If the size cannot change, nothing should happen!
411 if( nChgHght >= 0)
412 {
413 SwTwips nChgHeight = nChgHght;
414 if( nChgHght && !bHasToFit )
415 {
416 if( IsInFootnote() && !IsInSct() )
417 {
418 SwTwips nReal = Grow( nChgHght, true );
419 if( nReal < nChgHght )
420 {
421 SwTwips nBot = aRectFnSet.YInc( aRectFnSet.GetBottom(getFrameArea()),
422 nChgHght - nReal );
423 SwFrame* pCont = FindFootnoteFrame()->GetUpper();
424
425 if( aRectFnSet.BottomDist( pCont->getFrameArea(), nBot ) > 0 )
426 {
428 aRectFnSet.AddBottom( aFrm, nChgHght );
429
431
432 if( aRectFnSet.IsVert() )
433 {
434 aPrt.AddWidth(nChgHght );
435 }
436 else
437 {
438 aPrt.AddHeight(nChgHght );
439 }
440
441 return;
442 }
443 }
444 }
445
446 Grow( nChgHght );
447
448 if ( IsInFly() )
449 {
450 // If one of the Upper is a Fly, it's very likely that this fly changes its
451 // position by the Grow. Therefore, my position has to be corrected also or
452 // the check further down is not meaningful.
453 // The predecessors need to be calculated, so that the position can be
454 // calculated correctly.
455 if ( GetPrev() )
456 {
457 SwFrame *pPre = GetUpper()->Lower();
458 do
459 { pPre->Calc(pRenderContext);
460 pPre = pPre->GetNext();
461 } while ( pPre && pPre != this );
462 }
463 const Point aOldPos( getFrameArea().Pos() );
464 MakePos();
465 if ( aOldPos != getFrameArea().Pos() )
466 {
467 InvalidateObjs(false);
468 }
469 }
470 nChgHeight = 0;
471 }
472 // A Grow() is always accepted by the Layout, even if the
473 // FixSize of the surrounding layout frame should not allow it.
474 // We text for this case and correct the values.
475 // The Frame must NOT be shrunk further than its size permits
476 // even in the case of an emergency.
477 SwTwips nRstHeight;
478 if ( IsVertical() )
479 {
480 OSL_ENSURE( ! IsSwapped(),"Swapped frame while calculating nRstHeight" );
481
482 if ( IsVertLR() )
483 nRstHeight = GetUpper()->getFrameArea().Left()
486 - getFrameArea().Left();
487 else
488 nRstHeight = getFrameArea().Left() + getFrameArea().Width() -
490 }
491 else
492 nRstHeight = GetUpper()->getFrameArea().Top()
495 - getFrameArea().Top();
496
497 // We can get a bit of space in table cells, because there could be some
498 // left through a vertical alignment to the top.
499 // Assure that first lower in upper is the current one or is valid.
500 if ( IsInTab() &&
501 ( GetUpper()->Lower() == this ||
503 {
504 tools::Long nAdd = aRectFnSet.YDiff( aRectFnSet.GetTop(GetUpper()->Lower()->getFrameArea()),
505 aRectFnSet.GetPrtTop(*GetUpper()) );
506 OSL_ENSURE( nAdd >= 0, "Ey" );
507 nRstHeight += nAdd;
508 }
509
510 // nRstHeight < 0 means that the TextFrame is located completely outside of its Upper.
511 // This can happen, if it's located within a FlyAtContentFrame, which changed sides by a
512 // Grow(). In such a case, it's wrong to execute the following Grow().
513 // In the case of a bug, we end up with an infinite loop.
514 SwTwips nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
515 SwTwips nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
516
517 if( nRstHeight < nFrameHeight )
518 {
519 // It can be that I have the right size, but the Upper is too small and can get me some room
520 if( ( nRstHeight >= 0 || ( IsInFootnote() && IsInSct() ) ) && !bHasToFit )
521 nRstHeight += GetUpper()->Grow( nFrameHeight - nRstHeight );
522 // In column sections we do not want to get too big or else more areas are created by
523 // GetNextSctLeaf. Instead, we shrink and remember bUndersized, so that FormatWidthCols
524 // can calculate the right column size.
525 if ( nRstHeight < nFrameHeight )
526 {
527 if( bHasToFit || !IsMoveable() ||
528 ( IsInSct() && !FindSctFrame()->MoveAllowed(this) ) )
529 {
530 SetUndersized( true );
531 Shrink( std::min( ( nFrameHeight - nRstHeight), nPrtHeight ) );
532 }
533 else
534 SetUndersized( false );
535 }
536 }
537 else if( nChgHeight )
538 {
539 if( nRstHeight - nFrameHeight < nChgHeight )
540 nChgHeight = nRstHeight - nFrameHeight;
541 if( nChgHeight )
542 Grow( nChgHeight );
543 }
544 }
545 else
546 Shrink( -nChgHght );
547}
548
549css::uno::Sequence< css::style::TabStop > SwTextFrame::GetTabStopInfo( SwTwips CurrentPos )
550{
551 SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this );
552 SwTextFormatter aLine( this, &aInf );
553 SwTextCursor TextCursor( this, &aInf );
554 const Point aCharPos( TextCursor.GetTopLeft() );
555
556 SwTwips nRight = aLine.Right();
557 CurrentPos -= aCharPos.X();
558
559 // get current tab stop information stored in the Frame
560 const SvxTabStop *pTS = aLine.GetLineInfo().GetTabStop( CurrentPos, nRight );
561
562 if( !pTS )
563 {
564 return {};
565 }
566
567 // copy tab stop information into a Sequence, which only contains one element.
568 css::style::TabStop ts;
569 ts.Position = pTS->GetTabPos();
570 ts.DecimalChar = pTS->GetDecimal();
571 ts.FillChar = pTS->GetFill();
572 switch( pTS->GetAdjustment() )
573 {
574 case SvxTabAdjust::Left : ts.Alignment = css::style::TabAlign_LEFT; break;
575 case SvxTabAdjust::Center : ts.Alignment = css::style::TabAlign_CENTER; break;
576 case SvxTabAdjust::Right : ts.Alignment = css::style::TabAlign_RIGHT; break;
577 case SvxTabAdjust::Decimal: ts.Alignment = css::style::TabAlign_DECIMAL; break;
578 case SvxTabAdjust::Default: ts.Alignment = css::style::TabAlign_DEFAULT; break;
579 default: break; // prevent warning
580 }
581
582 return { ts };
583}
584
585// AdjustFollow expects the following situation:
586// The SwTextIter points to the lower end of the Master, the Offset is set in the Follow.
587// nOffset holds the Offset in the text string, from which the Master closes
588// and the Follow starts.
589// If it's 0, the FollowFrame is deleted.
591 const TextFrameIndex nOffset, const TextFrameIndex nEnd,
592 const sal_uInt8 nMode )
593{
594 SwFrameSwapper aSwapper( this, false );
595
596 // We got the rest of the text mass: Delete all Follows
597 // DummyPortions() are a special case.
598 // Special cases are controlled by parameter <nMode>.
599 if( HasFollow() && !(nMode & 1) && nOffset == nEnd )
600 {
601 while( GetFollow() )
602 {
603 if( GetFollow()->IsLocked() )
604 {
605 // this can happen when follow calls pMaster->GetFormatted()
606 SAL_INFO("sw.core", "+SwTextFrame::JoinFrame: Follow is locked." );
607 return;
608 }
610 return;
611
613 {
614 // If a fly frame is anchored to us that has a follow, then don't join the anchor.
615 // First those fly frames have to be joined.
616 return;
617 }
618
619 JoinFrame();
620 }
621
622 return;
623 }
624
625 // Dancing on the volcano: We'll just format the last line quickly
626 // for the QuoVadis stuff.
627 // The Offset can move of course:
628 const TextFrameIndex nNewOfst = (IsInFootnote() && (!GetIndNext() || HasFollow()))
629 ? rLine.FormatQuoVadis(nOffset) : nOffset;
630
631 if( !(nMode & 1) )
632 {
633 // We steal text mass from our Follows
634 // It can happen that we have to join some of them
635 while( GetFollow() && GetFollow()->GetFollow() &&
636 nNewOfst >= GetFollow()->GetFollow()->GetOffset() )
637 {
639 {
640 // A non-last split fly is anchored to us, don't move content from the last frame to
641 // this one and don't join.
642 return;
643 }
644
645 JoinFrame();
646 }
647 }
648
649 // The Offset moved
650 if( GetFollow() )
651 {
652 if ( nMode )
654
655 if ( CalcFollow( nNewOfst ) ) // CalcFollow only at the end, we do a SetOffset there
656 rLine.SetOnceMore( true );
657 }
658}
659
661{
662 OSL_ENSURE( GetFollow(), "+SwTextFrame::JoinFrame: no follow" );
663 SwTextFrame *pFoll = GetFollow();
664
665 SwTextFrame *pNxt = pFoll->GetFollow();
666
667 // All footnotes of the to-be-destroyed Follow are relocated to us
668 TextFrameIndex nStart = pFoll->GetOffset();
669 if ( pFoll->HasFootnote() )
670 {
671 SwFootnoteBossFrame *pFootnoteBoss = nullptr;
672 SwFootnoteBossFrame *pEndBoss = nullptr;
673 SwTextNode const* pNode(nullptr);
674 sw::MergedAttrIter iter(*pFoll);
675 for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
676 {
677 if (RES_TXTATR_FTN == pHt->Which()
678 && nStart <= pFoll->MapModelToView(pNode, pHt->GetStart()))
679 {
680 if (pHt->GetFootnote().IsEndNote())
681 {
682 if (!pEndBoss)
683 pEndBoss = pFoll->FindFootnoteBossFrame();
684 SwFootnoteBossFrame::ChangeFootnoteRef( pFoll, static_cast<const SwTextFootnote*>(pHt), this );
685 }
686 else
687 {
688 if (!pFootnoteBoss)
689 pFootnoteBoss = pFoll->FindFootnoteBossFrame( true );
690 SwFootnoteBossFrame::ChangeFootnoteRef( pFoll, static_cast<const SwTextFootnote*>(pHt), this );
691 }
692 SetFootnote( true );
693 }
694 }
695 }
696
697#ifdef DBG_UTIL
698 else if ( pFoll->isFramePrintAreaValid() ||
699 pFoll->isFrameAreaSizeValid() )
700 {
701 pFoll->CalcFootnoteFlag();
702 OSL_ENSURE( !pFoll->HasFootnote(), "Missing FootnoteFlag." );
703 }
704#endif
705
706 pFoll->MoveFlyInCnt( this, nStart, TextFrameIndex(COMPLETE_STRING) );
707 pFoll->SetFootnote( false );
708 // i#27138
709 // Notify accessibility paragraphs objects about changed CONTENT_FLOWS_FROM/_TO relation.
710 // Relation CONTENT_FLOWS_FROM for current next paragraph will change
711 // and relation CONTENT_FLOWS_TO for current previous paragraph, which
712 // is <this>, will change.
713#if !ENABLE_WASM_STRIP_ACCESSIBILITY
714 {
715 SwViewShell* pViewShell( pFoll->getRootFrame()->GetCurrShell() );
716 if ( pViewShell && pViewShell->GetLayout() &&
717 pViewShell->GetLayout()->IsAnyShellAccessible() )
718 {
719 auto pNext = pFoll->FindNextCnt( true );
721 pNext ? pNext->DynCastTextFrame() : nullptr,
722 this );
723 }
724 }
725#endif
726
727 pFoll->Cut();
728 SetFollow(pNxt);
730 return pNxt;
731}
732
734{
735 SwSwapIfSwapped swap( this );
736
737 // The Paste sends a Modify() to me
738 // I lock myself, so that my data does not disappear
739 TextFrameLockGuard aLock( this );
740 SwTextFrame *const pNew = static_cast<SwTextFrame *>(GetTextNodeFirst()->MakeFrame(this));
741
742 pNew->SetFollow( GetFollow() );
743 SetFollow( pNew );
744
745 pNew->Paste( GetUpper(), GetNext() );
746 // i#27138
747 // notify accessibility paragraphs objects about changed CONTENT_FLOWS_FROM/_TO relation.
748 // Relation CONTENT_FLOWS_FROM for current next paragraph will change
749 // and relation CONTENT_FLOWS_TO for current previous paragraph, which
750 // is <this>, will change.
751#if !ENABLE_WASM_STRIP_ACCESSIBILITY
752 {
753 SwViewShell* pViewShell( pNew->getRootFrame()->GetCurrShell() );
754 if ( pViewShell && pViewShell->GetLayout() &&
755 pViewShell->GetLayout()->IsAnyShellAccessible() )
756 {
757 auto pNext = pNew->FindNextCnt( true );
759 pNext ? pNext->DynCastTextFrame() : nullptr,
760 this );
761 }
762 }
763#endif
764
765 // If footnotes end up in pNew bz our actions, we need
766 // to re-register them
767 if ( HasFootnote() )
768 {
769 SwFootnoteBossFrame *pFootnoteBoss = nullptr;
770 SwFootnoteBossFrame *pEndBoss = nullptr;
771 SwTextNode const* pNode(nullptr);
772 sw::MergedAttrIter iter(*this);
773 for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
774 {
775 if (RES_TXTATR_FTN == pHt->Which()
776 && nTextPos <= MapModelToView(pNode, pHt->GetStart()))
777 {
778 if (pHt->GetFootnote().IsEndNote())
779 {
780 if (!pEndBoss)
781 pEndBoss = FindFootnoteBossFrame();
782 SwFootnoteBossFrame::ChangeFootnoteRef( this, static_cast<const SwTextFootnote*>(pHt), pNew );
783 }
784 else
785 {
786 if (!pFootnoteBoss)
787 pFootnoteBoss = FindFootnoteBossFrame( true );
788 SwFootnoteBossFrame::ChangeFootnoteRef( this, static_cast<const SwTextFootnote*>(pHt), pNew );
789 }
790 pNew->SetFootnote( true );
791 }
792 }
793 }
794
795#ifdef DBG_UTIL
796 else
797 {
798 CalcFootnoteFlag( nTextPos - TextFrameIndex(1) );
799 OSL_ENSURE( !HasFootnote(), "Missing FootnoteFlag." );
800 }
801#endif
802
803 MoveFlyInCnt( pNew, nTextPos, TextFrameIndex(COMPLETE_STRING) );
804
805 // No SetOffset or CalcFollow, because an AdjustFollow follows immediately anyways
806
807 pNew->ManipOfst( nTextPos );
808}
809
811{
812 // We do not need to invalidate our Follow.
813 // We are a Follow, get formatted right away and call
814 // SetOffset() from there
815 mnOffset = nNewOfst;
816 SwParaPortion *pPara = GetPara();
817 if( pPara )
818 {
819 SwCharRange &rReformat = pPara->GetReformat();
820 rReformat.Start() = TextFrameIndex(0);
821 rReformat.Len() = TextFrameIndex(GetText().getLength());
822 pPara->SetDelta(sal_Int32(rReformat.Len()));
823 }
825}
826
828{
829 OSL_ENSURE( ! IsVertical() || ! IsSwapped(), "SwTextFrame::CalcPreps with swapped frame" );
830 SwRectFnSet aRectFnSet(this);
831
832 SwParaPortion *pPara = GetPara();
833 if ( !pPara )
834 return false;
835 const bool bPrep = pPara->IsPrep();
836 const bool bPrepWidows = pPara->IsPrepWidows();
837 const bool bPrepAdjust = pPara->IsPrepAdjust();
838 const bool bPrepMustFit = pPara->IsPrepMustFit();
839 ResetPreps();
840
841 bool bRet = false;
842 if( bPrep && !pPara->GetReformat().Len() )
843 {
844 // PrepareHint::Widows means that the orphans rule got activated in the Follow.
845 // In unfortunate cases we could also have a PrepAdjust!
846 if( bPrepWidows )
847 {
848 if( !GetFollow() )
849 {
850 OSL_ENSURE( GetFollow(), "+SwTextFrame::CalcPreps: no credits" );
851 return false;
852 }
853
854 // We need to prepare for two cases:
855 // We were able to hand over a few lines to the Follow
856 // -> we need to shrink
857 // or we need to go on the next page
858 // -> we let our Frame become too big
859
860 SwTwips nChgHeight = GetParHeight();
861 if( nChgHeight >= aRectFnSet.GetHeight(getFramePrintArea()) )
862 {
863 if( bPrepMustFit )
864 {
865 GetFollow()->SetJustWidow( true );
866 GetFollow()->Prepare();
867 }
868 else if ( aRectFnSet.IsVert() )
869 {
870 {
872 aFrm.Width( aFrm.Width() + aFrm.Left() );
873 aFrm.Left( 0 );
874 }
875
876 {
878 aPrt.Width( aPrt.Width() + getFrameArea().Left() );
879 }
880
881 SetWidow( true );
882 }
883 else
884 {
885 // nTmp should be very large, but not so large as to cause overflow later (e.g.,
886 // GetFrameOfModify in sw/source/core/layout/frmtool.cxx calculates nCurrentDist
887 // from, among others, the square of aDiff.getY(), which can be close to nTmp);
888 // the previously used value TWIPS_MAX/2 (i.e., (LONG_MAX - 1)/2) depended on
889 // the range of 'long', while the value (SAL_MAX_INT32 - 1)/2 (which matches the
890 // old value on platforms where 'long' is 'sal_Int32') is empirically shown to
891 // be large enough in practice even on platforms where 'long' is 'sal_Int64':
892 SwTwips const nTmp = sw::WIDOW_MAGIC - (getFrameArea().Top()+10000);
893 SwTwips nDiff = nTmp - getFrameArea().Height();
894
895 {
897 aFrm.Height( nTmp );
898 }
899
900 {
902 aPrt.Height( aPrt.Height() + nDiff );
903 }
904
905 SetWidow( true );
906 }
907 }
908 else
909 {
910 OSL_ENSURE( nChgHeight < aRectFnSet.GetHeight(getFramePrintArea()),
911 "+SwTextFrame::CalcPrep: want to shrink" );
912
913 nChgHeight = aRectFnSet.GetHeight(getFramePrintArea()) - nChgHeight;
914
915 GetFollow()->SetJustWidow( true );
916 GetFollow()->Prepare();
917 Shrink( nChgHeight );
918 SwRect &rRepaint = pPara->GetRepaint();
919
920 if ( aRectFnSet.IsVert() )
921 {
923 SwitchVerticalToHorizontal( aRepaint );
924 rRepaint.Chg( aRepaint.Pos(), aRepaint.SSize() );
925 }
926 else
928
929 if( 0 >= rRepaint.Width() )
930 rRepaint.Width(1);
931 }
932 bRet = true;
933 }
934 else if ( bPrepAdjust )
935 {
936 if ( HasFootnote() )
937 {
939 {
940 if( bPrepMustFit )
941 {
942 SwTextLineAccess aAccess( this );
943 aAccess.GetPara()->SetPrepMustFit(true);
944 }
945 return false;
946 }
947 }
948
949 {
950 SwSwapIfNotSwapped swap( this );
951
952 SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this );
953 SwTextFormatter aLine( this, &aInf );
954
955 WidowsAndOrphans aFrameBreak( this );
956 // Whatever the attributes say: we split the paragraph in
957 // MustFit case if necessary
958 if( bPrepMustFit )
959 {
960 aFrameBreak.SetKeep( false );
961 aFrameBreak.ClrOrphLines();
962 }
963 // Before calling FormatAdjust, we need to make sure
964 // that the lines protruding at the bottom get indeed
965 // truncated
966 bool bBreak = aFrameBreak.IsBreakNowWidAndOrp( aLine );
967 bRet = true;
968 while( !bBreak && aLine.Next() )
969 {
970 bBreak = aFrameBreak.IsBreakNowWidAndOrp( aLine );
971 }
972 if( bBreak )
973 {
974 // We run into troubles: when TruncLines is called, the
975 // conditions in IsInside change immediately such that
976 // IsBreakNow can return different results.
977 // For this reason, we tell rFrameBreak that the
978 // end is reached at the location of rLine.
979 // Let's see if it works ...
980 aLine.TruncLines();
981 aFrameBreak.SetRstHeight( aLine );
982 FormatAdjust( aLine, aFrameBreak, TextFrameIndex(aInf.GetText().getLength()), aInf.IsStop() );
983 }
984 else
985 {
986 if( !GetFollow() )
987 {
988 FormatAdjust( aLine, aFrameBreak,
989 TextFrameIndex(aInf.GetText().getLength()), aInf.IsStop() );
990 }
991 else if ( !aFrameBreak.IsKeepAlways() )
992 {
993 // We delete a line before the Master, because the Follow
994 // could hand over a line
995 const SwCharRange aFollowRg(GetFollow()->GetOffset(), TextFrameIndex(1));
996 pPara->GetReformat() += aFollowRg;
997 // We should continue!
998 bRet = false;
999 }
1000 }
1001 }
1002
1003 // A final check, if FormatAdjust() didn't help we need to
1004 // truncate
1005 if( bPrepMustFit )
1006 {
1007 const SwTwips nMust = aRectFnSet.GetPrtBottom(*GetUpper());
1008 const SwTwips nIs = aRectFnSet.GetBottom(getFrameArea());
1009
1010 if( aRectFnSet.IsVert() && nIs < nMust )
1011 {
1012 Shrink( nMust - nIs );
1013
1014 if( getFramePrintArea().Width() < 0 )
1015 {
1017 aPrt.Width( 0 );
1018 }
1019
1020 SetUndersized( true );
1021 }
1022 else if ( ! aRectFnSet.IsVert() && nIs > nMust )
1023 {
1024 Shrink( nIs - nMust );
1025
1026 if( getFramePrintArea().Height() < 0 )
1027 {
1029 aPrt.Height( 0 );
1030 }
1031
1032 SetUndersized( true );
1033 }
1034 }
1035 }
1036 }
1037 pPara->SetPrepMustFit( bPrepMustFit );
1038 return bRet;
1039}
1040
1041// Move the as-character objects - footnotes must be moved by RemoveFootnote!
1043{
1044 if( pFrame->GetOffset() < nNew )
1045 pFrame->MoveFlyInCnt( this, TextFrameIndex(0), nNew );
1046 else if( pFrame->GetOffset() > nNew )
1048}
1049
1051 WidowsAndOrphans &rFrameBreak,
1052 TextFrameIndex const nStrLen,
1053 const bool bDummy )
1054{
1055 SwSwapIfNotSwapped swap( this );
1056
1057 SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1058
1059 TextFrameIndex nEnd = rLine.GetStart();
1060
1061 const bool bHasToFit = pPara->IsPrepMustFit();
1062
1063 // The StopFlag is set by footnotes which want to go onto the next page
1064 // Call base class method <SwTextFrameBreak::IsBreakNow(..)>
1065 // instead of method <WidowsAndOrphans::IsBreakNow(..)> to get a break,
1066 // even if due to widow rule no enough lines exists.
1067 sal_uInt8 nNew = ( !GetFollow() &&
1068 nEnd < nStrLen &&
1069 ( rLine.IsStop() ||
1070 ( bHasToFit
1071 ? ( rLine.GetLineNr() > 1 &&
1072 !rFrameBreak.IsInside( rLine ) )
1073 : rFrameBreak.IsBreakNow( rLine ) ) ) )
1074 ? 1 : 0;
1075 // i#84870
1076 // no split of text frame, which only contains an as-character anchored object
1077 bool bOnlyContainsAsCharAnchoredObj =
1078 !IsFollow() && nStrLen == TextFrameIndex(1) &&
1079 GetDrawObjs() && GetDrawObjs()->size() == 1 &&
1080 (*GetDrawObjs())[0]->GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR;
1081
1082 // Still try split text frame if we have columns.
1083 if (FindColFrame())
1084 bOnlyContainsAsCharAnchoredObj = false;
1085
1086 if ( nNew && bOnlyContainsAsCharAnchoredObj )
1087 {
1088 nNew = 0;
1089 }
1090
1091 if ( nNew )
1092 {
1093 SplitFrame( nEnd );
1094 }
1095
1096 const SwFrame *pBodyFrame = FindBodyFrame();
1097
1098 const tools::Long nBodyHeight = pBodyFrame ? ( IsVertical() ?
1099 pBodyFrame->getFrameArea().Width() :
1100 pBodyFrame->getFrameArea().Height() ) : 0;
1101
1102 // If the current values have been calculated, show that they
1103 // are valid now
1104 pPara->GetReformat() = SwCharRange();
1105 bool bDelta = pPara->GetDelta() != 0;
1106 pPara->SetDelta(0);
1107
1108 if( rLine.IsStop() )
1109 {
1110 rLine.TruncLines( true );
1111 nNew = 1;
1112 }
1113
1114 // FindBreak truncates the last line
1115 if( !rFrameBreak.FindBreak( this, rLine, bHasToFit ) )
1116 {
1117 // If we're done formatting, we set nEnd to the end.
1118 // AdjustFollow might execute JoinFrame() because of this.
1119 // Else, nEnd is the end of the last line in the Master.
1120 TextFrameIndex nOld = nEnd;
1121 // Make sure content from the last floating table anchor is not shifted to previous anchors.
1123 {
1124 nEnd = rLine.GetEnd();
1125 }
1126 if( GetFollow() )
1127 {
1128 if( nNew && nOld < nEnd )
1129 RemoveFootnote( nOld, nEnd - nOld );
1130 ChangeOffset( GetFollow(), nEnd );
1131 if( !bDelta )
1132 GetFollow()->ManipOfst( nEnd );
1133 }
1134 }
1135 else
1136 { // If we pass over lines, we must not call Join in Follows, instead we even
1137 // need to create a Follow.
1138 // We also need to do this if the whole mass of text remains in the Master,
1139 // because a hard line break could necessitate another line (without text mass)!
1140 TextFrameIndex const nOld(nEnd);
1141 nEnd = rLine.GetEnd();
1142 if( GetFollow() )
1143 {
1144 // Another case for not joining the follow:
1145 // Text frame has no content, but a numbering. Then, do *not* join.
1146 // Example of this case: When an empty, but numbered paragraph
1147 // at the end of page is completely displaced by a fly frame.
1148 // Thus, the text frame introduced a follow by a
1149 // <SwTextFrame::SplitFrame(..)> - see below. The follow then shows
1150 // the numbering and must stay.
1151 if ( GetFollow()->GetOffset() != nEnd ||
1152 GetFollow()->IsFieldFollow() ||
1153 (nStrLen == TextFrameIndex(0) && GetTextNodeForParaProps()->GetNumRule()))
1154 {
1155 nNew |= 3;
1156 }
1157 else if (FindTabFrame() && nEnd > TextFrameIndex(0) &&
1158 rLine.GetInfo().GetChar(nEnd - TextFrameIndex(1)) == CH_BREAK)
1159 {
1160 // We are in a table, the paragraph has a follow and the text
1161 // ends with a hard line break. Don't join the follow just
1162 // because the follow would have no content, we may still need it
1163 // for the paragraph mark.
1164 nNew |= 1;
1165 }
1166 // move footnotes if the follow is kept - if RemoveFootnote() is
1167 // called in next format iteration, it will be with the *new*
1168 // offset so no effect!
1169 if (nNew && nOld < nEnd)
1170 {
1171 RemoveFootnote(nOld, nEnd - nOld);
1172 }
1173 ChangeOffset( GetFollow(), nEnd );
1174 GetFollow()->ManipOfst( nEnd );
1175 }
1176 else
1177 {
1178 const SwTextNode* pTextNode = GetTextNodeForParaProps();
1179 bool bHasVisibleNumRule = nStrLen == TextFrameIndex(0) && pTextNode->GetNumRule();
1180
1181 if (!pTextNode->HasVisibleNumberingOrBullet())
1182 {
1183 bHasVisibleNumRule = false;
1184 }
1185
1186 // Only split frame, if the frame contains
1187 // content or contains no content, but has a numbering.
1188 // i#84870 - No split, if text frame only contains one
1189 // as-character anchored object.
1190 if ( !bOnlyContainsAsCharAnchoredObj &&
1191 (nStrLen > TextFrameIndex(0) ||
1192 bHasVisibleNumRule )
1193 )
1194 {
1195 SplitFrame( nEnd );
1196 nNew |= 3;
1197 }
1198 }
1199 // If the remaining height changed e.g by RemoveFootnote() we need to
1200 // fill up in order to avoid oscillation.
1201 if( bDummy && pBodyFrame &&
1202 nBodyHeight < ( IsVertical() ?
1203 pBodyFrame->getFrameArea().Width() :
1204 pBodyFrame->getFrameArea().Height() ) )
1205 rLine.MakeDummyLine();
1206 }
1207
1208 // In AdjustFrame() we set ourselves via Grow/Shrink
1209 // In AdjustFollow() we set our FollowFrame
1210
1211 const SwTwips nDocPrtTop = getFrameArea().Top() + getFramePrintArea().Top();
1212 const SwTwips nOldHeight = getFramePrintArea().SSize().Height();
1213 SwTwips nChg = rLine.CalcBottomLine() - nDocPrtTop - nOldHeight;
1214
1215 //#i84870# - no shrink of text frame, if it only contains one as-character anchored object.
1216 if ( nChg < 0 && !bDelta && bOnlyContainsAsCharAnchoredObj )
1217 {
1218 nChg = 0;
1219 }
1220
1221 // Vertical Formatting:
1222 // The (rotated) repaint rectangle's x coordinate refers to the frame.
1223 // If the frame grows (or shirks) the repaint rectangle cannot simply
1224 // be rotated back after formatting, because we use the upper left point
1225 // of the frame for rotation. This point changes when growing/shrinking.
1226
1227 if ( IsVertical() && !IsVertLR() && nChg )
1228 {
1229 SwRect &rRepaint = pPara->GetRepaint();
1230 rRepaint.Left( rRepaint.Left() - nChg );
1231 rRepaint.Width( rRepaint.Width() - nChg );
1232 }
1233
1234 AdjustFrame( nChg, bHasToFit );
1235
1236 if( HasFollow() || IsInFootnote() )
1237 AdjustFollow_( rLine, nEnd, nStrLen, nNew );
1238
1239 pPara->SetPrepMustFit( false );
1240}
1241
1242// bPrev is set whether Reformat.Start() was called because of Prev().
1243// Else, we don't know whether we can limit the repaint or not.
1244bool SwTextFrame::FormatLine( SwTextFormatter &rLine, const bool bPrev )
1245{
1246 OSL_ENSURE( ! IsVertical() || IsSwapped(),
1247 "SwTextFrame::FormatLine( rLine, bPrev) with unswapped frame" );
1248 SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1249 const SwLineLayout *pOldCur = rLine.GetCurr();
1250 const TextFrameIndex nOldLen = pOldCur->GetLen();
1251 const SwTwips nOldAscent = pOldCur->GetAscent();
1252 const SwTwips nOldHeight = pOldCur->Height();
1253 const SwTwips nOldWidth = pOldCur->Width() + pOldCur->GetHangingMargin();
1254 const bool bOldHyph = pOldCur->IsEndHyph();
1255 SwTwips nOldTop = 0;
1256 SwTwips nOldBottom = 0;
1257 if( rLine.GetCurr()->IsClipping() )
1258 rLine.CalcUnclipped( nOldTop, nOldBottom );
1259
1260 TextFrameIndex const nNewStart = rLine.FormatLine( rLine.GetStart() );
1261
1262 OSL_ENSURE( getFrameArea().Pos().Y() + getFramePrintArea().Pos().Y() == rLine.GetFirstPos(),
1263 "SwTextFrame::FormatLine: frame leaves orbit." );
1264 OSL_ENSURE( rLine.GetCurr()->Height(),
1265 "SwTextFrame::FormatLine: line height is zero" );
1266
1267 // The current line break object
1268 const SwLineLayout *pNew = rLine.GetCurr();
1269
1270 bool bUnChg = nOldLen == pNew->GetLen() &&
1271 bOldHyph == pNew->IsEndHyph();
1272 if ( bUnChg && !bPrev )
1273 {
1274 const tools::Long nWidthDiff = nOldWidth > pNew->Width()
1275 ? nOldWidth - pNew->Width()
1276 : pNew->Width() - nOldWidth;
1277
1278 // we only declare a line as unchanged, if its main values have not
1279 // changed and it is not the last line (!paragraph end symbol!)
1280 bUnChg = nOldHeight == pNew->Height() &&
1281 nOldAscent == pNew->GetAscent() &&
1282 nWidthDiff <= SLOPPY_TWIPS &&
1283 pOldCur->GetNext();
1284 }
1285
1286 // Calculate rRepaint
1287 const SwTwips nBottom = rLine.Y() + rLine.GetLineHeight();
1288 SwRepaint &rRepaint = pPara->GetRepaint();
1289 if( bUnChg && rRepaint.Top() == rLine.Y()
1290 && (bPrev || nNewStart <= pPara->GetReformat().Start())
1291 && (nNewStart < TextFrameIndex(GetText().getLength())))
1292 {
1293 rRepaint.Top( nBottom );
1294 rRepaint.Height( 0 );
1295 }
1296 else
1297 {
1298 if( nOldTop )
1299 {
1300 if( nOldTop < rRepaint.Top() )
1301 rRepaint.Top( nOldTop );
1302 if( !rLine.IsUnclipped() || nOldBottom > rRepaint.Bottom() )
1303 {
1304 rRepaint.Bottom( nOldBottom - 1 );
1305 rLine.SetUnclipped( true );
1306 }
1307 }
1308 if( rLine.GetCurr()->IsClipping() && rLine.IsFlyInCntBase() )
1309 {
1310 SwTwips nTmpTop, nTmpBottom;
1311 rLine.CalcUnclipped( nTmpTop, nTmpBottom );
1312 if( nTmpTop < rRepaint.Top() )
1313 rRepaint.Top( nTmpTop );
1314 if( !rLine.IsUnclipped() || nTmpBottom > rRepaint.Bottom() )
1315 {
1316 rRepaint.Bottom( nTmpBottom - 1 );
1317 rLine.SetUnclipped( true );
1318 }
1319 }
1320 else
1321 {
1322 if( !rLine.IsUnclipped() || nBottom > rRepaint.Bottom() )
1323 {
1324 rRepaint.Bottom( nBottom - 1 );
1325 rLine.SetUnclipped( false );
1326 }
1327 }
1328 SwTwips nRght = std::max( nOldWidth, pNew->Width() +
1329 pNew->GetHangingMargin() );
1331 const SwViewOption *pOpt = pSh ? pSh->GetViewOptions() : nullptr;
1332 if( pOpt && (pOpt->IsParagraph() || pOpt->IsLineBreak()) )
1333 nRght += ( std::max( nOldAscent, pNew->GetAscent() ) );
1334 else
1335 nRght += ( std::max( nOldAscent, pNew->GetAscent() ) / 4);
1336 nRght += rLine.GetLeftMargin();
1337 if( rRepaint.GetOffset() || rRepaint.GetRightOfst() < nRght )
1338 rRepaint.SetRightOfst( nRght );
1339
1340 // Finally we enlarge the repaint rectangle if we found an underscore
1341 // within our line. 40 Twips should be enough
1342 const bool bHasUnderscore =
1343 ( rLine.GetInfo().GetUnderScorePos() < nNewStart );
1344 if ( bHasUnderscore || rLine.GetCurr()->HasUnderscore() )
1345 rRepaint.Bottom( rRepaint.Bottom() + 40 );
1346
1347 const_cast<SwLineLayout*>(rLine.GetCurr())->SetUnderscore( bHasUnderscore );
1348 }
1349
1350 // Calculating the good ol' nDelta
1351 const sal_Int32 nDiff = sal_Int32(pNew->GetLen()) - sal_Int32(nOldLen);
1352 pPara->SetDelta(pPara->GetDelta() - nDiff);
1353
1354 // Stop!
1355 if( rLine.IsStop() )
1356 return false;
1357
1358 // Absolutely another line
1359 if( rLine.IsNewLine() )
1360 return true;
1361
1362 // Until the String's end?
1363 if (nNewStart >= TextFrameIndex(GetText().getLength()))
1364 return false;
1365
1366 if( rLine.GetInfo().IsShift() )
1367 return true;
1368
1369 // Reached the Reformat's end?
1370 const TextFrameIndex nEnd = pPara->GetReformat().Start() +
1371 pPara->GetReformat().Len();
1372
1373 if( nNewStart <= nEnd )
1374 return true;
1375
1376 return 0 != pPara->GetDelta();
1377}
1378
1380 const bool bAdjust )
1381{
1382 OSL_ENSURE( ! IsVertical() || IsSwapped(),"SwTextFrame::Format_ with unswapped frame" );
1383
1384 SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1385 rLine.SetUnclipped( false );
1386
1387 const OUString & rString = GetText();
1388 const TextFrameIndex nStrLen(rString.getLength());
1389
1390 SwCharRange &rReformat = pPara->GetReformat();
1391 SwRepaint &rRepaint = pPara->GetRepaint();
1392 std::unique_ptr<SwRepaint> pFreeze;
1393
1394 // Due to performance reasons we set rReformat to COMPLETE_STRING in Init()
1395 // In this case we adjust rReformat
1396 if( rReformat.Len() > nStrLen )
1397 rReformat.Len() = nStrLen;
1398
1399 if( rReformat.Start() + rReformat.Len() > nStrLen )
1400 rReformat.Len() = nStrLen - rReformat.Start();
1401
1402 SwTwips nOldBottom;
1403 if( GetOffset() && !IsFollow() )
1404 {
1405 rLine.Bottom();
1406 nOldBottom = rLine.Y();
1407 rLine.Top();
1408 }
1409 else
1410 nOldBottom = 0;
1411 rLine.CharToLine( rReformat.Start() );
1412
1413 // When inserting or removing a Space, words can be moved out of the edited
1414 // line and into the preceding line, hence the preceding line must be
1415 // formatted as well.
1416 // Optimization: If rReformat starts after the first word of the line,
1417 // this line cannot possibly influence the previous one.
1418 // ...Turns out that unfortunately it can: Text size changes + FlyFrames;
1419 // the feedback can affect multiple lines (Frames!)!
1420
1421 // i#46560
1422 // FME: Yes, consider this case: "(word )" has to go to the next line
1423 // because ")" is a forbidden character at the beginning of a line although
1424 // "(word" would still fit on the previous line. Adding text right in front
1425 // of ")" would not trigger a reformatting of the previous line. Adding 1
1426 // to the result of FindBrk() does not solve the problem in all cases,
1427 // nevertheless it should be sufficient.
1428 bool bPrev = rLine.GetPrev() &&
1429 (FindBrk(rString, rLine.GetStart(), rReformat.Start() + TextFrameIndex(1))
1430 // i#46560
1431 + TextFrameIndex(1)
1432 >= rReformat.Start() ||
1433 rLine.GetCurr()->IsRest() );
1434 if( bPrev )
1435 {
1436 while( rLine.Prev() )
1437 if( rLine.GetCurr()->GetLen() && !rLine.GetCurr()->IsRest() )
1438 {
1439 if( !rLine.GetStart() )
1440 rLine.Top(); // So that NumDone doesn't get confused
1441 break;
1442 }
1443 TextFrameIndex nNew = rLine.GetStart() + rLine.GetLength();
1444 if( nNew )
1445 {
1446 --nNew;
1447 if (CH_BREAK == rString[sal_Int32(nNew)])
1448 {
1449 ++nNew;
1450 rLine.Next();
1451 bPrev = false;
1452 }
1453 }
1454 rReformat.Len() += rReformat.Start() - nNew;
1455 rReformat.Start() = nNew;
1456 }
1457
1458 rRepaint.SetOffset( 0 );
1459 rRepaint.SetRightOfst( 0 );
1460 rRepaint.Chg( getFrameArea().Pos() + getFramePrintArea().Pos(), getFramePrintArea().SSize() );
1461 if( pPara->IsMargin() )
1462 rRepaint.Width( rRepaint.Width() + pPara->GetHangingMargin() );
1463 rRepaint.Top( rLine.Y() );
1464 if( 0 >= rRepaint.Width() )
1465 rRepaint.Width(1);
1466 WidowsAndOrphans aFrameBreak( this, rInf.IsTest() ? 1 : 0 );
1467
1468 // rLine is now set to the first line which needs formatting.
1469 // The bFirst flag makes sure that Next() is not called.
1470 // The whole thing looks weird, but we need to make sure that
1471 // rLine stops at the last non-fitting line when calling IsBreakNow.
1472 bool bFirst = true;
1473 bool bFormat = true;
1474
1475 // The CharToLine() can also get us into the danger zone.
1476 // In that case we need to walk back until rLine is set
1477 // to the non-fitting line. Or else the mass of text is lost,
1478 // because the Ofst was set wrongly in the Follow.
1479
1480 bool bBreak = ( !pPara->IsPrepMustFit() || rLine.GetLineNr() > 1 )
1481 && aFrameBreak.IsBreakNowWidAndOrp( rLine );
1482 if( bBreak )
1483 {
1484 bool bPrevDone = nullptr != rLine.Prev();
1485 while( bPrevDone && aFrameBreak.IsBreakNowWidAndOrp(rLine) )
1486 bPrevDone = nullptr != rLine.Prev();
1487 if( bPrevDone )
1488 {
1489 aFrameBreak.SetKeep( false );
1490 rLine.Next();
1491 }
1492 rLine.TruncLines();
1493
1494 // Play it safe
1495 aFrameBreak.IsBreakNowWidAndOrp(rLine);
1496 }
1497
1498 /* Meaning if the following flags are set:
1499
1500 Watch(End/Mid)Hyph: we need to format if we have a break at
1501 the line end/Fly, as long as MaxHyph is reached
1502
1503 Jump(End/Mid)Flag: the next line which has no break (line end/Fly),
1504 needs to be formatted, because we could wrap now. This might have been
1505 forbidden earlier by MaxHyph
1506
1507 Watch(End/Mid)Hyph: if the last formatted line got a cutoff point, but
1508 didn't have one before
1509
1510 Jump(End/Mid)Hyph: if a cutoff point disappears
1511 */
1512 bool bJumpEndHyph = false;
1513 bool bWatchEndHyph = false;
1514 bool bJumpMidHyph = false;
1515 bool bWatchMidHyph = false;
1516
1517 const SwAttrSet& rAttrSet = GetTextNodeForParaProps()->GetSwAttrSet();
1518 rInf.MaxHyph() = rAttrSet.GetHyphenZone().GetMaxHyphens();
1519 bool bMaxHyph = 0 != rInf.MaxHyph();
1520 if ( bMaxHyph )
1521 rLine.InitCntHyph();
1522
1523 if( IsFollow() && IsFieldFollow() && rLine.GetStart() == GetOffset() )
1524 {
1525 SwTextFrame *pMaster = FindMaster();
1526 OSL_ENSURE( pMaster, "SwTextFrame::Format: homeless follow" );
1527 const SwLineLayout* pLine=nullptr;
1528 if (pMaster)
1529 {
1530 if (!pMaster->HasPara())
1531 { // master could be locked because it's being formatted upstack
1532 SAL_WARN("sw", "SwTextFrame::Format_: master not formatted!");
1533 }
1534 else
1535 {
1536 SwTextSizeInfo aInf( pMaster );
1537 SwTextIter aMasterLine( pMaster, &aInf );
1538 aMasterLine.Bottom();
1539 pLine = aMasterLine.GetCurr();
1540 assert(aMasterLine.GetEnd() == GetOffset());
1541 }
1542 }
1543 SwLinePortion* pRest = pLine ?
1544 rLine.MakeRestPortion(pLine, GetOffset()) : nullptr;
1545 if( pRest )
1546 rInf.SetRest( pRest );
1547 else
1548 SetFieldFollow( false );
1549 }
1550
1551 /* Ad cancel criterion:
1552 * In order to recognize, whether a line does not fit onto the page
1553 * anymore, we need to format it. This overflow is removed again in
1554 * e.g. AdjustFollow.
1555 * Another complication: if we are the Master, we need to traverse
1556 * the lines, because it could happen that one line can overflow
1557 * from the Follow to the Master.
1558 */
1559 do
1560 {
1561 if( bFirst )
1562 bFirst = false;
1563 else
1564 {
1565 if ( bMaxHyph )
1566 {
1567 if ( rLine.GetCurr()->IsEndHyph() )
1568 rLine.CntEndHyph()++;
1569 else
1570 rLine.CntEndHyph() = 0;
1571 if ( rLine.GetCurr()->IsMidHyph() )
1572 rLine.CntMidHyph()++;
1573 else
1574 rLine.CntMidHyph() = 0;
1575 }
1576 if( !rLine.Next() )
1577 {
1578 if( !bFormat )
1579 {
1580 SwLinePortion* pRest =
1581 rLine.MakeRestPortion( rLine.GetCurr(), rLine.GetEnd() );
1582 if( pRest )
1583 rInf.SetRest( pRest );
1584 }
1585 rLine.Insert( new SwLineLayout() );
1586 rLine.Next();
1587 bFormat = true;
1588 }
1589 }
1590 if ( !bFormat && bMaxHyph &&
1591 (bWatchEndHyph || bJumpEndHyph || bWatchMidHyph || bJumpMidHyph) )
1592 {
1593 if ( rLine.GetCurr()->IsEndHyph() )
1594 {
1595 if ( bWatchEndHyph )
1596 bFormat = ( rLine.CntEndHyph() == rInf.MaxHyph() );
1597 }
1598 else
1599 {
1600 bFormat = bJumpEndHyph;
1601 bWatchEndHyph = false;
1602 bJumpEndHyph = false;
1603 }
1604 if ( rLine.GetCurr()->IsMidHyph() )
1605 {
1606 if ( bWatchMidHyph && !bFormat )
1607 bFormat = ( rLine.CntEndHyph() == rInf.MaxHyph() );
1608 }
1609 else
1610 {
1611 bFormat |= bJumpMidHyph;
1612 bWatchMidHyph = false;
1613 bJumpMidHyph = false;
1614 }
1615 }
1616 if( bFormat )
1617 {
1618 const bool bOldEndHyph = rLine.GetCurr()->IsEndHyph();
1619 const bool bOldMidHyph = rLine.GetCurr()->IsMidHyph();
1620 bFormat = FormatLine( rLine, bPrev );
1621 // There can only be one bPrev ... (???)
1622 bPrev = false;
1623 if ( bMaxHyph )
1624 {
1625 if ( rLine.GetCurr()->IsEndHyph() != bOldEndHyph )
1626 {
1627 bWatchEndHyph = !bOldEndHyph;
1628 bJumpEndHyph = bOldEndHyph;
1629 }
1630 if ( rLine.GetCurr()->IsMidHyph() != bOldMidHyph )
1631 {
1632 bWatchMidHyph = !bOldMidHyph;
1633 bJumpMidHyph = bOldMidHyph;
1634 }
1635 }
1636 }
1637
1638 if( !rInf.IsNewLine() )
1639 {
1640 if( !bFormat )
1641 bFormat = nullptr != rInf.GetRest();
1642 if( rInf.IsStop() || rInf.GetIdx() >= nStrLen )
1643 break;
1644 if( !bFormat && ( !bMaxHyph || ( !bWatchEndHyph &&
1645 !bJumpEndHyph && !bWatchMidHyph && !bJumpMidHyph ) ) )
1646 {
1647 if( GetFollow() )
1648 {
1649 while( rLine.Next() )
1650 ; //Nothing
1651 pFreeze.reset(new SwRepaint( rRepaint )); // to minimize painting
1652 }
1653 else
1654 break;
1655 }
1656 }
1657 bBreak = aFrameBreak.IsBreakNowWidAndOrp(rLine);
1658 }while( !bBreak );
1659
1660 if( pFreeze )
1661 {
1662 rRepaint = *pFreeze;
1663 pFreeze.reset();
1664 }
1665
1666 if( !rLine.IsStop() )
1667 {
1668 // If we're finished formatting the text and we still
1669 // have other line objects left, these are superfluous
1670 // now because the text has gotten shorter.
1671 bool bTruncLines = false;
1672 if( rLine.GetStart() + rLine.GetLength() >= nStrLen &&
1673 rLine.GetCurr()->GetNext() )
1674 {
1675 bTruncLines = true;
1676 }
1677 else if (GetMergedPara() && rLine.GetCurr()->GetNext())
1678 {
1679 // We can also have superfluous lines with redlining in case the current line is shorter
1680 // than the text length, but the total length of lines is still more than expected.
1681 // Truncate in this case as well.
1682 TextFrameIndex nLen(0);
1683 for (const SwLineLayout* pLine = pPara; pLine; pLine = pLine->GetNext())
1684 {
1685 nLen += pLine->GetLen();
1686 }
1687 bTruncLines = nLen > nStrLen;
1688 }
1689
1690 if (bTruncLines)
1691 {
1692 rLine.TruncLines();
1693 rLine.SetTruncLines( true );
1694 }
1695 }
1696
1697 if( rInf.IsTest() )
1698 return;
1699
1700 // FormatAdjust does not pay off at OnceMore
1701 if( bAdjust || !rLine.GetDropFormat() || !rLine.CalcOnceMore() )
1702 {
1703 FormatAdjust( rLine, aFrameBreak, nStrLen, rInf.IsStop() );
1704 }
1705 if( rRepaint.HasArea() )
1706 SetRepaint();
1707 rLine.SetTruncLines( false );
1708 if( nOldBottom ) // We check whether paragraphs that need scrolling can
1709 // be shrunk, so that they don't need scrolling anymore
1710 {
1711 rLine.Bottom();
1712 SwTwips nNewBottom = rLine.Y();
1713 if( nNewBottom < nOldBottom )
1715 }
1716}
1717
1719{
1720 OSL_ENSURE( ! IsVertical() || IsSwapped(),
1721 "A frame is not swapped in SwTextFrame::FormatOnceMore" );
1722
1723 SwParaPortion *pPara = rLine.GetInfo().GetParaPortion();
1724 if( !pPara )
1725 return;
1726
1727 // If necessary the pPara
1728 sal_uInt16 nOld = static_cast<const SwTextMargin&>(rLine).GetDropHeight();
1729 bool bShrink = false;
1730 bool bGrow = false;
1731 bool bGoOn = rLine.IsOnceMore();
1732 sal_uInt8 nGo = 0;
1733 while( bGoOn )
1734 {
1735 ++nGo;
1736 rInf.Init();
1737 rLine.Top();
1738 if( !rLine.GetDropFormat() )
1739 rLine.SetOnceMore( false );
1740 SwCharRange aRange(TextFrameIndex(0), TextFrameIndex(rInf.GetText().getLength()));
1741 pPara->GetReformat() = aRange;
1742 Format_( rLine, rInf );
1743
1744 bGoOn = rLine.IsOnceMore();
1745 if( bGoOn )
1746 {
1747 const sal_uInt16 nNew = static_cast<const SwTextMargin&>(rLine).GetDropHeight();
1748 if( nOld == nNew )
1749 bGoOn = false;
1750 else
1751 {
1752 if( nOld > nNew )
1753 bShrink = true;
1754 else
1755 bGrow = true;
1756
1757 if( bShrink == bGrow || 5 < nGo )
1758 bGoOn = false;
1759
1760 nOld = nNew;
1761 }
1762
1763 // If something went wrong, we need to reformat again
1764 if( !bGoOn )
1765 {
1767 rLine.CtorInitTextFormatter( this, &rInf );
1768 rLine.SetDropLines( 1 );
1769 rLine.CalcDropHeight( 1 );
1770 SwCharRange aTmpRange(TextFrameIndex(0), TextFrameIndex(rInf.GetText().getLength()));
1771 pPara->GetReformat() = aTmpRange;
1772 Format_( rLine, rInf, true );
1773 // We paint everything ...
1775 }
1776 }
1777 }
1778}
1779
1781 std::vector<SwAnchoredObject *> & rIntersectingObjs)
1782{
1783 const bool bIsEmpty = GetText().isEmpty();
1784
1785 if ( bIsEmpty )
1786 {
1787 // Empty lines do not get tortured for very long:
1788 // pPara is cleared, which is the same as:
1789 // *pPara = SwParaPortion;
1790 const bool bMustFit = pPara->IsPrepMustFit();
1791 pPara->Truncate();
1792 pPara->FormatReset();
1793
1794 // delete pSpaceAdd and pKanaComp
1795 pPara->FinishSpaceAdd();
1796 pPara->FinishKanaComp();
1797 pPara->ResetFlags();
1798 pPara->SetPrepMustFit( bMustFit );
1799 }
1800
1801 OSL_ENSURE( ! IsSwapped(), "A frame is swapped before Format_" );
1802
1803 if ( IsVertical() )
1805
1806 SwTextFormatInfo aInf( pRenderContext, this );
1807 SwTextFormatter aLine( this, &aInf );
1808
1810
1811 Format_( aLine, aInf );
1812
1813 if( aLine.IsOnceMore() )
1814 FormatOnceMore( aLine, aInf );
1815
1816 if (aInf.GetTextFly().IsOn())
1817 {
1818 SwRect const aRect(aInf.GetTextFly().GetFrameArea());
1819 for (SwAnchoredObject *const pObj : *aInf.GetTextFly().GetAnchoredObjList())
1820 {
1821 if (!aInf.GetTextFly().AnchoredObjToRect(pObj, aRect).IsEmpty())
1822 {
1823 rIntersectingObjs.push_back(pObj);
1824 }
1825 }
1826 }
1827
1828 if ( IsVertical() )
1830
1831 OSL_ENSURE( ! IsSwapped(), "A frame is swapped after Format_" );
1832
1833 if( 1 >= aLine.GetDropLines() )
1834 return;
1835
1836 if( SvxAdjust::Left != aLine.GetAdjust() &&
1837 SvxAdjust::Block != aLine.GetAdjust() )
1838 {
1839 aLine.CalcDropAdjust();
1840 aLine.SetPaintDrop( true );
1841 }
1842
1843 if( aLine.IsPaintDrop() )
1844 {
1845 aLine.CalcDropRepaint();
1846 aLine.SetPaintDrop( false );
1847 }
1848}
1849
1850// We calculate the text frame's size and send a notification.
1851// Shrink() or Grow() to adjust the frame's size to the changed required space.
1853{
1854 SwRectFnSet aRectFnSet(this);
1855
1857
1858 // The range autopilot or the BASIC interface pass us TextFrames with
1859 // a width <= 0 from time to time
1860 if( aRectFnSet.GetWidth(getFramePrintArea()) <= 0 )
1861 {
1862 // If MustFit is set, we shrink to the Upper's bottom edge if needed.
1863 SwTextLineAccess aAccess( this );
1864
1865 if( aAccess.GetPara()->IsPrepMustFit() )
1866 {
1867 const SwTwips nLimit = aRectFnSet.GetPrtBottom(*GetUpper());
1868 const SwTwips nDiff = - aRectFnSet.BottomDist( getFrameArea(), nLimit );
1869 if( nDiff > 0 )
1870 Shrink( nDiff );
1871 }
1872
1873 tools::Long nFrameHeight = aRectFnSet.GetHeight(getFrameArea());
1874 const tools::Long nTop = aRectFnSet.GetTopMargin(*this);
1875
1876 if( nTop > nFrameHeight )
1877 {
1878 aRectFnSet.SetYMargins( *this, nFrameHeight, 0 );
1879 }
1880 else if( aRectFnSet.GetHeight(getFramePrintArea()) < 0 )
1881 {
1883 aRectFnSet.SetHeight( aPrt, 0 );
1884 }
1885
1886 return;
1887 }
1888
1889 TextFrameIndex nStrLen(GetText().getLength());
1890
1892 {
1893 // Non-last part of split fly anchor: consider this empty.
1894 nStrLen = TextFrameIndex(0);
1895 }
1896
1897 if ( nStrLen || !FormatEmpty() )
1898 {
1899
1900 SetEmpty( false );
1901 // In order to not get confused by nested Formats
1902 FormatLevel aLevel;
1903 if( 12 == FormatLevel::GetLevel() )
1904 return;
1905
1906 // We could be possibly not allowed to alter the format information
1907 if( IsLocked() )
1908 return;
1909
1910 // Attention: Format() could be triggered by GetFormatted()
1911 if( IsHiddenNow() )
1912 {
1913 tools::Long nPrtHeight = aRectFnSet.GetHeight(getFramePrintArea());
1914 if( nPrtHeight )
1915 {
1916 HideHidden();
1917 Shrink( nPrtHeight );
1918 }
1919 else
1920 {
1921 // Assure that objects anchored
1922 // at paragraph resp. at/as character inside paragraph
1923 // are hidden.
1925 }
1926 ChgThisLines();
1927 return;
1928 }
1929
1930 // We do not want to be interrupted during formatting
1931 TextFrameLockGuard aLock(this);
1932
1933 // this is to ensure that the similar code in SwTextFrame::Format_
1934 // finds the master formatted in case it's needed
1935 if (IsFollow() && IsFieldFollow())
1936 {
1937 SwTextFrame *pMaster = FindMaster();
1938 assert(pMaster);
1939 if (!pMaster->HasPara())
1940 {
1941 pMaster->GetFormatted();
1942 }
1943 if (!pMaster->HasPara())
1944 { // master could be locked because it's being formatted upstack
1945 SAL_WARN("sw", "SwTextFrame::Format: failed to format master!");
1946 }
1947 else
1948 {
1949 SwTextSizeInfo aInf( pMaster );
1950 SwTextIter aMasterLine( pMaster, &aInf );
1951 aMasterLine.Bottom();
1952 SetOffset(aMasterLine.GetEnd());
1953 }
1954 }
1955
1956 SwTextLineAccess aAccess( this );
1957 const bool bNew = !aAccess.IsAvailable();
1958 const bool bSetOffset =
1960
1961 if( CalcPreps() )
1962 ; // nothing
1963 // We return if already formatted, but if the TextFrame was just created
1964 // and does not have any format information
1965 else if( !bNew && !aAccess.GetPara()->GetReformat().Len() )
1966 {
1968 {
1969 aAccess.GetPara()->SetPrepAdjust();
1970 aAccess.GetPara()->SetPrep();
1971 CalcPreps();
1972 }
1973 SetWidow( false );
1974 }
1975 else if( bSetOffset && IsFollow() )
1976 {
1977 SwTextFrame *pMaster = FindMaster();
1978 OSL_ENSURE( pMaster, "SwTextFrame::Format: homeless follow" );
1979 if( pMaster )
1981 SwTwips nMaxY = aRectFnSet.GetPrtBottom(*GetUpper());
1982
1983 if( aRectFnSet.OverStep( getFrameArea(), nMaxY ) )
1984 {
1985 aRectFnSet.SetLimit( *this, nMaxY );
1986 }
1987 else if( aRectFnSet.BottomDist( getFrameArea(), nMaxY ) < 0 )
1988 {
1990 aRectFnSet.AddBottom( aFrm, -aRectFnSet.GetHeight(aFrm) );
1991 }
1992 }
1993 else
1994 {
1995 // bSetOffset here means that we have the "red arrow situation"
1996 if ( bSetOffset )
1998
1999 const bool bOrphan = IsWidow();
2000 const SwFootnoteBossFrame* pFootnoteBoss = HasFootnote() ? FindFootnoteBossFrame() : nullptr;
2001 SwTwips nFootnoteHeight = 0;
2002 if( pFootnoteBoss )
2003 {
2004 const SwFootnoteContFrame* pCont = pFootnoteBoss->FindFootnoteCont();
2005 nFootnoteHeight = pCont ? aRectFnSet.GetHeight(pCont->getFrameArea()) : 0;
2006 }
2007 do
2008 {
2009 ::std::vector<SwAnchoredObject *> intersectingObjs;
2010 ::std::vector<SwFrame const*> nexts;
2011 for (SwFrame const* pNext = GetNext(); pNext; pNext = pNext->GetNext())
2012 {
2013 nexts.push_back(pNext);
2014 }
2015 FormatImpl(pRenderContext, aAccess.GetPara(), intersectingObjs);
2016 if( pFootnoteBoss && nFootnoteHeight )
2017 {
2018 const SwFootnoteContFrame* pCont = pFootnoteBoss->FindFootnoteCont();
2019 SwTwips nNewHeight = pCont ? aRectFnSet.GetHeight(pCont->getFrameArea()) : 0;
2020 // If we lost some footnotes, we may have more space
2021 // for our main text, so we have to format again ...
2022 if( nNewHeight < nFootnoteHeight )
2023 {
2024 nFootnoteHeight = nNewHeight;
2025 continue;
2026 }
2027 }
2028 if (!intersectingObjs.empty())
2029 {
2030 // assumption is that FormatImpl() only moves frames
2031 // in the next-chain to next page
2032 SwPageFrame *const pPage(FindPageFrame());
2033 SwTextFrame * pLastMovedAnchor(nullptr);
2034 auto lastIter(nexts.end());
2035 for (SwAnchoredObject *const pObj : intersectingObjs)
2036 {
2037 SwFrame *const pAnchor(pObj->AnchorFrame());
2038 SwPageFrame *const pAnchorPage(pAnchor->FindPageFrame());
2039 if (pAnchorPage != pPage)
2040 {
2041 auto const iter(::std::find(nexts.begin(), nexts.end(), pAnchor));
2042 if (iter != nexts.end())
2043 {
2044 assert(pAnchor->IsTextFrame());
2045 // (can't check SwOszControl::IsInProgress()?)
2046 // called in loop in FormatAnchorFrameAndItsPrevs()
2047 if (static_cast<SwTextFrame const*>(pAnchor)->IsJoinLocked()
2048 // called in loop in SwFrame::PrepareMake()
2049 || pAnchor->IsDeleteForbidden())
2050 {
2051 // when called via FormatAnchorFrameAndItsPrevs():
2052 // don't do anything, caller will handle it
2053 pLastMovedAnchor = nullptr;
2054 break;
2055 }
2056 assert(pPage->GetPhyPageNum() < pAnchorPage->GetPhyPageNum()); // how could it move backward?
2057
2058 if (!pLastMovedAnchor || iter < lastIter)
2059 {
2060 pLastMovedAnchor = static_cast<SwTextFrame *>(pAnchor);
2061 lastIter = iter;
2062 }
2063 }
2064 }
2065 }
2066 SwPageFrame const*const pPrevPage(static_cast<SwPageFrame const*>(pPage->GetPrev()));
2067 if (pLastMovedAnchor)
2068 {
2069 for (SwAnchoredObject *const pObj : intersectingObjs)
2070 {
2071 if (pObj->AnchorFrame() == pLastMovedAnchor)
2072 {
2073 SwPageFrame *const pAnchorPage(pLastMovedAnchor->FindPageFrame());
2074 SAL_INFO("sw.layout", "SwTextFrame::Format: move anchored " << pObj << " from " << pPage->GetPhyPageNum() << " to " << pAnchorPage->GetPhyPageNum());
2075 pObj->RegisterAtPage(*pAnchorPage);
2076 // tdf#143239 if the position remains valid, it may not be
2077 // positioned again so would remain on the wrong page!
2078 pObj->InvalidateObjPos();
2079 ::Notify_Background(pObj->GetDrawObj(), pPage,
2080 pObj->GetObjRect(), PrepareHint::FlyFrameLeave, false);
2081 pObj->SetForceNotifyNewBackground(true);
2082 }
2083 }
2084 if (GetFollow() // this frame was split
2085 && (!pPrevPage // prev page is still valid
2086 || (!pPrevPage->IsInvalid()
2087 && (!pPrevPage->GetSortedObjs() || !pPrevPage->IsInvalidFly()))))
2088 { // this seems a bit risky...
2090 *pLastMovedAnchor, FindPageFrame()->GetPhyPageNum() + 1);
2091 }
2092 continue; // try again without the fly
2093 }
2094 }
2095 break;
2096 } while ( pFootnoteBoss );
2097 if( bOrphan )
2098 {
2099 ValidateFrame();
2100 SetWidow( false );
2101 }
2102 }
2103 if( IsEmptyMaster() )
2104 {
2105 SwFrame* pPre = GetPrev();
2106 if( pPre &&
2107 // i#10826 It's the first, it cannot keep!
2108 pPre->GetIndPrev() &&
2109 pPre->GetAttrSet()->GetKeep().GetValue() )
2110 {
2111 pPre->InvalidatePos();
2112 }
2113 }
2114 }
2115
2116 ChgThisLines();
2117
2118 // the PrepMustFit should not survive a Format operation
2119 SwParaPortion *pPara = GetPara();
2120 if ( pPara )
2121 pPara->SetPrepMustFit( false );
2122
2124 CalcHeightOfLastLine(); // i#11860 - Adjust spacing implementation for
2125 // object positioning - Compatibility to MS Word
2126 // tdf#117982 -- Fix cell spacing hides content
2127 // Check if the cell's content has greater size than the row height
2129 || (getFramePrintArea().Height() <= 0)))
2130 {
2131 SAL_INFO("sw.core", "Warn: Cell content has greater size than cell height!");
2132 //get font size...
2133 SwTwips aTmpHeight = getFrameArea().Height();
2134 //...and push it into the text frame
2136 //if only bottom margin what we have:
2137 if (GetTopMargin() == 0)
2138 //set the frame to its original location
2139 aPrt.SetTopAndHeight(0, aTmpHeight);
2140 }
2141}
2142
2143// bForceQuickFormat is set if GetFormatted() has been called during the
2144// painting process. Actually I cannot imagine a situation which requires
2145// a full formatting of the paragraph during painting, on the other hand
2146// a full formatting can cause the invalidation of other layout frames,
2147// e.g., if there are footnotes in this paragraph, and invalid layout
2148// frames will not calculated during the painting. So I actually want to
2149// avoid a formatting during painting, but since I'm a coward, I'll only
2150// force the quick formatting in the situation of issue i29062.
2151bool SwTextFrame::FormatQuick( bool bForceQuickFormat )
2152{
2153 OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
2154 "SwTextFrame::FormatQuick with swapped frame" );
2155
2156 if( IsEmpty() && FormatEmpty() )
2157 return true;
2158
2159 // We're very picky:
2160 if( HasPara() || IsWidow() || IsLocked()
2161 || !isFrameAreaSizeValid() ||
2163 return false;
2164
2165 SwTextLineAccess aAccess( this );
2166 SwParaPortion *pPara = aAccess.GetPara();
2167 if( !pPara )
2168 return false;
2169
2170 SwFrameSwapper aSwapper( this, true );
2171
2172 TextFrameLockGuard aLock(this);
2173 SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this, false, true );
2174 if( 0 != aInf.MaxHyph() ) // Respect MaxHyphen!
2175 return false;
2176
2177 SwTextFormatter aLine( this, &aInf );
2178
2179 // DropCaps are too complicated ...
2180 if( aLine.GetDropFormat() )
2181 return false;
2182
2183 TextFrameIndex nStart = GetOffset();
2184 const TextFrameIndex nEnd = GetFollow()
2185 ? GetFollow()->GetOffset()
2186 : TextFrameIndex(aInf.GetText().getLength());
2187
2188 int nLoopProtection = 0;
2189 do
2190 {
2191 TextFrameIndex nNewStart = aLine.FormatLine(nStart);
2192 if (nNewStart == nStart)
2193 ++nLoopProtection;
2194 else
2195 nLoopProtection = 0;
2196 nStart = nNewStart;
2197 const bool bWillEndlessInsert = nLoopProtection > 250;
2198 SAL_WARN_IF(bWillEndlessInsert, "sw", "loop detection triggered");
2199 if ((!bWillEndlessInsert) // Check for special case: line is invisible,
2200 // like in too thin table cell: tdf#66141
2201 && (aInf.IsNewLine() || (!aInf.IsStop() && nStart < nEnd)))
2202 aLine.Insert( new SwLineLayout() );
2203 } while( aLine.Next() );
2204
2205 // Last exit: the heights need to match
2206 Point aTopLeft( getFrameArea().Pos() );
2207 aTopLeft += getFramePrintArea().Pos();
2208 const SwTwips nNewHeight = aLine.Y() + aLine.GetLineHeight();
2209 const SwTwips nOldHeight = aTopLeft.Y() + getFramePrintArea().Height();
2210
2211 if( !bForceQuickFormat && nNewHeight != nOldHeight && !IsUndersized() )
2212 {
2213 // Attention: This situation can occur due to FormatLevel==12. Don't panic!
2214 TextFrameIndex const nStrt = GetOffset();
2215 InvalidateRange_( SwCharRange( nStrt, nEnd - nStrt) );
2216 return false;
2217 }
2218
2219 if (m_pFollow && nStart != static_cast<SwTextFrame*>(m_pFollow)->GetOffset())
2220 return false; // can be caused by e.g. Orphans
2221
2222 // We made it!
2223
2224 // Set repaint
2225 pPara->GetRepaint().Pos( aTopLeft );
2226 pPara->GetRepaint().SSize( getFramePrintArea().SSize() );
2227
2228 // Delete reformat
2229 pPara->GetReformat() = SwCharRange();
2230 pPara->SetDelta(0);
2231
2232 return true;
2233}
2234
2235/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
virtual const SwRedlineTable & GetRedlineTable() const =0
bool GetValue() const
sal_uInt8 & GetMaxHyphens()
sal_Unicode & GetFill()
sal_Int32 & GetTabPos()
sal_Unicode & GetDecimal()
SvxTabAdjust & GetAdjustment()
wrapper class for the positioning of Writer fly frames and drawing objects
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:68
const SvxHyphenZoneItem & GetHyphenZone(bool=true) const
Definition: paratr.hxx:215
const SwRegisterItem & GetRegister(bool=true) const
Definition: paratr.hxx:207
TextFrameIndex & Len()
Definition: porlay.hxx:49
TextFrameIndex & Start()
Definition: porlay.hxx:45
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:59
virtual void Cut() override
Definition: wsfrm.cxx:1141
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1038
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:738
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:765
static void ChangeFootnoteRef(const SwContentFrame *pOld, const SwTextFootnote *, SwContentFrame *pNew)
Definition: ftnfrm.cxx:1764
SwFootnoteContFrame * FindFootnoteCont()
Definition: ftnfrm.cxx:1038
const SwRect & getFrameArea() const
Definition: frame.hxx:179
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:171
const SwRect & getFramePrintArea() const
Definition: frame.hxx:180
bool isFramePrintAreaValid() const
Definition: frame.hxx:168
bool isFrameAreaSizeValid() const
Definition: frame.hxx:167
void setFrameAreaSizeValid(bool bNew)
Definition: wsfrm.cxx:94
Helper class which can be used instead of the macros if a function has too many returns.
Definition: txtfrm.hxx:943
Base class of the Writer layout elements.
Definition: frame.hxx:315
SwTwips Grow(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1515
bool IsCellFrame() const
Definition: frame.hxx:1232
const SwBodyFrame * FindBodyFrame() const
Definition: frame.hxx:1126
bool IsTextFrame() const
Definition: frame.hxx:1240
SwFrame * GetIndPrev() const
Definition: frame.hxx:730
SwTwips Shrink(SwTwips, bool bTst=false, bool bInfo=false)
Definition: wsfrm.cxx:1559
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1121
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1105
SwFrame * GetNext()
Definition: frame.hxx:682
bool IsPageFrame() const
Definition: frame.hxx:1184
bool IsColLocked() const
Definition: frame.hxx:892
bool IsColumnFrame() const
Definition: frame.hxx:1188
bool IsInFootnote() const
Definition: frame.hxx:955
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1799
void InvalidateObjs(const bool _bNoInvaOfAsCharAnchoredObjs=true)
Definition: fly.cxx:2574
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:568
bool IsInTab() const
Definition: frame.hxx:961
virtual void MakePos()
Calculates the frame area position, in case it's invalid.
Definition: calcmove.cxx:526
bool IsRightToLeft() const
Definition: frame.hxx:993
bool IsInFly() const
Definition: frame.hxx:967
virtual bool IsDeleteForbidden() const
Definition: frame.hxx:893
const SwAttrSet * GetAttrSet() const
WARNING: this may not return correct RES_PAGEDESC/RES_BREAK items for SwTextFrame,...
Definition: findfrm.cxx:762
bool IsMoveable(const SwLayoutFrame *_pLayoutFrame=nullptr) const
determine, if frame is moveable in given environment
Definition: findfrm.cxx:1447
void InvalidatePos()
Definition: frame.hxx:1049
SwLayoutFrame * GetUpper()
Definition: frame.hxx:684
bool IsVertical() const
Definition: frame.hxx:979
SwRootFrame * getRootFrame()
Definition: frame.hxx:685
void SetCompletePaint() const
Definition: frame.hxx:1000
bool IsFlyFrame() const
Definition: frame.hxx:1216
friend void ValidateText(SwFrame *pFrame)
Definition: frmform.cxx:75
SwFrame * GetPrev()
Definition: frame.hxx:683
SwFrame * FindColFrame()
Definition: findfrm.cxx:615
bool IsSctFrame() const
Definition: frame.hxx:1220
bool IsVertLR() const
Definition: frame.hxx:985
void InvalidateSize()
Definition: frame.hxx:1035
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:217
SwPageFrame * FindPageFrame()
Definition: frame.hxx:686
SwFootnoteFrame * FindFootnoteFrame()
Definition: frame.hxx:1113
SwFrame * GetIndNext()
Definition: frame.hxx:733
SwFootnoteBossFrame * FindFootnoteBossFrame(bool bFootnotes=false)
Definition: findfrm.cxx:491
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1706
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Definition: ssfrm.cxx:390
tools::Long GetTopMargin() const
Definition: ssfrm.cxx:44
bool IsBodyFrame() const
Definition: frame.hxx:1212
bool IsInSct() const
Definition: frame.hxx:973
bool IsAnLower(const SwFrame *) const
Definition: findfrm.cxx:233
const SwFrame * Lower() const
Definition: layfrm.hxx:101
static void InsertMovedFwdFrame(const SwDoc &_rDoc, const SwTextFrame &_rMovedFwdFrameByObjPos, const sal_uInt32 _nToPageNum)
Definition: layouter.cxx:308
const SvxTabStop * GetTabStop(const SwTwips nSearchPos, SwTwips &nRight) const
#i24363# tab stops relative to indent
Definition: txttab.cxx:43
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:79
bool IsRest() const
Definition: porlay.hxx:129
void FinishSpaceAdd()
Definition: porlay.hxx:186
SwLineLayout * GetNext()
Definition: porlay.hxx:159
void ResetFlags()
Definition: porlay.cxx:831
void FinishKanaComp()
Definition: porlay.hxx:201
virtual void Height(const SwTwips nNew, const bool bText=true) override
Definition: porlay.cxx:239
bool IsMidHyph() const
Definition: porlay.hxx:125
SwTwips GetHangingMargin() const
Definition: porlay.hxx:176
bool IsClipping() const
Definition: porlay.hxx:154
bool HasUnderscore() const
Definition: porlay.hxx:147
bool IsEndHyph() const
Definition: porlay.hxx:123
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:52
TextFrameIndex GetLen() const
Definition: porlin.hxx:77
void Truncate()
Definition: porlin.hxx:214
SwTwips & GetAscent()
Definition: porlin.hxx:80
const IDocumentRedlineAccess & getIDocumentRedlineAccess() const
Provides access to the document redline interface.
Definition: node.cxx:2140
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
SwNodeOffset GetIndex() const
Definition: node.hxx:312
const SwPosition * GetMark() const
Definition: pam.hxx:255
const SwPosition * End() const
Definition: pam.hxx:263
const SwPosition * GetPoint() const
Definition: pam.hxx:253
A page of the document layout.
Definition: pagefrm.hxx:59
void ValidateContent() const
Definition: pagefrm.hxx:420
bool IsInvalid() const
Definition: pagefrm.hxx:442
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:205
const SwSortedObjs * GetSortedObjs() const
Definition: pagefrm.hxx:133
bool IsInvalidContent() const
Definition: pagefrm.hxx:236
bool IsInvalidFly() const
Definition: pagefrm.hxx:446
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
Definition: porlay.hxx:251
bool IsMargin() const
Definition: porlay.hxx:321
bool IsPrepMustFit() const
Definition: porlay.hxx:310
bool IsPrepWidows() const
Definition: porlay.hxx:308
bool IsPrepAdjust() const
Definition: porlay.hxx:312
bool IsPrep() const
Definition: porlay.hxx:306
SwCharRange & GetReformat()
Definition: porlay.hxx:287
void FormatReset()
Definition: porlay.hxx:340
void SetDelta(tools::Long nDelta)
Definition: porlay.hxx:289
void SetPrepAdjust()
Definition: porlay.hxx:311
void SetPrep()
Definition: porlay.hxx:305
bool IsFollowField() const
Definition: porlay.hxx:314
void SetPrepMustFit(const bool bNew)
Definition: porlay.hxx:309
SwRepaint & GetRepaint()
Definition: porlay.hxx:285
tools::Long GetDelta() const
Definition: porlay.hxx:290
SwTwips Width() const
Definition: possiz.hxx:51
void MaybeNotifyRedlinePositionModification(tools::Long nTop)
Definition: docredln.cxx:1236
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1975
bool IsVert() const
Definition: frame.hxx:1372
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1387
tools::Long YInc(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1430
tools::Long GetTopMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1408
tools::Long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1386
void SetYMargins(SwFrame &rFrame, tools::Long nTop, tools::Long nBottom) const
Definition: frame.hxx:1413
void SetHeight(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1396
tools::Long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1382
void SetLimit(SwFrame &rFrame, tools::Long nNew) const
Definition: frame.hxx:1422
void AddBottom(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1399
bool OverStep(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1423
tools::Long YDiff(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1428
tools::Long GetPrtTop(const SwFrame &rFrame) const
Definition: frame.hxx:1414
tools::Long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1383
tools::Long BottomDist(const SwRect &rRect, tools::Long nPos) const
Definition: frame.hxx:1419
tools::Long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1415
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Chg(const Point &rNP, const Size &rNS)
Definition: swrect.hxx:166
void Height(tools::Long nNew)
Definition: swrect.hxx:193
bool IsEmpty() const
Definition: swrect.hxx:304
bool HasArea() const
Definition: swrect.hxx:300
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void SetTopAndHeight(tools::Long nTop, tools::Long nNew)
Definition: swrect.cxx:156
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
void Pos(const Point &rNew)
Definition: swrect.hxx:171
void SSize(const Size &rNew)
Definition: swrect.hxx:180
void AddHeight(const tools::Long nAdd)
Definition: swrect.cxx:124
void AddWidth(const tools::Long nAdd)
Definition: swrect.cxx:123
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
void Width(tools::Long nNew)
Definition: swrect.hxx:189
size_type size() const
Definition: docary.hxx:268
vector_type::size_type size_type
Definition: docary.hxx:223
void SetRightOfst(const SwTwips nNew)
Definition: porlay.hxx:73
SwTwips GetOffset() const
Definition: porlay.hxx:70
SwTwips GetRightOfst() const
Definition: porlay.hxx:72
void SetOffset(const SwTwips nNew)
Definition: porlay.hxx:71
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:215
bool IsAnyShellAccessible() const
Definition: rootfrm.hxx:402
void ColUnlock()
Definition: sectfrm.hxx:100
void SimpleFormat()
Definition: sectfrm.cxx:1176
void ColLock()
Definition: sectfrm.hxx:99
const SwSectionFrame * GetFollow() const
Definition: sectfrm.hxx:174
size_t size() const
Definition: sortedobjs.cxx:43
void CalcDropRepaint()
Definition: itradj.cxx:828
void CalcDropAdjust()
Definition: itradj.cxx:745
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
SwRect AnchoredObjToRect(const SwAnchoredObject *pAnchoredObj, const SwRect &rRect) const
Determines the demanded rectangle for an anchored object, considering its surround for text wrapping.
Definition: txtfly.cxx:1326
SwRect GetFrameArea() const
Definition: txtfly.cxx:826
bool IsOn() const
Definition: txtfly.hxx:323
SwAnchoredObjList * GetAnchoredObjList() const
Definition: txtfly.hxx:311
SwTextAttr subclass for footnotes and endnotes.
Definition: txtftn.hxx:34
void CtorInitTextFormatInfo(OutputDevice *pRenderContext, SwTextFrame *pFrame, const bool bInterHyph=false, const bool bQuick=false, const bool bTst=false)
Definition: inftxt.cxx:1608
void SetRest(SwLinePortion *pNewRest)
Definition: inftxt.hxx:582
bool IsTest() const
Definition: inftxt.hxx:593
bool IsShift() const
Definition: inftxt.hxx:585
sal_uInt8 & MaxHyph()
Definition: inftxt.hxx:559
SwLinePortion * GetRest()
Definition: inftxt.hxx:581
bool IsNewLine() const
Definition: inftxt.hxx:583
TextFrameIndex GetUnderScorePos() const
Definition: inftxt.hxx:646
bool IsStop() const
Definition: inftxt.hxx:579
bool IsFlyInCntBase() const
Definition: itrform2.hxx:210
void SetUnclipped(bool bNew)
Definition: itrform2.hxx:208
bool IsOnceMore() const
Definition: itrform2.hxx:201
bool CalcOnceMore()
Definition: itrform2.cxx:2297
const sal_uInt8 & CntMidHyph() const
Definition: itrform2.hxx:220
void InitCntHyph()
Definition: itrform2.hxx:218
const sal_uInt8 & CntEndHyph() const
Definition: itrform2.hxx:219
void SetOnceMore(bool bNew)
Definition: itrform2.hxx:202
void MakeDummyLine()
This function creates a Line that reaches to the other Page Margin.
Definition: txtftn.cxx:1276
void SetTruncLines(bool bNew)
Definition: itrform2.hxx:205
void CalcUnclipped(SwTwips &rTop, SwTwips &rBottom)
Definition: itrform2.cxx:2398
void CalcDropHeight(const sal_uInt16 nLines)
Definition: txtdrop.cxx:484
void CtorInitTextFormatter(SwTextFrame *pFrame, SwTextFormatInfo *pInf)
Definition: itrform2.cxx:93
bool IsStop() const
Definition: itrform2.hxx:174
bool IsNewLine() const
Definition: itrform2.hxx:177
const SwFormatDrop * GetDropFormat() const
Definition: itrform2.hxx:196
TextFrameIndex FormatQuoVadis(TextFrameIndex nStart)
Definition: txtftn.cxx:1072
SwLinePortion * MakeRestPortion(const SwLineLayout *pLine, TextFrameIndex nPos)
Definition: pormulti.cxx:2397
TextFrameIndex FormatLine(TextFrameIndex nStart)
Definition: itrform2.cxx:1873
bool IsUnclipped() const
Definition: itrform2.hxx:207
SwTwips CalcBottomLine() const
Definition: itrform2.cxx:2310
SwTextFormatInfo & GetInfo()
Definition: itrform2.hxx:213
void Insert(SwLineLayout *pLine)
Definition: itrform2.cxx:129
bool IsBreakNow(SwTextMargin &rLine)
Definition: widorp.cxx:219
void SetRstHeight(const SwTextMargin &rLine)
Definition: widorp.cxx:257
void SetKeep(const bool bNew)
Definition: widorp.hxx:40
bool IsKeepAlways() const
Definition: widorp.hxx:38
bool IsInside(SwTextMargin const &rLine) const
BP 18.6.93: Widows.
Definition: widorp.cxx:103
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
void FormatOnceMore(SwTextFormatter &rLine, SwTextFormatInfo &rInf)
Definition: frmform.cxx:1718
SwTextFrame * GetFormatted(bool bForceQuickFormat=false)
In case the SwLineLayout was cleared out of the s_pTextCache, recreate it.
Definition: txtfrm.cxx:3421
SwDoc & GetDoc()
Definition: txtfrm.hxx:475
void SwitchVerticalToHorizontal(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from vertical to horizontal layout.
Definition: txtfrm.cxx:580
bool CalcPrepFootnoteAdjust()
Definition: txtftn.cxx:139
bool FollowFormatAllowed() const
Definition: txtfrm.hxx:758
void SetOffset(TextFrameIndex nNewOfst)
Definition: txtfrm.hxx:886
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:876
void CalcFootnoteFlag(TextFrameIndex nStop=TextFrameIndex(COMPLETE_STRING))
Does the Frame have a local footnote (in this Frame or Follow)?
Definition: txtftn.cxx:104
void HideAndShowObjects()
Hides respectively shows objects, which are anchored at paragraph, at/as a character of the paragraph...
Definition: txtfrm.cxx:1570
void ValidateFrame()
Definition: frmform.cxx:86
TextFrameIndex GetOffset() const
Definition: txtfrm.hxx:453
bool HasPara() const
Definition: txtfrm.hxx:840
void FormatAdjust(SwTextFormatter &rLine, WidowsAndOrphans &rFrameBreak, TextFrameIndex nStrLen, const bool bDummy)
Definition: frmform.cxx:1050
void SwitchLTRtoRTL(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from LTR to RTL layout.
Definition: txtfrm.cxx:683
bool FormatQuick(bool bForceQuickFormat)
Definition: frmform.cxx:2151
bool IsWidow() const
Definition: txtfrm.hxx:534
void RemoveFootnote(TextFrameIndex nStart, TextFrameIndex nLen=TextFrameIndex(COMPLETE_STRING))
Footnote.
Definition: txtftn.cxx:408
bool IsSwapped() const
Definition: txtfrm.hxx:550
void HideHidden()
Removes Textfrm's attachments, when it's hidden.
Definition: txtfrm.cxx:1464
void CalcBaseOfstForFly()
Definition: txtfrm.cxx:4049
void SetFootnote(const bool bNew)
Will be moved soon.
Definition: txtfrm.hxx:614
bool CalcFollow(TextFrameIndex nTextOfst)
Definition: frmform.cxx:177
bool IsEmptyMaster() const
If there's a Follow and we don't contain text ourselves.
Definition: txtfrm.hxx:461
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
Calculates the frame area size and the print area, in case they are invalid.
Definition: frmform.cxx:1852
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:465
bool FormatLine(SwTextFormatter &rLine, const bool bPrev)
Definition: frmform.cxx:1244
void AdjustFrame(const SwTwips nChgHeight, bool bHasToFit=false)
Definition: frmform.cxx:394
bool HasFootnote() const
Definition: txtfrm.hxx:537
SwContentFrame * JoinFrame()
Definition: frmform.cxx:660
void SetWidow(const bool bNew)
Definition: txtfrm.hxx:254
void ResetPreps()
Definition: txtfrm.cxx:1351
void CalcHeightOfLastLine(const bool _bUseFont=false)
method to determine height of last line, needed for proportional line spacing
Definition: txtfrm.cxx:3606
void CalcAdditionalFirstLineOffset()
Simulate format for a list item paragraph, whose list level attributes are in LABEL_ALIGNMENT mode,...
Definition: txtfrm.cxx:3520
SwTwips GetParHeight() const
Returns the sum of line height in pLine.
Definition: txtfrm.cxx:3381
SwParaPortion * GetPara()
Definition: txtcache.cxx:90
TextFrameIndex MapModelToView(SwTextNode const *pNode, sal_Int32 nIndex) const
Definition: txtfrm.cxx:1252
bool IsFieldFollow() const
Definition: txtfrm.hxx:539
void AllowFollowFormat()
Definition: txtfrm.hxx:763
virtual void MakePos() override
Calculates the frame area position, in case it's invalid.
Definition: frmform.cxx:343
bool GetDropRect_(SwRect &rRect) const
Definition: frmform.cxx:152
bool IsLocked() const
Definition: txtfrm.hxx:532
void InvalidateRange_(const SwCharRange &, const tools::Long=0)
Definition: txtfrm.cxx:1716
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout.
Definition: txtfrm.cxx:473
bool CalcPreps()
Definition: frmform.cxx:827
void SetFieldFollow(const bool bNew)
Definition: txtfrm.hxx:257
void FormatImpl(vcl::RenderContext *pRenderContext, SwParaPortion *pPara, ::std::vector< SwAnchoredObject * > &rIntersectingObjs)
Definition: frmform.cxx:1780
static TextFrameIndex FindBrk(std::u16string_view aText, TextFrameIndex nStart, TextFrameIndex nEnd)
Returns the first possible break point in the current line.
Definition: txtfrm.cxx:1654
bool IsHiddenNow() const
Hidden.
Definition: txtfrm.cxx:1360
void SetJustWidow(const bool bNew)
Definition: txtfrm.hxx:255
bool HasNonLastSplitFlyDrawObj() const
This text frame may have a split fly frames anchored to it.
Definition: itratr.cxx:1483
void Format_(SwTextFormatter &rLine, SwTextFormatInfo &rInf, const bool bAdjust=false)
Definition: frmform.cxx:1379
void ValidateBodyFrame()
Definition: frmform.cxx:142
void ChgThisLines()
Definition: txtfrm.cxx:3857
void ChangeOffset(SwTextFrame *pFrame, TextFrameIndex nNew)
Definition: frmform.cxx:1042
void AdjustFollow_(SwTextFormatter &rLine, TextFrameIndex nOffset, TextFrameIndex nStrEnd, const sal_uInt8 nMode)
Definition: frmform.cxx:590
void ForbidFollowFormat()
Definition: txtfrm.hxx:768
void MoveFlyInCnt(SwTextFrame *pNew, TextFrameIndex nStart, TextFrameIndex nEnd)
Rewires FlyInContentFrame, if nEnd > Index >= nStart.
Definition: porfly.cxx:150
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:472
void SetOffset_(TextFrameIndex nNewOfst)
Definition: frmform.cxx:810
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true) override
SwContentFrame: the shortcut for the Frames If the void* casts wrongly, it's its own fault!...
Definition: txtfrm.cxx:2768
void ManipOfst(TextFrameIndex const nNewOfst)
Definition: txtfrm.hxx:456
css::uno::Sequence< css::style::TabStop > GetTabStopInfo(SwTwips CurrentPos) override
Definition: frmform.cxx:549
void SwapWidthAndHeight()
Swaps width and height of the text frame.
Definition: txtfrm.cxx:420
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1293
void SetRepaint() const
Definition: txtfrm.hxx:892
std::vector< SwFlyAtContentFrame * > GetSplitFlyDrawObjs() const
Like GetDrawObjs(), but limit to fly frames which are allowed to split.
Definition: itratr.cxx:1455
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1303
bool FormatEmpty()
Definition: porrst.cxx:406
void SplitFrame(TextFrameIndex nTextPos)
Methods to manage the FollowFrame.
Definition: frmform.cxx:733
TextFrameIndex mnOffset
Definition: txtfrm.hxx:207
void SetEmpty(const bool bNew)
Definition: txtfrm.hxx:256
bool IsEmpty() const
Definition: txtfrm.hxx:536
SwParaPortion * GetParaPortion()
Definition: inftxt.hxx:121
TextFrameIndex GetLength() const
Definition: itrtxt.hxx:86
TextFrameIndex GetEnd() const
Definition: itrtxt.hxx:89
SwTwips Y() const
Definition: itrtxt.hxx:90
TextFrameIndex GetStart() const
Definition: itrtxt.hxx:88
void TruncLines(bool bNoteFollow=false)
Definition: itrtxt.cxx:365
void Bottom()
Definition: itrtxt.cxx:186
void Top()
Definition: itrtxt.hxx:99
SwTwips GetLineHeight() const
Definition: itrtxt.hxx:116
const SwLineLayout * Next()
Definition: itrtxt.cxx:108
SwTwips GetFirstPos() const
Definition: itrtxt.hxx:129
void CharToLine(TextFrameIndex)
Definition: itrtxt.cxx:194
const SwLineLayout * GetCurr() const
Definition: itrtxt.hxx:83
const SwLineLayout * Prev()
Definition: itrtxt.cxx:90
sal_uInt16 GetLineNr() const
Definition: itrtxt.hxx:87
const SwLineInfo & GetLineInfo() const
Definition: itrtxt.hxx:128
const SwLineLayout * GetPrev()
Definition: itrtxt.cxx:83
bool IsAvailable() const
Definition: txtcache.cxx:70
SwParaPortion * GetPara()
Definition: txtcache.cxx:50
sal_uInt16 GetDropLeft() const
Definition: itrtxt.hxx:204
sal_uInt16 GetDropLines() const
Definition: itrtxt.hxx:202
Point GetTopLeft() const
Definition: itrtxt.hxx:186
SwTwips GetLeftMargin() const
Definition: itrtxt.hxx:329
void SetDropLines(const sal_uInt16 nNew)
Definition: itrtxt.hxx:203
sal_uInt16 GetDropHeight() const
Definition: itrtxt.hxx:205
SvxAdjust GetAdjust() const
Definition: itrtxt.hxx:190
SwTwips GetLineStart() const
Definition: itrcrsr.cxx:379
void Right(const SwTwips nNew)
Definition: itrtxt.hxx:157
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
virtual SwContentFrame * MakeFrame(SwFrame *) override
Virtual methods from ContentNode.
Definition: ndtxt.cxx:285
bool HasVisibleNumberingOrBullet() const
Returns if the paragraph has a visible numbering or bullet.
Definition: ndtxt.cxx:4282
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2919
SwTextFly & GetTextFly()
Definition: inftxt.hxx:387
bool IsPaintDrop() const
Definition: itrpaint.hxx:62
void SetPaintDrop(const bool bNew)
Definition: itrpaint.hxx:61
sal_Unicode GetChar(TextFrameIndex const nPos) const
Definition: inftxt.hxx:241
const OUString & GetText() const
Definition: inftxt.hxx:240
TextFrameIndex GetIdx() const
Definition: inftxt.hxx:273
bool IsParagraph(bool bHard=false) const
Definition: viewopt.hxx:371
bool IsLineBreak(bool bHard=false) const
Definition: viewopt.hxx:391
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:364
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:451
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2149
void InvalidateAccessibleParaFlowRelation(const SwTextFrame *_pFromTextFrame, const SwTextFrame *_pToTextFrame)
invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
Definition: viewsh.cxx:2586
bool FindBreak(SwTextFrame *pFrame, SwTextMargin &rLine, bool bHasToFit)
The Find*-Methods do not only search, but adjust the SwTextMargin to the line where the paragraph sho...
Definition: widorp.cxx:364
bool IsBreakNowWidAndOrp(SwTextMargin &rLine)
Definition: widorp.hxx:69
void ClrOrphLines()
Definition: widorp.hxx:63
SwTextAttr const * NextAttr(SwTextNode const **ppNode=nullptr)
Definition: txtfrm.cxx:91
static void ValidateBodyFrame_(SwFrame *pFrame)
Definition: frmform.cxx:122
#define SLOPPY_TWIPS
Definition: frmform.cxx:57
void ValidateText(SwFrame *pFrame)
Definition: frmform.cxx:75
void Notify_Background(const SdrObject *pObj, SwPageFrame *pPage, const SwRect &rRect, const PrepareHint eHint, const bool bInva)
Definition: frmtool.cxx:3394
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(59)
const long LONG_MAX
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
determines the list style, which directly set at the given paragraph style
Definition: fmtcol.cxx:74
double getLength(const B2DPolygon &rCandidate)
void swap(cow_wrapper< T, P > &a, cow_wrapper< T, P > &b)
const SwTwips WIDOW_MAGIC
Definition: txtfrm.hxx:1043
long Long
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
#define Y
SwNode & GetNode() const
Definition: pam.hxx:81
const sal_Unicode CH_BREAK
Definition: swfont.hxx:43
tools::Long SwTwips
Definition: swtypes.hxx:51
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:57
Left
Right
unsigned char sal_uInt8